From 3a1a0126c4922d42c252b6808978af2f6f46bbe8 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Wed, 25 Nov 2026 15:14:42 +0000 Subject: [PATCH 1/6] feat(ui): split the tab strip into resizable tab groups --- CHANGELOG.md | 1 + app/globals.css | 37 +++ components/AppShell.tsx | 341 ++++++++++++++++++++-------- components/ChatWindow.tsx | 4 +- components/FileTabs.tsx | 17 +- components/TabBar.tsx | 33 ++- components/TabLayoutView.tsx | 118 ++++++++++ hooks/useAgentSession.rpc.test.mjs | 48 +++- hooks/useKeyboardShortcuts.test.mjs | 21 ++ hooks/useKeyboardShortcuts.ts | 10 +- lib/i18n/locales/en.json | 5 + lib/i18n/locales/ja.json | 5 + lib/i18n/locales/zh-CN.json | 5 + lib/i18n/locales/zh-TW.json | 5 + lib/tab-groups.test.mjs | 83 +++++++ lib/tab-groups.ts | 162 +++++++++++++ 16 files changed, 785 insertions(+), 110 deletions(-) create mode 100644 components/TabLayoutView.tsx create mode 100644 hooks/useKeyboardShortcuts.test.mjs create mode 100644 lib/tab-groups.test.mjs create mode 100644 lib/tab-groups.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 03de18a8..53f98327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to **tau** (`@ompweb-dev/tau`) are documented in this file. ### Changed +- **Tabs split into groups side by side.** Split right or Split down at the end of a tab strip moves the shown tab into a new group beside or below it, and each group shows its own chat or file, so two conversations can run in view at once. Drag a tab onto another strip to move it there (or along its own strip to reorder it), and drag the line between two groups, or focus it and use the arrow keys, to resize them. Clicking into a group shows its tab; new tabs open in that group, and a group whose last tab closes goes away. On a phone one group shows at a time, and a 1/2 button at the start of its strip switches to the next. Groups are kept until the page reloads. - **Chats and files open as tabs in one strip above the chat.** Every conversation you open gets a tab beside the files you open, in the order they were opened; clicking a tab shows it, and closing the shown conversation shows its neighbour (or a new chat in its workspace once none is left). Files now open in the main area instead of the file panel, with their actions (mention, copy path, reveal, download, close) at the end of the strip; the file panel keeps Explorer, Git, Worktrees and the other tools. While a file is shown, the chat behind it keeps its place and Esc no longer stops its run. An agent's `open_file` from the shown conversation also opens over its chat. On a phone the strip is the same, scrolled sideways. - **One light and one dark theme, modelled on Pendant.** tau ships Light (warm paper surfaces) and Dark (charcoal), both with a muted blue accent, plus System, which follows the operating system and is the default. Midnight, Dracula, Nord and the other nine themes are gone: a stored choice of one of them now reads as Light or Dark, whichever side it was on. Headings use the UI's sans instead of a serif, and the fonts only those themes used (Geist, JetBrains Mono, Source Serif, Noto Serif SC) are no longer shipped. On desktop the sidebar, the chat and the file panel are rounded cards on a frame of their own. Your message is a bordered bubble, the selected session is outlined, and Send is a round arrow button in the text colour. - **tau runs sessions on pi.** Every session is a `pi --mode rpc` child (`@earendil-works/pi-coding-agent`, found on `PATH` or through `TAU_PI_BIN`) loaded with tau's companion extension (`lib/pi/tau-extension.ts`), which adds host tools, the `ask` dialog, message origins, `/btw`, history Edit and per-host provider logins. The ompweb omp runner, its pinned release and `fetch-omp` are gone. tau keeps pi's state in `~/.pi/agent` (sessions, `settings.json`, `models.json`), lists and installs pi packages and skills instead of omp plugins, and mirrors pi's configuration to cluster members. The host link starts again at protocol v1, and host software updates go through a separately versioned maintenance API. tau shares no state with ompweb: hosts, settings and sessions are set up anew. The routes `/api/omp-settings` and `/api/omp-version` are now `/api/pi-settings` and `/api/pi-version`, a host without pi reports `pi-missing`, and the unused `/api/omp-update` route is removed. diff --git a/app/globals.css b/app/globals.css index 6485bf15..d83cd4af 100644 --- a/app/globals.css +++ b/app/globals.css @@ -3906,6 +3906,43 @@ html[data-touch-targets="accessible"] .right-panel-toolbar { scrollbar-width: thin; scrollbar-color: var(--border) transparent; } +/* Tab groups: split, switch and resize controls. */ +.tab-group-action { + display: flex; + align-items: center; + justify-content: center; + min-width: 26px; + height: 26px; + margin-right: 2px; + padding: 0 4px; + border: none; + border-radius: var(--radius-control); + background: none; + color: var(--text-dim); + font-size: var(--text-sm); + cursor: pointer; + flex-shrink: 0; +} +.tab-group-action:hover:not(:disabled) { + background: var(--bg-hover); + color: var(--text); +} +.tab-group-action:disabled { + opacity: 0.4; + cursor: default; +} +.tab-group-switch { + margin: 0 2px 0 6px; + font-variant-numeric: tabular-nums; +} +.tab-group-sash-line { + background: var(--border); + transition: background var(--dur-fast) var(--ease-out-warm); +} +.tab-group-sash:hover > .tab-group-sash-line, +.tab-group-sash:focus-visible > .tab-group-sash-line { + background: var(--accent); +} .tabbar-tab { transition: background var(--dur-fast) var(--ease-out-warm), color var(--dur-fast) var(--ease-out-warm); } diff --git a/components/AppShell.tsx b/components/AppShell.tsx index 7a71bf0b..afa86e9b 100644 --- a/components/AppShell.tsx +++ b/components/AppShell.tsx @@ -19,6 +19,8 @@ import { ConfirmDialog } from "./ui/field"; import { ThemedSelect } from "./ui/primitives"; import { ChatWindow } from "./ChatWindow"; import { TabBar, type StripTab, type Tab } from "./TabBar"; +import { TabLayoutView } from "./TabLayoutView"; +import { activateTab, groupOfTab, groupsOf, initialLayout, moveTab, reconcileTabs, resizeSplit, splitGroup, type TabGroup, type TabLayout } from "@/lib/tab-groups"; import { FileTabToolbar, FileTabViews } from "./FileTabs"; import { getFileIcon } from "./FileIcons"; import { type FileExplorerHandle } from "./FileExplorer"; @@ -28,7 +30,7 @@ import { NotificationBell } from "./NotificationBell"; import { BranchNavigator } from "./BranchNavigator"; import { LanguageSwitcher } from "./LanguageSwitcher"; import { CommandPaletteMount } from "./CommandPaletteMount"; -import { Check, ChevronDown, Command, Ellipsis, Folder, GitBranch, History, Menu, MessageSquare, PanelLeft, PanelRight, Server, Terminal, Wand2 } from "lucide-react"; +import { Check, ChevronDown, Columns2, Command, Ellipsis, Folder, GitBranch, History, Menu, MessageSquare, PanelLeft, PanelRight, Rows2, Server, Terminal, Wand2 } from "lucide-react"; import { ThemeSwitcher } from "./ThemeSwitcher"; import { translate, useI18n } from "@/lib/i18n"; import { formatApiError } from "@/lib/i18n/api-error"; @@ -1865,13 +1867,14 @@ export function AppShell({ appName }: { appName: string }) { setFileSearchOpen((open) => !open); }, []); - const handleCloseOtherFileTabs = useCallback(() => { + // Close others / Close all act on the files of the shown file's tab group. + const handleCloseOtherFileTabs = useCallback((groupTabIds: readonly string[]) => { if (!activeFileTab) return; - setFileTabs([activeFileTab]); + setFileTabs((tabs) => tabs.filter((tab) => tab.id === activeFileTab.id || !groupTabIds.includes(tab.id))); }, [activeFileTab]); - const handleCloseAllFileTabs = useCallback(() => { - setFileTabs([]); + const handleCloseAllFileTabs = useCallback((groupTabIds: readonly string[]) => { + setFileTabs((tabs) => tabs.filter((tab) => !groupTabIds.includes(tab.id))); setActiveFileTabId(null); setFileShown(false); }, []); @@ -1889,19 +1892,6 @@ export function AppShell({ appName }: { appName: string }) { }, [selectedSession]); - const handleCloseChatTab = useCallback((session: SessionInfo) => { - const index = chatTabs.findIndex((tab) => sameSessionTarget(tab, session)); - const rest = chatTabs.filter((tab) => !sameSessionTarget(tab, session)); - setChatTabs(rest); - if (!selectedSession || !sameSessionTarget(selectedSession, session)) return; - // Closing the shown conversation shows its neighbour, else a new chat in - // its workspace; a file shown over it stays shown. - const neighbour = rest[Math.min(index, rest.length - 1)]; - if (neighbour) handleSelectSession(neighbour); - else handleNewSession(randomUUID(), session.poolId ? null : session.cwd, session.hostId, poolProjectOf(session)); - // Both of those show the chat; batched, this wins. - if (fileShown) setFileShown(true); - }, [chatTabs, selectedSession, fileShown, handleSelectSession, handleNewSession, poolProjectOf]); const handleViewFullHistory = useCallback(() => { if (!selectedSession) return; @@ -2000,38 +1990,69 @@ export function AppShell({ appName }: { appName: string }) { // While restoring initial session from URL, don't show the placeholder const showPlaceholder = initialSessionRestored && !showChat; const draftTabShown = showChat && !selectedSession; - // Chats and files share one strip, in the order they were opened - // (the unsent chat's tab from when it appears). - const [stripOrder, setStripOrder] = useState([]); - useEffect(() => { - const ids = [...chatTabs.map(chatTabId), ...(draftTabShown ? [NEW_CHAT_TAB_ID] : []), ...fileTabs.map((tab) => tab.id)]; - setStripOrder((order) => { - const kept = order.filter((id) => ids.includes(id)); - const added = ids.filter((id) => !kept.includes(id)); - return added.length > 0 || kept.length !== order.length ? [...kept, ...added] : order; - }); - }, [chatTabs, fileTabs, draftTabShown]); + // Chats and files share the strips of the tab groups: each group holds its + // tabs in the order they were opened or dropped there (the unsent chat's + // tab from when it appears). The focused group is the one showing the app's + // shown tab; new tabs open there. + const [tabLayout, setTabLayout] = useState(initialLayout); + const [lastFocusedGroupId, setLastFocusedGroupId] = useState("g0"); + const stripIds = useMemo( + () => [...chatTabs.map(chatTabId), ...(draftTabShown ? [NEW_CHAT_TAB_ID] : []), ...fileTabs.map((tab) => tab.id)], + [chatTabs, fileTabs, draftTabShown], + ); const activeFileMatchesSource = activeFileTab?.hostId === workspaceHostId && (activeFileTab?.sourceSessionId ?? null) === (selectedSession?.id ?? null); const fileTabShown = fileShown && activeFileTab !== null; + const selectedChatId = selectedSession ? chatTabId(selectedSession) : showChat ? NEW_CHAT_TAB_ID : null; + const activeStripTabId = fileTabShown ? activeFileTabId ?? "" : selectedChatId ?? ""; + useEffect(() => { + setTabLayout((layout) => { + const next = reconcileTabs(layout, stripIds, lastFocusedGroupId); + return activeStripTabId ? activateTab(next, activeStripTabId) : next; + }); + }, [stripIds, activeStripTabId, lastFocusedGroupId]); + const tabGroups = groupsOf(tabLayout); + const focusedGroup = groupOfTab(tabLayout, activeStripTabId) ?? tabGroups.find((group) => group.id === lastFocusedGroupId) ?? tabGroups[0]; + useEffect(() => { setLastFocusedGroupId(focusedGroup.id); }, [focusedGroup.id]); + // The group showing the selected chat (or the new chat, or the workspace + // placeholders): the focused one until the chat has its tab. + const primaryGroupId = (selectedChatId ? groupOfTab(tabLayout, selectedChatId)?.id : undefined) ?? focusedGroup.id; + const chatTabById = (id: string) => chatTabs.find((tab) => chatTabId(tab) === id); + const fileTabIds = new Set(fileTabs.map((tab) => tab.id)); + // Chats the groups show (as of their last activation). + const shownChatIds = new Set(tabGroups.flatMap((group) => group.active && !fileTabIds.has(group.active) ? [group.active] : [])); + + // Mount keys of the chats the groups show. A chat keeps its key while it + // turns from the selected chat into another group's and back, so focusing a + // group remounts nothing. A sessionKey bump remounts the selected chat (a + // switch to a chat another group already shows keeps that mount), and the + // selected chat changing identity without one (a new chat's first send, an + // Edit move) keeps its mount, as the single chat keyed by sessionKey did. + const [chatMounts, setChatMounts] = useState({ selected: selectedChatId, sessionKey, keys: {} as Record }); + let chatMountKeys = chatMounts.keys; + if (chatMounts.selected !== selectedChatId || chatMounts.sessionKey !== sessionKey) { + // Only open chats keep a key. + chatMountKeys = Object.fromEntries(Object.entries(chatMounts.keys).filter(([id]) => stripIds.includes(id))); + if (selectedChatId) { + if (chatMounts.sessionKey === sessionKey) { + chatMountKeys[selectedChatId] = chatMounts.selected ? chatMountKeys[chatMounts.selected] ?? chatMounts.selected : `${selectedChatId}~${sessionKey}`; + } else if (chatMounts.selected === selectedChatId || !shownChatIds.has(selectedChatId)) { + chatMountKeys[selectedChatId] = `${selectedChatId}~${sessionKey}`; + } + } + setChatMounts({ selected: selectedChatId, sessionKey, keys: chatMountKeys }); + } + const chatMountKey = (id: string) => chatMountKeys[id] ?? id; + const chatIcon =