Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

fix: show session navigation in one place

justrach56e317e3a266
diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml
index c3a9dcce..631a7ad3 100644
--- a/.github/workflows/desktop.yml
+++ b/.github/workflows/desktop.yml
@@ -27,6 +27,7 @@ jobs:
- run: bun run test:queue
- run: bun run test:turns
- run: bun run test:tab-drag
+ - run: bun run test:session-navigation
- run: bun run test:stream-performance
- run: bun run test:history-performance
- run: bun run test:browser-resources
@@ -74,6 +75,12 @@ jobs:
env:
GRAFF_ELECTRON_FOREGROUND: '1'
GRAFF_VISUAL_OUTPUT: ../../zig-out/native-tab-drag
+ - name: Session navigation modes and sidebar drag
+ if: ${{ !cancelled() && steps.gui.conclusion == 'success' }}
+ run: bun run test:session-navigation
+ env:
+ GRAFF_ELECTRON_FOREGROUND: '1'
+ GRAFF_VISUAL_OUTPUT: ../../zig-out/session-navigation
- uses: ./.github/actions/setup-codegraff-zig
id: zig
if: ${{ !cancelled() && steps.gui.conclusion == 'success' }}
@@ -133,6 +140,7 @@ jobs:
zig-out/packaged-titles/
zig-out/split-stress/
zig-out/native-tab-drag/
+ zig-out/session-navigation/
zig-out/visual-tests/test-run.json
zig-out/visual-tests/stress-results.json
zig-out/visual-tests/stress-fullscreen.png
diff --git a/apps/native/components/primitives/SidebarNav.tsx b/apps/native/components/primitives/SidebarNav.tsx
index 9ffe9536..92402cbf 100644
--- a/apps/native/components/primitives/SidebarNav.tsx
+++ b/apps/native/components/primitives/SidebarNav.tsx
@@ -60,6 +60,8 @@ const DEFAULT_RECENTS: SidebarRecent[] = [
type SidebarNavProps = {
onCloseNavigation?: () => void;
+ onCollapsedChange?: (collapsed: boolean) => void;
+ openSessions?: ReactNode;
activeTitle?: string | null;
/** When set, rows highlight by id instead of by label (titles can repeat). */
activeId?: string | null;
@@ -171,7 +173,7 @@ function RailButton({
}
export default function SidebarNav({
- onCloseNavigation,
+ onCloseNavigation, onCollapsedChange, openSessions,
activeTitle,
activeId,
className = "",
@@ -197,6 +199,7 @@ export default function SidebarNav({
onSeeAll,
}: SidebarNavProps) {
const [collapsed, setCollapsed] = useState(false);
+ useEffect(() => { onCollapsedChange?.(collapsed); }, [collapsed, onCollapsedChange]);
useEffect(() => { if (onCloseNavigation) setCollapsed(false); }, [!!onCloseNavigation]);
const [internalNav, setInternalNav] = useState("chats");
const currentNav = activeNav ?? internalNav;
@@ -353,6 +356,7 @@ export default function SidebarNav({
</GlideGroup>
<div inert={collapsed} aria-hidden={collapsed} className="mt-3 min-h-0 flex-1 overflow-y-auto">
+ {openSessions}
<div className="sidebar-copy relative mx-2 mb-1 h-8">
<button
type="button"
@@ -368,7 +372,7 @@ export default function SidebarNav({
<span className={`flex transition-transform duration-150 ${chatsOpen ? "" : "-rotate-90"}`}>
<IconChevronDownSmall size={16} />
</span>
- <span>Chats</span>
+ <span>{openSessions ? "History" : "Chats"}</span>
{visibleRecents.length > 0 && <span className="tabular-nums text-ink-3">{visibleRecents.length}</span>}
</button>
@@ -476,7 +480,7 @@ export default function SidebarNav({
})}
{visibleRecents.length === 0 && (
<div className="sidebar-copy mx-2 px-2 py-2 text-[12.5px] text-ink-3">
- {query ? "No chats found" : "No chats yet — start one and it appears here."}
+ {query ? "No chats found" : openSessions ? "No saved conversations yet." : "No chats yet — start one and it appears here."}
</div>
)}
{!query && onSeeAll && (recentsTotal ?? recents.length) > recents.length && (
diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsx
index a07becb3..6327d90e 100644
--- a/apps/native/components/site/GraffHarness.tsx
+++ b/apps/native/components/site/GraffHarness.tsx
@@ -1,4 +1,5 @@
"use client";
+import SessionTabs from "./SessionTabs";
import { useResponsiveNavigation } from "./useResponsiveNavigation";
import { useNavigationPromptFocus } from "./useNavigationPromptFocus";
import { useUnreadChats } from "./useUnreadChats";
@@ -403,7 +404,7 @@ export default function GraffHarness() {
});
const columnBody = (thread: Chat) => <ChatColumn key={thread.id} thread={thread}
- compact={columnIds.length > 1} following={tailing[thread.id] ?? true} register={paneRef(thread.id)}
+ compact={columnIds.length > 1 || !navigation.sidebarVisible} following={tailing[thread.id] ?? true} register={paneRef(thread.id)}
onOpenPath={openPath} onReview={openChanges}
onRefresh={loaded => {
const messages: Msg[] = loaded.messages.map(m => ({ id: ++msgIdRef.current, ...m }));
@@ -458,9 +459,17 @@ export default function GraffHarness() {
return (
<main ref={promptFocusRoot} data-graff-main data-workspace-ready={projectsReady} className="flex h-[100dvh] gap-0 bg-canvas p-2.5 text-ink lg:pl-0">
<div {...navigation.panelProps}><SidebarNav
- onCloseNavigation={navigation.close}
+ onCloseNavigation={navigation.close} onCollapsedChange={navigation.onCollapsedChange}
+ openSessions={navigation.sidebarVisible && <div className="mb-4">
+ <button type="button" aria-label="Show agents" aria-pressed={agentsOpen} onClick={() => { setProjectsOpen(false); setAgentsOpen(!agentsOpen); setFilesOpen(false); setBrowserOpen(false); setConversationsOpen(false); }} className="mx-3 mb-2 rounded-md px-2 py-1 text-[13px] text-ink-2 hover:bg-hover">Agents{workingAgents ? ` (${workingAgents})` : ""}</button>
+ <p className="mb-1 px-4 text-[11px] font-medium text-ink-3">Open chats</p>
+ <SessionTabs vertical chats={groups.tabs} activeId={groups.activeTab} agentsOpen={agentsOpen}
+ busyIds={new Set(groups.groups.filter(group => group.ids.some(id => busyIds.has(id))).map(group => group.ids[0]))} unreadIds={unread}
+ focusChat={id => focusChat(groups.focusOf(id))} closeChat={closeTab}
+ onTabPointerDown={tabDrag.begin} onTabClickCapture={tabDrag.suppressClick} />
+ </div>}
fill
- recents={recents}
+ recents={recents.filter(recent => !chats.some(chat => chat.session === recent.id))}
recentsTotal={storedTotal}
activeTitle={chatThread.title}
activeId={chatThread.session ?? null}
@@ -490,7 +499,7 @@ export default function GraffHarness() {
<div className="flex min-w-0 flex-1 flex-col gap-2.5">
{tabDrag.overlay}
- <HarnessChrome navigationToggle={navigation.trigger} unreadIds={unread} onTabPointerDown={tabDrag.begin} onTabClickCapture={tabDrag.suppressClick} chats={groups.tabs} activeId={groups.activeTab} busyIds={new Set(groups.groups.filter(group => group.ids.some(id => busyIds.has(id))).map(group => group.ids[0]))} focusChat={id => focusChat(groups.focusOf(id))} closeChat={closeTab} newChat={newChat}
+ <HarnessChrome sidebarVisible={navigation.sidebarVisible} navigationToggle={navigation.trigger} unreadIds={unread} onTabPointerDown={tabDrag.begin} onTabClickCapture={tabDrag.suppressClick} chats={groups.tabs} activeId={groups.activeTab} busyIds={new Set(groups.groups.filter(group => group.ids.some(id => busyIds.has(id))).map(group => group.ids[0]))} focusChat={id => focusChat(groups.focusOf(id))} closeChat={closeTab} newChat={newChat}
conversationsOpen={conversationsOpen} openConversations={openConversations} split={panes.length > 0} toggleSplit={toggleSplit}
filesOpen={filesOpen} onFiles={() => { setAgentsOpen(false); setFileRequest(null); setProjectsOpen(false); setBrowserOpen(false); setConversationsOpen(false); setFilesOpen(fileRequest?.changes ? true : !filesOpen); }}
chatCwd={chatCwd} workspaceName={workspaceName} onFolder={() => setDialog({ mode: "new" })} openChanges={openChanges}
diff --git a/apps/native/components/site/HarnessChrome.tsx b/apps/native/components/site/HarnessChrome.tsx
index f51fa41e..79df3948 100644
--- a/apps/native/components/site/HarnessChrome.tsx
+++ b/apps/native/components/site/HarnessChrome.tsx
@@ -1,13 +1,12 @@
-import SplitLayoutIcon from "./SplitLayoutIcon";
+import SessionTabs from "./SessionTabs";
import type {SplitTree} from "@/lib/split-tree";
import ActionMenu from "@/components/primitives/ActionMenu";
-import { useEffect, useRef } from "react";
import AppSettings from "./AppSettings";
import type { PointerEvent, MouseEvent, ReactNode } from "react";
import type { Chat } from "./harness-types";
import reviewStyles from "./ChangesPane.module.css";
type Props = {
- navigationToggle?: ReactNode;
+ navigationToggle?: ReactNode; sidebarVisible?: boolean;
unreadIds?: ReadonlySet<number>;
onTabPointerDown?(event: PointerEvent, id: number): void; onTabClickCapture?(event: MouseEvent): void;
chats: (Pick<Chat, "id" | "title"> & { paneIds?: number[]; direction?: "row" | "column"; tree?: SplitTree })[]; activeId: number; busyIds: ReadonlySet<number>;
@@ -18,68 +17,21 @@ type Props = {
terminalVisible: boolean; toggleTerminal(): void; agentsOpen: boolean; onAgents(): void; workingAgents?: number;
tasksOpen?: boolean; taskCount?: number; onTasks?: () => void; splitNotice?: string | null;
};
-export default function HarnessChrome({navigationToggle, unreadIds, chats, activeId, busyIds, focusChat, closeChat, newChat,
+export default function HarnessChrome({navigationToggle, sidebarVisible = false, unreadIds, chats, activeId, busyIds, focusChat, closeChat, newChat,
conversationsOpen, openConversations, split, toggleSplit, filesOpen, onFiles, chatCwd,
workspaceName, onFolder, openChanges, browserOpen, onBrowser, pinCount, terminalVisible,
toggleTerminal, agentsOpen, onAgents, workingAgents = 0, tasksOpen = false, taskCount = 0, onTasks, splitNotice, onTabPointerDown, onTabClickCapture}: Props) {
- const frame = useRef<HTMLDivElement>(null);
- useEffect(() => { frame.current?.querySelector(`[data-tab-id="${activeId}"]`)?.scrollIntoView({block: "nearest", inline: "nearest"}); }, [activeId]);
return (
- <div ref={frame} data-workspace-toolbar className={`${reviewStyles.chatbar} flex shrink-0 flex-col overflow-hidden rounded-[14px] border border-line bg-page`}>
+ <div data-workspace-toolbar className={`${reviewStyles.chatbar} flex shrink-0 flex-col overflow-hidden rounded-[14px] border border-line bg-page`}>
{/* One workspace-level tab strip above every split; never owned by a pane. */}
- <div className="flex h-10 min-w-0 shrink-0 items-center gap-1 px-2">
- {navigationToggle}
+ <div data-session-tab-strip hidden={sidebarVisible} className={sidebarVisible ? "hidden" : "flex h-10 min-w-0 shrink-0 items-center gap-1 px-2"}>
<div className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
<button type="button" aria-label="Show agents" aria-pressed={agentsOpen} onClick={onAgents}
className={`h-7 shrink-0 rounded-[7px] px-3 text-[12.5px] font-medium ${agentsOpen ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover"}`}>Agents{workingAgents > 0 ? ` (${workingAgents})` : ""}</button>
<span aria-hidden="true" className="mx-1 h-4 w-px shrink-0 bg-line" />
- {chats.map((c) => (
- <div
- data-tab-id={c.id}
- data-tab-members={(c.paneIds ?? [c.id]).join(",")}
- onPointerDown={event => onTabPointerDown?.(event, c.id)}
- onClickCapture={onTabClickCapture}
- onDragStart={event => event.preventDefault()}
- title={c.title ?? "Drag to reorder or to a chat edge to split"}
- key={c.id}
- style={{ width: (c.paneIds?.length ?? 1) > 1 ? 230 : 144 }}
- className={`group/tab select-none touch-none flex h-7 shrink-0 items-center gap-0.5 rounded-[7px] pl-2.5 pr-1 text-[12.5px] font-medium transition-colors duration-100 ${
- c.id === activeId && !agentsOpen ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover hover:text-ink"
- }`}
- >
- {c.tree && (c.paneIds?.length ?? 1) > 1 && <SplitLayoutIcon tree={c.tree} />}
- {busyIds.has(c.id) && (
- <span
- className="mr-1 size-3 shrink-0 animate-spin rounded-full border-[1.5px] border-current border-r-transparent text-ink-2 motion-reduce:animate-none"
- role="img"
- aria-label="Working"
- />
- )}
- {!busyIds.has(c.id) && (c.paneIds ?? [c.id]).some(id => unreadIds?.has(id)) && <span role="img" aria-label="Unread response" className="mr-1 size-1.5 shrink-0 rounded-full bg-blue-500" />}
- <button
- type="button"
- aria-pressed={c.id === activeId && !agentsOpen}
- onClick={() => {
- focusChat(c.id);
- }}
- title={c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "New chat")}
- className="min-w-0 flex-1 text-left"
- >
- <span className="block truncate">{c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "New chat")}</span>
- </button>
- <button
- type="button"
- aria-label="Close tab"
- title={(c.paneIds?.length ?? 1) > 1 ? "Close all chats in this split tab" : "Close tab"}
- onClick={() => closeChat(c.id)}
- className="-my-1 flex size-6 shrink-0 items-center justify-center rounded-[5px] text-ink-3 transition-[background-color,color] duration-100 hover:bg-hover-2 hover:text-ink"
- >
- <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" aria-hidden>
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- </div>
- ))}
+ {!sidebarVisible && <SessionTabs chats={chats} activeId={activeId} busyIds={busyIds} unreadIds={unreadIds}
+ agentsOpen={agentsOpen} focusChat={focusChat} closeChat={closeChat}
+ onTabPointerDown={onTabPointerDown} onTabClickCapture={onTabClickCapture} />}
<button
type="button"
aria-label="New chat"
@@ -92,9 +44,9 @@ export default function HarnessChrome({navigationToggle, unreadIds, chats, activ
</svg>
</button>
</div>
- <div data-desktop-update-slot className="shrink-0" />
</div>
- <div className={`${reviewStyles.actions} flex min-h-10 shrink-0 items-center gap-2 border-t border-line px-3 py-1`}>
+ <div className={`${reviewStyles.actions} flex min-h-10 shrink-0 items-center gap-2 ${sidebarVisible ? "" : "border-t border-line"} px-3 py-1`}>
+ {navigationToggle}
<button type="button" aria-pressed={filesOpen} onClick={onFiles} title={`${chatCwd ?? "Workspace"}\nShow this chat's files`}
className="max-w-48 truncate lg:hidden rounded-md px-2 py-1 text-xs font-medium text-ink-2 hover:bg-hover">{workspaceName}</button>
<button type="button" onClick={openChanges} aria-label="Review workspace changes" className="rounded-md px-2 py-1 text-xs text-ink-2 hover:bg-hover">Changes</button>
@@ -111,7 +63,8 @@ export default function HarnessChrome({navigationToggle, unreadIds, chats, activ
<button type="button" aria-pressed={split} onClick={toggleSplit}>{split ? "Close splits" : "Split view"} <span className="ml-auto text-ink-3">⌘\</span></button>
<button type="button" aria-pressed={conversationsOpen} onClick={openConversations}>All conversations</button>
</ActionMenu>
- <span className="lg:hidden"><AppSettings /></span>
+ {!sidebarVisible && <AppSettings />}
+ <div data-desktop-update-slot className="shrink-0" />
</div>
{splitNotice && <p role="status" data-split-limit className="border-t border-line px-3 py-1.5 text-[12px] text-ink-2">{splitNotice}</p>}
</div>
diff --git a/apps/native/components/site/SessionTabs.tsx b/apps/native/components/site/SessionTabs.tsx
new file mode 100644
index 00000000..e257eb3e
--- /dev/null
+++ b/apps/native/components/site/SessionTabs.tsx
@@ -0,0 +1,69 @@
+import { useEffect, useRef, type PointerEvent, type MouseEvent } from "react";
+import SplitLayoutIcon from "./SplitLayoutIcon";
+import type { SplitTree } from "@/lib/split-tree";
+
+export type SessionTab = { id: number; title?: string | null; paneIds?: number[]; tree?: SplitTree };
+export type SessionTabsProps = {
+ chats: SessionTab[]; activeId: number; busyIds: ReadonlySet<number>;
+ unreadIds?: ReadonlySet<number>; agentsOpen: boolean; vertical?: boolean;
+ focusChat(id: number): void; closeChat(id: number): void;
+ onTabPointerDown?(event: PointerEvent, id: number): void;
+ onTabClickCapture?(event: MouseEvent): void;
+};
+
+/** One mounted session list, laid out for the sidebar or compact top bar. */
+export default function SessionTabs({ chats, activeId, busyIds, unreadIds, agentsOpen, vertical = false,
+ focusChat, closeChat, onTabPointerDown, onTabClickCapture }: SessionTabsProps) {
+ const root = useRef<HTMLDivElement>(null);
+ useEffect(() => { root.current?.querySelector(`[data-tab-id="${activeId}"]`)?.scrollIntoView({ block: "nearest", inline: "nearest" }); }, [activeId]);
+ return <div ref={root} data-session-navigation={vertical ? "sidebar" : "tabs"}
+ aria-label="Open chats" className={vertical ? "flex min-w-0 flex-col gap-1 px-3" : "flex min-w-0 items-center gap-1"}>
+ {chats.map((c) => (
+ <div
+ data-tab-id={c.id}
+ data-tab-members={(c.paneIds ?? [c.id]).join(",")}
+ onPointerDown={event => onTabPointerDown?.(event, c.id)}
+ onClickCapture={onTabClickCapture}
+ onDragStart={event => event.preventDefault()}
+ title={c.title ?? "Drag to reorder or to a chat edge to split"}
+ key={c.id}
+ style={{ width: vertical ? "100%" : (c.paneIds?.length ?? 1) > 1 ? 230 : 144 }}
+ className={`group/tab select-none touch-none flex h-8 shrink-0 items-center gap-0.5 rounded-[7px] pl-2.5 pr-1 text-[12.5px] font-medium transition-colors duration-100 ${
+ c.id === activeId && !agentsOpen ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover hover:text-ink"
+ }`}
+ >
+ {c.tree && (c.paneIds?.length ?? 1) > 1 && <SplitLayoutIcon tree={c.tree} />}
+ {busyIds.has(c.id) && (
+ <span
+ className="mr-1 size-3 shrink-0 animate-spin rounded-full border-[1.5px] border-current border-r-transparent text-ink-2 motion-reduce:animate-none"
+ role="img"
+ aria-label="Working"
+ />
+ )}
+ {!busyIds.has(c.id) && (c.paneIds ?? [c.id]).some(id => unreadIds?.has(id)) && <span role="img" aria-label="Unread response" className="mr-1 size-1.5 shrink-0 rounded-full bg-blue-500" />}
+ <button
+ type="button"
+ aria-pressed={c.id === activeId && !agentsOpen}
+ onClick={() => {
+ focusChat(c.id);
+ }}
+ title={c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "New chat")}
+ className="min-w-0 flex-1 text-left"
+ >
+ <span className="block truncate">{c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "New chat")}</span>
+ </button>
+ <button
+ type="button"
+ aria-label="Close tab"
+ title={(c.paneIds?.length ?? 1) > 1 ? "Close all chats in this split tab" : "Close tab"}
+ onClick={() => closeChat(c.id)}
+ className={`${vertical ? "opacity-0 group-hover/tab:opacity-100 group-focus-within/tab:opacity-100 [@media(hover:none)]:opacity-100" : ""} -my-1 flex size-6 shrink-0 items-center justify-center rounded-[5px] text-ink-3 transition-[background-color,color] duration-100 hover:bg-hover-2 hover:text-ink`}
+ >
+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" aria-hidden>
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ </div>
+ ))}
+ </div>;
+}
diff --git a/apps/native/components/site/useResponsiveNavigation.tsx b/apps/native/components/site/useResponsiveNavigation.tsx
index 823e8a91..1f6897cb 100644
--- a/apps/native/components/site/useResponsiveNavigation.tsx
+++ b/apps/native/components/site/useResponsiveNavigation.tsx
@@ -7,6 +7,7 @@ import styles from "./ResponsiveNavigation.module.css";
export function useResponsiveNavigation() {
const id = useId(), panel = useRef<HTMLDivElement>(null);
const [narrow, setNarrow] = useState(false), [open, setOpen] = useState(false);
+ const [collapsed, setCollapsed] = useState(false);
const close = () => { if (panel.current?.matches(":popover-open")) panel.current.hidePopover(); };
useEffect(() => {
const query = matchMedia("(width < 64rem)");
@@ -15,6 +16,8 @@ export function useResponsiveNavigation() {
return () => query.removeEventListener("change", update);
}, []);
return {
+ sidebarVisible: narrow ? open : !collapsed,
+ onCollapsedChange: setCollapsed,
close: narrow ? close : undefined,
panelProps: {
id, ref: panel, popover: narrow ? "auto" as const : undefined,
diff --git a/apps/native/components/site/useTabDrag.tsx b/apps/native/components/site/useTabDrag.tsx
index d76e378f..966aa7a4 100644
--- a/apps/native/components/site/useTabDrag.tsx
+++ b/apps/native/components/site/useTabDrag.tsx
@@ -44,7 +44,10 @@ export function useTabDrag(onDrop: (id: number, drop: TabDrop) => void) {
const element = document.elementFromPoint(x, y);
const tab = element?.closest<HTMLElement>('[data-tab-id]');
if (tab && Number(tab.dataset.tabId) !== id) {
- const r = tab.getBoundingClientRect(), after = x > r.left + r.width / 2;
+ const r = tab.getBoundingClientRect();
+ const vertical = tab.closest('[data-session-navigation="sidebar"]') !== null;
+ const after = vertical ? y > r.top + r.height / 2 : x > r.left + r.width / 2;
+ if (vertical) return { drop: { kind: "tab", id: Number(tab.dataset.tabId), after }, left: r.left, top: after ? r.bottom - 2 : r.top, width: r.width, height: 3, label: "Move chat" };
return { drop: { kind: "tab", id: Number(tab.dataset.tabId), after }, left: after ? r.right - 2 : r.left, top: r.top, width: 3, height: r.height, label: "Move tab" };
}
const pane = element?.closest<HTMLElement>('[data-chat]');
diff --git a/apps/native/electron/frontend-runtime.cjs b/apps/native/electron/frontend-runtime.cjs
index 73e2005b..b8d62b5d 100644
--- a/apps/native/electron/frontend-runtime.cjs
+++ b/apps/native/electron/frontend-runtime.cjs
@@ -214,6 +214,12 @@ app.whenReady().then(async () => {
assert.equal(await js(`Array.from(document.querySelectorAll('[data-tool-summary]')).some(e=>/\\b(?:running|interrupted)\\b/.test(e.textContent))`), false, 'Completed tools must not become interrupted');
fs.writeFileSync(path.join(output, 'error-keeps-result.png'), (await wc.capturePage()).toPNG());
report.passed.push('typed prompt, real file write, explicit error and retained completed tool');
+ if (!process.env.GRAFF_NARROW_NAV_TEST && !process.env.GRAFF_CLI_TEST && !process.env.GRAFF_SPLIT_STRESS) {
+ await click('[aria-label="Collapse sidebar"]');
+ await until(() => js(`!!document.querySelector('[data-session-navigation="tabs"]')`), 'completed session moves to top tabs');
+ assert.ok(await js(`document.body.textContent.includes('Scripted final request rejected')`));
+ report.passed.push('same real failed session survives sidebar-to-tabs navigation change');
+ }
await send('Read the fixture file and report its state.');
await until(() => js(`document.body.textContent.includes('The earlier result is still present.') && !document.querySelector('article[aria-busy="true"]')`), 'successful follow-up', 25000);
const status = () => js(`Array.from(document.querySelectorAll('article')).at(-1)?.textContent.match(/Worked for [^·]+/)?.[0]`);
@@ -224,6 +230,8 @@ app.whenReady().then(async () => {
const calls = JSON.parse(fs.readFileSync(requests, 'utf8'));
assert.equal(calls.length, historyTest ? 6 : 4, 'Both turns must execute the scripted tool and terminal reply');
assert.ok(JSON.stringify(calls.at(-1)).includes('kept'), 'Follow-up must receive retained tool output');
+ fs.copyFileSync(requests, path.join(output, 'model-requests.json'));
+ fs.cpSync(path.join(workspace, '.graff'), path.join(output, 'harness-evidence'), {recursive:true});
fs.writeFileSync(path.join(output, 'follow-up-finished.png'), (await wc.capturePage()).toPNG());
report.passed.push('typed follow-up, real saved history, finished status and frozen elapsed time');
if (process.env.GRAFF_CLI_TEST) {
diff --git a/apps/native/electron/navigation-prompt-focus-visual.cjs b/apps/native/electron/navigation-prompt-focus-visual.cjs
index 80cf32e3..cbf106b2 100644
--- a/apps/native/electron/navigation-prompt-focus-visual.cjs
+++ b/apps/native/electron/navigation-prompt-focus-visual.cjs
@@ -41,19 +41,23 @@ async function runNavigationPromptFocus({ win, origin }) {
await click(`${sidebar} button[aria-label="Home"]`); await focused(first);
await click(`${sidebar} button[aria-label="New chat"]`);
const second = await active(); assert.notEqual(second, first); await focused(second);
+ await click('[aria-label="Collapse sidebar"]');
+ await wait(`!!document.querySelector('[data-session-navigation="tabs"]')`);
await click('[data-workspace-toolbar] button[aria-label="New chat"]');
const third = await active(); assert.notEqual(third, second); await focused(third);
await click(tab(first)); await focused(first);
await click(tab(first)); await focused(first);
- // A saved row already open in the renderer follows the same-current path.
+ await click('[aria-label="Expand sidebar"]');
+ await wait(`!!document.querySelector('[data-session-navigation="sidebar"]')`);
+ // A saved conversation moves into the open-chat list once selected.
await click(`${sidebar} button[title^="Focus history"]`);
await wait(`!!document.querySelector('[data-continue-snapshot]') || document.querySelectorAll('[data-tab-id]').length===4`);
if (await js(`!!document.querySelector('[data-continue-snapshot]')`)) await click('[data-continue-snapshot]');
const saved = await active();
await click(tab(first));
- await click(`${sidebar} button[title^="Focus history"]`); await focused(saved);
- await click(`${sidebar} button[title^="Focus history"]`); await focused(saved);
+ await click(tab(saved)); await focused(saved);
+ await click(tab(saved)); await focused(saved);
wc.send('desktop-action', 'split-right');
await wait(`document.querySelectorAll('[data-chat]').length===2`);
diff --git a/apps/native/electron/navigation-visual.cjs b/apps/native/electron/navigation-visual.cjs
index 4e279ba7..cefda601 100644
--- a/apps/native/electron/navigation-visual.cjs
+++ b/apps/native/electron/navigation-visual.cjs
@@ -24,10 +24,11 @@ async function runNavigationVisuals({win:fixtureWindow,origin,output}) {
await wc.debugger.sendCommand('Page.addScriptToEvaluateOnNewDocument',{source:`(${installGalleryFixture.toString()})();
localStorage.setItem('graff.native.workspaces',JSON.stringify(Array.from({length:50},(_,i)=>({name:'Project '+(i%10),path:'/demo/folder-'+i}))));
const commands=[{name:'compact',description:'Compact conversation context'},...Array.from({length:100},(_,i)=>({name:'command-'+i,description:'Command '+i}))];
- const galleryFetch=window.fetch;window.fetch=async(input,options)=>{const response=await galleryFetch(input,options);if(options?.body&&JSON.parse(options.body).method==='bootstrap')return new Response(JSON.stringify({sessionId:'demo',commands}),{headers:{'content-type':'application/json'}});if(String(input).includes('/api/models')){const data=await response.json();data.result.commands=commands;data.result.current.model='${process.env.GRAFF_VISUAL_SUITE === 'tab-drag' ? 'Graff' : 'example-model-with-a-long-name'}';data.result.models[0].name=data.result.current.model;return new Response(JSON.stringify(data),{headers:{'content-type':'application/json'}});}return response;};`});
+ const galleryFetch=window.fetch;window.fetch=async(input,options)=>{const response=await galleryFetch(input,options);if(options?.body&&JSON.parse(options.body).method==='bootstrap')return new Response(JSON.stringify({sessionId:'demo',commands}),{headers:{'content-type':'application/json'}});if(String(input).includes('/api/models')){const data=await response.json();data.result.commands=commands;data.result.current.model='${['tab-drag','session-navigation'].includes(process.env.GRAFF_VISUAL_SUITE) ? 'Graff' : 'example-model-with-a-long-name'}';data.result.models[0].name=data.result.current.model;return new Response(JSON.stringify(data),{headers:{'content-type':'application/json'}});}return response;};`});
await wc.loadURL(origin);testDesktop.present(win);await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
+ if(process.env.GRAFF_VISUAL_SUITE==='session-navigation'){await require('./session-navigation-visual.cjs').runSessionNavigation({win,origin,output});return;}
if(process.env.GRAFF_VISUAL_SUITE==='tagged'){await require('./yxlyx-regressions-visual.cjs').runYxlyxRegressions({win,origin});return;}
- if(process.env.GRAFF_VISUAL_SUITE==='tab-drag'){await require('./tab-drag-visual.cjs').runTabDrag({win,origin,output});return;}
+ if(process.env.GRAFF_VISUAL_SUITE==='tab-drag'){await js(`document.querySelector('[aria-label="Collapse sidebar"]').click()`);await wait(`!!document.querySelector('[data-session-navigation="tabs"]')`);await require('./tab-drag-visual.cjs').runTabDrag({win,origin,output});return;}
if(process.env.GRAFF_VISUAL_SUITE==='splits'){await require('./split-focus-visual.cjs').runSplitFocus({win,origin,output});return;}
const interactions = async () => {
await require('./navigation-prompt-focus-visual.cjs').runNavigationPromptFocus({win,origin});
diff --git a/apps/native/electron/session-navigation-visual.cjs b/apps/native/electron/session-navigation-visual.cjs
new file mode 100644
index 00000000..ca6fc6a0
--- /dev/null
+++ b/apps/native/electron/session-navigation-visual.cjs
@@ -0,0 +1,79 @@
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const desktop = require('./test-desktop.cjs');
+
+async function runSessionNavigation({ win, output }) {
+ const wc = win.webContents, js = source => wc.executeJavaScript(source);
+ const pause = ms => new Promise(resolve => setTimeout(resolve, ms));
+ const wait = async source => {
+ for (let n=0;n<150;n++) { if (await js(source)) return; await pause(40); }
+ throw Error(`Session navigation timeout: ${source}`);
+ };
+ const click = async selector => {
+ const point = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)throw Error('Missing target');const r=e.getBoundingClientRect();return {x:r.x+r.width/2,y:r.y+r.height/2};})()`);
+ for (const type of ['mouseDown','mouseUp']) await desktop.testInput(wc,{type,...point,button:'left',clickCount:1});
+ await pause(80);
+ };
+ const active = () => js(`Number(document.querySelector('[data-chat][data-focused="true"]').dataset.chat)`);
+ const ids = () => js(`Array.from(document.querySelectorAll('[data-tab-id]'),e=>Number(e.dataset.tabId))`);
+ const capture = async name => {
+ await js('document.fonts.ready.then(()=>true)'); await pause(320);
+ fs.writeFileSync(path.join(output,name+'.png'),(await wc.capturePage()).toPNG());
+ };
+ await wait(`!!document.querySelector('[data-session-navigation="sidebar"]')`);
+ assert.equal(await js(`document.querySelector('[data-session-tab-strip]').getBoundingClientRect().height`),0);
+ await click('[aria-label="Workspace navigation"] button[aria-label="New chat"]');
+ const drafted = await active();
+ for (const keyCode of 'Keep this draft') await desktop.testInput(wc,{type:'char',keyCode});
+ await click('[aria-label="Workspace navigation"] button[aria-label="New chat"]');
+ const last = await active(), before = await ids();
+ assert.equal(before.length,3);
+ await click(`[data-tab-id="${drafted}"] button[aria-pressed]`);
+ assert.equal(await js(`document.querySelector('[data-chat="${drafted}"] textarea').value`),'Keep this draft');
+ await capture('sidebar-open');
+ // Sidebar reordering uses the vertical midpoint, while pane-edge drops remain available.
+ const points = await js(`(()=>{const a=document.querySelector('[data-tab-id="${last}"]').getBoundingClientRect(),b=document.querySelector('[data-tab-id="${before[0]}"]').getBoundingClientRect();return {a:{x:a.x+a.width/2,y:a.y+a.height/2},b:{x:b.x+b.width/2,y:b.y+2}}})()`);
+ await desktop.testInput(wc,{type:'mouseDown',...points.a,button:'left',clickCount:1});
+ for(let i=1;i<=8;i++){await desktop.testInput(wc,{type:'mouseMove',x:points.a.x+(points.b.x-points.a.x)*i/8,y:points.a.y+(points.b.y-points.a.y)*i/8,button:'left',buttons:['left']});await pause(20);}
+ await desktop.testInput(wc,{type:'mouseUp',...points.b,button:'left',clickCount:1});
+ await wait(`Number(document.querySelector('[data-tab-id]').dataset.tabId)===${last}`);
+ await click('[aria-label="Collapse sidebar"]');
+ await wait(`!!document.querySelector('[data-session-navigation="tabs"]')`);
+ assert.equal(await js(`document.querySelectorAll('[data-session-navigation]').length`),1);
+ await click(`[data-tab-id="${drafted}"] button[aria-pressed]`);
+ assert.equal(await active(),drafted);
+ assert.equal(await js(`document.querySelector('[data-chat="${drafted}"] textarea').value`),'Keep this draft');
+ assert.equal(await js(`!!document.querySelector('[data-chat-empty] h1')`),false,'focused mode keeps the empty composer compact');
+ await click('[data-workspace-toolbar] button[aria-label="Settings"]');
+ await wait(`!!document.querySelector(':popover-open')`);
+ assert.ok(await js(`document.querySelector(':popover-open').textContent.includes('Appearance')`),'theme control remains available');
+ await click(':popover-open button[aria-label="Appearance"]');
+ await wait(`!!document.querySelector('[role="dialog"][aria-label="Appearance"]')`);
+ await click('[aria-label="Close appearance"]');
+ await desktop.testInput(wc,{type:'keyDown',keyCode:'Escape'});
+ await desktop.testInput(wc,{type:'keyUp',keyCode:'Escape'});
+ await capture('tabs-only');
+ wc.send('desktop-action','split-right');
+ await wait(`document.querySelectorAll('[data-chat]').length===2`);
+ const splitIds = await js(`Array.from(document.querySelectorAll('[data-chat]'),e=>Number(e.dataset.chat))`);
+ await click('[aria-label="Expand sidebar"]');
+ await wait(`!!document.querySelector('[data-session-navigation="sidebar"]')`);
+ const group = await js(`document.querySelector('[data-tab-members*="${drafted},"]')?.dataset.tabId`);
+ assert.ok(group,'split group remains navigable in sidebar');
+ await click(`[data-tab-id="${last}"] button[aria-pressed]`);
+ await click(`[data-tab-id="${group}"] button[aria-pressed]`);
+ assert.deepEqual(await js(`Array.from(document.querySelectorAll('[data-chat]'),e=>Number(e.dataset.chat))`),splitIds);
+ win.setContentSize(800,760);
+ await wait(`!!document.querySelector('[data-session-navigation="tabs"]')`);
+ await click('[aria-label="Open navigation"]');
+ await wait(`!!document.querySelector('[data-session-navigation="sidebar"]')`);
+ assert.equal(await js(`document.querySelector('[data-session-tab-strip]').getBoundingClientRect().height`),0);
+ await capture('narrow-sidebar');
+ await click('[aria-label="Close navigation"]');
+ await wait(`!!document.querySelector('[data-session-navigation="tabs"]')`);
+ assert.equal(await js(`document.querySelectorAll('[data-session-navigation]').length`),1);
+ assert.equal(await js(`document.querySelector('[data-chat="${drafted}"] textarea').value`),'Keep this draft');
+ console.log('Session navigation passed: one surface, unsaved chats, drafts, vertical reorder, split groups and narrow popover.');
+}
+module.exports = { runSessionNavigation };
diff --git a/apps/native/electron/tab-drag-visual.cjs b/apps/native/electron/tab-drag-visual.cjs
index 2b586799..213f076a 100644
--- a/apps/native/electron/tab-drag-visual.cjs
+++ b/apps/native/electron/tab-drag-visual.cjs
@@ -9,7 +9,11 @@ async function runTabDrag({win, origin, output}) {
// Both motion modes are explicit test inputs, independent of runner settings.
await wc.debugger.sendCommand('Emulation.setEmulatedMedia',{features:[{name:'prefers-reduced-motion',value:'no-preference'}]});
const wait=async code=>{for(let i=0;i<100;i++){if(await js(code))return;await new Promise(r=>setTimeout(r,50));}throw Error(`Tab drag condition failed: ${code}`);};
- const ready=()=>wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
+ const ready=async()=>{
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
+ if(await js(`!!document.querySelector('[aria-label="Collapse sidebar"]')?.checkVisibility()`))await click('[aria-label="Collapse sidebar"]');
+ await wait(`!!document.querySelector('[data-session-navigation="tabs"]')`);
+ };
const tabs=()=>js(`Array.from(document.querySelectorAll('[data-tab-id]')).map(t=>Number(t.dataset.tabId))`);
const panes=()=>js(`Array.from(document.querySelectorAll('[data-chat]')).map(t=>Number(t.dataset.chat))`);
const point=selector=>js(`(()=>{const r=document.querySelector(${JSON.stringify(selector)}).getBoundingClientRect();return {x:Math.round(r.left+r.width/2),y:Math.round(r.top+r.height/2)}})()`);
diff --git a/apps/native/electron/visual-tests.cjs b/apps/native/electron/visual-tests.cjs
index 4e833fc4..898503d0 100644
--- a/apps/native/electron/visual-tests.cjs
+++ b/apps/native/electron/visual-tests.cjs
@@ -65,9 +65,9 @@ app.whenReady().then(async () => {
assert.deepEqual(apiRequests, [], 'Browser fixtures never call engine or model APIs');
return;
}
- if (['projects', 'splits', 'interactions', 'tagged', 'tab-drag'].includes(process.env.GRAFF_VISUAL_SUITE)) {
+ if (['projects', 'splits', 'interactions', 'tagged', 'tab-drag', 'session-navigation'].includes(process.env.GRAFF_VISUAL_SUITE)) {
await require('./navigation-visual.cjs').runNavigationVisuals({ win, origin, output });
- if (!['interactions', 'tagged', 'tab-drag'].includes(process.env.GRAFF_VISUAL_SUITE)) {
+ if (!['interactions', 'tagged', 'tab-drag', 'session-navigation'].includes(process.env.GRAFF_VISUAL_SUITE)) {
await require('./browser-visual.cjs').runBrowserVisuals({ win, origin, output });
await require('./dev-preview-visual.cjs').runDevPreview({ output });
await require('./link-destination-visual.cjs').runLinkDestinationVisuals({ origin, output });
diff --git a/apps/native/package.json b/apps/native/package.json
index f2077875..dc69d5a2 100644
--- a/apps/native/package.json
+++ b/apps/native/package.json
@@ -14,6 +14,7 @@
"electron:build": "bash electron/build.sh",
"test:electron": "bun test electron/policy.test.cjs",
"test:desktop": "bun test lib ./electron/*.test.cjs",
+ "test:session-navigation": "GRAFF_VISUAL_SUITE=session-navigation bun scripts/test-visual.mjs",
"test:tab-drag": "GRAFF_VISUAL_SUITE=tab-drag bun scripts/test-visual.mjs",
"test:turns": "GRAFF_VISUAL_SUITE=turns bun scripts/test-visual.mjs",
"test:visual": "bun scripts/test-visual.mjs",
diff --git a/docs/adr/0122-one-session-navigation-surface.md b/docs/adr/0122-one-session-navigation-surface.md
new file mode 100644
index 00000000..aae55428
--- /dev/null
+++ b/docs/adr/0122-one-session-navigation-surface.md
@@ -0,0 +1,33 @@
+# 0122. One session-navigation surface at a time
+
+Status: accepted 2026-09-15
+
+## Context
+
+The expanded sidebar and top session strip duplicated navigation (#921), but
+the sidebar only listed saved conversations. Simply hiding the top strip would
+hide unsaved chats and split groups from navigation.
+
+## Decision
+
+One mounted list represents open chat groups. It appears vertically in the
+expanded sidebar and horizontally above the workspace when the sidebar is
+collapsed or the narrow-window navigation popover is closed. Opening that
+popover hides the full session strip until it closes. The sidebar history
+omits conversations already represented in the open list.
+
+Both placements use the same selection, close, unread, busy and split-group
+state. Sidebar reordering uses the vertical midpoint; top tabs use the
+horizontal midpoint. Moving the navigation never remounts conversation drafts.
+
+Expanded navigation keeps the welcome screen. Collapsed navigation uses a
+compact composer at the bottom of an empty chat, supporting focused work.
+Settings is available in the sidebar when expanded and the toolbar when
+collapsed. Workspace actions and update controls stay available in both modes.
+
+## Verification
+
+The desktop regression drives pointer and keyboard input through open chats,
+drafts, vertical reordering, split-group restoration, sidebar collapse, the
+narrow popover and appearance controls. Existing navigation regressions still
+exercise both sidebar and top-tab actions explicitly.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 76880455..6969e6b4 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -131,6 +131,8 @@ record only when you need the evidence or the edge cases.
| [0120](0120-draft-publication-does-not-complete-verification.md) | Draft PRs cannot satisfy verified completion; only a user control scoped to this conversation and goal permits an unverified draft handoff. |
| [0121](0121-claims-include-repository-identity.md) | Claims include repository identity; literal PR mutations compare the observed repository, PR number and branch, while unknown scopes stay conservative. |
+| [0122](0122-one-session-navigation-surface.md) | Open chats use the expanded sidebar or collapsed top tabs, preserving drafts and groups; focused mode keeps a compact composer and accessible settings. |
+
## When to write one
Write an ADR when a decision is load-bearing and non-obvious: it was reached