graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(gui): focus prompt after chat selection
yxlyx48e983e3110a
diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsxindex dd04e725..643cfe81 100644--- a/apps/native/components/site/GraffHarness.tsx+++ b/apps/native/components/site/GraffHarness.tsx@@ -244,7 +244,7 @@ export default function GraffHarness() {const next = [...chatsRef.current, { id, title: null, messages: [], model: ws?.model ?? model ?? undefined, session, cwd }];chatsRef.current = next; setChats(next);setZoomedPane(null);- setActiveId(id); requestPromptFocus(id);+ setActiveId(id); navigation.finishNavigation(() => requestPromptFocus(id));setFilesOpen(false);setConversationsOpen(false);setFollowing(true);@@ -286,7 +286,7 @@ export default function GraffHarness() {if (folder && folder !== activePathRef.current) activateWorkspace(folder);if (!columnIds.includes(id) || (zoomedPane !== null && zoomedPane !== id)) setZoomedPane(null);setActiveId(id);- if (focusPrompt) requestPromptFocus(id);+ if (focusPrompt) navigation.finishNavigation(() => requestPromptFocus(id));};const tabDrag = useTabDrag((id, drop) => {@@ -480,7 +480,7 @@ export default function GraffHarness() {onSeeAll={openConversations}activeNav={agentsOpen ? "agents" : projectsOpen ? "projects" : filesOpen ? (fileRequest?.changes ? "changes" : "workspace") : browserOpen ? "browser" : conversationsOpen ? "conversations" : "home"}onNavigate={(key) => {- if (key === "home") requestPromptFocus(activeId);+ if (key === "home") navigation.finishNavigation(() => requestPromptFocus(activeId));if (key === "agents") {setProjectsOpen(false); setFilesOpen(false); setBrowserOpen(false); setConversationsOpen(false);setAgentsOpen(open => !open);diff --git a/apps/native/components/site/useResponsiveNavigation.tsx b/apps/native/components/site/useResponsiveNavigation.tsxindex 5af61913..7ed69e83 100644--- a/apps/native/components/site/useResponsiveNavigation.tsx+++ b/apps/native/components/site/useResponsiveNavigation.tsx@@ -6,9 +6,15 @@ import styles from "./ResponsiveNavigation.module.css";* layer, with light dismissal and Escape, instead of removing navigation. */export function useResponsiveNavigation() {const id = useId(), panel = useRef<HTMLDivElement>(null);+ const afterClose = useRef<(() => void) | null>(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(); };+ const finishNavigation = (next: () => void) => {+ if (!panel.current?.matches(":popover-open")) { next(); return; }+ afterClose.current = next;+ panel.current.hidePopover();+ };useEffect(() => {const query = matchMedia("(width < 64rem)");const update = () => { if (!query.matches) close(); setNarrow(query.matches); };@@ -29,12 +35,17 @@ export function useResponsiveNavigation() {// focus; opening an action menu must not refocus the sidebar close button.if (event.target !== event.currentTarget) return;const shown = panel.current?.matches(":popover-open") ?? false; setOpen(shown);+ if (!shown && afterClose.current) {+ const next = afterClose.current; afterClose.current = null; next();+ return;+ }// 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();},},+ finishNavigation,trigger: <button type="button" aria-label="Open navigation" title="Projects and conversations"aria-expanded={open} aria-controls={id} aria-haspopup="dialog" popoverTarget={id}className="flex size-7 shrink-0 items-center justify-center rounded-md text-ink-2 hover:bg-hover lg:hidden">diff --git a/apps/native/electron/narrow-navigation-frontend.cjs b/apps/native/electron/narrow-navigation-frontend.cjsindex 6b6105ca..a83e896e 100644--- a/apps/native/electron/narrow-navigation-frontend.cjs+++ b/apps/native/electron/narrow-navigation-frontend.cjs@@ -8,8 +8,19 @@ async function runNarrowNavigation({win, output, click, until, report}) {for (const type of ['keyDown','keyUp']) await desktop.testInput(wc, {type,keyCode:'Escape'});};assert.equal(await js(`innerWidth < 1024`), true, 'Exercise the breakpoint that hid navigation');+ const first = await js(`document.querySelector('[data-chat][data-focused="true"]').dataset.chat`);+ await click('[title="New chat (⌘T)"]');+ const second = await js(`document.querySelector('[data-chat][data-focused="true"]').dataset.chat`);+ assert.notEqual(second, first);await click('[aria-label="Open navigation"]');await until(() => js(`!!document.querySelector('[data-navigation-panel]:popover-open')`), 'navigation opens');+ await click(`[data-session-navigation="sidebar"] [data-tab-members="${first}"] button[aria-pressed]`);+ await until(() => js(`!document.querySelector('[data-navigation-panel]:popover-open') && document.activeElement===document.querySelector('[data-chat="${first}"] textarea[aria-label="Prompt"]')`), 'chat selection dismisses navigation and focuses its prompt');+ const draftLength = await js(`document.activeElement.value.length`);+ await desktop.testInput(wc, {type:'char',keyCode:'x'});+ assert.equal(await js(`document.querySelector('[data-chat="${first}"] textarea[aria-label="Prompt"]').value.length`), draftLength + 1, 'typing after chat selection goes straight to its prompt');+ await click('[aria-label="Open navigation"]');+ await until(() => js(`!!document.querySelector('[data-navigation-panel]:popover-open')`), 'navigation reopens');await click('[data-workspace-trigger]');await until(() => js(`!!document.querySelector('[data-navigation-panel] [data-workspace-menu]')`), 'folder picker stays inside native popover layer');await escape();