The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): page-owned header controls get their own area; titleBar.center stays permanent
teknium114d862384b19
diff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsxindex 0b7b39215ad..343243564b7 100644--- a/apps/desktop/src/app/contrib/controller.tsx+++ b/apps/desktop/src/app/contrib/controller.tsx@@ -39,6 +39,7 @@ import {import { $workspaceOwnerLabels, workspaceOwnerTitle } from '@/components/pane-shell/workspace-scope'import { SidebarProvider } from '@/components/ui/sidebar'import { discoverBundledPlugins } from '@/contrib/plugins'+import { Slot } from '@/contrib/react/slot'import { registry } from '@/contrib/registry'import { discoverRuntimePlugins } from '@/contrib/runtime-loader'import { translateNow } from '@/i18n'@@ -92,7 +93,7 @@ import {import { AppContextMenu } from '../context-menu/app-context-menu'import { HudShell } from '../hud/hud-shell'import { $terminalTakeover, setTerminalTakeover } from '../right-sidebar/store'-import { $workspaceIsPage } from '../routes'+import { $workspaceIsPage, WORKSPACE_PAGE_HEADER_AREA } from '../routes'import { DEFAULT_TREE, registerLayoutPresets } from './layout-presets'import { FilesPane, LogsPane, ReviewPaneContent } from './panes'@@ -474,6 +475,13 @@ const syncWorkspaceTitle = () => {tabTitle: stored ? undefined : () => <SessionDraftTitle scope={selected} />,// Pages aren't tab-able: the main zone's bar stands down while one shows.headerVeto: $workspaceIsPage.get(),+ // Page-owned controls take the vetoed tab row. Deliberately NOT the+ // `titleBar.center` slot: that one stays mounted in the titlebar on every+ // route so plugin components (and their effects) survive navigation.+ headerContent:+ $workspaceIsPage.get() && registry.getArea(WORKSPACE_PAGE_HEADER_AREA).length+ ? () => <Slot area={WORKSPACE_PAGE_HEADER_AREA} />+ : undefined,placement: 'main',minWidth: '22vw',tabDrag: workspaceTabDrag,@@ -489,6 +497,7 @@ $sessions.listen(syncWorkspaceTitle)$botChatScopes.listen(syncWorkspaceTitle)$workspaceOwnerLabels.listen(syncWorkspaceTitle)$workspaceIsPage.listen(syncWorkspaceTitle)+registry.subscribeArea(WORKSPACE_PAGE_HEADER_AREA, syncWorkspaceTitle)// Layout reset collapses every session tile into main as a tab (after the// workspace) instead of re-scattering them — pre-placed before adoption.diff --git a/apps/desktop/src/app/routes.ts b/apps/desktop/src/app/routes.tsindex 0e5998c810a..98249354127 100644--- a/apps/desktop/src/app/routes.ts+++ b/apps/desktop/src/app/routes.ts@@ -242,6 +242,12 @@ export function isWorkspacePageRoute(to: string): boolean {* (settings/…) don't count — the chat stays beneath them. */export const $workspaceIsPage = atom(false)+/** Page-owned controls (kanban's board switcher) projected into the workspace+ * panel's tab-header space while `$workspaceIsPage` holds — the page's title+ * row, not the native band. Distinct from `titleBar.*`, whose slots stay+ * mounted on every route so plugin components never remount on navigation. */+export const WORKSPACE_PAGE_HEADER_AREA = 'workspace.pageHeader'+function revealWorkspacePane(): void {noteActiveTreeGroup(null)revealTreePane('workspace')diff --git a/apps/desktop/src/app/shell/titlebar-controls.test.tsx b/apps/desktop/src/app/shell/titlebar-controls.test.tsxindex c67744a31c7..a656013946c 100644--- a/apps/desktop/src/app/shell/titlebar-controls.test.tsx+++ b/apps/desktop/src/app/shell/titlebar-controls.test.tsx@@ -1,6 +1,7 @@// @vitest-environment jsdomimport { act, cleanup, render, screen, within } from '@testing-library/react'-import { MemoryRouter } from 'react-router'+import { useEffect } from 'react'+import { MemoryRouter, useNavigate } from 'react-router'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { registry } from '@/contrib/registry'@@ -14,10 +15,19 @@ import { TitlebarControls, type TitlebarTool } from './titlebar-controls'const PLUGIN_TOOL: TitlebarTool = { icon: <span />, id: 'plugin-tool', label: 'plugin tool' }+let navigateTo: (to: string) => void = () => {}++function NavigateProbe() {+ navigateTo = useNavigate()++ return null+}+function renderControls(pathname: string, props?: { leftTools?: TitlebarTool[]; tools?: TitlebarTool[] }) {return render(<MemoryRouter initialEntries={[pathname]}><I18nProvider configClient={null} initialLocale="en">+ <NavigateProbe /><TitlebarControls leftTools={props?.leftTools} onOpenSettings={() => {}} tools={props?.tools} /></I18nProvider></MemoryRouter>@@ -89,18 +99,41 @@ describe('TitlebarControls fixed clusters', () => {expect(pluginTool()).not.toBeNull()})- it('keeps titleBar.center in the titlebar on a workspace page', () => {+ it('keeps a titleBar.center component mounted across a chat -> page -> chat round trip', () => {+ // Plugins tear down global side effects (style tags, observers) in their+ // effect cleanup; a remount on navigation ran the OLD cleanup after the+ // NEW setup and left the plugin dead until reload (#114290).+ const life = { cleanups: 0, mounts: 0 }++ function PluginCenter() {+ useEffect(() => {+ life.mounts += 1++ return () => {+ life.cleanups += 1+ }+ }, [])++ return <span>plugin-center</span>+ }+const disposeTitle = registry.register({area: 'titleBar.center',- id: 'test-page-title',- render: () => <span>plugin-center</span>+ id: 'test-plugin-center',+ render: () => <PluginCenter />})try {- renderControls('/skills')+ renderControls('/')+ expect(life).toEqual({ cleanups: 0, mounts: 1 })++ act(() => navigateTo('/skills'))expect(screen.getByText('plugin-center')).not.toBeNull()expect(windowControls()).not.toBeNull()expect(appControls()).not.toBeNull()++ act(() => navigateTo('/'))+ expect(life).toEqual({ cleanups: 0, mounts: 1 })} finally {act(disposeTitle)}diff --git a/apps/desktop/src/plugins/kanban/board-switcher.tsx b/apps/desktop/src/plugins/kanban/board-switcher.tsxindex 0f5d1094666..32a2ad2292d 100644--- a/apps/desktop/src/plugins/kanban/board-switcher.tsx+++ b/apps/desktop/src/plugins/kanban/board-switcher.tsx@@ -1,5 +1,6 @@/**- * Board switcher projected through `titleBar.center` (permanent titlebar slot).+ * Board switcher projected through `WORKSPACE_PAGE_HEADER_AREA` into the+ * workspace panel's tab-header space while the board page is mounted.*/import {diff --git a/apps/desktop/src/plugins/kanban/board.tsx b/apps/desktop/src/plugins/kanban/board.tsxindex fb8ce6b605a..a7a8dcd14ad 100644--- a/apps/desktop/src/plugins/kanban/board.tsx+++ b/apps/desktop/src/plugins/kanban/board.tsx@@ -44,12 +44,12 @@ import {Switch,Textarea,Tip,- TITLEBAR_AREAS,useGrabScroll,useMutation,useQuery,useQueryClient,- useValue+ useValue,+ WORKSPACE_PAGE_HEADER_AREA} from '@hermes/plugin-sdk'import {type CSSProperties,@@ -1323,8 +1323,8 @@ export function KanbanBoardPage() {return (<div className="relative flex h-full flex-col overflow-hidden bg-(--ui-surface-background)">- {/* Page-owned titlebar chrome: exists exactly while this page is mounted. */}- <Contribute area={TITLEBAR_AREAS.center} id="kanban:board-switcher">+ {/* Page-owned header chrome: exists exactly while this page is mounted. */}+ <Contribute area={WORKSPACE_PAGE_HEADER_AREA} id="kanban:board-switcher"><BoardSwitcher /></Contribute>diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex d39ce7402b8..35b6694390c 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -1596,7 +1596,13 @@ export {PanelRowMenu,PanelSectionLabel} from '@/app/overlays/panel'-export { type RouteContribution, ROUTES_AREA, SIDEBAR_NAV_AREA, type SidebarNavContribution } from '@/app/routes'+export {+ type RouteContribution,+ ROUTES_AREA,+ SIDEBAR_NAV_AREA,+ type SidebarNavContribution,+ WORKSPACE_PAGE_HEADER_AREA+} from '@/app/routes'/** THE full per-toolset config panel core Settings renders — provider picker,* env vars / API keys, model catalog picker, and post-setup runners. Route-@@ -1810,6 +1816,10 @@ export { reasoningEffortLabel } from '@/lib/reasoning-effort'export const PANES_AREA = 'panes'export const STATUSBAR_AREAS = { left: 'statusBar.left', right: 'statusBar.right' } as const+/** Titlebar slots are PERMANENT mount points: a component registered here+ * stays mounted across chat ↔ page navigation, so `useEffect` setup/cleanup+ * runs once per registration, not once per route. Page-owned controls that+ * should exist only while a page is up go to `WORKSPACE_PAGE_HEADER_AREA`. */export const TITLEBAR_AREAS = { center: 'titleBar.center', left: 'titleBar.left', right: 'titleBar.right' } as const/** The app's own gateway-readiness evaluation (setup.status +diff --git a/website/docs/developer-guide/desktop-plugin-sdk.md b/website/docs/developer-guide/desktop-plugin-sdk.mdindex 099c0bf75a6..fe9fc06eee3 100644--- a/website/docs/developer-guide/desktop-plugin-sdk.md+++ b/website/docs/developer-guide/desktop-plugin-sdk.md@@ -212,6 +212,7 @@ Import the area constants from the SDK; each area has its own `data` payload.| Sidebar nav | `SIDEBAR_NAV_AREA` | `data: { path, label, codicon }` || Status bar | `STATUSBAR_AREAS.left` / `.right` | `render` (or `data` as `StatusbarItem`) || Title bar | `TITLEBAR_AREAS.left` / `.center` / `.right` | `data` as `TitlebarTool`, or a mount-scoped `<Contribute>` |+| Page header | `WORKSPACE_PAGE_HEADER_AREA` | `render` via a mount-scoped `<Contribute>` inside your page || ⌘K palette | `PALETTE_AREA` | `data: PaletteContribution` || Keybind | `KEYBINDS_AREA` | `data: KeybindContribution` || Theme | `THEMES_AREA` | `data` as a `DesktopTheme` |@@ -303,6 +304,18 @@ ctx.register({Title-bar tools live in `TITLEBAR_AREAS.left | .center | .right` as `TitlebarTool`data (`{ id, label, icon, active?, onSelect? }`).+Title-bar slots are **permanent mount points**: a component you register there+stays mounted while the user moves between the chat and full pages (Capabilities,+Messaging, Artifacts, contributed routes), so a `useEffect` that injects global+side effects (a `<style>` tag, `html[data-*]` attributes, a `MutationObserver`)+runs its setup once per registration and its cleanup once at dispose — never+mid-navigation.++Controls that belong to ONE page (the Kanban board switcher) go in+`WORKSPACE_PAGE_HEADER_AREA` instead: it renders in the workspace panel's+tab-header row while that page is on screen and is empty otherwise. Register it+with a mount-scoped `<Contribute>` (below) so it leaves with the page.+### Palette commands and keybinds```javascript@@ -451,14 +464,14 @@ per frame.### Mount-scoped chrome (`Contribute`)`ctx.register` is for **permanent** contributions. When chrome should live and-die with a component that's already on screen (a page's own title-bar control+die with a component that's already on screen (a page's own header controlleaves when the page unmounts), render `<Contribute>` inside it instead:```javascript-import { Contribute, TITLEBAR_AREAS } from '@hermes/plugin-sdk'+import { Contribute, WORKSPACE_PAGE_HEADER_AREA } from '@hermes/plugin-sdk'jsx(Contribute, {- area: TITLEBAR_AREAS.center,+ area: WORKSPACE_PAGE_HEADER_AREA,id: 'my-page:switcher', // namespace with your slugchildren: jsx(MySwitcher, {})})@@ -919,7 +932,7 @@ not treat this pipeline as a trust boundary.|----------|---------|| Host | `host` (`.state.*`, `.notify`, `.notifyError`, `.navigate`, `.onEvent`, `.logs`, `.status`, `.restartGateway`, `.request`) || Plugin contract | `HermesPlugin`, `PluginContext`, `PluginContribution`, `PluginStorage`, `PluginOs`, `PluginRestOptions`, `PluginNativeNotificationInput`, `PluginNotificationAction`, `HermesOpenTarget`, `Contribution` |-| Area constants | `PANES_AREA`, `ROUTES_AREA`, `SIDEBAR_NAV_AREA`, `STATUSBAR_AREAS`, `TITLEBAR_AREAS`, `PALETTE_AREA`, `KEYBINDS_AREA`, `THEMES_AREA`, `COMPOSER_AREAS` |+| Area constants | `PANES_AREA`, `ROUTES_AREA`, `SIDEBAR_NAV_AREA`, `STATUSBAR_AREAS`, `TITLEBAR_AREAS`, `WORKSPACE_PAGE_HEADER_AREA`, `PALETTE_AREA`, `KEYBINDS_AREA`, `THEMES_AREA`, `COMPOSER_AREAS` || Area payloads | `RouteContribution`, `SidebarNavContribution`, `StatusbarItem`, `TitlebarTool`, `PaletteContribution`, `KeybindContribution`, `ComposerMiddleware`, `ComposerAttachmentProvider` || React / state | `useValue`, `atom`, `computed`, `useQuery`, `useMutation`, `useQueryClient`, `queryClient`, `Contribute` || Theming | `useTheme`, `requestTheme`, `setAccentOverride`, `$accentOverride`, `retintTheme`, `themeHue`, `DesktopTheme`, `DesktopThemeColors`, plus OKLCH math (`hexToOklch`, `oklchToHex`, `oklchToSrgb255`, `mixOklab`, `maxChroma`, `hueDelta`, `normalizeHex`) and sRGB measures (`contrastRatio` — `number | null`, null for unparseable input — `readableOn`) |