Skip to content

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

Python

fix: resolve focus and fixture failures exposed by CI

yxlyxf49c5342d9e5
diff --git a/apps/native/components/site/useDesktopShortcuts.ts b/apps/native/components/site/useDesktopShortcuts.ts
index a0ffc183..dac58b43 100644
--- a/apps/native/components/site/useDesktopShortcuts.ts
+++ b/apps/native/components/site/useDesktopShortcuts.ts
@@ -38,7 +38,9 @@ export function useDesktopShortcuts(actions: Actions) {
const command=e.metaKey||e.ctrlKey;
const focus=(id:number)=>{
a.focusChat(id);
- requestAnimationFrame(()=>document.querySelector<HTMLTextAreaElement>(`[data-chat="${id}"] textarea`)?.focus({preventScroll:true}));
+ requestAnimationFrame(()=>{
+ if(ref.current.activeId===id)document.querySelector<HTMLTextAreaElement>(`[data-chat="${id}"] textarea`)?.focus({preventScroll:true});
+ });
};
const cycle=(ids:number[],delta:number)=>{const index=ids.indexOf(a.activeId);const id=ids[(index+delta+ids.length)%ids.length];if(id!==undefined)focus(id);};
if(e.ctrlKey&&!e.metaKey&&k==='tab'){cycle(a.chats.map(c=>c.id),e.shiftKey?-1:1);handled=true;}
diff --git a/apps/native/electron/composer-interaction-visual.cjs b/apps/native/electron/composer-interaction-visual.cjs
index 59323756..f7c5fd0d 100644
--- a/apps/native/electron/composer-interaction-visual.cjs
+++ b/apps/native/electron/composer-interaction-visual.cjs
@@ -102,11 +102,17 @@ async function runComposerInteractions({ win, origin, output }) {
await key('2', { metaKey: true });
assert.equal(await draft(second), 'Second unsent draft', 'An older upload must not reset another chat');
assert.equal(await js(`!!document.querySelector('[aria-label="Remove composer-image.png"]')`), false, 'Attachments never move between chats');
- await key('1', { metaKey: true });
-
+ // Delay the first shortcut's focus frame until a newer navigation has won.
+ await js(`(()=>{const raf=window.requestAnimationFrame,frames=[];window.requestAnimationFrame=callback=>{frames.push(callback);return 0;};
+ try{document.activeElement.dispatchEvent(new KeyboardEvent('keydown',{key:'1',metaKey:true,bubbles:true,cancelable:true}));}
+ finally{window.requestAnimationFrame=raf;}window.flushOldFocus=()=>frames.forEach(callback=>callback(performance.now()));})()`);
+ await wait(`document.querySelector('[data-chat][data-focused="true"]')?.dataset.chat==='${first}'`);
await key('d', { metaKey: true });
await wait(`document.querySelectorAll('[data-chat]').length===2`);
const split = await focused();
+ assert.notEqual(split, first, 'A new split becomes active');
+ await js('window.flushOldFocus()');
+ assert.equal(await focused(), split, 'An older shortcut focus frame must not steal the new split');
await input('Keep this split draft');
await pointer(`[data-chat="${first}"] textarea`);
// Use a native key event so an accidental textarea newline is observable.