fix: home's acting-on pick switches the current workspace (#11929)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-10-21 20:59:14 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 73f655db98
commit cdaddcce59
2 changed files with 20 additions and 5 deletions
@@ -83,7 +83,7 @@
{#snippet actingOn()}
{#if session}
<SessionWorkspaceBar {session} />
<SessionWorkspaceBar {session} switchesWorkspace />
{/if}
{/snippet}
@@ -8,8 +8,22 @@
} from './sessionState.svelte'
import WorkspaceFamilyPicker from './WorkspaceFamilyPicker.svelte'
import WorkspaceScopeTrigger from '$lib/components/WorkspaceScopeTrigger.svelte'
import { switchWorkspace } from '$lib/storeUtils'
import { workspaceAIClients } from '$lib/components/copilot/lib'
import { fixupUrlAfterWorkspaceSwitch } from '$lib/components/sidebar/workspaceSwitchUrl'
let { session }: { session: Session } = $props()
// `switchesWorkspace`: a pick also moves the navigation workspace. For a host whose page
// shows the navigation workspace around the composer (Home), where a pick that left it
// behind would read as ignored; the session page follows the session's own workspace instead.
let { session, switchesWorkspace = false }: { session: Session; switchesWorkspace?: boolean } =
$props()
function followPick(id: string) {
if (!switchesWorkspace || $workspaceStore === id) return
workspaceAIClients.init(id)
switchWorkspace(id)
void fixupUrlAfterWorkspaceSwitch(id)
}
// Effective workspace for display: committed → pending pick → active store.
const effectiveId = $derived(getEffectiveWorkspaceId(session) ?? $workspaceStore ?? undefined)
@@ -17,14 +31,15 @@
function pick(id: string) {
// Pre-send only: writes the pending pick. workspace_id stays undefined until
// the user sends their first message. The global workspaceStore is left
// untouched — the chat targets this pending workspace via the manager's
// workspace resolver, so picking here must not switch the active workspace.
// the user sends their first message. The chat targets this pending workspace
// via the manager's workspace resolver, not the global workspaceStore.
setSessionPendingWorkspace(session.id, id)
followPick(id)
}
function stageFork(req: { parent_workspace_id: string; id: string; name: string }) {
setSessionPendingFork(session.id, req)
followPick(req.parent_workspace_id)
}
</script>