diff --git a/apps/server/src/keybindings.test.ts b/apps/server/src/keybindings.test.ts
index 2eef6ac841..67a6867720 100644
--- a/apps/server/src/keybindings.test.ts
+++ b/apps/server/src/keybindings.test.ts
@@ -198,6 +198,8 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
assert.equal(defaultsByCommand.get("thread.jump.1"), "mod+1");
assert.equal(defaultsByCommand.get("thread.jump.9"), "mod+9");
assert.equal(defaultsByCommand.get("modelPicker.toggle"), "mod+shift+m");
+ assert.equal(defaultsByCommand.get("chat.newTab"), "mod+t");
+ assert.equal(defaultsByCommand.get("chat.reopenClosedTab"), "mod+shift+t");
assert.equal(defaultsByCommand.get("sidebar.toggle"), "mod+b");
assert.equal(defaultsByCommand.get("rightPanel.toggle"), "mod+alt+b");
assert.equal(defaultsByCommand.get("terminal.splitVertical"), "mod+shift+d");
diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsx
index a992acf91b..3023cc9c51 100644
--- a/apps/web/src/components/SidebarV2.tsx
+++ b/apps/web/src/components/SidebarV2.tsx
@@ -317,8 +317,7 @@ function SidebarV2ThreadTooltip({
- {tabCount} tabs sharing this worktree and branch. Each tab keeps its own
- conversation.
+ {tabCount} tabs · Shared files, separate chats.
) : null}
diff --git a/apps/web/src/components/WorkspaceTaskTabs.tsx b/apps/web/src/components/WorkspaceTaskTabs.tsx
index dc6aceaa61..d639162e34 100644
--- a/apps/web/src/components/WorkspaceTaskTabs.tsx
+++ b/apps/web/src/components/WorkspaceTaskTabs.tsx
@@ -1,25 +1,52 @@
-import { CircleDashedIcon, GitForkIcon, InfoIcon, PlusIcon, XIcon } from "lucide-react";
+import {
+ CircleDashedIcon,
+ CopyPlusIcon,
+ HistoryIcon,
+ PlusIcon,
+ RotateCcwIcon,
+ XIcon,
+} from "lucide-react";
import { useMemo, useState } from "react";
import { shortcutLabelForCommand } from "../keybindings";
import { useClientSettings } from "../hooks/useSettings";
-import { type WorkspaceTaskTab, useWorkspaceTaskTabs } from "../hooks/useWorkspaceTaskTabs";
import {
- TASK_TABS_SHARED_SCOPE_EXPLANATION,
+ type ClosedWorkspaceTaskTab,
+ type WorkspaceTaskTab,
+ useWorkspaceTaskTabs,
+} from "../hooks/useWorkspaceTaskTabs";
+import {
describeTaskTabContexts,
type TaskTabContextDescriptor,
+ type TaskTabContextSource,
} from "../lib/taskTabContext";
import { cn } from "../lib/utils";
+import { Menu, MenuItem, MenuPopup, MenuShortcut, MenuTrigger } from "./ui/menu";
import { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from "./ui/tooltip";
-function tabThreadId(tab: WorkspaceTaskTab): string {
- return String(tab.kind === "server" ? tab.threadRef.threadId : tab.threadId);
+type AnyWorkspaceTaskTab = WorkspaceTaskTab | ClosedWorkspaceTaskTab;
+
+function tabContextSource(tab: AnyWorkspaceTaskTab): TaskTabContextSource {
+ return {
+ kind: tab.kind,
+ threadId: String(tab.kind === "server" ? tab.threadRef.threadId : tab.threadId),
+ title: tab.title,
+ position: tab.position,
+ forkProvenance: tab.forkProvenance
+ ? {
+ mode: tab.forkProvenance.mode,
+ sourceThreadId:
+ tab.forkProvenance.sourceThreadId === null
+ ? null
+ : String(tab.forkProvenance.sourceThreadId),
+ }
+ : null,
+ };
}
/**
* State is carried by shape and text as well as hue: blocked tabs get a filled
- * ring plus "Waiting on you", working tabs get a dashed spinner glyph. Colour
- * is the accent, never the only signal.
+ * ring plus "Waiting on you", working tabs get a dashed spinner glyph.
*/
function TabStateGlyph(props: { tab: WorkspaceTaskTab }) {
const { tab } = props;
@@ -35,8 +62,6 @@ function TabStateGlyph(props: { tab: WorkspaceTaskTab }) {
);
}
if (tab.working) {
- // Duty-cycled steps() pulse from index.css, not a continuous spin: this
- // strip can be on screen for hours on a 120Hz display.
return (
+ · {props.context.label}
+
+ );
}
export function WorkspaceTaskTabs() {
const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);
- const { tabs, keybindings, hasTask, canForkContext, createTab, closeTab, navigateToTab } =
- useWorkspaceTaskTabs();
+ const {
+ tabs,
+ closedTabs,
+ keybindings,
+ hasTask,
+ canForkContext,
+ createTab,
+ closeTab,
+ reopenTab,
+ navigateToTab,
+ } = useWorkspaceTaskTabs();
const [creatingMode, setCreatingMode] = useState<"fresh" | "portable" | null>(null);
- const contexts = useMemo(
- () =>
- describeTaskTabContexts(
- tabs.map((tab) => ({
- kind: tab.kind,
- threadId: tabThreadId(tab),
- title: tab.title,
- position: tab.position,
- forkProvenance: tab.forkProvenance
- ? {
- mode: tab.forkProvenance.mode,
- sourceThreadId:
- tab.forkProvenance.sourceThreadId === null
- ? null
- : String(tab.forkProvenance.sourceThreadId),
- }
- : null,
- })),
- ),
- [tabs],
- );
+ const [reopeningKey, setReopeningKey] = useState(null);
+ const contextByTabKey = useMemo(() => {
+ const allTabs = [...tabs, ...closedTabs];
+ const contexts = describeTaskTabContexts(allTabs.map(tabContextSource));
+ return new Map(allTabs.map((tab, index) => [tab.key, contexts[index]!]));
+ }, [closedTabs, tabs]);
if (!sidebarV2Enabled || !hasTask) return null;
const newTabShortcut = shortcutLabelForCommand(keybindings, "chat.newTab");
+ const reopenShortcut = shortcutLabelForCommand(keybindings, "chat.reopenClosedTab");
const create = (mode: "fresh" | "portable") => {
if (creatingMode !== null) return;
setCreatingMode(mode);
void createTab(mode).finally(() => setCreatingMode(null));
};
+ const reopen = (tab: ClosedWorkspaceTaskTab) => {
+ if (reopeningKey !== null) return;
+ setReopeningKey(tab.key);
+ void reopenTab(tab).finally(() => setReopeningKey(null));
+ };
return (
@@ -98,11 +135,9 @@ export function WorkspaceTaskTabs() {
data-testid="workspace-task-tabs"
className="flex h-9 shrink-0 items-center gap-2 border-b border-border/60 bg-background px-3 sm:px-5"
>
- {/* One segmented control, not browser chrome: the tabs sit inside a
- single inset track so the strip reads as a compact control. */}
- {tabs.map((tab, index) => {
- const context = contexts[index];
+ {tabs.map((tab) => {
+ const context = contextByTabKey.get(tab.key);
return (
- {tab.forkProvenance?.mode === "portable" ? (
-
- ) : null}
{context?.title ?? tab.title}
- {/* Context stays legible to assistive tech even when the
- chip is hidden at narrow widths. */}
{context ? — {context.label} : null}
- {context ? (
-
- {context.label}
-
- ) : null}
+ {context ?
: null}
-
-
+
+
- {context?.label ?? "Own context"}
+ {context?.label ?? "Independent"}
{context ? (
- {context.detail}
+ {context.detail}
) : null}
- {tabs.length > 1 && tab.position > 0 ? (
+ {tabs.length > 1 ? (