diff --git a/CHANGELOG.md b/CHANGELOG.md index 03de18a8..7bc8332c 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), or press Alt+Shift+Left/Right to move the focused tab along its strip and Alt+Shift+Up/Down to move it to the previous or next group, 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..ac2c3e62 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, nextChatMounts, type ChatMounts, 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,55 @@ 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, !fileTabShown) : next; + }); + }, [stripIds, activeStripTabId, fileTabShown, 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). + // The chat a group shows: its shown tab when that is a chat, else the chat under its file. + const groupChat = (group: TabGroup) => group.active && !fileTabIds.has(group.active) ? group.active : group.chat ?? null; + const shownChatIds = new Set(tabGroups.flatMap((group) => groupChat(group) ?? [])); + + // Mount keys of the chats the groups show: stable across group focus (see nextChatMounts). + const [chatMounts, setChatMounts] = useState({ selected: selectedChatId, sessionKey, keys: {} }); + const currentChatMounts = nextChatMounts(chatMounts, selectedChatId, sessionKey, stripIds, shownChatIds); + if (currentChatMounts !== chatMounts) setChatMounts(currentChatMounts); + const chatMountKey = (id: string) => currentChatMounts.keys[id] ?? id; + const chatIcon =