Skip to content

Commit 4e4be21

Browse files
author
ben
authored
fix(ci): restore native readiness and repair failing fixtures (#7054)
* revert: back out incomplete Code Mode App result integration Revert #7049 at the maintainers request: its new proof requires host-only MCP metadata support absent from the bundled OpenCode release. Restore the previous integration and remove the newly introduced proof rather than claiming that unsupported App rendering works. This does not fix the underlying App-form limitation. * fix(evals): restart the selected engine without requesting a downgrade The permissions journey attempted to stop v2 by selecting v1, which correctly receives HTTP 409 once v2 history has been adopted. Use the actual desktop engineRestart action, require a replacement v2 PID, and keep the post-restart permission assertions unchanged. * fix(tests): make upload file-change fixtures deterministic on Linux Immediate rewrites can retain both filesystem timestamps within one Linux clock tick. Give fixture files a known past modification time before testing real replacements and edits. Preserve the existing no-dispatch and rejection assertions; production metadata-only identity checks are unchanged. * fix(server): inspect native Cloud readiness without a legacy engine Native v2 has its own connection and must not fail prerequisites merely because no v1 base URL exists. Use native MCP and model probes, registration and direct authenticated tool checks without constructing a legacy SDK client. Keep unavailable engines, rejected credentials and incomplete registration unusable. * fix(evals): boot and configure only the selected parity engine Preserve the approved rollback of unsupported MCP envelope integration while independently repairing the fixture boot path: v2-only journeys must not open the same database in the legacy engine or call the legacy provider reload endpoint. Preserve native readiness assertions and v1 coverage. * fix(tests): wait for Chromium teardown before removing its profile Capture close before Chromium can exit, bound termination and escalation, and retry transient profile-directory removal. Register teardown as a test hook so cleanup does not replace the original assertion failure. Keep the real chooser policy assertions unchanged. * fix(evals): align calendar mock with recurrence fields Match the existing Den Google Calendar extractor by returning recurringEventId and normalized recurrence. Preserve the route/extractor equality assertion; this changes only the mock contract.
1 parent 621185e commit 4e4be21

17 files changed

Lines changed: 269 additions & 560 deletions

‎apps/app/src/app/lib/opencode-v2-adapter.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,8 @@ export function codeModeConnectionParts(part: ToolPart): ToolPart[] {
720720
const status = readString(entry, "status");
721721
if (status === "completed") {
722722
const output = toolOutput(undefined, entry.output);
723-
// Transport metadata is separate from the value returned to the script.
724-
// Older transcripts stored the envelope directly in output instead.
725-
const envelope = readRecord(entry, "mcpResult") ?? readRecord(entry, "output");
726-
const result = envelope && Array.isArray(envelope.content) ? envelope : {
727-
content: [{ type: "text", text: output }], structuredContent: entry.output,
728-
...(isRecord(entry.output) && isRecord(entry.output.launch) ? { _meta: { "openwork/mcpApp": entry.output.launch } } : {}),
729-
};
730-
return [{ ...base, state: { status, input, output, title: tool, time, metadata: { openworkMcpResult: result } } }];
723+
return [{ ...base, state: { status, input, output, title: tool, time,
724+
metadata: { openworkMcpResult: isRecord(entry.output) && Array.isArray(entry.output.content) ? entry.output : { content: [{ type: "text", text: output }], structuredContent: entry.output, ...(isRecord(entry.output) && isRecord(entry.output.launch) ? { _meta: { "openwork/mcpApp": entry.output.launch } } : {}) } } } }];
731725
}
732726
const error = readString(entry, "error");
733727
return status === "error" && error ? [{ ...base, state: { status, input, error, metadata: {}, time } }] : [];

‎apps/app/tests/opencode-v2-mcp-app-results.test.ts‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

‎apps/desktop/electron/browser-upload-chooser.test.mjs‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ import { tmpdir } from 'node:os';
77
import { test } from 'node:test';
88
import assert from 'node:assert/strict';
99
import { createBrowserUploadGrantStore, createBrowserUploadPermissions } from './browser-upload-permissions.mjs';
10+
11+
async function stopChrome(chrome, closed) {
12+
const waitForClose = async (ms) => {
13+
let timer;
14+
try {
15+
return await Promise.race([closed.then(() => true), new Promise(resolve => { timer = setTimeout(() => resolve(false), ms); })]);
16+
} finally { clearTimeout(timer); }
17+
};
18+
if (chrome.exitCode === null && chrome.signalCode === null) chrome.kill('SIGTERM');
19+
if (await waitForClose(3_000)) return;
20+
chrome.kill('SIGKILL');
21+
if (!await waitForClose(3_000)) throw new Error('Chromium did not close within the teardown deadline');
22+
}
23+
1024
test('real Chromium checks the receiving chooser frame against managed upload policy', { timeout: 30_000 }, async (t) => {
1125
let binary;
1226
for (const candidate of [process.env.OPENWORK_TEST_CHROME, process.platform === 'darwin' ? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' : '/usr/bin/google-chrome', '/usr/bin/chromium']) {
@@ -20,8 +34,19 @@ const server = createServer((req,res)=> { res.setHeader('Content-Type','text/htm
2034
server.listen(0,'127.0.0.1'); await once(server,'listening');
2135
const origin=`http://127.0.0.1:${server.address().port}`;
2236
const chrome=spawn(binary,['--headless=new','--no-sandbox','--no-first-run','--no-default-browser-check',`--user-data-dir=${tmp}/profile`,'--remote-debugging-port=0','about:blank'],{stdio:['ignore','ignore','pipe']});
37+
// Register before the test can fail or Chromium can exit. `exit` alone does not
38+
// mean its stdio has closed, and subscribing after kill can miss the event.
39+
const closed = new Promise(resolve => chrome.once('close', resolve));
2340
let socket;
24-
try {
41+
t.after(async () => {
42+
socket?.close();
43+
try { await stopChrome(chrome, closed); }
44+
finally {
45+
server.closeAllConnections(); await new Promise((resolve,reject) => server.close(error => error ? reject(error) : resolve()));
46+
// Chromium helpers may finish profile writes just after the browser closes.
47+
await rm(tmp,{recursive:true,force:true,maxRetries:5,retryDelay:100});
48+
}
49+
});
2550
const debug=await new Promise((resolve,reject)=>{let err=''; const timer=setTimeout(()=>reject(new Error(err)),15000); chrome.stderr.on('data',d=>{err+=d; const m=err.match(/DevTools listening on ws:\/\/(127\.0\.0\.1:\d+)\//); if(m){clearTimeout(timer); resolve(`http://${m[1]}`);}});});
2651
const targets=await (await fetch(`${debug}/json/list`)).json();
2752
socket=new WebSocket(targets.find(t=>t.type==='page').webSocketDebuggerUrl); await once(socket,'open');
@@ -48,6 +73,4 @@ try {
4873
assert.equal(new URL(frame.url).origin,origin);assert.equal(await authorization.revalidate(frame.url),false);
4974
const child=await send('Runtime.evaluate',{expression:'document.querySelector("iframe").contentDocument.querySelector("input").files.length',returnByValue:true});assert.equal(child.result.value,0);
5075
console.log('PASS real Chromium: same-origin blocked-path iframe chooser is refused and receives zero files');
51-
} finally { socket?.close(); if (chrome.exitCode === null) { chrome.kill('SIGTERM'); await once(chrome,'exit').catch(()=>{}); } server.closeAllConnections(); await new Promise(r=>server.close(r)); await rm(tmp,{recursive:true,force:true}); }
52-
5376
});

‎apps/server/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"publish:npm": "pnpm build && pnpm build:npm-bundle && pnpm build:web-ui && node scripts/build-opencode-plugin-deps.mjs && node scripts/publish-npm.mjs",
1919
"start": "bun dist/cli.js",
2020
"typecheck": "tsc -p tsconfig.json --noEmit",
21-
"test:readiness": "bun test test/agent-permission-tools.test.ts test/opencode-stop-fence.test.ts test/opencode-v2-mcp-readiness.test.ts test/openwork-mcp-results-v2.test.ts test/codemode-mcp-envelope.test.ts test/cloud-mcp-app-host-provisioning.test.ts test/openwork-session-groups.test.ts test/openwork-session-questions.test.ts test/openwork-affordance-args.test.ts test/session-read-detail.test.ts test/opencode-v2-drive-upload-approval.test.ts test/approved-drive-upload.test.ts test/cloud-drive-uploads.test.ts test/drive-resumable-upload.test.ts test/opencode-v2-instructions.test.ts test/opencode-v2-tool-schemas.test.ts test/opencode-v2-website-tools.test.ts test/openwork-context-computer-gate-v2.test.ts test/computer-listing-files.test.ts test/opencode-v2-background-questions.test.ts test/cloud-provider-sync-prompts.test.ts test/engine-v2-mcp-mapping.test.ts test/engine-v2-mcp-reconciliation.test.ts && pnpm test:drive-upload-stop",
21+
"test:readiness": "bun test test/agent-permission-tools.test.ts test/opencode-stop-fence.test.ts test/opencode-v2-mcp-readiness.test.ts test/openwork-mcp-results-v2.test.ts test/cloud-mcp-native-health.test.ts test/openwork-session-groups.test.ts test/openwork-session-questions.test.ts test/openwork-affordance-args.test.ts test/session-read-detail.test.ts test/opencode-v2-drive-upload-approval.test.ts test/approved-drive-upload.test.ts test/cloud-drive-uploads.test.ts test/drive-resumable-upload.test.ts test/opencode-v2-instructions.test.ts test/opencode-v2-tool-schemas.test.ts test/opencode-v2-website-tools.test.ts test/openwork-context-computer-gate-v2.test.ts test/computer-listing-files.test.ts test/opencode-v2-background-questions.test.ts test/cloud-provider-sync-prompts.test.ts test/engine-v2-mcp-mapping.test.ts test/engine-v2-mcp-reconciliation.test.ts && pnpm test:drive-upload-stop",
2222
"test:drive-upload-stop": "node --conditions=development --import tsx --test test/drive-upload-stop.test.ts",
2323
"test:drive-upload-duration": "node --conditions=development --import tsx --test test/drive-upload-duration.test.ts",
2424
"test:drive-upload-session-native": "node --conditions=development --import tsx --test test/drive-upload-session-approval-native.test.ts",

0 commit comments

Comments
 (0)