The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): SESSIONS | BOTS is always a tab strip — the Bots pane re-homes beside Sessions on every boot, no heal guards
Teknium47eadccdc4b2
diff --git a/apps/desktop/src/components/pane-shell/tree/dock-heal.test.ts b/apps/desktop/src/components/pane-shell/tree/dock-enforce.test.tssimilarity index 57%rename from apps/desktop/src/components/pane-shell/tree/dock-heal.test.tsrename to apps/desktop/src/components/pane-shell/tree/dock-enforce.test.tsindex 6619a8cefa6..21a03e431f4 100644--- a/apps/desktop/src/components/pane-shell/tree/dock-heal.test.ts+++ b/apps/desktop/src/components/pane-shell/tree/dock-enforce.test.ts@@ -1,14 +1,16 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-// One-time dock heals: a pane already adopted under an OLD dock hint (Bot-// Mode's Bots pane split BELOW sessions) re-homes onto its new center anchor-// exactly once — persisted layouts otherwise pin the stale arrangement-// forever, because adoption only ever places panes MISSING from the tree.-// Guards under test: user-placed layouts are never touched, and a burned-// token never re-fights the user across later adoption passes.+// Enforced dock invariants: a pane whose dock hint carries `enforce: true`+// (Bot Mode's Bots pane) re-homes onto its center anchor at EVERY boot's+// first adoption pass — persisted layouts otherwise pin the stale stacked+// arrangement forever, because adoption only ever places panes MISSING from+// the tree. Unlike the retired one-time heal, nothing exempts the pane: not+// a previously burned heal token, not $userPlacedPanes. The invariant is+// boot-scoped, so an intra-session drag sticks until the next launch.const TREE_KEY = 'hermes.desktop.layoutTree.v2'const USER_PLACED_KEY = 'hermes.desktop.userPlacedPanes.v1'+const LEGACY_HEAL_KEY = 'hermes.desktop.paneDockHeals.v1'// The shipped regression shape: sessions and bots as SIBLING groups in a// column (the old `pos: 'bottom'` split), workspace beside them.@@ -32,7 +34,7 @@ const stackedTree = {]}-describe('one-time dock heal (stacked Bots pane → sessions-zone tab)', () => {+describe('enforced dock (stacked Bots pane → sessions-zone tab, every boot)', () => {beforeEach(() => {window.localStorage.clear()vi.resetModules()@@ -69,7 +71,7 @@ describe('one-time dock heal (stacked Bots pane → sessions-zone tab)', () => {title: 'Bots',data: {placement: 'left',- dock: { pane: 'sessions', pos: 'center', heal: 'sessions-tab-v1' }+ dock: { pane: 'sessions', pos: 'center', enforce: true }},render: () => null})@@ -85,15 +87,15 @@ describe('one-time dock heal (stacked Bots pane → sessions-zone tab)', () => {const group = model.findGroupOfPane(tree.$layoutTree.get()!, 'hermes-bots:pane')!expect(group.panes).toEqual(['sessions', 'hermes-bots:pane'])- // Silent like adoption — the heal must not steal the sessions tab.+ // Silent like adoption — the enforce must not steal the sessions tab.expect(group.active).toBe('sessions')- // The persisted tree carries the healed shape (survives the next boot).+ // The persisted tree carries the tabbed shape (survives the next boot).const persisted = JSON.parse(window.localStorage.getItem(TREE_KEY)!) as { children?: unknown[] }expect(JSON.stringify(persisted)).toContain('"panes":["sessions","hermes-bots:pane"]')})- it('never touches a layout the user placed the pane in themselves', async () => {+ it('re-homes even a USER-PLACED pane — the owner invariant beats the drag record', async () => {window.localStorage.setItem(USER_PLACED_KEY, JSON.stringify(['hermes-bots:pane']))const { model, tree } = await setup()@@ -102,22 +104,36 @@ describe('one-time dock heal (stacked Bots pane → sessions-zone tab)', () => {const group = model.findGroupOfPane(tree.$layoutTree.get()!, 'hermes-bots:pane')!- // Still its own zone below sessions — the user's spot wins.- expect(group.panes).toEqual(['hermes-bots:pane'])+ expect(group.panes).toEqual(['sessions', 'hermes-bots:pane'])+ })++ it('re-homes even when the retired heal token was already burned, and clears the stale ledger', async () => {+ window.localStorage.setItem(LEGACY_HEAL_KEY, JSON.stringify(['hermes-bots:pane:sessions-tab-v1']))++ const { model, tree } = await setup()++ tree.watchContributedPanes()++ const group = model.findGroupOfPane(tree.$layoutTree.get()!, 'hermes-bots:pane')!++ expect(group.panes).toEqual(['sessions', 'hermes-bots:pane'])+ // The one-time-heal ledger is dead state now — importing the store drops it.+ expect(window.localStorage.getItem(LEGACY_HEAL_KEY)).toBeNull()})- it('burns its token once: a user who re-stacks the pane afterward is not fought', async () => {+ it('is idempotent within a boot and does not fight an intra-session drag', async () => {const { model, tree, registry } = await setup()tree.watchContributedPanes()- // Sanity: healed.+ // Sanity: enforced into the strip.expect(model.findGroupOfPane(tree.$layoutTree.get()!, 'hermes-bots:pane')!.panes).toContain('sessions')// The user drags the pane back out into its own zone below sessions.tree.$layoutTree.set(JSON.parse(JSON.stringify(stackedTree)))- // A later registry mutation re-runs the adoption pass (the heal's caller).+ // A later registry mutation re-runs the adoption pass (the enforce's+ // caller) — same boot, so the drag sticks until the next launch.registry.register({id: 'other',area: 'panes',@@ -130,4 +146,23 @@ describe('one-time dock heal (stacked Bots pane → sessions-zone tab)', () => {expect(group.panes).toEqual(['hermes-bots:pane'])})++ it('re-homes again on the NEXT boot after a drag persisted the stacked shape', async () => {+ const first = await setup()++ first.tree.watchContributedPanes()+ first.tree.$layoutTree.set(JSON.parse(JSON.stringify(stackedTree)))+ first.tree.persistTree()++ // Simulate the next launch: fresh module graph, persisted stacked tree.+ vi.resetModules()++ const second = await setup()++ second.tree.watchContributedPanes()++ const group = second.model.findGroupOfPane(second.tree.$layoutTree.get()!, 'hermes-bots:pane')!++ expect(group.panes).toEqual(['sessions', 'hermes-bots:pane'])+ })})diff --git a/apps/desktop/src/components/pane-shell/tree/store.ts b/apps/desktop/src/components/pane-shell/tree/store.tsindex bc75a0f072b..d6c85ce8561 100644--- a/apps/desktop/src/components/pane-shell/tree/store.ts+++ b/apps/desktop/src/components/pane-shell/tree/store.ts@@ -1105,43 +1105,40 @@ interface PaneDockHint {pos: DropPosition/** Center docks: stack BEFORE this pane id (the strip divider's slot). */before?: null | string- /** One-time re-home token: a pane ALREADY adopted under an older dock hint- * moves onto this hint's center anchor once per token — never when the- * user has placed the pane themselves. See `healDockedPanes`. */- heal?: string+ /** Enforced dock invariant: the pane is re-homed onto this hint's center+ * anchor on EVERY boot when it isn't already stacked with the anchor —+ * no one-time token, and user placement does not exempt it. Once per+ * adoption lifetime (per boot), so an intra-session drag sticks until the+ * next boot. See `enforceDockedPanes`. */+ enforce?: boolean}-// One-time dock heals already applied, persisted so a heal runs exactly once-// per pane per token across boots (and never re-fights a user who re-arranges-// the healed pane afterward).-const DOCK_HEAL_KEY = 'hermes.desktop.paneDockHeals.v1'+// The retired one-time dock-heal ledger (`heal: '<token>'` hints). Its guards+// (token burned even when the heal was skipped; $userPlacedPanes exempt) left+// exactly the users who had fought the old stacked layout stuck with it —+// enforced docks (`enforce: true`) replaced it. Drop the stale key.+writeKey('hermes.desktop.paneDockHeals.v1', null)-const appliedDockHeals = new Set<string>(readJson<string[]>(DOCK_HEAL_KEY) ?? [])--function markDockHealApplied(token: string) {- appliedDockHeals.add(token)- writeJson(DOCK_HEAL_KEY, [...appliedDockHeals])-}+// Panes already enforced THIS boot: the invariant re-asserts at boot, not+// against a live user — a mid-session drag out of the anchor strip sticks+// until the next launch, so there is never a tug-of-war.+const enforcedDocksThisBoot = new Set<string>()/**- * A `panes` contribution whose dock hint carries a `heal` token gets ONE- * chance to re-home its already-adopted pane onto the hint's anchor —- * adoption is once per pane lifetime (the persisted tree remembers it), so a- * contribution whose default dock CHANGED would otherwise never reach- * existing installs. Guarded hard:- *- * - the token burns exactly once per pane (idempotent across boots), and it- * burns even when the heal is skipped, so a user who later drags the pane- * back to the old spot is never fought;- * - a USER-PLACED pane ($userPlacedPanes) is never touched — their spot wins;- * - center re-homes only: a heal exists to consolidate a stray split into- * its anchor's tab strip, not to re-run arbitrary splits.+ * A `panes` contribution whose dock hint carries `enforce: true` is re-homed+ * onto the hint's center anchor at every boot's first adoption pass when it+ * isn't already stacked there. Unlike the retired one-time heal, nothing+ * exempts the pane — not a burned token, not $userPlacedPanes — because the+ * hint is the owner's standing invariant about where the pane lives+ * (Bot Mode's Bots pane IS the SESSIONS | BOTS tab strip), not a one-shot+ * migration. Center re-homes only: the invariant consolidates the pane into+ * its anchor's tab strip, it never re-runs arbitrary splits.** Silent like adoption — the anchor zone keeps its active tab. The center* insert pins the zone's header shown, which is the point: the strip is how- * the user finds the healed tab.+ * the user finds the tab.*/-function healDockedPanes(+function enforceDockedPanes(tree: LayoutNode,dataOf: (paneId: string) => { dock?: PaneDockHint; placement?: string } | undefined): LayoutNode {@@ -1150,21 +1147,15 @@ function healDockedPanes(for (const pane of registry.getArea('panes')) {const dock = dataOf(pane.id)?.dock- if (!dock?.heal || dock.pos !== 'center' || !allPaneIds(next).includes(pane.id)) {+ if (!dock?.enforce || dock.pos !== 'center' || !allPaneIds(next).includes(pane.id)) {continue}- const token = `${pane.id}:${dock.heal}`-- if (appliedDockHeals.has(token)) {+ if (enforcedDocksThisBoot.has(pane.id)) {continue}- markDockHealApplied(token)-- if ($userPlacedPanes.get().has(pane.id)) {- continue- }+ enforcedDocksThisBoot.add(pane.id)const from = findGroupOfPane(next, pane.id)const anchor = findGroupOfPane(next, dock.pane)@@ -1205,9 +1196,9 @@ function adoptContributedPanes(): void {const dismissed = $dismissedPanes.get()- // One-time dock heals run FIRST: a heal re-homes a pane that is ALREADY in- // the tree, so the missing-pane adoption below never sees it.- const healed = healDockedPanes(tree, dataOf)+ // Enforced dock invariants run FIRST: they re-home panes that are ALREADY+ // in the tree, so the missing-pane adoption below never sees them.+ const healed = enforceDockedPanes(tree, dataOf)// `placement: 'floating'` opts OUT of the tree entirely — those panes render// as fixed cards above it (renderer/floating-panes.tsx). Adopting one woulddiff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.jsindex 68a01f7c96a..98aaf64c07f 100644--- a/apps/desktop/src/plugins/hermes-bots/plugin.js+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js@@ -8366,10 +8366,17 @@ export default {// stays shown once the zone has stacked), so the sessions pane can// never vanish behind a stripless Bots tab — the lone-pane auto-hide// trap this dock used to work around with a 'bottom' split.- // heal: one-shot re-home for installs that adopted under the old- // 'bottom' split — moves the pane into the sessions strip ONCE, never- // touching a user-placed layout (see healDockedPanes in the tree store).- data: { placement: 'left', width: '260px', dock: { pane: 'sessions', pos: 'center', heal: 'sessions-tab-v1' } },+ // enforce: standing invariant, not a one-shot migration — the pane+ // re-homes into the sessions strip at EVERY boot it isn't already+ // there, whatever tokens or user placement an older install persisted.+ // The one-time heal ('sessions-tab-v1') burned its token even when its+ // guards skipped the move, so exactly the users who had fought the old+ // stacked layout (dragged panes → $userPlacedPanes) stayed stacked+ // forever. Owner's order: SESSIONS | BOTS is always a tab strip.+ // An intra-session drag still sticks until the next launch (the+ // invariant runs at adoption time only — see enforceDockedPanes in the+ // tree store).+ data: { placement: 'left', width: '260px', dock: { pane: 'sessions', pos: 'center', enforce: true } },render: () => jsx(BotsPane, {})})diff --git a/apps/desktop/src/plugins/hermes-bots/tests/pane-dock-layout.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/pane-dock-layout.test.mjsindex 229ed607822..f8b85d3d604 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/pane-dock-layout.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/pane-dock-layout.test.mjs@@ -4,8 +4,10 @@ import test from 'node:test'// Bot Mode layout contract:// - the Bots pane center-stacks into the sessions zone (SESSIONS | BOTS tab-// strip), never splits below it, and carries a one-shot heal token so-// installs that adopted under the old 'bottom' split migrate;+// strip), never splits below it, and carries the ENFORCED dock invariant+// so every boot re-homes a stacked install — no heal token, no+// user-placed exemption (the retired one-shot heal left users who had+// dragged panes stuck stacked forever);// - the Cronjobs (routines) pane only exists while the Bots pane is on// screen — registered/unregistered through the contribution disposer,// driven by the feature-detected host.paneVisibility SDK export, with the@@ -13,10 +15,12 @@ import test from 'node:test'const source = readFileSync(new URL('../plugin.js', import.meta.url), 'utf8')-test('the Bots pane center-docks into the sessions zone with a heal token', () => {- assert.match(source, /dock: \{ pane: 'sessions', pos: 'center', heal: 'sessions-tab-v1' \}/)+test('the Bots pane center-docks into the sessions zone as an enforced invariant', () => {+ assert.match(source, /dock: \{ pane: 'sessions', pos: 'center', enforce: true \}/)// The old workaround split must not come back.assert.doesNotMatch(source, /pane: 'sessions', pos: 'bottom'/)+ // Neither may the retired one-shot heal token.+ assert.doesNotMatch(source, /heal: 'sessions-tab-v1'/)})test('routines registration is a reusable disposer-returning function', () => {