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:
1 parent
5572ac0d84
commit
0ef019f58d
57 files changed
+3549
-684
No files matched your search
@@ -10,12 +10,28 @@ describe("safeNext", () => {
|
||||
expect(safeNext("/workspace/ws-pi2?x=1")).toBe("/workspace/ws-pi2?x=1");
|
||||
});
|
||||
|
||||
it("keeps paired deep links (session + workspace query) across the pairing round trip", () => {
|
||||
expect(safeNext("/chat/01a15368?workspace=ws-1")).toBe("/chat/01a15368?workspace=ws-1");
|
||||
expect(safeNext("/chat/01a1?workspace=ws-1&tab=todo")).toBe("/chat/01a1?workspace=ws-1&tab=todo");
|
||||
expect(connectHref(safeNext("/chat/01a1?workspace=ws-1"))).toBe(
|
||||
"/connect?next=%2Fchat%2F01a1%3Fworkspace%3Dws-1",
|
||||
);
|
||||
// The `next` param survives a full redirect → pairing → redirect cycle.
|
||||
const href = connectHref("/chat/01a1?workspace=ws-1");
|
||||
const next = new URLSearchParams(href.split("?")[1]).get("next");
|
||||
expect(safeNext(next)).toBe("/chat/01a1?workspace=ws-1");
|
||||
});
|
||||
|
||||
it("falls back for unknown or unsafe targets", () => {
|
||||
expect(safeNext(undefined)).toBe("/workspaces");
|
||||
expect(safeNext("/servers")).toBe("/workspaces");
|
||||
expect(safeNext("/connect")).toBe("/workspaces");
|
||||
expect(safeNext("/pair/ABCD1234")).toBe("/workspaces");
|
||||
expect(safeNext("javascript:alert(1)")).toBe("/workspaces");
|
||||
expect(safeNext("https://evil.example/not-a-page")).toBe("/workspaces");
|
||||
// A protocol-relative link keeps only its path (the host is never used).
|
||||
expect(safeNext("//evil.example/chat/1")).toBe("/chat/1");
|
||||
expect(safeNext("//evil.example/not-a-page")).toBe("/workspaces");
|
||||
});
|
||||
|
||||
it("builds an encoded connect redirect", () => {
|
||||
|
||||
Reference in new issue
Block a user