The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): route the palette and artifact "open chat" doors through openSessionFromPicker
teknium1b811892ce625
diff --git a/apps/desktop/src/app/artifacts/index.tsx b/apps/desktop/src/app/artifacts/index.tsxindex e7e4de02e41..d87a76a4a65 100644--- a/apps/desktop/src/app/artifacts/index.tsx+++ b/apps/desktop/src/app/artifacts/index.tsx@@ -38,7 +38,7 @@ import { notify, notifyError } from '@/store/notifications'import { useRefreshHotkey } from '../hooks/use-refresh-hotkey'import { useRouteEnumParam } from '../hooks/use-route-enum-param'-import { openSession } from '../open-session'+import { openSessionFromPicker } from '../open-session'import { PageSearchShell } from '../page-search-shell'import type { SetStatusbarItemGroup } from '../shell/statusbar-controls'@@ -312,7 +312,7 @@ export function ArtifactsView({ setStatusbarItemGroup: _setStatusbarItemGroup, .// every artifact cell re-render whenever the page did — and a link cell's// async title fetch re-rendered the page repeatedly. openArtifact is already// a useCallback; navigate is stable, so onOpenChat can be too.- const openChat = useCallback((sessionId: string) => openSession(sessionId, navigate), [navigate])+ const openChat = useCallback((sessionId: string) => openSessionFromPicker(sessionId, navigate), [navigate])const cellCtx: CellCtx = useMemo(() => ({ onOpen: openArtifact, onOpenChat: openChat }), [openArtifact, openChat])return (@@ -377,7 +377,7 @@ export function ArtifactsView({ setStatusbarItemGroup: _setStatusbarItemGroup, .failedImage={failedImageIds.has(artifact.id)}key={artifact.id}onImageError={markImageFailed}- onOpenChat={sessionId => openSession(sessionId, navigate)}+ onOpenChat={sessionId => openSessionFromPicker(sessionId, navigate)}/>))}</div>diff --git a/apps/desktop/src/app/command-palette/index.tsx b/apps/desktop/src/app/command-palette/index.tsxindex 28201cbf498..eee68e05e5c 100644--- a/apps/desktop/src/app/command-palette/index.tsx+++ b/apps/desktop/src/app/command-palette/index.tsx@@ -89,7 +89,7 @@ import { luminance } from '@/themes/color'import { type ThemeMode, useTheme } from '@/themes/context'import { isUserTheme, resolveTheme } from '@/themes/user-themes'-import { openSession, openSessionIntentFromModifiers } from '../open-session'+import { openSessionFromPicker, openSessionIntentFromModifiers } from '../open-session'import {AGENTS_ROUTE,ARTIFACTS_ROUTE,@@ -691,7 +691,7 @@ function CommandPaletteBody({ onExited }: { onExited: () => void }) {// sidebar, minus the sidebar's licence to spend main.const goSession = useCallback((sessionId: string) => (event?: { ctrlKey?: boolean; metaKey?: boolean; shiftKey?: boolean }) => {- openSession(sessionId, navigate, openSessionIntentFromModifiers(event, 'stack'))+ openSessionFromPicker(sessionId, navigate, openSessionIntentFromModifiers(event, 'stack'))},[navigate])diff --git a/apps/desktop/src/app/open-session.test.ts b/apps/desktop/src/app/open-session.test.tsindex 9be492a136a..c3448ce64c1 100644--- a/apps/desktop/src/app/open-session.test.ts+++ b/apps/desktop/src/app/open-session.test.ts@@ -4,9 +4,11 @@ const focusOpenSession = vi.fn()const openSessionTile = vi.fn()const reuseBlankDraftTile = vi.fn()const setSessionTileWorkspaceScope = vi.fn()+const focusedSessionWorkspaceScope = vi.fn<() => { workspaceMode: 'bots' | 'sessions'; workspaceOwnerKey?: string }>(() => ({ workspaceMode: 'sessions' }))+const openSessionInNewWindow = vi.fn()const canOpenSessionWindow = vi.fn(() => true)const workspaceIsPageGet = vi.fn(() => false)@@ -223,40 +225,31 @@ describe('openSession', () => {expect(openSessionTile).not.toHaveBeenCalled()})- it('stack spends the focused Bot-scoped blank draft even when main is empty', () => {+ it('picker doors resume into the focused Bot workspace and stay in-place in Sessions', () => {const scope = { workspaceMode: 'bots' as const, workspaceOwnerKey: 'connection-a::default' }+ // /resume overlay and an artifact's "open chat" (unmodified = in-place) from a Bot tab.+ focusedSessionWorkspaceScope.mockReturnValue(scope)focusOpenSession.mockReturnValue(null)reuseBlankDraftTile.mockReturnValue(true)- openSession('s1', navigate, 'stack', scope)+ openSessionFromPicker('s1', navigate)expect(reuseBlankDraftTile).toHaveBeenCalledWith('s1', scope)- expect(openSessionTile).not.toHaveBeenCalled()expect(navigate).not.toHaveBeenCalled()- })- it('picker resumes into the focused Bot workspace instead of the Sessions main', () => {- const scope = { workspaceMode: 'bots' as const, workspaceOwnerKey: 'connection-a::default' }+ // ⌘K session search (unmodified = stack) from the same Bot tab lands in the Bot workspace too.+ reuseBlankDraftTile.mockReturnValue(false)+ openSessionFromPicker('s2', navigate, 'stack')- focusedSessionWorkspaceScope.mockReturnValue(scope)- focusOpenSession.mockReturnValue(null)- reuseBlankDraftTile.mockReturnValue(true)- openSessionFromPicker('s1', navigate)-- expect(focusedSessionWorkspaceScope).toHaveBeenCalledOnce()- expect(reuseBlankDraftTile).toHaveBeenCalledWith('s1', scope)+ expect(openSessionTile).toHaveBeenCalledWith('s2', 'center', undefined, undefined, scope)expect(navigate).not.toHaveBeenCalled()- })- it('picker keeps its existing in-place behavior in the Sessions workspace', () => {+ // Control: the same doors in the Sessions workspace keep their in-place behaviour.$activeSessionId.set('runtime-current')focusedSessionWorkspaceScope.mockReturnValue({ workspaceMode: 'sessions' })- focusOpenSession.mockReturnValue(null)+ openSessionFromPicker('s3', navigate)- openSessionFromPicker('s1', navigate)-- expect(openSessionTile).not.toHaveBeenCalled()- expect(navigate).toHaveBeenCalledWith('/c/s1')+ expect(navigate).toHaveBeenCalledWith('/c/s3')})it('window pops out when the bridge supports it', () => {diff --git a/apps/desktop/src/app/open-session.ts b/apps/desktop/src/app/open-session.tsindex 3173aa7499c..2c441057d6a 100644--- a/apps/desktop/src/app/open-session.ts+++ b/apps/desktop/src/app/open-session.ts@@ -76,13 +76,21 @@ export function openSessionIntentFromModifiers(return base}-/** Picker selection preserves the workspace of the tab that opened it without- * changing the established Sessions behavior. */-export function openSessionFromPicker(storedSessionId: string, navigate: OpenSessionNavigate): void {+/** Every door that opens a saved chat from a picker-like surface (the /resume+ * overlay, ⌘K session search, an artifact's "open chat") preserves the+ * workspace of the tab the user acted from. `intent` is the caller's unmodified+ * meaning (`in-place` for the overlay and artifacts, `stack` for ⌘K, or the+ * ⌘/⇧⌘ modifier result); a Bot-scoped `in-place` becomes `stack` so the chat+ * lands in the Bot tab instead of the Sessions main. */+export function openSessionFromPicker(+ storedSessionId: string,+ navigate: OpenSessionNavigate,+ intent: OpenSessionIntent = 'in-place'+): void {const workspaceScope = focusedSessionWorkspaceScope()- const intent = workspaceScope.workspaceMode === 'bots' ? 'stack' : 'in-place'+ const resolved = workspaceScope.workspaceMode === 'bots' && intent === 'in-place' ? 'stack' : intent- openSession(storedSessionId, navigate, intent, workspaceScope)+ openSession(storedSessionId, navigate, resolved, workspaceScope)}/**