Skip to content

The agent that grows with you

fix(desktop): name the zone menu from the tab's text, not its element

Teknium748ee7e990ac
diff --git a/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.test.tsx b/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.test.tsx
index def5ce9a3c0..dcbf229adde 100644
--- a/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.test.tsx
+++ b/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.test.tsx
@@ -257,6 +257,29 @@ describe('TreeGroup', () => {
expect(strip.style).toHaveProperty('WebkitAppRegion', '')
})
+ // A pane's live tab label is a React element (the terminal's
+ // locale-following title), so the zone menu's accessible name must come
+ // from the string form, never the element ("Zone options for [object
+ // Object]").
+ it.each([
+ ['its string label', { tabTitleText: () => 'Terminal' }, 'Terminal'],
+ ['its registered title without one', {}, 'Shell']
+ ])('names the body zone menu from %s when the tab label is an element', (_case, chrome, expected) => {
+ disposePane = registry.register({
+ area: 'panes',
+ data: { placement: 'main', tabTitle: () => <span>Live label</span>, ...chrome },
+ id: 'terminal',
+ title: 'Shell',
+ render: () => <div>Terminal</div>
+ })
+ vi.stubGlobal('CSS', { escape: (value: string) => value })
+ stubResizeObserver()
+ render(<TreeGroup leftEdge node={terminalGroup(false)} rightEdge topEdge />)
+
+ const body = container!.querySelector<HTMLElement>('[data-zone-body="terminal-zone"]')!
+ expect(body.getAttribute('aria-label')).toBe(`Zone options for ${expected}`)
+ })
+
// The invariant behind the shared eligibility predicate
// (hostsSessionDropTarget): a session or new-session drag must paint the
// SAME zones either drag resolver would accept, and stay dark everywhere
diff --git a/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx b/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx
index e87cb6f14cc..69e14401267 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
@@ -934,7 +934,7 @@ export function TreeGroup({
wrap={
!isEmpty
? body => (
- <ZoneBodyMenu {...zoneMenu} label={t.zones.zoneMenuLabel(String(tabLabel(activeId)))}>
+ <ZoneBodyMenu {...zoneMenu} label={t.zones.zoneMenuLabel(tabText(activeId))}>
{body}
</ZoneBodyMenu>
)