Files
windmill/frontend/src/lib/components/sessions/VariableEditorView.svelte
T
Diego ImbertandClaude Opus 5 3f8485060d fix(sessions): send the removed item's own tab back to the list, not the active one
A discard resolves asynchronously — the schedule's awaits a fetch of the
runnable — so by the time it lands the user may be looking at another tab.
Routing removal through `onBack` moved whichever tab was active, taking that
one to the list while the tab whose item was gone stayed on it. Removal now
retargets by tab id, as the deletion and rename paths already do.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KcyBRxE8j3ujCYkum9KrC4
2026-09-06 01:09:15 +02:00

51 lines
1.6 KiB
Svelte

<script lang="ts">
import VariableEditor from '$lib/components/VariableEditor.svelte'
import { untrack } from 'svelte'
let {
path,
workspaceId,
onBack,
onRemoved,
onRenamed
}: {
/** The variable this tab edits (the row its location deep-links). */
path: string
/** The session's acting workspace, which the editor operates on instead of
* `$workspaceStore` (the nav workspace, which a session leaves put). */
workspaceId: string
/** Back to the list this editor was reached through; the tab replaced it. */
onBack?: () => void
/** The item is gone — a draft-only one whose draft was discarded. Distinct from
* `onBack`, which moves whichever tab is active: a discard can complete after
* the user has moved on, and only this tab is the one to send back. */
onRemoved?: () => void
/** The item was saved under a different path. The tab addresses it by path —
* as do its label, the chat's ACTIVE PREVIEW and the draft key — so the tab
* has to follow, or all four keep naming an item that no longer exists. */
onRenamed?: (newPath: string) => void
} = $props()
let editor = $state<VariableEditor | undefined>()
// Re-selects when the tab is pointed at another variable; the component keeps
// its identity across that, as it does for the drawer's row-to-row switch.
$effect(() => {
const p = path
const e = editor
if (!p || !e) return
untrack(() => e.editVariable(p))
})
</script>
<VariableEditor
bind:this={editor}
useDrawer={false}
workspace={workspaceId}
{onBack}
{onRemoved}
onSaved={(saved) => {
if (saved && saved !== path) onRenamed?.(saved)
}}
/>