From 6f58ef5058000375beb68d9e960629c0e88edbc4 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Wed, 25 Nov 2026 09:32:03 +0000 Subject: [PATCH 1/7] feat(ui): chats and files open as tabs in one strip above the chat --- CHANGELOG.md | 1 + components/AppShell.tsx | 163 +++++++++++++++++++--- components/ConnectionDiagnostics.test.mjs | 12 +- components/FileTabs.tsx | 128 +++++++++++++++++ components/RightPanel.tsx | 135 +----------------- components/TabBar.test.mjs | 19 ++- components/TabBar.tsx | 55 +++++--- hooks/useAgentSession.rpc.test.mjs | 10 +- lib/i18n/locales/en.json | 1 + lib/i18n/locales/ja.json | 1 + lib/i18n/locales/zh-CN.json | 1 + lib/i18n/locales/zh-TW.json | 1 + 12 files changed, 336 insertions(+), 191 deletions(-) create mode 100644 components/FileTabs.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index da84f1be..a287b399 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 +- **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. 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. - **Browsers connect over server-sent events only.** The browser WebSocket link (`/api/events/link`) and the Settings → Interface & Behavior → **Browser connection** choice are gone; chat commands and uploads go over HTTP. A stored `browserTransport` setting is ignored. diff --git a/components/AppShell.tsx b/components/AppShell.tsx index 71bcb778..14bfa70c 100644 --- a/components/AppShell.tsx +++ b/components/AppShell.tsx @@ -18,7 +18,9 @@ import { notificationHistory, useUnreadNotificationCount } from "@/lib/notificat import { ConfirmDialog } from "./ui/field"; import { ThemedSelect } from "./ui/primitives"; import { ChatWindow } from "./ChatWindow"; -import { type Tab } from "./TabBar"; +import { TabBar, type StripTab, type Tab } from "./TabBar"; +import { FileTabToolbar, FileTabViews } from "./FileTabs"; +import { getFileIcon } from "./FileIcons"; import { type FileExplorerHandle } from "./FileExplorer"; import type { RightPanelView } from "./RightPanel"; import { useConnectionDiagnosticsEnabled } from "@/lib/connection-diagnostics-prefs"; @@ -26,7 +28,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, PanelLeft, PanelRight, Server, Terminal, Wand2 } from "lucide-react"; +import { Check, ChevronDown, Command, Ellipsis, Folder, GitBranch, History, Menu, MessageSquare, PanelLeft, PanelRight, Server, Terminal, Wand2 } from "lucide-react"; import { ThemeSwitcher } from "./ThemeSwitcher"; import { translate, useI18n } from "@/lib/i18n"; import { formatApiError } from "@/lib/i18n/api-error"; @@ -119,6 +121,9 @@ const SHOW_TOOL_CALLS_UNFOLDED_STORAGE_KEY = "tau:show-tool-calls-unfolded"; const EXPAND_THINKING_STORAGE_KEY = "tau:expand-thinking"; const NATIVE_SELECT_ALL_STORAGE_KEY = "tau:scope-native-select-all"; const OPEN_URL_AUTOMATICALLY_STORAGE_KEY = "tau:open-url-automatically"; +/** The transient tab of a chat not yet sent (no session yet). */ +const NEW_CHAT_TAB_ID = "chat:new"; +const chatTabId = (session: SessionInfo) => `chat:${remoteHostId(session.hostId) ?? LOCAL_HOST_ID}:${session.id}`; type AutoNameStatus = @@ -1059,6 +1064,10 @@ export function AppShell({ appName }: { appName: string }) { // Right panel tabs: Explorer | Git changes | open files (Tauri parity). const [fileTabs, setFileTabs] = useState([]); const [activeFileTabId, setActiveFileTabId] = useState(null); + // The main tab strip: open conversations beside the open files. A file tab + // shown (fileShown) covers the chat, which stays mounted behind it. + const [chatTabs, setChatTabs] = useState([]); + const [fileShown, setFileShown] = useState(false); const [rightPanelOpen, setRightPanelOpen] = useState(false); const closeRightPanel = useCallback(() => { setRightPanelOpen(false); @@ -1186,6 +1195,7 @@ export function AppShell({ appName }: { appName: string }) { const handleFileLineMention = useCallback((relativePath: string, startLine: number, endLine: number) => { chatInputRef.current?.insertText(buildFileLineMentionText(relativePath, startLine, endLine)); + setFileShown(false); }, []); const initialSessionId = initialNavigation.sessionId; @@ -1304,6 +1314,7 @@ export function AppShell({ appName }: { appName: string }) { // re-select, notification click) must not bump sessionKey: that remounts // ChatWindow, reconnects SSE, and drops the mid-run streaming view. setSettingsTab(null); + setFileShown(false); // Re-picking the current conversation still closes/rearms the drawer, // without remounting the chat or disturbing its draft. if (isMobile && !isRestore) { @@ -1334,6 +1345,7 @@ export function AppShell({ appName }: { appName: string }) { const handleNewSession = useCallback((creationId: string, cwd: string | null, hostId?: string, project?: ManagedProject, initialization?: string) => { setSettingsTab(null); + setFileShown(false); setSelectedSession(null); const target = project ?? (cwd === activeCwd ? activePoolProject : null); setNewSessionCreation({ id: creationId || randomUUID(), initialization }); @@ -1586,6 +1598,7 @@ export function AppShell({ appName }: { appName: string }) { // The composer for this session can never be reopened, so its draft would // otherwise keep the exit guard armed for unreachable content. clearDraft(sessionId); + setChatTabs((tabs) => tabs.filter((tab) => tab.id !== sessionId)); setRefreshKey((k) => k + 1); if (selectedSession?.id === sessionId) { const cwd = selectedSession.cwd; @@ -1650,9 +1663,8 @@ export function AppShell({ appName }: { appName: string }) { // would still have read the pre-close list from the closure). const next = fileTabs.filter((t) => t.id !== tabId); setFileTabs(next); - // The panel now hosts the Explorer tab, so it stays open: closing the - // last file falls back to the explorer instead of hiding the panel. - if (next.length === 0) setRightView("explorer"); + // Closing the last file shows the chat again. + if (next.length === 0) setFileShown(false); setActiveFileTabId((cur) => { if (cur !== tabId) return cur; return next.length > 0 ? next[next.length - 1].id : null; @@ -1668,11 +1680,11 @@ export function AppShell({ appName }: { appName: string }) { ? prev : [...prev, { id: tabId, label: fileName, filePath: target, hostId: source.hostId, sourceCwd: source.cwd, sourceSessionId: source.sessionId }]); setActiveFileTabId(tabId); - setRightView("file"); - setRightPanelOpen(true); - // On mobile the file panel is full-screen; close the drawer so it shows. + setFileShown(true); + // The file opens in the main area: close what covers it there. if (isMobile) setSidebarOpen(false); - }, [isMobile]); + if (isCompactOverlay) setRightPanelOpen(false); + }, [isMobile, isCompactOverlay]); // Agent open requests that wait for the user. URLs always ask unless the // user opted into opening links from the viewed session automatically; URLs @@ -1788,6 +1800,7 @@ export function AppShell({ appName }: { appName: string }) { if (!activeFileTab || activeFileTab.sourceSessionId !== (selectedSession?.id ?? null)) return; if (activeFileTab.hostId !== workspaceHostId) { toast.info(t("hosts.fileOtherHost")); return; } handleAtMention(getRelativeFilePath(activeFileTab.filePath, activeFileTab.sourceCwd ?? undefined), false); + setFileShown(false); }, [activeFileTab, selectedSession?.id, handleAtMention, workspaceHostId, t]); const handleCopyActiveFilePath = useCallback(() => { @@ -1822,7 +1835,7 @@ export function AppShell({ appName }: { appName: string }) { const handleSelectFileTab = useCallback((tabId: string) => { setActiveFileTabId(tabId); - setRightView("file"); + setFileShown(true); }, []); // Stable selectors for the memoized RightPanel: inline arrows here would be // new identities every render and defeat the memo boundary. @@ -1846,9 +1859,51 @@ export function AppShell({ appName }: { appName: string }) { const handleCloseAllFileTabs = useCallback(() => { setFileTabs([]); setActiveFileTabId(null); - setRightView("explorer"); + setFileShown(false); }, []); + // Every conversation shown gets a chat tab, kept until closed; a newer copy + // of its session (title, hydrated root) replaces the stored one. + useEffect(() => { + if (!selectedSession) return; + setChatTabs((tabs) => { + const index = tabs.findIndex((tab) => sameSessionTarget(tab, selectedSession)); + if (index < 0) return [...tabs, selectedSession]; + if (tabs[index] === selectedSession) return tabs; + return tabs.map((tab, i) => (i === index ? selectedSession : tab)); + }); + }, [selectedSession]); + + // Chats and files share one strip, in the order they were opened. + const [stripOrder, setStripOrder] = useState([]); + useEffect(() => { + const ids = [...chatTabs.map(chatTabId), ...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]); + + 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 keepFile = fileShown; + const neighbour = rest[Math.min(index, rest.length - 1)]; + if (neighbour) handleSelectSession(neighbour); + else handleNewSession( + randomUUID(), + session.poolId ? null : session.cwd, + session.hostId, + session.poolId ? workspaceOptions.projects.find((project) => project.poolId === session.poolId && project.projectId === session.projectId) : undefined, + ); + if (keepFile) setFileShown(true); + }, [chatTabs, selectedSession, fileShown, handleSelectSession, handleNewSession, workspaceOptions.projects]); + const handleViewFullHistory = useCallback(() => { if (!selectedSession) return; window.open( @@ -1946,6 +2001,35 @@ export function AppShell({ appName }: { appName: string }) { // While restoring initial session from URL, don't show the placeholder const showPlaceholder = initialSessionRestored && !showChat; + const activeFileMatchesSource = activeFileTab?.hostId === workspaceHostId && (activeFileTab?.sourceSessionId ?? null) === (selectedSession?.id ?? null); + const fileTabShown = fileShown && activeFileTab !== null; + const chatIcon =