Skip to content

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

Python

test: control motion preferences and await workspace readiness

Rach Pradhan4b228f090e9d
diff --git a/apps/native/electron/chat-overflow-visual.cjs b/apps/native/electron/chat-overflow-visual.cjs
index 751f8f6d..33c5845c 100644
--- a/apps/native/electron/chat-overflow-visual.cjs
+++ b/apps/native/electron/chat-overflow-visual.cjs
@@ -151,7 +151,7 @@ async function runChatOverflow({ win, origin, output }) {
source: `(${require('./gallery-fixture.cjs').installGalleryFixture.toString()})()`,
});
await wc.loadURL(origin); win.setSize(1100, 760);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
await js(`(() => {
const previous = window.fetch;
window.fetch = async (input, options) => {
diff --git a/apps/native/electron/chat-scroll-visual.cjs b/apps/native/electron/chat-scroll-visual.cjs
index 0f3503aa..cc5d7656 100644
--- a/apps/native/electron/chat-scroll-visual.cjs
+++ b/apps/native/electron/chat-scroll-visual.cjs
@@ -13,7 +13,7 @@ async function runChatScroll({ win, origin, output }) {
throw Error(`Chat scroll timed out: ${code}`);
};
await wc.loadURL(origin); win.setSize(1100, 760); testDesktop.present(win);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
await js(`(() => {
const previous = window.fetch;
window.fetch = async (input, options) => {
@@ -58,6 +58,6 @@ async function runChatScroll({ win, origin, output }) {
await wait(`(()=>{const e=document.querySelector('[data-chat-transcript]');return e.scrollHeight-e.scrollTop-e.clientHeight<50})()`);
console.log('Chat reading passed: first reply preserves scroll position and resumes following at the tail.');
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
}
module.exports = { runChatScroll };
diff --git a/apps/native/electron/files-recovery-visual.cjs b/apps/native/electron/files-recovery-visual.cjs
index a3feb16f..88638bdf 100644
--- a/apps/native/electron/files-recovery-visual.cjs
+++ b/apps/native/electron/files-recovery-visual.cjs
@@ -154,7 +154,7 @@ async function runFilesRecovery({ win, origin, output }) {
assert.equal(await js(`!!document.querySelector('${pane} [role="alert"]')`), false, 'Old project failure cannot replace the current root');
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
console.log('Files recovery passed: loading, directory/diff/action retry, stale navigation and errors, and workspace isolation.');
}
module.exports = { runFilesRecovery };
diff --git a/apps/native/electron/link-destination-visual.cjs b/apps/native/electron/link-destination-visual.cjs
index b530eaa1..3ed67255 100644
--- a/apps/native/electron/link-destination-visual.cjs
+++ b/apps/native/electron/link-destination-visual.cjs
@@ -134,7 +134,7 @@ async function runLinkDestinationVisuals({ origin, output }) {
try {
await wc.loadURL('about:blank'); wc.debugger.attach('1.3'); await wc.debugger.sendCommand('Page.enable');
await wc.debugger.sendCommand('Page.addScriptToEvaluateOnNewDocument', { source: `(${installGalleryFixture.toString()})();` });
- await wc.loadURL(origin); testDesktop.present(win); await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wc.loadURL(origin); testDesktop.present(win); await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
assert.equal(await js(`typeof window.graffDesktop.linkSettings`), 'function', 'real preload exposes linkSettings');
await openSettings(); await selected('system');
assert.equal(await store.load(), 'system');
@@ -150,11 +150,11 @@ async function runLinkDestinationVisuals({ origin, output }) {
await screenshot('link-destination-graff.png');
await closeBrowser();
await new Promise(resolve => { wc.once('did-finish-load', resolve); wc.reload(); });
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
await openSettings(); await selected('graff'); await closeSettings();
store = linkSettings(directory);
await new Promise(resolve => { wc.once('did-finish-load', resolve); wc.reload(); });
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
await openSettings(); await selected('graff'); await closeSettings();
await route('graff', '', 'persisted'); await closeBrowser();
await openSettings(); await choose('system'); await closeSettings();
diff --git a/apps/native/electron/navigation-keyboard-visual.cjs b/apps/native/electron/navigation-keyboard-visual.cjs
index 162deb53..03721f10 100644
--- a/apps/native/electron/navigation-keyboard-visual.cjs
+++ b/apps/native/electron/navigation-keyboard-visual.cjs
@@ -20,7 +20,7 @@ async function runNavigationKeyboard({win, origin}) {
const focusDiagnostic = () => js(`JSON.stringify({hasFocus:document.hasFocus(),active:document.activeElement?.outerHTML.slice(0,2500),modal:document.querySelector('[aria-modal="true"]')?.getAttribute('aria-label')})`);
await wc.loadURL(origin); testDesktop.present(win);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
wc.send('desktop-action', 'new');
await wait(`document.querySelectorAll('[aria-label="Close tab"]').length===2`);
const originalTabs = await tabs();
@@ -86,7 +86,7 @@ async function runNavigationKeyboard({win, origin}) {
await click('button[aria-label="Expand sidebar"]');
await wait(`document.activeElement.matches('[aria-label="Collapse sidebar"]')`);
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
console.log('Keyboard navigation passed: modal Tab boundaries, focus restoration, native menu guards, reveal errors, and hidden sidebar controls.');
}
diff --git a/apps/native/electron/navigation-visual.cjs b/apps/native/electron/navigation-visual.cjs
index a7567f1a..3ca3538b 100644
--- a/apps/native/electron/navigation-visual.cjs
+++ b/apps/native/electron/navigation-visual.cjs
@@ -25,7 +25,7 @@ async function runNavigationVisuals({win:fixtureWindow,origin,output}) {
localStorage.setItem('graff.native.workspaces',JSON.stringify(Array.from({length:50},(_,i)=>({name:'Project '+(i%10),path:'/demo/folder-'+i}))));
const commands=[{name:'compact',description:'Compact conversation context'},...Array.from({length:100},(_,i)=>({name:'command-'+i,description:'Command '+i}))];
const galleryFetch=window.fetch;window.fetch=async(input,options)=>{const response=await galleryFetch(input,options);if(options?.body&&JSON.parse(options.body).method==='bootstrap')return new Response(JSON.stringify({sessionId:'demo',commands}),{headers:{'content-type':'application/json'}});if(String(input).includes('/api/models')){const data=await response.json();data.result.commands=commands;data.result.current.model='${process.env.GRAFF_VISUAL_SUITE === 'tab-drag' ? 'Graff' : 'example-model-with-a-long-name'}';data.result.models[0].name=data.result.current.model;return new Response(JSON.stringify(data),{headers:{'content-type':'application/json'}});}return response;};`});
- await wc.loadURL(origin);testDesktop.present(win);await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wc.loadURL(origin);testDesktop.present(win);await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
if(process.env.GRAFF_VISUAL_SUITE==='tagged'){await require('./yxlyx-regressions-visual.cjs').runYxlyxRegressions({win,origin});return;}
if(process.env.GRAFF_VISUAL_SUITE==='tab-drag'){await require('./tab-drag-visual.cjs').runTabDrag({win,origin,output});return;}
if(process.env.GRAFF_VISUAL_SUITE==='splits'){await require('./split-focus-visual.cjs').runSplitFocus({win,origin,output});return;}
diff --git a/apps/native/electron/pane-motion-observer.cjs b/apps/native/electron/pane-motion-observer.cjs
index c6cd0bca..eb2d14c5 100644
--- a/apps/native/electron/pane-motion-observer.cjs
+++ b/apps/native/electron/pane-motion-observer.cjs
@@ -3,13 +3,13 @@
async function observePaneMotion(wc) {
await wc.executeJavaScript(`(()=>{
const original = Element.prototype.animate;
- const state = { started: 0, finished: 0, original };
+ const state = { started: 0, finished: 0, cancelled: 0, original };
window.__paneMotionObservation = state;
Element.prototype.animate = function(...args) {
const animation = original.apply(this, args);
if (this.matches('[data-chat]') && Number(animation.effect.getTiming().duration) > 1) {
animation.ready.then(() => { state.started++; }, () => {});
- animation.finished.then(() => { state.finished++; }, () => {});
+ animation.finished.then(() => { state.finished++; }, () => { state.cancelled++; });
}
return animation;
};
@@ -20,7 +20,8 @@ async function observePaneMotion(wc) {
if (await wc.executeJavaScript('window.__paneMotionObservation.started > 0 && window.__paneMotionObservation.finished > 0')) return;
await new Promise(resolve => setTimeout(resolve, 50));
}
- throw Error('The downward drop did not run a native pane animation to completion');
+ const state = await wc.executeJavaScript('JSON.stringify(window.__paneMotionObservation)');
+ throw Error('The downward drop did not run a native pane animation to completion: ' + state);
},
async stop() {
await wc.executeJavaScript(`(()=>{
diff --git a/apps/native/electron/project-recovery-visual.cjs b/apps/native/electron/project-recovery-visual.cjs
index 75257bbf..12c3f074 100644
--- a/apps/native/electron/project-recovery-visual.cjs
+++ b/apps/native/electron/project-recovery-visual.cjs
@@ -135,7 +135,7 @@ async function runProjectRecovery({ win, origin, output }) {
await js(`new Promise(r=>setTimeout(r,100))`);
assert.ok(await js(`document.querySelector('[data-project-context]').textContent.includes('/demo/recovered')`),'A late folder listing cannot replace the chosen folder');
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
testDesktop.present(win);
console.log('Project recovery passed: initial/paged retry, stale searches, resume retry/cancel, navigation races, and typed folder validation.');
}
diff --git a/apps/native/electron/projects-visual.cjs b/apps/native/electron/projects-visual.cjs
index 6a107f55..70f51f5d 100644
--- a/apps/native/electron/projects-visual.cjs
+++ b/apps/native/electron/projects-visual.cjs
@@ -70,13 +70,13 @@ async function runProjectVisuals({ win, origin, output }) {
await js(`document.querySelector('[role="dialog"] button[aria-label="Close"]').click()`);
await wait(`!document.querySelector('[role="dialog"]')`);
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
win.setSize(900, 680);
await js(`Array.from(document.querySelectorAll('button')).find(b=>b.textContent==='All projects').click()`);
await wait(`!!document.querySelector('[aria-label="Search projects"]')`);
assert.ok(await js(`(()=>{const r=document.querySelector('section[aria-label="Projects"]').getBoundingClientRect();return r.left>=0&&r.right<=innerWidth})()`));
await js(`Array.from(document.querySelectorAll('button')).find(b=>b.textContent==='Back to chat').click()`);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
win.setSize(1100, 760);
console.log('Projects passed: search, folder identity, scoped resume, exactly one new tab, visible Changes/Files, open folder.');
}
diff --git a/apps/native/electron/review-recovery-visual.cjs b/apps/native/electron/review-recovery-visual.cjs
index b5cffbb9..4fa2954f 100644
--- a/apps/native/electron/review-recovery-visual.cjs
+++ b/apps/native/electron/review-recovery-visual.cjs
@@ -51,7 +51,7 @@ async function runReviewRecovery({ win, origin, output }) {
await wait(`!!document.querySelector('[aria-label="Workspace changes"] [role="alert"]')`);
assert.ok(await js(`document.querySelector('[aria-label="File diff"]').textContent.includes('Changes unavailable')`),'Diff failures must not masquerade as binary files');
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
testDesktop.present(win);
console.log('Review recovery passed: unavailable vs clean, explicit retry, stale filters/worktrees, and diff failures.');
}
diff --git a/apps/native/electron/tab-drag-visual.cjs b/apps/native/electron/tab-drag-visual.cjs
index c0ec0538..9499dcdb 100644
--- a/apps/native/electron/tab-drag-visual.cjs
+++ b/apps/native/electron/tab-drag-visual.cjs
@@ -4,6 +4,10 @@ const fs = require('node:fs');
const path = require('node:path');
async function runTabDrag({win, origin, output}) {
const wc=win.webContents, js=code=>wc.executeJavaScript(code);
+ desktop.attachTestDebugger(wc);
+ console.log('Host reduced motion:', await js(`matchMedia('(prefers-reduced-motion: reduce)').matches`));
+ // Both motion modes are explicit test inputs, independent of runner settings.
+ await wc.debugger.sendCommand('Emulation.setEmulatedMedia',{features:[{name:'prefers-reduced-motion',value:'no-preference'}]});
const wait=async code=>{for(let i=0;i<100;i++){if(await js(code))return;await new Promise(r=>setTimeout(r,50));}throw Error(`Tab drag condition failed: ${code}`);};
const ready=()=>wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
const tabs=()=>js(`Array.from(document.querySelectorAll('[data-tab-id]')).map(t=>Number(t.dataset.tabId))`);
diff --git a/apps/native/electron/workspace-layout-visual.cjs b/apps/native/electron/workspace-layout-visual.cjs
index 66674444..e63c33f0 100644
--- a/apps/native/electron/workspace-layout-visual.cjs
+++ b/apps/native/electron/workspace-layout-visual.cjs
@@ -75,7 +75,7 @@ app.whenReady().then(async () => {
};
stage = "load production GUI";
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
await js(`(()=>{const e=document.querySelector('textarea[aria-label="Prompt"]');Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,'value').set.call(e,'Check the layout');e.dispatchEvent(new Event('input',{bubbles:true}));})()`);
await wait(`!document.querySelector('[aria-label="Send"]').disabled`);
await click('[aria-label="Send"]');
diff --git a/apps/native/electron/yxlyx-regressions-visual.cjs b/apps/native/electron/yxlyx-regressions-visual.cjs
index 668f0aa6..c7b4760b 100644
--- a/apps/native/electron/yxlyx-regressions-visual.cjs
+++ b/apps/native/electron/yxlyx-regressions-visual.cjs
@@ -12,7 +12,7 @@ async function runYxlyxRegressions({ win, origin }) {
throw Error(`Tagged regression timed out: ${code}`);
};
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
await js(`(() => {
const previous = window.fetch;
const json = body => new Response(JSON.stringify(body), {headers:{'content-type':'application/json'}});
@@ -65,7 +65,7 @@ async function runYxlyxRegressions({ win, origin }) {
assert.match(await js(`document.querySelector('[data-split-limit]').textContent`), /four|4/i);
assert.match(await js(`document.querySelector('[data-split-limit]').textContent`), /read/i);
await wc.loadURL(origin);
- await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await wait(`!!document.querySelector('[data-workspace-ready="true"] textarea[aria-label="Prompt"]')`);
console.log('Tagged GUI checks passed: #839 saved snapshot disclosure and no false completion; #825 optional Tasks, close/navigation, four-pane limit explanation.');
}
module.exports = { runYxlyxRegressions };