graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix: preserve composer focus across navigation overlays
justrach4dcbe6040bf4
diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsxindex 6327d90e..bbb9a153 100644--- a/apps/native/components/site/GraffHarness.tsx+++ b/apps/native/components/site/GraffHarness.tsx@@ -404,7 +404,7 @@ export default function GraffHarness() {});const columnBody = (thread: Chat) => <ChatColumn key={thread.id} thread={thread}- compact={columnIds.length > 1 || !navigation.sidebarVisible} following={tailing[thread.id] ?? true} register={paneRef(thread.id)}+ compact={columnIds.length > 1 || navigation.focusedMode} 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 }));diff --git a/apps/native/components/site/useResponsiveNavigation.tsx b/apps/native/components/site/useResponsiveNavigation.tsxindex 1f6897cb..5af61913 100644--- a/apps/native/components/site/useResponsiveNavigation.tsx+++ b/apps/native/components/site/useResponsiveNavigation.tsx@@ -17,6 +17,7 @@ export function useResponsiveNavigation() {}, []);return {sidebarVisible: narrow ? open : !collapsed,+ focusedMode: narrow || collapsed,onCollapsedChange: setCollapsed,close: narrow ? close : undefined,panelProps: {@@ -27,8 +28,11 @@ export function useResponsiveNavigation() {// React also delivers descendant popover toggles here. They own their// focus; opening an action menu must not refocus the sidebar close button.if (event.target !== event.currentTarget) return;- const shown = event.newState === "open"; setOpen(shown);- if (shown) panel.current?.querySelector<HTMLButtonElement>('[aria-label="Close navigation"]')?.focus();+ const shown = panel.current?.matches(":popover-open") ?? false; setOpen(shown);+ // Native toggle delivery can follow an outside click. Do not take focus+ // back from the input or another control the user has already selected.+ if (shown && document.activeElement?.getAttribute("popovertarget") === id)+ panel.current?.querySelector<HTMLButtonElement>('[aria-label="Close navigation"]')?.focus();},},trigger: <button type="button" aria-label="Open navigation" title="Projects and conversations"diff --git a/apps/native/electron/browser-focus-frontend.cjs b/apps/native/electron/browser-focus-frontend.cjsindex b513fbeb..3729cba5 100644--- a/apps/native/electron/browser-focus-frontend.cjs+++ b/apps/native/electron/browser-focus-frontend.cjs@@ -32,8 +32,12 @@ async function runBrowserFocus({ win, output, click, until, report }) {await click('[aria-label="Workspace tools"]'); await click('[aria-label="Browser"]');await navigateUser(`${origin}/first`);const chatA = browser.visible;- await click('[title="New chat (⌘T)"]');+ await js(`Array.from(document.querySelectorAll('button[aria-label="New chat"]')).find(e=>e.checkVisibility()).setAttribute('data-browser-new-chat','true')`);+ await click('[data-browser-new-chat="true"]');await until(async () => (await focused()) !== a && browser.visible !== chatA, 'second chat');+ if (!await js(`!!document.querySelector('[aria-label="Address"]')?.checkVisibility()`)) {+ await click('[aria-label="Workspace tools"]'); await click('[aria-label="Browser"]');+ }await navigateUser(`${origin}/selected`);const b = await focused(), chatB = browser.visible;await click('textarea[aria-label="Prompt"]');diff --git a/apps/native/electron/frontend-runtime.cjs b/apps/native/electron/frontend-runtime.cjsindex b8d62b5d..90a81f62 100644--- a/apps/native/electron/frontend-runtime.cjs+++ b/apps/native/electron/frontend-runtime.cjs@@ -112,7 +112,7 @@ app.whenReady().then(async () => {const area = screen.getPrimaryDisplay().workArea;// Exercise the handoff with Browser open on a small desktop: the initial// project context can put the composer below the scroll viewport.- const size = process.env.GRAFF_NARROW_NAV_TEST ? { width: 1004, height: 657 } : process.env.GRAFF_CLI_TEST || process.env.GRAFF_SPLIT_STRESS ? { width: 1024, height: 664 } : { width: 1320, height: 900 };+ const size = process.env.GRAFF_NARROW_NAV_TEST || process.env.GRAFF_SMALL_DESKTOP_TEST ? { width: 1004, height: 657 } : process.env.GRAFF_CLI_TEST || process.env.GRAFF_SPLIT_STRESS ? { width: 1024, height: 664 } : { width: 1320, height: 900 };const bounds = desktop.foreground ? { x: area.x+10, y: area.y+10, width: Math.min(size.width, area.width-20), height: Math.min(size.height, area.height-20) } : size;win = desktop.createWindow({ ...bounds, webPreferences: {preload: path.join(__dirname, 'preload.cjs'), sandbox: true, contextIsolation: true, backgroundThrottling: false,@@ -215,7 +215,11 @@ app.whenReady().then(async () => {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"]');+ if (await js(`innerWidth < 1024`)) {+ await click('[aria-label="Open navigation"]');+ await until(() => js(`!!document.querySelector('[data-session-navigation="sidebar"]')`), 'completed session appears in narrow navigation');+ await click('[aria-label="Close navigation"]');+ } else 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');diff --git a/apps/native/electron/narrow-navigation-frontend.cjs b/apps/native/electron/narrow-navigation-frontend.cjsindex 050686e5..bcf9ef64 100644--- a/apps/native/electron/narrow-navigation-frontend.cjs+++ b/apps/native/electron/narrow-navigation-frontend.cjs@@ -16,8 +16,10 @@ async function runNarrowNavigation({win, output, click, until, report}) {await escape();await until(() => js(`!document.querySelector('[data-navigation-panel]:popover-open') && document.activeElement?.getAttribute('aria-label') === 'Open navigation'`), 'Escape dismisses and restores trigger focus');await click('[aria-label="Open navigation"]');- await until(() => js(`!!document.querySelector('#sidebar-chat-list button[data-row].bg-hover-2')`), 'saved conversation available');- await js(`document.querySelector('#sidebar-chat-list button[data-row].bg-hover-2').parentElement.querySelector('button[aria-label^="Actions for "]').setAttribute('data-narrow-actions','true')`);+ // Open conversations live in the session list; closing moves the saved one to History.+ await click('[data-session-navigation="sidebar"] [data-tab-id]:has(button[aria-pressed="true"]) [aria-label="Close tab"]');+ await until(() => js(`!!document.querySelector('#sidebar-chat-list button[data-row]')`), 'closed saved conversation available in History');+ await js(`document.querySelector('#sidebar-chat-list button[data-row]').parentElement.querySelector('button[aria-label^="Actions for "]').setAttribute('data-narrow-actions','true')`);await click('[data-narrow-actions="true"]');await until(() => js(`!!document.querySelector('button[aria-label^="Delete "]')?.checkVisibility()`), 'actual saved chat actions visible');await until(() => js(`document.activeElement?.getAttribute('aria-label')?.startsWith('Archive ')`), 'nested action menu keeps keyboard focus');@@ -28,10 +30,17 @@ async function runNarrowNavigation({win, output, click, until, report}) {await until(() => js(`!document.querySelector('button[aria-label^="Delete "]')?.checkVisibility()`), 'Escape closes actions');await click('[aria-label="Close navigation"]');await until(() => js(`!document.querySelector('[data-navigation-panel]:popover-open')`), 'sidebar close control dismisses drawer');+ // Give the composer space beside the drawer so an outside input click is possible.+ if (await js(`!!document.querySelector('[aria-label="Close browser"]')?.checkVisibility()`)) await click('[aria-label="Close browser"]');+ const composerBefore = await js(`document.querySelector('textarea[aria-label="Prompt"]').getBoundingClientRect().toJSON()`);await click('[aria-label="Open navigation"]');+ assert.deepEqual(await js(`document.querySelector('textarea[aria-label="Prompt"]').getBoundingClientRect().toJSON()`), composerBefore, 'overlay navigation must not move the underlying composer');const outside = await js(`(()=>{const e=document.querySelector('textarea[aria-label="Prompt"]'),r=e.getBoundingClientRect();const x=Math.round(r.right-8),y=Math.round(r.top+r.height/2);return{x,y,hit:e.contains(document.elementFromPoint(x,y))};})()`);assert.equal(outside.hit, true, 'Visible part of composer remains reachable beside navigation');+ await js(`window.__dismissEvents=[];for(const type of ['pointerdown','pointerup','focusin','focusout','click'])document.addEventListener(type,e=>window.__dismissEvents.push({type,label:e.target.getAttribute?.('aria-label'),tag:e.target.tagName}),{capture:true});`);for (const type of ['mouseDown','mouseUp']) await desktop.testInput(wc, {type,x:outside.x,y:outside.y,button:'left',clickCount:1});+ await new Promise(resolve=>setTimeout(resolve,200));+ report.navigationDismiss = await js(`({events:window.__dismissEvents,active:document.activeElement?.outerHTML,open:!!document.querySelector('[data-navigation-panel]:popover-open')})`);await until(() => js(`!document.querySelector('[data-navigation-panel]:popover-open') && document.activeElement?.getAttribute('aria-label') === 'Prompt'`), 'outside click dismisses without swallowing composer focus');await click('[data-desktop-update-settings]');await until(() => js(`!!document.querySelector('[data-desktop-update-panel]')?.checkVisibility()`), 'update settings remain available');diff --git a/apps/native/electron/smoke-titles.cjs b/apps/native/electron/smoke-titles.cjsindex d57b97f1..3e702b20 100644--- a/apps/native/electron/smoke-titles.cjs+++ b/apps/native/electron/smoke-titles.cjs@@ -25,7 +25,8 @@ async function run({win, backend}) {const text=saved().find(row=>typeof row.data.title==='string' && /retained work/i.test(row.data.title));fs.writeFileSync(path.join(output,'text-session.json'),JSON.stringify(text.data,null,2));await shot('packaged-text-title.png');- await click('[title="New chat (⌘T)"]');+ await js(`Array.from(document.querySelectorAll('button[aria-label="New chat"]')).find(e=>e.checkVisibility()).setAttribute('data-packaged-new-chat','true')`);+ await click('[data-packaged-new-chat="true"]');await send('/model lmstudio mock-vision');await until(()=>js(`document.body.textContent.includes('mock-vision') && !document.querySelector('article[aria-busy="true"]')`),'image model selected');const png=nativeImage.createFromBitmap(Buffer.alloc(48*32*4,180),{width:48,height:32}).toPNG().toString('base64');diff --git a/docs/adr/0122-one-session-navigation-surface.md b/docs/adr/0122-one-session-navigation-surface.mdindex aae55428..28084ae7 100644--- a/docs/adr/0122-one-session-navigation-surface.md+++ b/docs/adr/0122-one-session-navigation-surface.md@@ -22,6 +22,8 @@ horizontal midpoint. Moving the navigation never remounts conversation drafts.Expanded navigation keeps the welcome screen. Collapsed navigation uses acompact composer at the bottom of an empty chat, supporting focused work.+Narrow windows keep that composer layout while the navigation drawer overlays it,+so outside clicks cannot move the input between mouse-down and mouse-up.Settings is available in the sidebar when expanded and the toolbar whencollapsed. Workspace actions and update controls stay available in both modes.