graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Repair Windows and desktop CI fixture failures
justrach09ed76e7f1e4
diff --git a/apps/native/app/visual-tests/approval/fixture.tsx b/apps/native/app/visual-tests/approval/fixture.tsxindex 36b339cf..3d5eca96 100644--- a/apps/native/app/visual-tests/approval/fixture.tsx+++ b/apps/native/app/visual-tests/approval/fixture.tsx@@ -1,6 +1,6 @@"use client";-import { useRef, useState } from "react";+import { useEffect, useRef, useState } from "react";import ApprovalCard from "@/components/primitives/ApprovalCard";import { AssistantBody } from "@/components/site/ChatBubbles";import { emptyTurn, type AssistantTurn } from "@/lib/acp";@@ -23,6 +23,8 @@ const multiQuestions = [];export default function ApprovalFixture() {+ const [ready, setReady] = useState(false);+ useEffect(() => setReady(true), []);const [singleKey, setSingleKey] = useState(0);const [singleSubmissions, setSingleSubmissions] = useState<string[]>([]);const [singleCancellations, setSingleCancellations] = useState(0);@@ -33,7 +35,7 @@ export default function ApprovalFixture() {const [ackSubmissions, setAckSubmissions] = useState(0);return (- <main className="min-h-screen bg-page p-8 text-ink">+ <main data-approval-ready={ready} className="min-h-screen bg-page p-8 text-ink"><div className="mx-auto grid max-w-[900px] gap-10 md:grid-cols-2"><section aria-label="Single-question approval" className="space-y-4"><div className="flex items-center justify-between gap-3">diff --git a/apps/native/e2e/approval-card.pw.ts b/apps/native/e2e/approval-card.pw.tsindex 9e9fa562..821e290c 100644--- a/apps/native/e2e/approval-card.pw.ts+++ b/apps/native/e2e/approval-card.pw.ts@@ -4,6 +4,7 @@ const oldAutoSubmitDelay = 480;test.beforeEach(async ({ page }) => {await page.goto("/visual-tests/approval");+ await expect(page.locator("[data-approval-ready]")).toHaveAttribute("data-approval-ready", "true");});test("a radio click waits for Send, submits the latest selection once, and ignores repeated activation", async ({ page }) => {diff --git a/apps/native/electron/frontend-runtime.cjs b/apps/native/electron/frontend-runtime.cjsindex 30ca9cd1..a891aef5 100644--- a/apps/native/electron/frontend-runtime.cjs+++ b/apps/native/electron/frontend-runtime.cjs@@ -153,30 +153,47 @@ app.whenReady().then(async () => {if (selector !== '[aria-label="Open navigation"]' && await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)}), panel=document.querySelector('[data-navigation-panel]:popover-open');if(!e||!panel||panel.contains(e))return false;const r=e.getBoundingClientRect();return panel.contains(document.elementFromPoint(r.x+r.width/2,r.y+r.height/2));})()`)) {await click('[aria-label="Close navigation"]');}- let p, previous;- await until(async () => {- p = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)return null;e.scrollIntoView({block:'center',inline:'nearest',behavior:'instant'});const r=e.getBoundingClientRect();const x=Math.round(r.left+r.width/2),y=Math.round(r.top+r.height/2);return {x,y,hit:e.contains(document.elementFromPoint(x,y))}})()`);- const settled = p?.hit && previous?.x === p.x && previous?.y === p.y;- previous = p; return settled;- }, `stable pointer target: ${selector}`, 5000);+ let p;+ const stableTarget = async () => {+ let previous;+ await until(async () => {+ p = await js(`(()=>{const e=document.querySelector(${JSON.stringify(selector)});if(!e)return null;e.scrollIntoView({block:'center',inline:'nearest',behavior:'instant'});const r=e.getBoundingClientRect();const x=Math.round(r.left+r.width/2),y=Math.round(r.top+r.height/2);return {x,y,hit:e.contains(document.elementFromPoint(x,y))}})()`);+ const settled = p?.hit && previous?.x === p.x && previous?.y === p.y;+ previous = p; return settled;+ }, `stable pointer target: ${selector}`, 5000);+ };+ await stableTarget();if (computer) {const bounds = win.getContentBounds();- await js(`(()=>{- window.__nativeClickCleanup?.();- const target=document.querySelector(${JSON.stringify(selector)});- const trace=window.__nativeClickTrace={expected:${JSON.stringify(p)},events:[]};- const record=event=>trace.events.push({type:event.type,x:event.clientX,y:event.clientY,- target:event.target.tagName,label:event.target.getAttribute('aria-label'),matches:target.contains(event.target)});- const types=['pointerdown','pointerup','click'];- types.forEach(type=>document.addEventListener(type,record,true));- window.__nativeClickCleanup=()=>types.forEach(type=>document.removeEventListener(type,record,true));- })()`);- try {- await computer.command('click', { pid: process.pid, x: bounds.x+p.x, y: bounds.y+p.y });- await until(()=>js(`window.__nativeClickTrace.events.some(event=>event.type==='click'&&event.matches)`), `native click delivery: ${selector}`, 3000);- } finally {- report.nativePointer={bounds,trace:await js('window.__nativeClickTrace')};- await js('window.__nativeClickCleanup()');+ // Moving the system pointer can shift a small chat layout before mouse-down.+ // Retry only a missed composer click; duplicate clicks on buttons are unsafe.+ const attempts = selector === 'textarea[aria-label="Prompt"]' ? 2 : 1;+ for (let attempt = 0; attempt < attempts; attempt++) {+ if (attempt) await stableTarget();+ await js(`(()=>{+ window.__nativeClickCleanup?.();+ const target=document.querySelector(${JSON.stringify(selector)});+ const trace=window.__nativeClickTrace={expected:${JSON.stringify(p)},events:[]};+ const record=event=>trace.events.push({type:event.type,x:event.clientX,y:event.clientY,+ target:event.target.tagName,label:event.target.getAttribute('aria-label'),matches:target.contains(event.target)});+ const types=['pointerdown','pointerup','click'];+ types.forEach(type=>document.addEventListener(type,record,true));+ window.__nativeClickCleanup=()=>types.forEach(type=>document.removeEventListener(type,record,true));+ })()`);+ let missed = false;+ try {+ await computer.command('click', { pid: process.pid, x: bounds.x+p.x, y: bounds.y+p.y });+ try {+ await until(()=>js(`window.__nativeClickTrace.events.some(event=>event.type==='click'&&event.matches)`), `native click delivery: ${selector}`, attempt + 1 < attempts ? 1000 : 3000);+ } catch (error) {+ if (attempt + 1 === attempts) throw error;+ missed = true;+ }+ } finally {+ report.nativePointer={bounds,trace:await js('window.__nativeClickTrace')};+ await js('window.__nativeClickCleanup()');+ }+ if (!missed) break;}} else {await desktop.testInput(wc, { type: 'mouseDown', button: 'left', clickCount: 1, ...p });diff --git a/scripts/test-eval-cache-affinity.py b/scripts/test-eval-cache-affinity.pyindex d86eb7e0..30727c81 100644--- a/scripts/test-eval-cache-affinity.py+++ b/scripts/test-eval-cache-affinity.py@@ -57,7 +57,7 @@ p = Path('.graff/traces'); p.mkdir(parents=True)print('CACHE_OK')print({FOOTER!r}, file=__import__('sys').stderr)# {arm}-''')+''', encoding='utf-8')binary.chmod(0o700)out = root / 'result'env = dict(os.environ, CODEGRAFF_API_KEY='offline-fixture-only', OPENAI_API_KEY='must-not-inherit')diff --git a/src/list_dir.zig b/src/list_dir.zigindex f7b569ea..e5ac8191 100644--- a/src/list_dir.zig+++ b/src/list_dir.zig@@ -121,8 +121,8 @@ fn fill(w: *Walk, node: *Node, rel: []const u8) !void {if (dir.openFile(w.io, ".gitignore", .{ .follow_symlinks = false })) |file| {defer file.close(w.io);if ((try file.stat(w.io)).kind == .file) {- var reader = file.reader(w.io, &.{});- const text = try reader.interface.allocRemaining(w.arena, .limited(64 * 1024));+ // Windows no-follow handles can fail Zig positional reads; the kind check above skips symlinks.+ const text = try dir.readFileAlloc(w.io, ".gitignore", w.arena, .limited(64 * 1024));const extra = try gitignore.parse(w.arena, text, abs);try w.rules.appendSlice(w.arena, extra);}diff --git a/src/rlm_order_tests.zig b/src/rlm_order_tests.zigindex 5e1888e3..8554adac 100644--- a/src/rlm_order_tests.zig+++ b/src/rlm_order_tests.zig@@ -36,14 +36,10 @@ const Fixture = struct {test "rlm order applies native edit before dependent verification" {var f = try Fixture.init();defer f.deinit();- const code = if (@import("builtin").os.tag == .windows)- "e = edit_file(path=\"target.txt\", old_string=\"old\", new_string=\"new\")\nv = bash(\"findstr /x new target.txt >nul && echo VERIFIED\")\nprint(v)"- else- "e = edit_file(path=\"target.txt\", old_string=\"old\", new_string=\"new\")\nv = bash(\"test $(cat target.txt) = new && printf VERIFIED\")\nprint(v)";- const out = try f.run(code);+ const out = try f.run("e = edit_file(path=\"target.txt\", old_string=\"old\", new_string=\"new\")\nv = read_file(\"target.txt\")\nprint(v)");defer gpa.free(out.text);try std.testing.expect(!out.is_error and !out.pending);- try std.testing.expectEqualStrings("VERIFIED", std.mem.trim(u8, out.text, " \r\n"));+ try std.testing.expectEqualStrings("new", out.text);}test "rlm order failed edit prevents following verification side effects" {diff --git a/src/worktree_prune.zig b/src/worktree_prune.zigindex b8babcec..451f3229 100644--- a/src/worktree_prune.zig+++ b/src/worktree_prune.zig@@ -219,7 +219,8 @@ pub fn removeWorktree(gpa: Allocator, io: Io, e: Entry) bool {if (!ranOk(common)) return false;const git_dir = std.mem.trim(u8, common.stdout, " \t\r\n");if (git_dir.len == 0) return false;- const rm = runCapped(gpa, io, &.{ "git", "-C", e.path, "worktree", "remove", e.path }, 8192, 8192, 60_000) catch return false;+ // Do not make the child process use the directory it must remove as its cwd (Windows locks it).+ const rm = runCapped(gpa, io, &.{ "git", "--git-dir", git_dir, "worktree", "remove", e.path }, 8192, 8192, 60_000) catch return false;defer {gpa.free(rm.stdout);gpa.free(rm.stderr);