The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): derive the tab hover close button from the close verb
ethernet9815319d5fcd
diff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsxindex 05a0912dd91..79ba22d8172 100644--- a/apps/desktop/src/app/contrib/controller.tsx+++ b/apps/desktop/src/app/contrib/controller.tsx@@ -164,7 +164,6 @@ registry.registerMany([collapsible: true,dock: { pane: 'workspace', pos: 'left' },revealAliases: ['chat-sidebar'],- showCloseButton: false,// Standing chrome: no close gestures at all — the tab is shown/hidden// (zone menu Show/Hide rows + the auto-registered ⌘K toggle below).hideOnly: true,diff --git a/apps/desktop/src/components/pane-shell/tree/renderer/tab-close-affordance.test.tsx b/apps/desktop/src/components/pane-shell/tree/renderer/tab-close-affordance.test.tsxnew file mode 100644index 00000000000..cfecf788479--- /dev/null+++ b/apps/desktop/src/components/pane-shell/tree/renderer/tab-close-affordance.test.tsx@@ -0,0 +1,110 @@+import { cleanup, fireEvent, render } from '@testing-library/react'+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'++import { registry } from '@/contrib/registry'++import { allPaneIds, group, split } from '../model'+import { $layoutTree } from '../store'++import { TreeGroup } from './tree-group'++// The hover ✕ and middle-click are ONE affordance in two shapes: whichever tabs+// the pointer gesture can close must advertise it. A tab that closes on+// middle-click but hides its ✕ is a close verb the user cannot discover, and a+// tab that shows a ✕ it will not honor is a dead control. This asserts the+// equivalence over every tab kind the app registers, so the ✕ can never be+// wired (or un-wired) on its own again.++class TestResizeObserver {+ observe() {}+ unobserve() {}+ disconnect() {}+}++beforeAll(() => {+ vi.stubGlobal('ResizeObserver', TestResizeObserver)+ // jsdom lacks CSS.escape, which tab-strip-scroll uses in a layout effect.+ vi.stubGlobal('CSS', { ...globalThis.CSS, escape: (value: string) => value })+ Element.prototype.hasPointerCapture ??= () => false+ Element.prototype.setPointerCapture ??= () => undefined+ Element.prototype.releasePointerCapture ??= () => undefined+ HTMLElement.prototype.scrollIntoView ??= () => undefined+})++const disposers: (() => void)[] = []++/** Every tab kind that shares a strip, paired with what its chrome declares. */+const PANES: readonly (readonly [string, Record<string, unknown>])[] = [+ // Standing chrome: no close gesture of any kind.+ ['sessions', { hideOnly: true, placement: 'left' }],+ // A plain side pane: closes, so it must say so.+ ['files', { placement: 'right' }],+ // The one surface that cannot leave the tree.+ ['workspace', { placement: 'main', uncloseable: true }],+ // A mirrored session tile — `placement: 'main'` but closeable.+ ['session-tile:abc', { placement: 'main' }]+]++beforeEach(async () => {+ window.localStorage.clear()++ const { $dismissedPanes, $hiddenTreePanes } = await import('../store')+ $dismissedPanes.set(new Set())+ $hiddenTreePanes.set(new Set())++ for (const [id, data] of PANES) {+ disposers.push(registry.register({ area: 'panes', data, id, render: () => null, title: id }))+ }+})++afterEach(() => {+ cleanup()+ disposers.splice(0).forEach(dispose => dispose())+})++/** All four panes in ONE zone, so every tab renders in the same strip. */+function renderOneStrip() {+ $layoutTree.set(+ split('row', [+ group(+ PANES.map(([id]) => id),+ { active: 'workspace', id: 'grp-all' }+ ),+ group(['spacer'], { id: 'grp-spacer' })+ ])+ )++ const node = $layoutTree.get()!+ const zone = (node.type === 'split' ? node.children[0] : node) as never++ render(<TreeGroup node={zone} parentAxis="row" />)+}++const tabEl = (paneId: string) => document.querySelector<HTMLElement>(`[data-tree-tab="${paneId}"]`)++/** Does this tab advertise a ✕? */+const hasCloseButton = (paneId: string) => Boolean(tabEl(paneId)?.querySelector('button[aria-label]'))++/** Does the middle-click gesture actually close this tab? Observed through the+ * tree, not through a spy — a pane that is gone stopped being a tab. */+function middleClickCloses(paneId: string): boolean {+ const tab = tabEl(paneId)!+ fireEvent.pointerDown(tab, { button: 1 })+ fireEvent.pointerUp(tab, { button: 1 })++ return !allPaneIds($layoutTree.get()!).includes(paneId)+}++describe('a tab advertises exactly the close gesture it honors', () => {+ for (const [paneId] of PANES) {+ it(`${paneId}: ✕ presence matches middle-click`, () => {+ renderOneStrip()++ expect(tabEl(paneId)).toBeTruthy()++ const advertised = hasCloseButton(paneId)++ expect(advertised).toBe(middleClickCloses(paneId))+ })+ }+})diff --git a/apps/desktop/src/components/pane-shell/tree/renderer/track-model.ts b/apps/desktop/src/components/pane-shell/tree/renderer/track-model.tsindex 565c613e324..268dbb4b56e 100644--- a/apps/desktop/src/components/pane-shell/tree/renderer/track-model.ts+++ b/apps/desktop/src/components/pane-shell/tree/renderer/track-model.ts@@ -64,12 +64,12 @@ interface PaneChrome extends PaneSizing {/** No Close in the tab menu — the one surface the app can't lose (the* main workspace). Session tiles share `placement: 'main'` but close. */uncloseable?: boolean- /** Hide the hover ✕ while retaining explicit close behavior for this pane. */- showCloseButton?: boolean- /** Standing chrome tab (sessions / Bots) whose tab shows NO ✕ and no Close- * verbs — it is shown/hidden instead (the zone menu's Show/Hide rows and a- * ⌘K toggle, via `setStripTabHidden`). Close was too destructive for these:- * an accidental ✕ removed Bot Mode until the next launch. */+ /** Standing chrome tab (sessions / Bots) with NO close verb at all: no ✕,+ * no middle / ⌘-click, no Close menu rows. It is shown/hidden instead (the+ * zone menu's Show/Hide rows and a ⌘K toggle, via `setStripTabHidden`).+ * Close was too destructive for these: an accidental ✕ removed Bot Mode+ * until the next launch. The ✕ follows the verb (see `PaneTab.onClose`),+ * so dropping the verb here is what takes the chip off the tab. */hideOnly?: boolean/** Wrap this pane's TAB (e.g. in a domain context menu — a session tile's* pin/branch/rename/archive/delete). The wrapper must render `tab` as itsdiff --git a/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx b/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsxindex fa5fca4e51b..bc1e7b90eff 100644--- a/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx+++ b/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx@@ -556,7 +556,6 @@ export function TreeGroup({}}role="tab"selected={isSelected}- showCloseButton={chrome.showCloseButton !== false}style={{ cursor: 'grab' }}>{chrome.tabLead ? (diff --git a/apps/desktop/src/components/ui/pane-tab.test.tsx b/apps/desktop/src/components/ui/pane-tab.test.tsxindex 2ada280145d..bdd275497ab 100644--- a/apps/desktop/src/components/ui/pane-tab.test.tsx+++ b/apps/desktop/src/components/ui/pane-tab.test.tsx@@ -124,15 +124,16 @@ describe('PaneTab hover close button', () => {expect(screen.queryByRole('button', { name: 'Close' })).toBeNull()})- it('can hide the hover ✕ while retaining the close handler', () => {+ it('a closeable horizontal tab always shows its ✕ — the chip and the pointer gestures are one affordance', () => {const onClose = vi.fn()render(- <PaneTab onClose={onClose} showCloseButton={false}>+ <PaneTab onClose={onClose}><PaneTabLabel>tab</PaneTabLabel></PaneTab>)- expect(screen.queryByRole('button', { name: 'Close' })).toBeNull()+ expect(screen.getByRole('button', { name: 'Close' })).toBeTruthy()+const tab = screen.getByText('tab')fireEvent.pointerDown(tab, { button: 1 })fireEvent.pointerUp(tab, { button: 1 })diff --git a/apps/desktop/src/components/ui/pane-tab.tsx b/apps/desktop/src/components/ui/pane-tab.tsxindex c08e98d10b4..dbf9fab10e5 100644--- a/apps/desktop/src/components/ui/pane-tab.tsx+++ b/apps/desktop/src/components/ui/pane-tab.tsx@@ -53,13 +53,14 @@ interface PaneTabProps extends React.ComponentProps<'div'> {dirty?: boolean/** Close verb. Horizontal tabs reveal a hover ✕ on the right (a `--tab-face`* gradient fades it over the label); middle-click and ⌘-click always work,- * and stay the only gestures on vertical rails (no room for a chip ✕). */+ * and stay the only gestures on vertical rails (no room for a chip ✕).+ * There is no way to take the ✕ off a tab that HAS this verb: the chip and+ * the pointer gestures are one affordance, so a closeable tab always says+ * so. Omit `onClose` to make a tab uncloseable. */onClose?: () => void/** Part of a multi-tab selection (⌥/Ctrl-click, Shift-click) — an accent* wash marks every tab that a drag would carry, Chrome-style. */selected?: boolean- /** Whether a closeable horizontal tab reveals the hover ✕. */- showCloseButton?: boolean/** Vertical rail form (collapsed sidebar zones). */vertical?: boolean/** Content-facing edge of a vertical rail — the strip line the active tab cuts. */@@ -83,7 +84,6 @@ export const PaneTab = React.forwardRef<HTMLDivElement, PaneTabProps>(function PonPointerUp,onClickCapture,selected = false,- showCloseButton = true,vertical = false,side = 'left',children,@@ -162,7 +162,7 @@ export const PaneTab = React.forwardRef<HTMLDivElement, PaneTabProps>(function P<span className="size-2 rounded-full bg-amber-500 shadow-[0_0_0_2px_var(--tab-bg),0_1px_2px_rgba(0,0,0,0.45)] dark:bg-amber-400" /></span>)}- {onClose && showCloseButton && !vertical && (+ {onClose && !vertical && (// Hover ✕, painted OVER the label's right edge as an overlay (no// layout shift, tab width never jumps on hover). The runway is a tiny// transparent→`--tab-face` gradient, so the button melts into thediff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.jsindex 07b3df6e54a..3fe2c4eb7ec 100644--- a/apps/desktop/src/plugins/hermes-bots/plugin.js+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js@@ -11857,7 +11857,7 @@ export default {// sessions pane collapses alone without this flag. The zone then keeps// a stranded BOTS tab on screen. The narrow edge overlay mirrors the// zone's tab strip, so the pane stays reachable while collapsed.- data: { placement: 'left', width: '260px', collapsible: true, showCloseButton: false, hideOnly: true, dock: { pane: 'sessions', pos: 'center', enforce: true } },+ data: { placement: 'left', width: '260px', collapsible: true, hideOnly: true, dock: { pane: 'sessions', pos: 'center', enforce: true } },render: () => jsx(BotsPane, {})})