merge PR #4839: fix(coding-agent): handle JS eval worker cwd conflicts via worker protocol

This commit is contained in:
can1357
2026-07-08 15:21:30 +02:00
2 changed files with 116 additions and 2 deletions
@@ -213,8 +213,6 @@ export class WorkerCore {
}
async #runOne(runId: string, code: string, filename: string, snapshot: SessionSnapshot): Promise<void> {
const runtime = this.#ensureRuntime(snapshot);
runtime.setCwd(snapshot.cwd);
const active: ActiveRun = { runId, filename, pendingTools: new Map(), floatingRejections: [] };
this.#runs.set(runId, active);
const hooks: RuntimeHooks = {
@@ -224,6 +222,8 @@ export class WorkerCore {
};
let result: RunResult;
try {
const runtime = this.#ensureRuntime(snapshot);
runtime.setCwd(snapshot.cwd);
const value = await runtime.run(code, filename, hooks, { runId, cwd: snapshot.cwd });
runtime.displayValue(value, hooks);
result = { type: "result", runId, ok: true };