diff --git a/frontend/src/lib/components/sessions/DraftDiffDrawer.svelte b/frontend/src/lib/components/sessions/DraftDiffDrawer.svelte index b855c4591a..0716398131 100644 --- a/frontend/src/lib/components/sessions/DraftDiffDrawer.svelte +++ b/frontend/src/lib/components/sessions/DraftDiffDrawer.svelte @@ -61,7 +61,18 @@ const baseKind = it.raw_app ? 'raw_app' : it.kind const kind = DEPLOY_KIND_BY_DRAFT_KIND[baseKind] ?? baseKind donly[`${kind}/${it.path}`] = it.draft_only - return { kind, path: it.path, status: it.draft_only ? 'added' : 'modified' } + // A never-deployed app/raw_app is parked at a synthetic `…/draft_` + // storage path with the user's typed name in `draft_path`; show that + // (matches the home list) while `path` stays the storage key for loading. + // `summary` comes straight from the draft row, so it shows for every kind + // up front instead of only after the diff value loads. + return { + kind, + path: it.path, + displayPath: it.draft_path ?? it.path, + summary: it.summary, + status: it.draft_only ? 'added' : 'modified' + } }) draftOnlyByKey = donly } catch (e) { @@ -75,10 +86,11 @@ async function loadValues(d: DiffRow): Promise<{ before: unknown; after: unknown }> { const draftOnly = draftOnlyByKey[`${d.kind}/${d.path}`] ?? false - // getDraftDiffValues works on the draft itemKind ('app' for raw apps too); - // map the deploy-style display kind back to it. - const kind: DraftKind = - d.kind === 'raw_app' ? 'app' : ((DRAFT_KIND_BY_DEPLOY_KIND[d.kind] ?? d.kind) as DraftKind) + // getDraftDiffValues keys on the draft itemKind: `raw_app` must stay + // `raw_app` (the helper sends rawApp:true only for that exact kind, which a + // never-deployed raw app needs, else it hits the normal app endpoint and + // 404s). Only the trigger display kinds map back from their deploy-style names. + const kind = (DRAFT_KIND_BY_DEPLOY_KIND[d.kind] ?? d.kind) as DraftKind const { deployed, draft } = await getDraftDiffValues(kind, d.path, workspaceId, draftOnly) // draft_only items have never been deployed → render as "added" (empty // before), matching how the fork drawer renders added items. diff --git a/frontend/src/lib/components/sessions/WorkspaceDiffDrawer.svelte b/frontend/src/lib/components/sessions/WorkspaceDiffDrawer.svelte index 3eae6f9205..472ea1515b 100644 --- a/frontend/src/lib/components/sessions/WorkspaceDiffDrawer.svelte +++ b/frontend/src/lib/components/sessions/WorkspaceDiffDrawer.svelte @@ -8,6 +8,13 @@ status: DiffStatus ahead?: number behind?: number + /** Human-facing path; defaults to `path`. Lets a draft parked at a + * synthetic storage path (`…/draft_`) show its friendly typed path + * while keys, value-loading and edit links stay keyed on `path`. */ + displayPath?: string + /** Summary supplied by the data source. Preferred over the one derived + * from the loaded diff value, and shown before that value loads. */ + summary?: string } @@ -88,6 +95,12 @@ return `${d.kind}/${d.path}` } + // Friendly path for display only; `path` stays the storage key everywhere + // keys/loads happen, so a never-deployed draft still loads from `…/draft_`. + function displayPathOf(d: DiffRow): string { + return d.displayPath ?? d.path + } + const KIND_LABELS: Record = { script: 'Script', flow: 'Flow', @@ -183,9 +196,9 @@ } const folderCache = new Map() for (const d of rows) { - const parts = d.path.split('/') + const parts = displayPathOf(d).split('/') if (parts.length < 2) { - root.children.push({ type: 'file', name: d.path, diff: d }) + root.children.push({ type: 'file', name: displayPathOf(d), diff: d }) continue } const scopeKey = parts.slice(0, 2).join('/') @@ -226,8 +239,8 @@ } function searchableText(d: DiffRow): string { - const parts = [d.path, KIND_LABELS[d.kind] ?? d.kind] - const s = summaries[itemKey(d)] + const parts = [displayPathOf(d), KIND_LABELS[d.kind] ?? d.kind] + const s = summaries[itemKey(d)] ?? d.summary if (s) parts.push(s) return parts.join(' ') } @@ -433,12 +446,12 @@ { highlightedKey = key scrollToDiff(node.diff) @@ -556,6 +569,7 @@ {@const StatusIcon = statusIcons[status]} {@const loaded = loadedDiffs[key]} {@const editUrl = editUrlFor?.(d)} + {@const dpath = displayPathOf(d)}
- {d.path} + {dpath} {:else} -
- {d.path} +
+ {dpath}
{/if}