Skip to content

The agent that grows with you

fix(desktop): host.navigate fronts the workspace pane on a re-click (#112942)

Austin Pickettf57857ade521
diff --git a/apps/desktop/src/app/routes.workspace-reveal.test.ts b/apps/desktop/src/app/routes.workspace-reveal.test.ts
index 7db75e610ae..1945352eb00 100644
--- a/apps/desktop/src/app/routes.workspace-reveal.test.ts
+++ b/apps/desktop/src/app/routes.workspace-reveal.test.ts
@@ -187,3 +187,38 @@ describe('navigateToWorkspacePage', () => {
expect(revealTreePane).not.toHaveBeenCalled()
})
})
+
+/**
+ * `host.navigate` is the only nav door a plugin has (Kanban's ⌘K row, statusbar
+ * count, ⌘⌥N). It writes the hash, which the router follows on a CHANGE — but
+ * re-issuing the current route fires nothing, so it must reveal imperatively
+ * like the sidebar does.
+ */
+describe('host.navigate', () => {
+ it('fronts the workspace pane even when already on the contributed page', async () => {
+ const dispose = contributeRoute()
+
+ try {
+ const { host } = await import('@/sdk')
+
+ window.location.hash = `#${CONTRIBUTED_ROUTE}`
+ vi.mocked(revealTreePane).mockClear()
+ vi.mocked(noteActiveTreeGroup).mockClear()
+
+ host.navigate(CONTRIBUTED_ROUTE)
+
+ expect(window.location.hash).toBe(`#${CONTRIBUTED_ROUTE}`)
+ expect(fronted()).toBe(true)
+ } finally {
+ dispose()
+ }
+ })
+
+ it('does not front the pane for a chat route', async () => {
+ const { host } = await import('@/sdk')
+
+ host.navigate(sessionRoute('sess-a'))
+
+ expect(revealTreePane).not.toHaveBeenCalled()
+ })
+})
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index 69a8c2b04cf..432d0a48302 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -24,6 +24,7 @@ import type { ReactNode } from 'react'
import { capabilityScoped } from '@/api/client'
import { PRIMARY_SESSION_VIEW } from '@/app/chat/session-view'
import { openSession, type OpenSessionIntent } from '@/app/open-session'
+import { syncWorkspaceRoute } from '@/app/routes'
import type { ClientSessionState } from '@/app/types'
import {
$narrowViewport,
@@ -663,7 +664,16 @@ export const host = {
/** Navigate the app router (hash routes, e.g. '/command-center?section=system'). */
navigate: (path: string) => {
- window.location.hash = path.startsWith('#') ? path : `#${path}`
+ const to = path.startsWith('#') ? path.slice(1) : path
+
+ window.location.hash = `#${to}`
+ // The router follows the hash and fronts the workspace pane on a route
+ // CHANGE (wiring's `syncWorkspaceRoute` effect). Re-issuing the current
+ // route — palette/statusbar/hotkey while already on the page with a tile
+ // focused — changes nothing, so no event fires and the page stays behind
+ // the tile. Reveal imperatively, the same way `navigateToWorkspacePage`
+ // does for the sidebar and keybinds.
+ syncWorkspaceRoute(to)
},
/** Pre-dial a profile's gateway socket in the background — pool-only, no