Skip to content

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

Python

Integrate chat prompt focus regression (#1187)

Rach Pradhan42a9d860d232
diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsx
index c9d71fd0..155aedee 100644
--- a/apps/native/components/site/GraffHarness.tsx
+++ b/apps/native/components/site/GraffHarness.tsx
@@ -134,6 +134,7 @@ export default function GraffHarness() {
const [pinsByChat, setPinsByChat] = useState<Record<number, BrowserPin[]>>({});
const pinsRef = useRef<Record<number, BrowserPin[]>>({});
const { promptFocusRoot, requestPromptFocus } = useNavigationPromptFocus();
+ const activateChat = (id: number) => { setActiveId(id); requestPromptFocus(id); };
const chatIdRef = useRef(1);
const msgIdRef = useRef(0);
// Split view: ordered visible chats, independent of focus. Each keeps its
@@ -244,7 +245,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);
+ activateChat(id);
setFilesOpen(false);
setConversationsOpen(false);
setFollowing(true);
diff --git a/apps/native/electron/chat-prompt-focus-frontend.cjs b/apps/native/electron/chat-prompt-focus-frontend.cjs
new file mode 100644
index 00000000..bf68f8f8
--- /dev/null
+++ b/apps/native/electron/chat-prompt-focus-frontend.cjs
@@ -0,0 +1,29 @@
+const assert = require('node:assert/strict');
+const desktop = require('./test-desktop.cjs');
+
+async function runChatPromptFocus({ win, click, until, report }) {
+ const wc = win.webContents, js = code => wc.executeJavaScript(code);
+ const pointerClick = async selector => {
+ await until(() => js(`!!document.querySelector(${JSON.stringify(selector)})`), 'pointer target mounts');
+ const point = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)}),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 });
+ };
+ assert.equal(await js(`innerWidth < 1024`), true, 'Exercise narrow responsive navigation');
+ const first = await js(`document.querySelector('[data-chat][data-focused="true"]').dataset.chat`);
+ const firstDraft = await js(`document.querySelector('[data-chat][data-focused="true"] textarea[aria-label="Prompt"]').value`);
+ 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 js(`window.__promptTypingTarget=null;document.addEventListener('beforeinput',event=>window.__promptTypingTarget=event.target.closest?.('[data-chat]')?.dataset.chat,{capture:true,once:true})`);
+ await pointerClick(`[data-session-navigation="sidebar"] [data-tab-members="${first}"] button[aria-pressed]`);
+ await until(() => js(`document.querySelector('[data-chat][data-focused="true"]')?.dataset.chat==="${first}"`), 'chat selection handled');
+ await desktop.testInput(wc, { type: 'char', keyCode: 'x' });
+ 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');
+ assert.equal(await js(`window.__promptTypingTarget`), first, 'the first typed character targets the selected prompt');
+ assert.equal(await js(`document.querySelector('[data-chat="${first}"] textarea[aria-label="Prompt"]').value`), `${firstDraft}x`, 'the first character typed after chat selection appends to its prompt');
+ report.passed.push('selecting a chat from narrow navigation closes the popover, focuses its prompt and sends typing there');
+}
+
+module.exports = { runChatPromptFocus };
diff --git a/apps/native/electron/frontend-runtime.cjs b/apps/native/electron/frontend-runtime.cjs
index aca06d50..f9566950 100644
--- a/apps/native/electron/frontend-runtime.cjs
+++ b/apps/native/electron/frontend-runtime.cjs
@@ -277,7 +277,10 @@ app.whenReady().then(async () => {
return;
}
const narrowNavigation = Boolean(process.env.GRAFF_NARROW_NAV_TEST);
- if (narrowNavigation) await require('./narrow-navigation-frontend.cjs').runNarrowNavigation({ win, output, click, until, report });
+ if (narrowNavigation) {
+ await require('./chat-prompt-focus-frontend.cjs').runChatPromptFocus({ win, click, until, report });
+ await require('./narrow-navigation-frontend.cjs').runNarrowNavigation({ win, output, click, until, report });
+ }
await require('./attachment-lifetime-frontend.cjs').runAttachments({win,origin,temp,output,requests,workspace,send,click,until,report});
if (narrowNavigation) return;
await require('./browser-focus-frontend.cjs').runBrowserFocus({ win, output, click, until, report });