fix(web): make the web console work end-to-end

- Pair through the public POST /api/v1/pair and persist the device scopes;
  keep the allow-listed next deep link. Rename the manual field to pairing code.
- Authenticate the WebSocket with the raw device token (strip Bearer) and
  recover from a 401 by clearing the connection once.
- Fix chat payloads: setModel/setThinking, attention/diff responses, subagent
  dispatch items, queue ids/mode, task output and WS resume since.
- Render exactly one assistant message per turn: one-to-one snapshot/history
  merge plus a stale-delta guard after message_end (fixes PONGONG).
- Fix dialogs (content above the overlay), unknown-session deep links
  (error + retry, no silent fallback), device list/revoke, status identity and
  live pairing code, reconnect banner and Playwright selectors.
This commit is contained in:
yuez committed 2026-10-21 20:42:19 +08:00
1 parent 5572ac0d84
commit 0ef019f58d
57 files changed
+3549 -684

No files matched your search

+29
View File
@@ -63,6 +63,35 @@ describe("WorkspacesPage", () => {
const names = [...container.querySelectorAll(".list-row__name")].map((node) => node.textContent);
expect(names).toEqual(["Alpha", "Bravo", "Charlie"]);
// Stable hooks for the e2e/Playwright suite (row + enter link).
const rows = screen.getAllByTestId("workspace-row");
expect(rows.map((row) => row.getAttribute("data-workspace-id"))).toEqual(["ws-a", "ws-b", "ws-c"]);
const enters = screen.getAllByTestId("workspace-enter");
expect(enters.map((link) => link.getAttribute("href"))).toEqual([
"/chat?workspace=ws-a",
"/chat?workspace=ws-b",
"/chat?workspace=ws-c",
]);
});
it("opens the new-workspace dialog from the empty state", async () => {
const fetchMock = mockApi([
{ path: "/api/v1/info", handler: () => ({ body: infoBody }) },
{ path: "/api/v1/workspaces", handler: () => ({ body: [] }) },
]);
await renderPage(routes(), "/workspaces", { paired: true });
await screen.findByText("No workspaces yet");
fireEvent.click(screen.getAllByRole("button", { name: "Open new workspace" })[0]!);
const dialog = await screen.findByRole("dialog");
expect(within(dialog).getByLabelText("Path")).toBeInTheDocument();
// An empty path is rejected inline and issues no command.
fireEvent.click(within(dialog).getByRole("button", { name: "Open" }));
expect(await within(dialog).findByText("Enter a working directory path")).toBeInTheDocument();
expect(commandCalls(fetchMock)).toHaveLength(0);
});
it("renders the empty state without a server picker", async () => {