Skip to content

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

Python

test(native): detect folder listing flicker

yxlyx3adb898692ba
diff --git a/apps/native/electron/projects-visual.cjs b/apps/native/electron/projects-visual.cjs
index 2860c40e..790f1629 100644
--- a/apps/native/electron/projects-visual.cjs
+++ b/apps/native/electron/projects-visual.cjs
@@ -72,6 +72,7 @@ async function runProjectVisuals({ win, origin, output, pressEnter }) {
await js(`window.folderFetchCount=0;window.releaseFolderFetch=[];const folderBaseFetch=window.fetch;window.fetch=(input,options)=>{if(String(input).includes('/api/workspaces')){window.folderFetchCount+=1;const reply=()=>new Response(JSON.stringify({path:'/demo',parent:'/',git:false,home:'/demo',default:'/demo',entries:[{name:'apps',path:'/demo/apps',git:false}]}),{headers:{'content-type':'application/json'}});if(window.folderFetchCount===1)return Promise.resolve(reply());return new Promise(resolve=>window.releaseFolderFetch.push(()=>resolve(reply())));}return folderBaseFetch(input,options);};true`);
await js(`document.querySelector('button[aria-label="Open folder…"]').click()`);
await wait(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`);
+ await js(`(()=>{window.folderListingBlanked=false;window.monitorFolderListing=true;const check=()=>{if(!window.monitorFolderListing)return;const dialog=document.querySelector('[role="dialog"][aria-label="Open a folder"]');if(dialog&&!dialog.textContent.includes('apps'))window.folderListingBlanked=true;requestAnimationFrame(check);};requestAnimationFrame(check);return true;})()`);
await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"] input[aria-label="Folder path"]').focus()`);
await pressEnter(); await pressEnter(); await pressEnter();
await wait(`window.folderFetchCount===4`);
@@ -79,12 +80,16 @@ async function runProjectVisuals({ win, origin, output, pressEnter }) {
await js(`window.releaseFolderFetch.shift()();new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)))`);
assert.ok(await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`), 'The first stale navigation response does not clear the listing');
assert.equal(await js(`Array.from(document.querySelectorAll('[role="dialog"][aria-label="Open a folder"] button')).find(b=>b.textContent==='Open folder').disabled`), true, 'The newest folder request remains pending after the first stale response');
+ assert.equal(await js(`window.folderListingBlanked`), false, 'No rendered frame blanks the listing after the first stale response');
await js(`window.releaseFolderFetch.shift()();new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)))`);
assert.ok(await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`), 'The second stale navigation response does not clear the listing');
assert.equal(await js(`Array.from(document.querySelectorAll('[role="dialog"][aria-label="Open a folder"] button')).find(b=>b.textContent==='Open folder').disabled`), true, 'The newest folder request remains pending after both stale responses');
+ assert.equal(await js(`window.folderListingBlanked`), false, 'No rendered frame blanks the listing after either stale response');
await js(`window.releaseFolderFetch.shift()()`);
await wait(`!Array.from(document.querySelectorAll('[role="dialog"][aria-label="Open a folder"] button')).find(b=>b.textContent==='Open folder').disabled`);
assert.ok(await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`), 'The folder listing remains visible after the newest request settles');
+ await js(`window.monitorFolderListing=false`);
+ assert.equal(await js(`window.folderListingBlanked`), false, 'No rendered frame blanks the listing during repeated submission');
// Unmount the picker before navigating: an in-flight listing + loadURL
// left the renderer unable to run the next suite's scripts.
await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"] button[aria-label="Close"]').click()`);