Skip to content

Commit 1371cf9

Browse files
author
exe.dev user
committed
Merge remote-tracking branch 'origin/main' into gen-2921-docker-adapter
2 parents 263505e + 9e88f86 commit 1371cf9

4 files changed

Lines changed: 58 additions & 3 deletions

File tree

‎packages/api/src/exe-vm-backend.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export class ExeVmBackend implements ExecutionBackend {
195195
"sudo install -d -o exedev -g exedev -m 0700 /home/exedev/.factorize-job",
196196
`printf '%s' ${shellAtom(base64(FACTORIZE_JOB_LAUNCHER))} | sudo sh -c ${shellAtom("base64 -d > /usr/local/bin/factorize-job && chmod 0755 /usr/local/bin/factorize-job")}`,
197197
`printf '%s' ${shellAtom(base64(launchPayload))} | base64 -d > ${shellAtom(launchPayloadPath)} && sudo chown exedev:exedev ${shellAtom(launchPayloadPath)}`,
198-
`if [ "$(sudo systemctl show ${shellAtom(unit)} --property=LoadState --value 2>/dev/null || true)" != loaded ]; then sudo systemd-run --quiet --uid=exedev --gid=exedev --unit=${shellAtom(unit)} --property=Type=exec --property=RemainAfterExit=yes --property=WorkingDirectory=/home/exedev/workspace --property=StandardInput=/dev/null --property=StandardOutput=${output === "/tmp/factorize.log" ? `append:${output}` : shellAtom(`append:${output}`)} --property=StandardError=append:/tmp/factorize.stderr /bin/sh -c ${shellAtom(`exec /usr/local/bin/factorize-job launch --foreground < ${launchPayloadPath}`)}; fi`,
198+
`if [ "$(sudo systemctl show ${shellAtom(unit)} --property=LoadState --value 2>/dev/null || true)" != loaded ]; then sudo systemd-run --quiet --uid=exedev --gid=exedev --unit=${shellAtom(unit)} --property=Type=exec --property=RemainAfterExit=yes --property=WorkingDirectory=/home/exedev/workspace --property=StandardInput=null --property=StandardOutput=${output === "/tmp/factorize.log" ? `append:${output}` : shellAtom(`append:${output}`)} --property=StandardError=append:/tmp/factorize.stderr /bin/sh -c ${shellAtom(`exec /usr/local/bin/factorize-job launch --foreground < ${launchPayloadPath}`)}; fi`,
199199
"echo started",
200200
].join("; ");
201201
if (request.traceSources?.primary.formatVersion === "codex-exec-jsonl") {

‎packages/api/test/execution-backend.test.ts‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { spawnSync } from "node:child_process";
2+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
3+
import { tmpdir } from "node:os";
4+
import { join } from "node:path";
15
import { afterEach, describe, expect, it, vi } from "vitest";
26
import { ExeImageVerificationError, ExeVmBackend, isOwnedVmName, tagsFromInventory, vmNameFor } from "../src/exe-vm-backend";
37
import type { ExecutionBackend, ExecutionObservation, LaunchRequest, RunHandle } from "../src/execution";
@@ -96,7 +100,7 @@ describe("ExeVmBackend", () => {
96100
expect(requests[1]).toContain("--uid=exedev --gid=exedev");
97101
expect(requests[1]).toContain("--property=Type=exec");
98102
expect(requests[1]).toContain("--property=RemainAfterExit=yes");
99-
expect(requests[1]).toContain("--property=StandardInput=/dev/null");
103+
expect(requests[1]).toContain("--property=StandardInput=null");
100104
expect(requests[1]).toContain("--property=StandardOutput=append:/tmp/factorize.log");
101105
expect(requests[1]).toContain("--property=StandardError=append:/tmp/factorize.stderr");
102106
expect(launchPayload(requests[1]).traceSources.primary.path).toBe("/tmp/trace/events.jsonl");
@@ -106,6 +110,31 @@ describe("ExeVmBackend", () => {
106110
expect(requests[1]).toContain("systemctl show");
107111
});
108112

113+
it("generates standard I/O settings accepted by systemd", async () => {
114+
const requests: string[] = [];
115+
vi.stubGlobal("fetch", vi.fn(async (_url: string, init: RequestInit) => {
116+
requests.push(String(init.body));
117+
return new Response(requests.length === 1 ? "{}" : "started", { headers: { "X-Exe-Exit": "0" } });
118+
}));
119+
await new ExeVmBackend(connection).launch({ runId: "stdin-regression", prompt: "", code: { script: "true", context: {} } });
120+
const command = requests.find(value => value.includes("sudo systemd-run"))!;
121+
const properties = [...command.matchAll(/--property=(Standard(?:Input|Output|Error)=[^\s]+)/g)].map(match => match[1]);
122+
expect(properties).toHaveLength(3);
123+
const directory = await mkdtemp(join(tmpdir(), "factorize-systemd-"));
124+
try {
125+
const unit = join(directory, "launch.service");
126+
await writeFile(unit, `[Service]\nType=exec\n${properties.join("\n")}\nExecStart=/bin/true\n`);
127+
const verified = spawnSync("systemd-analyze", ["verify", unit], { encoding: "utf8", timeout: 10_000 });
128+
expect(verified.error).toBeUndefined();
129+
expect(verified.status).toBe(0);
130+
// Invalid StandardInput values are warnings in unit files but fatal to
131+
// systemd-run's transient-unit API. Reject parser warnings as well.
132+
expect(verified.stderr).toBe("");
133+
} finally {
134+
await rm(directory, { recursive: true, force: true });
135+
}
136+
});
137+
109138
it("quotes a snapshotted public image in the exe.dev VM creation command", async () => {
110139
const requests: string[] = [];
111140
vi.stubGlobal("fetch", vi.fn(async (_url: string, init: RequestInit) => { requests.push(String(init.body)); return new Response(requests.length === 1 ? "{}" : "started", { headers: { "X-Exe-Exit": "0" } }); }));

‎packages/app/src/features/runs/continuous-trace.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function ContinuousTrace({ runId, revision, active, onReset, preview = fa
7171
const latestSequence = items.at(-1)?.sequence ?? 0;
7272
const live = useQuery({
7373
queryKey: ["runs", runId, "conversation-tail", revision],
74-
enabled: !preview && active && visible && !!trace.data,
74+
enabled: active && visible && !!trace.data,
7575
queryFn: async ({ signal }) => {
7676
const { data, error, response } = await api.GET("/api/v1/runs/{runId}/trace-pages", { signal, params: { path: { runId }, query: { after: latestSequence, revision, limit: 100 } } });
7777
if (!data || error) throw response.status === 404 ? new RunNotFoundError() : new Error(messageOf(error)); return data;
@@ -182,6 +182,7 @@ export function ContinuousTrace({ runId, revision, active, onReset, preview = fa
182182
{trace.error && <p role="alert">{trace.error.message}</p>}{trace.isPending && <p role="status">Loading conversation…</p>}
183183
{!trace.isPending && !grouped.length && <p className="text-sm text-slate-600 dark:text-slate-400">No assistant messages yet.</p>}
184184
{grouped.map(item => item.kind === "assistant" ? <article key={item.event.id} className="min-w-0"><EventBody event={item.event} /></article> : <Disclosure key={groupKey(item)} className={traceClasses("tool_call")} open={expanded.has(groupKey(item))} onToggle={event => { const key = groupKey(item); const open = event.currentTarget.open; setExpanded(previous => { const next = new Set(previous); open ? next.add(key) : next.delete(key); return next; }); }}><Summary>{item.count} Tool Call{item.count === 1 ? "" : "s"}</Summary>{expanded.has(groupKey(item)) && <div className="space-y-3">{item.events.map(event => <div key={event.id}><EventBody event={event} /></div>)}</div>}</Disclosure>)}
185+
{active && <p data-run-trace-live role="status" aria-label="Run is still running" className="mt-5 flex items-center gap-2 text-sm font-medium"><RunStatusLabel state="running" /><span className="trace-live-dots" aria-hidden="true"><span /><span /><span /></span></p>}
185186
</div>;
186187
const virtualItems = virtualizer.getVirtualItems();
187188
return <>{trace.error && <p role="alert">{trace.error.message}</p>}{trace.isPending && <p role="status">Loading conversation…</p>}

‎packages/app/test/runs.browser.test.mjs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,31 @@ test("running trace shows animated dots and polls forward from its latest event"
281281
assert.deepEqual(tailRequests.slice(0, 2), [1, 2], "each poll should request events after the latest displayed sequence");
282282
await context.close();
283283
});
284+
test("active job run preview refreshes recent activity without scrolling and shows Running at the bottom", async () => {
285+
const { context, page } = await setup(); const tailRequests = [];
286+
const event = sequence => ({ id: `preview-${sequence}`, sequence, type: "assistant_message", title: `Preview ${sequence}`, preview: `Preview ${sequence}`, display: {} });
287+
await page.route(`**/api/v1/runs/${runId}/status`, route => route.fulfill({ json: { id: runId, job_id: jobId, job_name: "Job", run_name: "Live preview", state: "running", finalizing: false, trace_revision: "preview", artifact_state: "pending", created_at: time, updated_at: time, started_at: time, destination_url: null } }));
288+
await page.route(`**/api/v1/runs/${runId}/trace-pages?**`, route => {
289+
const query = new URL(route.request().url()).searchParams;
290+
if (query.has("after")) {
291+
const after = Number(query.get("after")); tailRequests.push(after);
292+
return route.fulfill({ json: { items: [event(after + 1)], nextCursor: null, previousCursor: null, revision: "preview", reset: false } });
293+
}
294+
return route.fulfill({ json: { items: [event(1)], nextCursor: null, previousCursor: null, revision: "preview", reset: false } });
295+
});
296+
await page.goto(origin + "/job-runs/" + runId);
297+
const trace = page.locator("[data-run-trace-preview]");
298+
const indicator = trace.locator("[data-run-trace-live]");
299+
await indicator.waitFor();
300+
assert.equal(await indicator.locator(".trace-live-dots > span").count(), 3);
301+
assert.equal(await trace.locator("[data-run-trace-scroll]").count(), 0, "recent activity should not use the scrolling history trace");
302+
await page.evaluate(() => { document.scrollingElement.scrollTop = 0; });
303+
await page.getByText("Preview 3", { exact: true }).waitFor({ timeout: 7000 });
304+
assert.deepEqual(tailRequests.slice(0, 2), [1, 2], "preview polling should continue after the latest displayed sequence");
305+
assert.ok(await trace.getByText("Preview 3", { exact: true }).count());
306+
assert.equal(await page.evaluate(() => document.scrollingElement.scrollTop), 0, "new activity should not auto-scroll the page through older entries");
307+
await context.close();
308+
});
284309
test("full run trace uses pull-to-load history, preserves the anchor, and never crashes on disclosure toggles", async () => {
285310
const { context, page } = await setup(); const requests = [];
286311
const event = (sequence, type = "assistant_message") => ({ id: `trace-${sequence}`, sequence, type, title: `Trace ${sequence}`, preview: `Trace ${sequence}`, display: {} });

0 commit comments

Comments
 (0)