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

yxlyx07e480d14b72
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 bca9d731..7ae67770 100644
--- a/apps/native/electron/composer-interaction-visual.cjs
+++ b/apps/native/electron/composer-interaction-visual.cjs
@@ -86,11 +86,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.
diff --git a/sdk/ts/scripts/test-packed-install.mjs b/sdk/ts/scripts/test-packed-install.mjs
index 0492458a..80f70230 100644
--- a/sdk/ts/scripts/test-packed-install.mjs
+++ b/sdk/ts/scripts/test-packed-install.mjs
@@ -66,12 +66,15 @@ try {
await chmod(sourceBinary, 0o755);
}
+ const sdkManifest = JSON.parse(await readFile(join(SDK_ROOT, "package.json"), "utf8"));
const nativeTarballs = {};
for (const [target, packageName] of ALL_TARGETS) {
const output = run(process.execPath, [
join(HERE, "package-platform.mjs"),
"--target", target,
"--binary", sourceBinary,
+ // Match the SDK's pin so npm uses the fixture instead of a registry binary.
+ "--version", sdkManifest.optionalDependencies[packageName],
"--out", packages,
], SDK_ROOT);
const { packageDir } = JSON.parse(output);
@@ -104,6 +107,7 @@ console.log("packed SDK resolved and ran its optional native package with no gra
const output = run(process.execPath, [join(consumer, "smoke.mjs")], consumer, {
...process.env,
CLEAN_PATH: emptyPath,
+ GRAFF_NO_TELEMETRY: "1",
});
process.stdout.write(output);
@@ -127,6 +131,7 @@ console.log("packed SDK rejects an incompatible optional native package");
process.stdout.write(run(process.execPath, [join(consumer, "mismatch.mjs")], consumer, {
...process.env,
CLEAN_PATH: emptyPath,
+ GRAFF_NO_TELEMETRY: "1",
}));
} finally {
await rm(temp, { recursive: true, force: true });
diff --git a/src/subagent_activity.zig b/src/subagent_activity.zig
index 756bfb7a..3bd3522d 100644
--- a/src/subagent_activity.zig
+++ b/src/subagent_activity.zig
@@ -208,7 +208,7 @@ test "cancel file marks a working child interrupted even if it later finishes" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
const io = std.testing.io;
- var r: Recorder = .{ .a = std.testing.allocator, .io = io, .dir = try tmp.dir.openDir(io, ".", .{}), .meta = .{ .id = "child", .label = "test", .task = "test" } };
+ var r: Recorder = .{ .a = std.testing.allocator, .io = io, .dir = try tmp.dir.openDir(io, ".", .{ .iterate = true }), .meta = .{ .id = "child", .label = "test", .task = "test" } };
defer r.deinit();
try requestInterrupt(io, r.dir, "child");
try std.testing.expect(interruptRequested(io, r.dir, "child"));