mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 00:02:30 +00:00
fix: take latest re-reads the head at click time; type the kept head as prepared diff data
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
19226a1783
commit
a4da7d3ee6
@@ -94,10 +94,11 @@
|
||||
let selectedVersion: string | undefined = $state(undefined)
|
||||
let versionLoader: ((id: string) => Promise<Value | undefined>) | undefined = $state(undefined)
|
||||
let headLabel: string | undefined = $state(undefined)
|
||||
/** The deployed head as it was handed to `setDiff`. `data.deployed` follows the
|
||||
* picker, and Restore always restores the head, so its enabled state compares
|
||||
* against this rather than whichever version is on display. */
|
||||
let headDeployed: Value | undefined = $state(undefined)
|
||||
/** The deployed head, prepared for diffing as `data.deployed` is: `data.deployed`
|
||||
* follows the picker while Restore always restores the head, so its enabled state
|
||||
* compares against this. Must hold `prepareDiff`'s output, not the raw value, or the
|
||||
* comparison never matches and Restore is always enabled. */
|
||||
let headDeployed: ReturnType<typeof prepareDiff> | undefined = $state(undefined)
|
||||
let loadingVersion = $state(false)
|
||||
/** Which version load the spinner belongs to, counted rather than keyed on the id so
|
||||
* re-picking the same version is still generation-safe. A response from any other
|
||||
|
||||
@@ -629,7 +629,15 @@
|
||||
deployedHeadVersion &&
|
||||
draftBaseVersion !== deployedHeadVersion
|
||||
? async () => {
|
||||
const head = Number(deployedHeadVersion)
|
||||
// Re-read rather than trusting the head this page loaded with; see
|
||||
// /scripts/edit.
|
||||
const head =
|
||||
(
|
||||
await AppService.getAppLatestVersion({
|
||||
workspace: $workspaceStore!,
|
||||
path: page.params.path ?? ''
|
||||
}).catch(() => undefined)
|
||||
)?.version ?? Number(deployedHeadVersion)
|
||||
parentVersion = head
|
||||
if (deployedBaseline) deployedBaseline = { ...deployedBaseline, parent_version: head }
|
||||
draftBaseVersion = String(head)
|
||||
|
||||
@@ -546,7 +546,15 @@
|
||||
<FlowBuilder
|
||||
onTakeLatest={draftBaseVersion && version != null && draftBaseVersion !== String(version)
|
||||
? async () => {
|
||||
const head = version
|
||||
// Re-read rather than trusting the head this page loaded with; see
|
||||
// /scripts/edit.
|
||||
const head =
|
||||
(
|
||||
await FlowService.getFlowLatestVersion({
|
||||
workspace: $workspaceStore!,
|
||||
path: flowDraftPath
|
||||
}).catch(() => undefined)
|
||||
)?.id ?? version
|
||||
if (!draftSync.draft || head == null || !$workspaceStore) return
|
||||
draftSync.draft = { ...draftSync.draft, version_id: head }
|
||||
draftBaseVersion = String(head)
|
||||
|
||||
@@ -527,7 +527,16 @@
|
||||
userDraftPath={draftPath}
|
||||
onTakeLatest={draftBaseHash && deployedHeadHash && draftBaseHash !== deployedHeadHash
|
||||
? async () => {
|
||||
const head = deployedHeadHash
|
||||
// Re-read rather than trusting the head this page loaded with: taking a
|
||||
// stale one would say the draft is up to date with a version that is not
|
||||
// the latest any more.
|
||||
const head =
|
||||
(
|
||||
await ScriptService.getScriptLatestVersion({
|
||||
workspace: $workspaceStore!,
|
||||
path: draftPath
|
||||
}).catch(() => undefined)
|
||||
)?.script_hash ?? deployedHeadHash
|
||||
if (!draftSync.draft || !head || !$workspaceStore) return
|
||||
draftSync.draft = { ...draftSync.draft, parent_hash: head }
|
||||
// The baseline mirrors the draft's base so an unedited draft still
|
||||
|
||||
Reference in New Issue
Block a user