graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(native): picking a workspace changes the folder in front of you
justrache95cfc07b1b1
diff --git a/apps/native/README.md b/apps/native/README.mdindex fbe127dd..ec660dd8 100644--- a/apps/native/README.md+++ b/apps/native/README.md@@ -98,10 +98,13 @@ server only validates a root it is handed) with the active one checked:pointing at an empty config: with a typical config every tab otherwisecosts a gigabyte or more of server processes). *Forget* removes itfrom the switcher only.-- Switching workspaces changes the sidebar's session list and where new- tabs open. A tab's agent is spawned in the workspace that was active- when the tab opened and stays there — the folder chip in the tab bar- names the tab's own workspace, the switcher names the active one.+- Switching workspaces moves the tab you are looking at when nothing has+ been asked in it yet: picking a folder should change the folder in+ front of you, so its agent is respawned there rather than a second tab+ appearing. A tab that already holds a conversation keeps its own+ folder, because its agent is bound to that folder at spawn — the chip+ in the tab bar and each split's header name the folder that tab runs+ in, and the switcher names the one new tabs will use.`/api/acp` bootstrap, `/api/sessions`, `/api/fs` and `/api/git` all takethe workspace root (`cwd` / `?root=`) and fall back to the default fromdiff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsxindex fb48504e..c266bdb9 100644--- a/apps/native/components/site/GraffHarness.tsx+++ b/apps/native/components/site/GraffHarness.tsx@@ -597,16 +597,38 @@ export default function GraffHarness() {void refreshStored();};- /** Switch the sidebar to a workspace and land on a tab that runs there:- * an empty tab of its own if one is open, else a fresh one. Tabs already- * running elsewhere keep their agents — a workspace is fixed at spawn. */+ /** Move a tab to another folder. Only sound for a tab with no messages:+ * an agent is bound to its folder at spawn, so this starts a fresh one+ * there, and a conversation would lose the ground it was standing on. */+ const moveChatTo = (chatId: number, path: string) => {+ const ws = findWorkspace(workspacesRef.current, path);+ const next = chatsRef.current.map((c) => (c.id === chatId ? { ...c, cwd: path, model: c.model ?? ws?.model } : c));+ // requireSession reads the chat from this ref in the same tick, before+ // React has re-rendered with the new cwd.+ chatsRef.current = next;+ setChats(next);+ setActiveId(chatId);+ void requireSession(chatId, true)+ .then(() => adoptCatalog(chatId))+ .catch(() => undefined);+ };++ /** Switch the sidebar to a workspace and land on a tab that runs there.+ * The tab in front follows the switch when nothing has been asked in it+ * yet — picking a folder should change the folder you are looking at.+ * A tab with a conversation keeps its own folder, and says which. */const switchWorkspace = (path: string) => {if (path === activePathRef.current) return;activate(path);+ setFilesOpen(false);+ const here = chatsRef.current.find((c) => c.id === activeId);+ if (here && here.messages.length === 0) {+ moveChatTo(here.id, path);+ return;+ }const empty = chatsRef.current.find((c) => c.cwd === path && c.messages.length === 0);if (empty) {setActiveId(empty.id);- setFilesOpen(false);return;}openChat((chatIdRef.current += 1));@@ -692,11 +714,12 @@ export default function GraffHarness() {// The tab bar's folder chip is the *tab's* workspace; the sidebar's// switcher is the *active* one (where new tabs open). They differ only// after a switch, and each says so on hover.+ const cwdOf = (thread: Chat) => thread.cwd ?? activePath ?? health?.cwd;const workspaceNameOf = (thread: Chat) => {- const dir = thread.cwd ?? health?.cwd;+ const dir = cwdOf(thread);return findWorkspace(workspaces, dir)?.name ?? (dir ? basename(dir) : "workspace");};- const chatCwd = chatThread.cwd ?? health?.cwd;+ const chatCwd = cwdOf(chatThread);const chatWorkspace = findWorkspace(workspaces, chatCwd);const workspaceName = chatWorkspace?.name ?? (chatCwd ? basename(chatCwd) : "workspace");const pinCount = (pinsByChat[chatThread.id] ?? []).length;@@ -818,7 +841,7 @@ export default function GraffHarness() {onSend={(text: string) => void send(text, thread.id)}health={health}history={threadHistory}- cwd={thread.cwd}+ cwd={cwdOf(thread)}offset={offset}shuffle={() => setOffset((current) => (current + 3) % STARTER_PROMPTS.length)}models={models}@@ -1049,7 +1072,7 @@ export default function GraffHarness() {{thread.title ?? "New chat"}</button><span- title={thread.cwd ?? health?.cwd ?? "workspace"}+ title={cwdOf(thread) ?? "workspace"}className="flex h-7 shrink-0 items-center gap-1.5 rounded-[7px] px-1.5 text-[12px] font-medium text-ink-2"><IconFolder size={14} />