Skip to content

The agent that grows with you

fix(webapp): the phone tab picker reaches every tab's menu (#145774)

Tekniumf0ee05c6b906
diff --git a/apps/desktop/src/app/chat/compact-tab-menu.test.tsx b/apps/desktop/src/app/chat/compact-tab-menu.test.tsx
new file mode 100644
index 00000000000..e9d2f87f60f
--- /dev/null
+++ b/apps/desktop/src/app/chat/compact-tab-menu.test.tsx
@@ -0,0 +1,124 @@
+import { useStore } from '@nanostores/react'
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import { MemoryRouter } from 'react-router'
+import { afterEach, beforeAll, beforeEach, expect, it, vi } from 'vitest'
+
+import { group } from '@/components/pane-shell/tree/model'
+import { TreeGroup } from '@/components/pane-shell/tree/renderer/tree-group'
+import { $layoutTree, $narrowViewport } from '@/components/pane-shell/tree/store'
+import { registry } from '@/contrib/registry'
+import { $sessions } from '@/store/session'
+import { $sessionTiles, type SessionTileDelegate, setSessionTileDelegate } from '@/store/session-states'
+import { stubMenuDomApis, stubResizeObserver } from '@/test/jsdom'
+import type { SessionInfo } from '@/types/hermes'
+
+import { watchSessionTiles } from './session-tile'
+
+// The transport: the REST rename the dialog falls back to with no live runtime.
+const renameSession = vi.hoisted(() => vi.fn())
+
+vi.mock('@/hermes', async importOriginal => ({ ...(await importOriginal<object>()), renameSession }))
+
+const row = (id: string, title: string): SessionInfo => ({
+ cwd: null,
+ ended_at: null,
+ id,
+ input_tokens: 0,
+ is_active: false,
+ last_active: 1,
+ message_count: 2,
+ model: null,
+ output_tokens: 0,
+ parent_session_id: null,
+ preview: null,
+ source: 'desktop',
+ started_at: 1,
+ title,
+ tool_call_count: 0
+})
+
+const panes = ['workspace', 'session-tile:s2', 'session-tile:s3']
+const delegate = { archiveSession: vi.fn(async () => {}), deleteSession: vi.fn(async () => {}) }
+
+let disposeWorkspace = () => {}
+
+function Host() {
+ const node = useStore($layoutTree)
+
+ return <MemoryRouter>{node?.type === 'group' && <TreeGroup node={node} />}</MemoryRouter>
+}
+
+/** Opens the phone picker, then the given tab's own menu from its row. */
+function openTabMenu(title: string) {
+ fireEvent.pointerDown(screen.getByRole('button', { name: /^3 tabs/ }), { button: 0, ctrlKey: false })
+ fireEvent.click(screen.getByRole('menuitem', { name: `Actions for ${title}` }))
+}
+
+beforeAll(() => {
+ // Real tile mirror: the tabs register with the same chrome a Webapp gets.
+ $sessionTiles.set([{ storedSessionId: 's2' }, { storedSessionId: 's3' }])
+ watchSessionTiles()
+})
+
+beforeEach(() => {
+ stubResizeObserver()
+ stubMenuDomApis()
+ vi.stubGlobal('CSS', { escape: (value: string) => value })
+ vi.stubGlobal(
+ 'matchMedia',
+ vi.fn().mockReturnValue({ matches: true, addEventListener: vi.fn(), removeEventListener: vi.fn() })
+ )
+ globalThis.document.documentElement.dataset.hermesDesktopHost = 'browser'
+ disposeWorkspace = registry.register({
+ area: 'panes',
+ id: 'workspace',
+ title: 'Main chat',
+ data: { placement: 'main' },
+ render: () => <p>main chat</p>
+ })
+ $sessions.set([row('s2', 'Trip plan'), row('s3', 'Old draft')])
+ setSessionTileDelegate(delegate as unknown as SessionTileDelegate)
+ renameSession.mockResolvedValue({ title: 'Trip plan v2' })
+ $layoutTree.set({ ...group(panes), active: 'workspace', tabStrip: 'always' })
+ $narrowViewport.set(true)
+})
+
+afterEach(() => {
+ cleanup()
+ disposeWorkspace()
+ $layoutTree.set(null)
+ $narrowViewport.set(false)
+ delete globalThis.document.documentElement.dataset.hermesDesktopHost
+ vi.clearAllMocks()
+ vi.unstubAllGlobals()
+})
+
+it('archives and deletes a background tab from the phone picker, delete behind its confirm', async () => {
+ render(<Host />)
+
+ openTabMenu('Trip plan')
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Archive' }))
+ expect(delegate.archiveSession).toHaveBeenCalledWith('s2')
+
+ openTabMenu('Old draft')
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
+ expect(delegate.deleteSession).not.toHaveBeenCalled()
+ fireEvent.click(within(await screen.findByRole('dialog')).getByRole('button', { name: 'Delete' }))
+ await waitFor(() => expect(delegate.deleteSession).toHaveBeenCalledWith('s3'))
+
+ // Neither verb touched the tab the user was on.
+ expect($layoutTree.get()).toMatchObject({ active: 'workspace' })
+})
+
+it('renames a background tab from the phone picker', async () => {
+ render(<Host />)
+
+ openTabMenu('Trip plan')
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Rename…' }))
+ const input = await screen.findByRole('textbox')
+ fireEvent.change(input, { target: { value: 'Trip plan v2' } })
+ await act(async () => fireEvent.click(screen.getByRole('button', { name: 'Save' })))
+
+ expect(renameSession).toHaveBeenCalledWith('s2', 'Trip plan v2', undefined)
+ await waitFor(() => expect($sessions.get().find(s => s.id === 's2')?.title).toBe('Trip plan v2'))
+})
diff --git a/apps/desktop/src/app/chat/pane-mirror.ts b/apps/desktop/src/app/chat/pane-mirror.ts
index 6b7507bc4a9..ab036c253bf 100644
--- a/apps/desktop/src/app/chat/pane-mirror.ts
+++ b/apps/desktop/src/app/chat/pane-mirror.ts
@@ -10,6 +10,7 @@ import type { ReadableAtom } from 'nanostores'
import type { ReactElement, ReactNode, PointerEvent as ReactPointerEvent } from 'react'
import { setTreePaneParked } from '@/components/pane-shell/tree/parked-panes'
+import type { TabActionsMenu } from '@/components/pane-shell/tree/renderer/track-model'
import {
adoptContributedPanes,
registerPaneCloser,
@@ -61,6 +62,8 @@ export interface PaneMirror<T> {
tabMenuPrefix?: (key: string) => ((kit: MenuKit) => ReactNode) | undefined
/** Wrap the tile's TAB (domain context menu — session verbs). */
tabWrap?: (key: string, tab: ReactElement) => ReactNode
+ /** The same menu from a button (see PaneChrome.tabActions). */
+ tabActions?: (key: string) => TabActionsMenu | undefined
/** Override the tile's TAB drag (session drop language: stack/split/link).
* Returns whether it took the drag (see PaneChrome.tabDrag). */
tabDrag?: (key: string, event: ReactPointerEvent<HTMLElement>, onTap: () => void) => boolean
@@ -91,6 +94,18 @@ export function paneMirror<T>(cfg: PaneMirror<T>): () => void {
pos: cfg.dir?.(tile) ?? 'right'
})
+ // The tile's tab hooks, bound to its key (absent when the mirror has none).
+ const tabChrome = (key: string) => ({
+ tabActions: cfg.tabActions ? () => cfg.tabActions!(key) : undefined,
+ // returns boolean (handled) — see PaneChrome.tabDrag
+ tabDrag: cfg.tabDrag
+ ? (event: ReactPointerEvent<HTMLElement>, onTap: () => void) => cfg.tabDrag!(key, event, onTap)
+ : undefined,
+ tabLead: cfg.tabLead ? () => cfg.tabLead!(key) : undefined,
+ tabTitle: cfg.tabTitle ? () => cfg.tabTitle!(key) : undefined,
+ tabWrap: cfg.tabWrap ? (tab: ReactElement) => cfg.tabWrap!(key, tab) : undefined
+ })
+
const dispose = (key: string) => {
registered.get(key)?.dispose()
registered.delete(key)
@@ -130,8 +145,7 @@ export function paneMirror<T>(cfg: PaneMirror<T>): () => void {
area: 'panes',
title,
data: {
- tabLead: cfg.tabLead ? () => cfg.tabLead!(key) : undefined,
- tabTitle: cfg.tabTitle ? () => cfg.tabTitle!(key) : undefined,
+ ...tabChrome(key),
dock,
lifecycleKeepAlive: cfg.lifecycleKeepAlive?.(key),
minWidth: cfg.minWidth,
@@ -140,11 +154,7 @@ export function paneMirror<T>(cfg: PaneMirror<T>): () => void {
// and closeable, which is what keeps its tab when it lands in a zone of
// its own (see strip-visibility.ts).
placement: 'main',
- tabDrag: cfg.tabDrag
- ? (event: ReactPointerEvent<HTMLElement>, onTap: () => void) => cfg.tabDrag!(key, event, onTap)
- : undefined, // returns boolean (handled) — see PaneChrome.tabDrag
- tabMenuPrefix: cfg.tabMenuPrefix?.(key),
- tabWrap: cfg.tabWrap ? (tab: ReactElement) => cfg.tabWrap!(key, tab) : undefined
+ tabMenuPrefix: cfg.tabMenuPrefix?.(key)
},
render: () => cfg.render(key)
})
diff --git a/apps/desktop/src/app/chat/session-tile.tsx b/apps/desktop/src/app/chat/session-tile.tsx
index 845144445fd..628319529ee 100644
--- a/apps/desktop/src/app/chat/session-tile.tsx
+++ b/apps/desktop/src/app/chat/session-tile.tsx
@@ -28,6 +28,7 @@ import { ReasoningMenuPanel } from '@/app/shell/reasoning-menu-panel'
import { formatRefValue } from '@/components/assistant-ui/directive-text'
import { CenteredThreadSpinner } from '@/components/assistant-ui/thread/status'
import { findGroupOfPane } from '@/components/pane-shell/tree/model'
+import type { TabActionsMenu, TabActionsMenuProps } from '@/components/pane-shell/tree/renderer/track-model'
import { $layoutTree, closeTreePane, moveTreePane, setTreeGroupTabStrip } from '@/components/pane-shell/tree/store'
import {
$workspaceOwnerLabels,
@@ -83,7 +84,7 @@ import { SessionStatusDot } from './session-status-dot'
import { useSessionTileActions } from './session-tile-actions'
import { tileOwnerRoute } from './session-tile-owner'
import { reasoningEffortPending, type SessionView, SessionViewProvider } from './session-view'
-import { SessionContextMenu } from './sidebar/session-actions-menu'
+import { SessionActionsMenu, SessionContextMenu } from './sidebar/session-actions-menu'
import { lastVisibleMessageIsUser } from './thread-loading'
import { ChatView } from '.'
@@ -867,19 +868,7 @@ function useTileMenuRow(storedSessionId: string): {
})
}
-/** A session TAB's context menu: the full session verb set (pin, copy id, new
- * window, branch, rename, archive, delete) — the SAME menu a sidebar row
- * gets, targeted through the tile delegate (whose verbs are generic over
- * stored ids, primary included). The wrapper stops the contextmenu from also
- * opening the zone strip's menu. Shared by tile tabs AND the main tab. */
-export function SessionTabMenu({
- children,
- onClose,
- onHideTabBar,
- storedSessionId,
- tabPaneId
-}: {
- children: React.ReactElement
+interface SessionTabMenuTarget {
/** Close this tab (tiles; the main tab passes nothing). */
onClose?: () => void
/** Hide the zone's tab bar (main tab only — the sticky bar's off switch). */
@@ -887,34 +876,75 @@ export function SessionTabMenu({
storedSessionId: string
/** Layout-tree pane id — powers the Close-others/right/all verbs. */
tabPaneId: string
-}) {
+}
+
+/** The session verbs a TAB offers, wired to the tile delegate (whose verbs are
+ * generic over stored ids, primary included). One source for the right-click
+ * menu and the phone picker's button menu, so the two never drift. */
+function useSessionTabActions({ onClose, onHideTabBar, storedSessionId, tabPaneId }: SessionTabMenuTarget) {
const { pinId, profile, renameable, title } = useTileMenuRow(storedSessionId)
const pinnedSessionIds = useStore($pinnedSessionIds)
const pinned = pinnedSessionIds.includes(pinId)
+ return {
+ onArchive: () => void sessionTileDelegate()?.archiveSession(storedSessionId),
+ onBranch: () => void sessionTileDelegate()?.branchSession(storedSessionId),
+ onClose,
+ onDelete: () => void sessionTileDelegate()?.deleteSession(storedSessionId),
+ onHideTabBar,
+ onPin: () => (pinned ? unpinSession(pinId) : pinSession(pinId)),
+ pinned,
+ profile,
+ renameable,
+ sessionId: storedSessionId,
+ surface: 'tab' as const,
+ tabPaneId,
+ title
+ }
+}
+
+/** A session TAB's context menu: the full session verb set (pin, copy id, new
+ * window, branch, rename, archive, delete) — the SAME menu a sidebar row
+ * gets. The wrapper stops the contextmenu from also opening the zone strip's
+ * menu. Shared by tile tabs AND the main tab. */
+export function SessionTabMenu({ children, ...target }: SessionTabMenuTarget & { children: React.ReactElement }) {
+ const actions = useSessionTabActions(target)
+
return (
<span className="contents" onContextMenu={event => event.stopPropagation()}>
- <SessionContextMenu
- onArchive={() => void sessionTileDelegate()?.archiveSession(storedSessionId)}
- onBranch={() => void sessionTileDelegate()?.branchSession(storedSessionId)}
- onClose={onClose}
- onDelete={() => void sessionTileDelegate()?.deleteSession(storedSessionId)}
- onHideTabBar={onHideTabBar}
- onPin={() => (pinned ? unpinSession(pinId) : pinSession(pinId))}
- pinned={pinned}
- profile={profile}
- renameable={renameable}
- sessionId={storedSessionId}
- surface="tab"
- tabPaneId={tabPaneId}
- title={title}
- >
- {children}
- </SessionContextMenu>
+ <SessionContextMenu {...actions}>{children}</SessionContextMenu>
</span>
)
}
+/** The same tab menu opened from a button — the phone tab picker, where no
+ * strip exists to right-click (#145774). */
+function SessionTabActionsMenu({ onOpenChange, open, trigger, ...target }: SessionTabMenuTarget & TabActionsMenuProps) {
+ const actions = useSessionTabActions(target)
+
+ return (
+ <SessionActionsMenu {...actions} align="start" onOpenChange={onOpenChange} open={open}>
+ {trigger}
+ </SessionActionsMenu>
+ )
+}
+
+const hideWorkspaceTabBar = () => {
+ const tree = $layoutTree.get()
+ const group = tree ? findGroupOfPane(tree, 'workspace') : null
+
+ if (group) {
+ setTreeGroupTabStrip(group.id, 'never')
+ }
+}
+
+const workspaceTabTarget = (storedSessionId: string): SessionTabMenuTarget => ({
+ onClose: () => closeTreePane('workspace'),
+ onHideTabBar: hideWorkspaceTabBar,
+ storedSessionId,
+ tabPaneId: 'workspace'
+})
+
/** The MAIN tab's menu: the same session verbs targeting the primary's loaded
* session, plus Close (the tab empties to a fresh draft — the workspace pane
* itself never leaves the tree) and the bar's off switch (the bar sticky-shows
@@ -923,31 +953,27 @@ export function SessionTabMenu({
export function WorkspaceTabMenu({ children }: { children: React.ReactElement }) {
const selected = useStore($selectedStoredSessionId)
- const hideTabBar = () => {
- const tree = $layoutTree.get()
- const group = tree ? findGroupOfPane(tree, 'workspace') : null
-
- if (group) {
- setTreeGroupTabStrip(group.id, 'never')
- }
- }
-
if (!selected) {
return children
}
- return (
- <SessionTabMenu
- onClose={() => closeTreePane('workspace')}
- onHideTabBar={hideTabBar}
- storedSessionId={selected}
- tabPaneId="workspace"
- >
- {children}
- </SessionTabMenu>
- )
+ return <SessionTabMenu {...workspaceTabTarget(selected)}>{children}</SessionTabMenu>
+}
+
+/** The main tab's button menu (see `PaneChrome.tabActions`); none on a fresh
+ * draft, same as the right-click menu. */
+export const workspaceTabActions = (): TabActionsMenu | undefined => {
+ const selected = $selectedStoredSessionId.get()
+
+ return selected ? props => <SessionTabActionsMenu {...props} {...workspaceTabTarget(selected)} /> : undefined
}
+const tileTabTarget = (storedSessionId: string): SessionTabMenuTarget => ({
+ onClose: () => requestCloseSessionTile(storedSessionId),
+ storedSessionId,
+ tabPaneId: `session-tile:${storedSessionId}`
+})
+
/** Keep pane contributions mirroring `$sessionTiles` (+ titles from
* `$sessions`). Tiles dock against main on the chosen edge, flex width. */
export const watchSessionTiles = paneMirror<SessionTile>({
@@ -983,15 +1009,8 @@ export const watchSessionTiles = paneMirror<SessionTile>({
<SessionDraftTitle scope={storedSessionId} />
),
render: storedSessionId => <SessionTilePane storedSessionId={storedSessionId} />,
- tabWrap: (storedSessionId, tab) => (
- <SessionTabMenu
- onClose={() => requestCloseSessionTile(storedSessionId)}
- storedSessionId={storedSessionId}
- tabPaneId={`session-tile:${storedSessionId}`}
- >
- {tab}
- </SessionTabMenu>
- ),
+ tabWrap: (storedSessionId, tab) => <SessionTabMenu {...tileTabTarget(storedSessionId)}>{tab}</SessionTabMenu>,
+ tabActions: storedSessionId => props => <SessionTabActionsMenu {...props} {...tileTabTarget(storedSessionId)} />,
// A tile's tab drags like a sidebar row — stack / split / drop-to-link — with
// its tap (activate) preserved. Always takes the drag.
tabDrag: (storedSessionId, event, onTap) => {
diff --git a/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx b/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx
index d1c9f1a2154..bdaf15a5efc 100644
--- a/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx
@@ -675,11 +675,20 @@ function DeleteSessionDialog({ open, onOpenChange, onConfirm, sessionTitle }: De
}
interface SessionActionsMenuProps
- extends SessionActions, Pick<React.ComponentProps<typeof ActionsMenu>, 'align' | 'sideOffset'> {
+ extends
+ SessionActions,
+ Pick<React.ComponentProps<typeof ActionsMenu>, 'align' | 'onOpenChange' | 'open' | 'sideOffset'> {
children: React.ReactNode
}
-export function SessionActionsMenu({ children, align = 'end', sideOffset = 6, ...actions }: SessionActionsMenuProps) {
+export function SessionActionsMenu({
+ children,
+ align = 'end',
+ onOpenChange,
+ open,
+ sideOffset = 6,
+ ...actions
+}: SessionActionsMenuProps) {
const { t } = useI18n()
const { deleteDialog, onCloseAutoFocus, renameDialog, renderItems } = useSessionActions(actions)
@@ -691,6 +700,8 @@ export function SessionActionsMenu({ children, align = 'end', sideOffset = 6, ..
contentClassName="w-40"
items={renderItems}
onCloseAutoFocus={onCloseAutoFocus}
+ onOpenChange={onOpenChange}
+ open={open}
sideOffset={sideOffset}
>
{children}
diff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsx
index 55c2b83e54f..16b1222fa97 100644
--- a/apps/desktop/src/app/contrib/controller.tsx
+++ b/apps/desktop/src/app/contrib/controller.tsx
@@ -108,6 +108,7 @@ import {
startTileBackendIdentityGuard,
startUnrestoredTileTitleBackfill,
watchSessionTiles,
+ workspaceTabActions,
WorkspaceTabMenu
} from '../chat/session-tile'
import { AppContextMenu } from '../context-menu/app-context-menu'
@@ -225,6 +226,7 @@ registry.registerMany([
placement: 'main',
minWidth: '22vw',
tabDrag: workspaceTabDrag,
+ tabActions: workspaceTabActions,
tabWrap: wrapWorkspaceTab,
uncloseable: true
},
@@ -526,6 +528,7 @@ const syncWorkspaceTitle = () => {
placement: 'main',
minWidth: '22vw',
tabDrag: workspaceTabDrag,
+ tabActions: workspaceTabActions,
tabWrap: wrapWorkspaceTab,
uncloseable: true
},
diff --git a/apps/desktop/src/components/pane-shell/tree/renderer/compact-tab-picker.tsx b/apps/desktop/src/components/pane-shell/tree/renderer/compact-tab-picker.tsx
index 073908a1cd0..4569e51f6c4 100644
--- a/apps/desktop/src/components/pane-shell/tree/renderer/compact-tab-picker.tsx
+++ b/apps/desktop/src/components/pane-shell/tree/renderer/compact-tab-picker.tsx
@@ -1,4 +1,4 @@
-import { type ReactNode, useId } from 'react'
+import { Fragment, type ReactNode, useId, useRef, useState } from 'react'
import { Button } from '@/components/ui/button'
import { Codicon } from '@/components/ui/codicon'
@@ -13,25 +13,38 @@ import {
} from '@/components/ui/dropdown-menu'
import { useI18n } from '@/i18n'
+import type { TabActionsMenu } from './track-model'
+
interface CompactTabPickerProps {
activeId: string
tabs: { id: string; title: string; label?: ReactNode }[]
onSelect: (id: string) => void
onClose?: () => void
newTab: { label: string; onSelect: () => void } | null
+ /** A tab's own menu (the strip's right-click one), resolved per row when
+ * the picker opens; undefined = that tab has none. */
+ tabActions?: (id: string) => TabActionsMenu | undefined
}
/** A phone's strip shows its current tab and a count; every open tab stays
- * reachable without a hidden horizontal drag gesture. */
-export function CompactTabPicker({ activeId, tabs, onSelect, onClose, newTab }: CompactTabPickerProps) {
+ * reachable without a hidden horizontal drag gesture, and so does every tab's
+ * menu (archive, delete, rename…) — a phone has no strip to right-click. */
+export function CompactTabPicker({ activeId, tabs, onSelect, onClose, newTab, tabActions }: CompactTabPickerProps) {
const { t } = useI18n()
const labelId = useId()
const countId = useId()
+ // The tab whose menu is showing. Kept after the menu closes: the dialog an
+ // item opened (rename, delete confirm) lives in that menu's owner.
+ const [menu, setMenu] = useState<{ id: string; open: boolean } | null>(null)
+ // A row's ⋯ hands focus to the tab menu; the closing picker must not pull
+ // it back to its trigger (that reads as an outside focus and shuts the menu).
+ const handingOff = useRef(false)
const active = tabs.find(tab => tab.id === activeId)
const count = t.zones.tabCount(tabs.length)
+ const menuFor = menu ? tabActions?.(menu.id) : undefined
return (
- <div className="flex min-w-0 flex-1 items-stretch" onPointerDown={event => event.stopPropagation()}>
+ <div className="relative flex min-w-0 flex-1 items-stretch" onPointerDown={event => event.stopPropagation()}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
@@ -46,22 +59,59 @@ export function CompactTabPicker({ activeId, tabs, onSelect, onClose, newTab }:
<Codicon name="chevron-down" />
</Button>
</DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="max-w-[calc(100vw-1rem)] min-w-56" side="bottom">
+ <DropdownMenuContent
+ align="start"
+ className="max-w-[calc(100vw-1rem)] min-w-56"
+ onCloseAutoFocus={event => {
+ if (handingOff.current) {
+ handingOff.current = false
+ event.preventDefault()
+ }
+ }}
+ side="bottom"
+ >
<DropdownMenuRadioGroup onValueChange={onSelect} value={activeId}>
{tabs.map(tab => (
- <DropdownMenuRadioItem className="min-h-11" key={tab.id} value={tab.id}>
- <span className="min-w-0 whitespace-normal break-words">{tab.label ?? tab.title}</span>
- </DropdownMenuRadioItem>
+ <div className="flex items-stretch" key={tab.id}>
+ <DropdownMenuRadioItem className="min-h-11 min-w-0 flex-1" value={tab.id}>
+ <span className="min-w-0 whitespace-normal break-words">{tab.label ?? tab.title}</span>
+ </DropdownMenuRadioItem>
+ {tabActions?.(tab.id) && (
+ <DropdownMenuItem
+ aria-label={t.zones.tabActions(tab.title)}
+ className="min-h-11 min-w-11 shrink-0 justify-center"
+ onSelect={() => {
+ handingOff.current = true
+ setMenu({ id: tab.id, open: true })
+ }}
+ >
+ <Codicon name="ellipsis" />
+ </DropdownMenuItem>
+ )}
+ </div>
))}
</DropdownMenuRadioGroup>
{onClose && (
<>
<DropdownMenuSeparator />
- <DropdownMenuItem className="min-h-11" onSelect={onClose}>{t.common.close}</DropdownMenuItem>
+ <DropdownMenuItem className="min-h-11" onSelect={onClose}>
+ {t.common.close}
+ </DropdownMenuItem>
</>
)}
</DropdownMenuContent>
</DropdownMenu>
+ {menu && menuFor && (
+ <Fragment key={menu.id}>
+ {menuFor({
+ onOpenChange: open => setMenu({ id: menu.id, open }),
+ open: menu.open,
+ // The menu drops from the picker row; the row's ⋯ that asked for
+ // it went away with the picker.
+ trigger: <span aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0" />
+ })}
+ </Fragment>
+ )}
{newTab && (
<Button aria-label={newTab.label} onClick={newTab.onSelect} size="touch" variant="ghost">
<Codicon name="add" />
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.ts
index 2e5a97b168a..d49b5040b4d 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
@@ -17,6 +17,17 @@ import { allPaneIds } from '../model'
import type { FloatingAnchor } from './floating-rect'
+/** Renders a pane's tab menu as a controlled dropdown on `trigger` (an
+ * anchor the caller owns). Stays mounted while closed, so a dialog the menu
+ * opened (rename, delete confirm) outlives the menu. */
+export interface TabActionsMenuProps {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ trigger: React.ReactElement
+}
+
+export type TabActionsMenu = (props: TabActionsMenuProps) => React.ReactNode
+
export const MIN_PANE_PX = 80
/**
@@ -81,6 +92,11 @@ interface PaneChrome extends PaneSizing {
* pin/branch/rename/archive/delete). The wrapper must render `tab` as its
* interactive child; the zone's own strip menu still owns non-tab space. */
tabWrap?: (tab: React.ReactElement) => React.ReactNode
+ /** The SAME tab menu as `tabWrap`'s, opened from a button instead of a
+ * right-click — the phone tab picker has no strip to right-click. Resolved
+ * when the picker opens: undefined = no menu for this tab right now (the
+ * main tab on a fresh draft). */
+ tabActions?: () => TabActionsMenu | undefined
/** Extra rows at the top of the zone tab menu. Called when the menu opens
* against the right-clicked pane — a Browser tab's Open-in-external, without
* replacing Reload / Close / the strip. */
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 69e14401267..7bbddc82fec 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
@@ -320,7 +320,7 @@ function EditVeil({ label, onPointerDown, top, ...menu }: EditVeilProps) {
type CompactTabPickerProps = ComponentProps<typeof CompactTabPicker>
-interface CompactZoneTabsProps extends Pick<CompactTabPickerProps, 'activeId' | 'newTab' | 'tabs'> {
+interface CompactZoneTabsProps extends Pick<CompactTabPickerProps, 'activeId' | 'newTab' | 'tabActions' | 'tabs'> {
belowControls: boolean
/** The active tab takes Close (see TreeGroup's `closeableTab`). */
closeable: boolean
@@ -329,7 +329,7 @@ interface CompactZoneTabsProps extends Pick<CompactTabPickerProps, 'activeId' |
/** A narrow touch zone's tab row: the picker in place of the scrolling strip.
* Picking a tab is a strip tap, so a minimized zone restores first. */
-function CompactZoneTabs({ activeId, belowControls, closeable, newTab, node, tabs }: CompactZoneTabsProps) {
+function CompactZoneTabs({ activeId, belowControls, closeable, newTab, node, tabActions, tabs }: CompactZoneTabsProps) {
return (
<div
className={cn('flex min-w-0 flex-1', belowControls && 'absolute inset-x-0 bottom-0')}
@@ -349,6 +349,7 @@ function CompactZoneTabs({ activeId, belowControls, closeable, newTab, node, tab
activateTreePane(node.id, paneId)
}}
+ tabActions={tabActions}
tabs={tabs}
/>
</div>
@@ -713,6 +714,7 @@ export function TreeGroup({
closeable={closeableTab(activeId)}
newTab={newTab}
node={node}
+ tabActions={paneId => paneChrome(paneFor(paneId)).tabActions?.()}
tabs={shown.map(id => ({ id, label: tabLabel(id), title: tabText(id) }))}
/>
) : headerVisible ? (
diff --git a/apps/desktop/src/i18n/ar_chrome.ts b/apps/desktop/src/i18n/ar_chrome.ts
index 32af052ebcb..e436ac88c67 100644
--- a/apps/desktop/src/i18n/ar_chrome.ts
+++ b/apps/desktop/src/i18n/ar_chrome.ts
@@ -564,7 +564,8 @@ export const arChrome = {
saveApply: 'حفظ وتطبيق',
notExpressible: 'هذا الترتيب متشابك — لا يمكن تمثيله كتقسيمات متداخلة بعد',
zoneCount: count => `${count} مناطق`,
- tabCount: count => `${count} تبويبات`
+ tabCount: count => `${count} تبويبات`,
+ tabActions: title => `إجراءات ${title}`
},
contextMenu: {
link: {
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index 896e5d12a18..d51af40dcbc 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -4797,7 +4797,8 @@ export const deOverrides = {
saveApply: 'Speichern & anwenden',
notExpressible: 'diese Anordnung greift ineinander (Windrad) — noch nicht als verschachtelte Splits ausdrückbar',
zoneCount: count => `${count} Zonen`,
- tabCount: count => `${count} Tabs`
+ tabCount: count => `${count} Tabs`,
+ tabActions: title => `Aktionen für ${title}`
},
contextMenu: {
link: {
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 6aac52c6d4f..ebbf3bb19da 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -4380,7 +4380,8 @@ export const en: Translations = {
saveApply: 'Save & apply',
notExpressible: 'this arrangement interlocks (pinwheel) — not expressible as nested splits yet',
zoneCount: count => `${count} zones`,
- tabCount: count => `${count} tab${count === 1 ? '' : 's'}`
+ tabCount: count => `${count} tab${count === 1 ? '' : 's'}`,
+ tabActions: title => `Actions for ${title}`
},
contextMenu: {
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index 3b5935378e0..2df74bbac36 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -4783,7 +4783,8 @@ export const esOverrides = {
saveApply: 'Guardar y aplicar',
notExpressible: 'esta disposición se entrelaza (en molinete) y aún no puede expresarse como divisiones anidadas',
zoneCount: count => `${count} zonas`,
- tabCount: count => `${count} pestañas`
+ tabCount: count => `${count} pestañas`,
+ tabActions: title => `Acciones de ${title}`
},
contextMenu: {
link: {
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index 84b90508fc4..c4de7a84848 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -4807,7 +4807,8 @@ export const frOverrides = {
saveApply: 'Enregistrer et appliquer',
notExpressible: "cet agencement s'entrelace (roue) — pas encore exprimable comme des divisions imbriquées",
zoneCount: count => `${count} zones`,
- tabCount: count => `${count} onglet${count === 1 ? '' : 's'}`
+ tabCount: count => `${count} onglet${count === 1 ? '' : 's'}`,
+ tabActions: title => `Actions pour ${title}`
},
contextMenu: {
link: {
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 9cab1715468..e49d1c2758a 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -3206,7 +3206,8 @@ export const jaOverrides = {
saveApply: '保存して適用',
notExpressible: 'この配置は互いに噛み合っています(風車型)— 入れ子の分割では表現できません',
zoneCount: count => `${count} ゾーン`,
- tabCount: count => `${count} 個のタブ`
+ tabCount: count => `${count} 個のタブ`,
+ tabActions: title => `${title} の操作`
},
contextMenu: {
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index cf6f35dd762..eebe8c175d8 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -3454,7 +3454,8 @@ export const ruOverrides = {
saveApply: 'Сохранить и применить',
notExpressible: 'эта расстановка зацеплена (pinwheel) — пока не выразима как вложенные разделения',
zoneCount: count => `${count} ${RU_NOUN(count, 'зона', 'зоны', 'зон')}`,
- tabCount: count => `${count} ${RU_NOUN(count, 'вкладка', 'вкладки', 'вкладок')}`
+ tabCount: count => `${count} ${RU_NOUN(count, 'вкладка', 'вкладки', 'вкладок')}`,
+ tabActions: title => `Действия: ${title}`
},
contextMenu: {
link: {
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 71ec717e7fb..51ff939239d 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -3833,6 +3833,8 @@ catalog: CatalogTranslations
notExpressible: string
zoneCount: (count: number) => string
tabCount: (count: number) => string
+ /** A phone tab picker row's actions button (names the tab). */
+ tabActions: (title: string) => string
}
contextMenu: {
diff --git a/apps/desktop/src/i18n/zh-hant_chrome.ts b/apps/desktop/src/i18n/zh-hant_chrome.ts
index 07a0a9b3ece..fb64274f44d 100644
--- a/apps/desktop/src/i18n/zh-hant_chrome.ts
+++ b/apps/desktop/src/i18n/zh-hant_chrome.ts
@@ -511,7 +511,8 @@ export const zhHantChrome = {
saveApply: '儲存並套用',
notExpressible: '此排列互相咬合(風車形)——暫時無法表示為巢狀分割',
zoneCount: count => `${count} 個區域`,
- tabCount: count => `${count} 個分頁`
+ tabCount: count => `${count} 個分頁`,
+ tabActions: title => `${title} 的動作`
},
contextMenu: {
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index cdbfad0448d..45eb8475299 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -4212,7 +4212,8 @@ export const zhOverrides = {
saveApply: '保存并应用',
notExpressible: '此排列互相咬合(风车形)——暂无法表示为嵌套拆分',
zoneCount: count => `${count} 个区域`,
- tabCount: count => `${count} 个标签页`
+ tabCount: count => `${count} 个标签页`,
+ tabActions: title => `${title} 的操作`
},
contextMenu: {