fix: read latest db draft for scripts/flows in global mode read tool (#9441)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
centdix
2026-06-04 09:06:05 +02:00
committed by GitHub
parent 468aa230e5
commit 819ba5e150
@@ -647,7 +647,7 @@ function itemMatches(
)
}
function scriptToItem(script: Script, includeValue: boolean): WorkspaceItem {
function scriptToItem(script: Script | NewScript, includeValue: boolean): WorkspaceItem {
return {
type: 'script',
path: script.path,
@@ -1153,10 +1153,16 @@ async function readWorkspaceItem(
triggerKind?: TriggerKind
): Promise<WorkspaceItem> {
switch (type) {
case 'script':
return scriptToItem(await ScriptService.getScriptByPath({ workspace, path }), true)
case 'flow':
return flowToItem(await FlowService.getFlowByPath({ workspace, path }), true)
case 'script': {
// Prefer the DB draft (newer than the deployed version) when one exists.
const script = await ScriptService.getScriptByPathWithDraft({ workspace, path })
return scriptToItem(script.draft ?? script, true)
}
case 'flow': {
// Prefer the DB draft (newer than the deployed version) when one exists.
const flow = await FlowService.getFlowByPathWithDraft({ workspace, path })
return flowToItem(flow.draft ?? flow, true)
}
case 'schedule':
return scheduleToItem(await ScheduleService.getSchedule({ workspace, path }), true)
case 'trigger':