graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Stabilize native CI pointer clicks after layout changes
justrach7edfa16c7795
diff --git a/apps/native/electron/frontend-runtime.cjs b/apps/native/electron/frontend-runtime.cjsindex a891aef5..7ee82660 100644--- a/apps/native/electron/frontend-runtime.cjs+++ b/apps/native/electron/frontend-runtime.cjs@@ -196,10 +196,34 @@ app.whenReady().then(async () => {if (!missed) break;}} else {- await desktop.testInput(wc, { type: 'mouseDown', button: 'left', clickCount: 1, ...p });- // Focusing a control can scroll the transcript between press and release.- const release = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)return null;const r=e.getBoundingClientRect(),x=Math.round(r.left+r.width/2),y=Math.round(r.top+r.height/2);return e.contains(document.elementFromPoint(x,y))?{x,y}:null})()`);- await desktop.testInput(wc, { type: 'mouseUp', button: 'left', clickCount: 1, ...p, ...release });+ // A missed Send press leaves the draft intact. Retry only when no click+ // reached that button to avoid resending an accepted prompt.+ const attempts = selector === '[aria-label="Send"]' ? 2 : 1;+ for (let attempt = 0; attempt < attempts; attempt++) {+ if (attempt) await stableTarget();+ if (attempts > 1) await js(`(()=>{+ window.__sendClickSeen=false;+ window.__sendClickObserver=event=>{if(event.target.closest('[aria-label="Send"]'))window.__sendClickSeen=true};+ document.addEventListener('click',window.__sendClickObserver,true);+ })()`);+ try {+ await desktop.testInput(wc, { type: 'mouseDown', button: 'left', clickCount: 1, ...p });+ // Focusing a control can scroll the transcript between press and release.+ const release = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)return null;const r=e.getBoundingClientRect(),x=Math.round(r.left+r.width/2),y=Math.round(r.top+r.height/2);return e.contains(document.elementFromPoint(x,y))?{x,y}:null})()`);+ await desktop.testInput(wc, { type: 'mouseUp', button: 'left', clickCount: 1, ...p, ...release });+ if (attempts > 1) {+ try {+ await until(() => js('window.__sendClickSeen'), 'trusted Send click delivery', attempt ? 1000 : 300);+ } catch (error) {+ if (attempt + 1 === attempts) throw error;+ continue;+ }+ }+ } finally {+ if (attempts > 1) await js("document.removeEventListener('click',window.__sendClickObserver,true)");+ }+ break;+ }}};const send = async text => {diff --git a/apps/native/electron/navigation-prompt-focus-visual.cjs b/apps/native/electron/navigation-prompt-focus-visual.cjsindex 46dab2b0..daf2f220 100644--- a/apps/native/electron/navigation-prompt-focus-visual.cjs+++ b/apps/native/electron/navigation-prompt-focus-visual.cjs@@ -11,9 +11,17 @@ async function runNavigationPromptFocus({ win, origin }) {throw Error(`Navigation prompt focus timeout: ${source}`);};const click = async selector => {- const point = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)throw Error('Missing click target');const r=e.getBoundingClientRect();return {x:r.x+r.width/2,y:r.y+r.height/2};})()`);- for (const type of ['mouseDown', 'mouseUp']) await testDesktop.testInput(wc, { type, ...point, button: 'left', clickCount: 1 });- await pause();+ const composer = selector.includes('textarea[aria-label="Prompt"]');+ for (let attempt = 0; attempt < (composer ? 2 : 1); attempt++) {+ const point = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)throw Error('Missing click target');if(${composer})e.scrollIntoView({block:'center',inline:'nearest',behavior:'instant'});const r=e.getBoundingClientRect(),x=r.x+r.width/2,y=r.y+r.height/2;return {x,y,hit:e.contains(document.elementFromPoint(x,y))};})()`);+ if (composer && !point.hit) { await pause(); continue; }+ await testDesktop.testInput(wc, { type: 'mouseDown', ...point, button: 'left', clickCount: 1 });+ const release = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)return null;const r=e.getBoundingClientRect(),x=r.x+r.width/2,y=r.y+r.height/2;return e.contains(document.elementFromPoint(x,y))?{x,y}:null;})()`);+ await testDesktop.testInput(wc, { type: 'mouseUp', ...point, ...release, button: 'left', clickCount: 1 });+ await pause();+ if (!composer || await js(`document.activeElement===document.querySelector(${JSON.stringify(selector)})`)) return;+ }+ throw Error(`Composer click did not focus ${selector}`);};const focused = id => wait(`document.activeElement===document.querySelector('[data-chat="${id}"] textarea[aria-label="Prompt"]') && document.activeElement?.tagName==='TEXTAREA'`);const active = () => js(`document.querySelector('[data-chat][data-focused="true"]').dataset.chat`);