Skip to content

The agent that grows with you

feat(desktop): shift-click and opt-click select tabs to drag together

Brooklyn Nicholson33c1d1f26695
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 4f7d7ada115..0694c6c3afa 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
@@ -50,6 +50,14 @@ import {
setTreeGroupMinimized,
treeTabCloseTargets
} from '../store'
+import {
+ $tabSelection,
+ clearTabSelection,
+ isToggleSelectClick,
+ selectionFor,
+ selectTabRange,
+ toggleTabSelected
+} from '../tab-selection'
import { type DoubleTapContext, startPaneDrag } from './drag-session'
import { forceLoneHeaderForPanes } from './lone-header'
@@ -186,6 +194,9 @@ export function TreeGroup({
const narrow = useStore($narrowViewport)
const newSessionTabAction = useStore($newSessionTabAction)
const panesWithCloser = useStore($panesWithCloser)
+ // Multi-tab selection (⌥/Ctrl-click, Shift-click) — null for every zone but
+ // the one holding it, so this subscription is quiet during normal use.
+ const tabSelection = useStore($tabSelection)
// Reload epochs: only an explicit tab-menu Reload writes here, so this
// subscription costs nothing on a normal render.
const paneEpochs = useStore($treePaneEpochs)
@@ -435,6 +446,7 @@ export function TreeGroup({
const chrome = paneChrome(paneFor(paneId))
const closeable = closeableTab(paneId)
const title = paneFor(paneId)?.title ?? paneId
+ const isSelected = tabSelection?.groupId === node.id && tabSelection.ids.has(paneId)
const tab = (
<PaneTab
@@ -444,11 +456,36 @@ export function TreeGroup({
key={paneId}
onClose={closeable ? () => closeTab(paneId) : undefined}
onPointerDown={e => {
+ // Chrome's tab-selection grammar, ahead of activate/drag:
+ // Shift-click ranges from the anchor, ⌥-click (Ctrl-click
+ // off-Mac) toggles. Neither activates nor starts a drag —
+ // the press IS the selection edit. ⌘-click stays close
+ // (PaneTab claims it first) and ⌃-click stays the macOS
+ // context menu.
+ if (e.button === 0 && e.shiftKey) {
+ e.preventDefault()
+ e.stopPropagation()
+ selectTabRange(node.id, shown, paneId, activeId)
+
+ return
+ }
+
+ if (isToggleSelectClick(e)) {
+ e.preventDefault()
+ e.stopPropagation()
+ toggleTabSelected(node.id, paneId, activeId)
+
+ return
+ }
+
// Tabs ACTIVATE (restoring a collapsed group). Minimize
// lives on the chevron / single-pane label — overloading
// the active tab made double-click a minimize/restore/hide
- // lottery.
+ // lottery. A plain click also collapses any multi-tab
+ // selection back to the one tab (Chrome semantics).
const onTap = () => {
+ clearTabSelection()
+
if (node.minimized) {
restoreTreePane(paneId)
}
@@ -465,6 +502,26 @@ export function TreeGroup({
e.stopPropagation()
}
+ // Dragging a SELECTED tab carries the whole selection as
+ // one block through the generic pane move — a multi-tab
+ // drag outranks the pane's own tab drag (the session drop
+ // language is single-session).
+ const dragSelection = selectionFor(node.id, shown, paneId)
+
+ if (dragSelection) {
+ startPaneDrag(
+ paneId,
+ e,
+ onTap,
+ stripRef.current ? { groupId: node.id, strip: stripRef.current } : undefined,
+ hideHeaderDoubleTap,
+ t.zones.tabCount(dragSelection.length),
+ dragSelection
+ )
+
+ return
+ }
+
// A pane may own its tab drag (a session tab speaks the
// session drop language — link/stack/split); `false` defers
// to the generic pane move (the workspace tab on a fresh
@@ -481,6 +538,7 @@ export function TreeGroup({
}
}}
role="tab"
+ selected={isSelected}
style={{ cursor: 'grab' }}
>
{chrome.tabLead ? (
diff --git a/apps/desktop/src/components/ui/pane-tab.tsx b/apps/desktop/src/components/ui/pane-tab.tsx
index 47aad2614df..906b0d1f80c 100644
--- a/apps/desktop/src/components/ui/pane-tab.tsx
+++ b/apps/desktop/src/components/ui/pane-tab.tsx
@@ -31,12 +31,21 @@ const TAB_ACTIVE_UNDERLINE = 'shadow-[inset_0_-2px_0_var(--pane-tab-active-accen
const TAB_IDLE =
'text-(--ui-text-tertiary) [--tab-bg:var(--pane-tab-strip-bg,var(--ui-sidebar-surface-background))] hover:shadow-[inset_0_0_0_100vmax_color-mix(in_srgb,#000_var(--ui-tab-hover-darken),transparent)] hover:text-(--ui-text-secondary)'
+// A tab riding a multi-tab selection: an accent wash over whatever surface the
+// tab sits on. A background-image gradient (not a shadow) so it stacks cleanly
+// over `--tab-bg` without fighting the active underline / hover shadows.
+const TAB_SELECTED =
+ '[background-image:linear-gradient(color-mix(in_srgb,var(--ui-accent)_14%,transparent),color-mix(in_srgb,var(--ui-accent)_14%,transparent))] text-foreground'
+
interface PaneTabProps extends React.ComponentProps<'div'> {
active?: boolean
dirty?: boolean
/** Close gesture, no hover X (too easy to hit on small tabs): middle-click,
* or ⌘-click as the trackpad-friendly Mac equivalent. */
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
/** Vertical rail form (collapsed sidebar zones). */
vertical?: boolean
/** Content-facing edge of a vertical rail — the strip line the active tab cuts. */
@@ -59,6 +68,7 @@ export const PaneTab = React.forwardRef<HTMLDivElement, PaneTabProps>(function P
onPointerDown,
onPointerUp,
onClickCapture,
+ selected = false,
vertical = false,
side = 'left',
children,
@@ -81,9 +91,11 @@ export const PaneTab = React.forwardRef<HTMLDivElement, PaneTabProps>(function P
active
? cn(TAB_ACTIVE, !vertical && TAB_ACTIVE_UNDERLINE)
: cn(TAB_IDLE, edge && `${edge}-(--ui-stroke-tertiary)`),
+ selected && TAB_SELECTED,
className
)}
data-active={active}
+ data-selected={selected || undefined}
data-vertical={vertical || undefined}
onClickCapture={event => {
// Sites whose tab activates on the label's own onClick (the preview
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 6091c916c33..20b5720ab8f 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -2265,7 +2265,8 @@ export const ar = defineLocale({
layoutNamePlaceholder: fallback => `اسم التخطيط (${fallback})`,
saveApply: 'حفظ وتطبيق',
notExpressible: 'هذا الترتيب متشابك — لا يمكن تمثيله كتقسيمات متداخلة بعد',
- zoneCount: count => `${count} مناطق`
+ zoneCount: count => `${count} مناطق`,
+ tabCount: count => `${count} تبويبات`
},
assistant: {
thread: {
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index fe764eb310a..5d89178f75d 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2693,7 +2693,8 @@ export const en: Translations = {
layoutNamePlaceholder: fallback => `Layout name (${fallback})`,
saveApply: 'Save & apply',
notExpressible: 'this arrangement interlocks (pinwheel) — not expressible as nested splits yet',
- zoneCount: count => `${count} zones`
+ zoneCount: count => `${count} zones`,
+ tabCount: count => `${count} tabs`
},
assistant: {
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 16d58834c62..bf1bd1abd1d 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -2519,7 +2519,8 @@ export const ja = defineLocale({
layoutNamePlaceholder: fallback => `レイアウト名(${fallback})`,
saveApply: '保存して適用',
notExpressible: 'この配置は互いに噛み合っています(風車型)— 入れ子の分割では表現できません',
- zoneCount: count => `${count} ゾーン`
+ zoneCount: count => `${count} ゾーン`,
+ tabCount: count => `${count} 個のタブ`
},
assistant: {
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index b82feb40011..2463286e1ca 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -2293,6 +2293,7 @@ export interface Translations {
saveApply: string
notExpressible: string
zoneCount: (count: number) => string
+ tabCount: (count: number) => string
}
assistant: {
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index 31a0b62a53e..56e9405a5da 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -2439,7 +2439,8 @@ export const zhHant = defineLocale({
layoutNamePlaceholder: fallback => `版面名稱(${fallback})`,
saveApply: '儲存並套用',
notExpressible: '此排列互相咬合(風車形)——暫時無法表示為巢狀分割',
- zoneCount: count => `${count} 個區域`
+ zoneCount: count => `${count} 個區域`,
+ tabCount: count => `${count} 個分頁`
},
assistant: {
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 10b47272459..9f9932d03fd 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2871,7 +2871,8 @@ export const zh: Translations = {
layoutNamePlaceholder: fallback => `布局名称(${fallback})`,
saveApply: '保存并应用',
notExpressible: '此排列互相咬合(风车形)——暂无法表示为嵌套拆分',
- zoneCount: count => `${count} 个区域`
+ zoneCount: count => `${count} 个区域`,
+ tabCount: count => `${count} 个标签页`
},
assistant: {