diff --git a/examples/loopx-chat-actions-smoke.py b/examples/loopx-chat-actions-smoke.py index f06ddc261f..d0ac017b36 100644 --- a/examples/loopx-chat-actions-smoke.py +++ b/examples/loopx-chat-actions-smoke.py @@ -124,6 +124,7 @@ def open_session(self, **kwargs: object) -> tuple[dict[str, object], bool]: agent_id=str(kwargs["agent_id"]), adapter_kind="fake", upstream_thread_id="thread-goal-create", + upstream_mode="chat" if kwargs["agent_id"] == "codex" else "default", channel_id=channel, ) return session, False diff --git a/examples/personal-workspace-browser/goal-workspace-backend.py b/examples/personal-workspace-browser/goal-workspace-backend.py index 8b4ba4d2e6..7406701a69 100644 --- a/examples/personal-workspace-browser/goal-workspace-backend.py +++ b/examples/personal-workspace-browser/goal-workspace-backend.py @@ -30,7 +30,23 @@ registry.write_text(json.dumps(data), encoding="utf-8") runtime = Path(data["common_runtime_root"]) store, sessions = ChatActionStore(runtime / "chat/actions"), ChatSessionStore(runtime) -controller = fixture["FakeRuntimeController"](sessions) + + +class WorkspaceRuntimeController(fixture["FakeRuntimeController"]): + def __init__(self, store: ChatSessionStore, registry_path: Path, runtime_root: Path) -> None: + super().__init__(store) + self.store = store + self.registry_path = registry_path + self.coordination_runtime_root = runtime_root + + def resume_session_queue(self, *, session_id: str, work_dir: Path, objective: str) -> None: + # Observe the queue target at the synthetic dispatch boundary. + session = self.store.load_session(session_id) + assert session is not None + assert Path(session["managed_workspace_path"]) == Path(work_dir) + + +controller = WorkspaceRuntimeController(sessions, registry, runtime) # One Dashboard-configured workspace that no Goal uses yet. configured = root / "docs-site" configured.mkdir() diff --git a/examples/personal-workspace-browser/goal-workspace-selection.mjs b/examples/personal-workspace-browser/goal-workspace-selection.mjs index 5b9a03f2a1..bfca50ca3a 100644 --- a/examples/personal-workspace-browser/goal-workspace-selection.mjs +++ b/examples/personal-workspace-browser/goal-workspace-selection.mjs @@ -91,10 +91,18 @@ runpy.run_path(sys.argv[0], run_name="__main__") assert.equal(await page.getByText(backend.second, {exact: false}).count(), 0); assert.equal(JSON.parse(await readFile(backend.registry, "utf8")).goals.length, 2, "Preview created a Goal"); const confirm = page.getByRole("button", {name: /创建 Goal.*开始首轮/}); + const confirmation = page.waitForResponse((response) => + response.request().method() === "POST" && new URL(response.url()).pathname.endsWith("/apply")); await confirm.click(); - await page.waitForFunction(() => document.body.innerText.includes("进入新 Goal")); + assert.ok((await confirmation).ok(), JSON.stringify(applied[0])); assert.equal(applied.length, 1); - assert.equal(applied[0].proposal.receipt.projection_verified, true); + const receipt = applied[0].proposal.receipt; + assert.equal(receipt.projection_verified, true); + assert.equal(receipt.original_task_request.todo_id, receipt.resource_ids.todo_ids[0]); + assert.equal(receipt.original_task_request.session_id, receipt.resource_ids.session_id); + assert.equal(receipt.original_task_request.permission, "read_only"); + assert.deepEqual(receipt.original_task_request.write_scope, []); + await page.getByRole("button", {name: "进入新 Goal", exact: true}).waitFor(); const goalId = requests.at(-1).normalized_parameters.goal_id; const registry = JSON.parse(await readFile(backend.registry, "utf8")); const created = registry.goals.find(goal => goal.id === goalId); diff --git a/examples/personal-workspace-browser/typed-actions.mjs b/examples/personal-workspace-browser/typed-actions.mjs index a4dc8fb3cf..fe06151219 100644 --- a/examples/personal-workspace-browser/typed-actions.mjs +++ b/examples/personal-workspace-browser/typed-actions.mjs @@ -325,13 +325,17 @@ export const typedActionsScenario = { } const writesBeforeSelection = api.durableWriteCount; await drawer.getByRole("button", { name: /Workspace 1/ }).click(); - await page.getByRole("button", { name: "创建 Goal 并开始首轮", exact: true }).waitFor({ state: "visible" }); + const create = drawer.getByRole("button", { name: "创建 Goal", exact: true }); + await create.waitFor({ state: "visible" }); const regenerated = api.actionPreviews.at(-1); if (regenerated?.normalized_parameters.workspace_ref !== "workspace-fixture") { throw new Error(`Stored workspace selection did not regenerate the Goal preview: ${JSON.stringify(regenerated)}`); } + if (regenerated.normalized_parameters.start_execution !== storedWorkspaceGate.normalized_parameters.start_execution) { + throw new Error("Workspace selection changed the saved execution intent"); + } if (api.durableWriteCount !== writesBeforeSelection) throw new Error("Selecting a workspace applied without confirmation"); - await page.getByRole("button", { name: "创建 Goal 并开始首轮", exact: true }).click(); + await create.click(); await page.getByText("已应用,LoopX 状态将刷新。", { exact: true }).waitFor({ state: "visible" }); if (!api.actionApplies.includes(regenerated.proposalId)) throw new Error("Confirmation did not apply the regenerated preview"); if (api.durableWriteCount !== writesBeforeSelection + 1) throw new Error("Confirmation did not write exactly one Goal");