fix(web): connect the chat to the daemon end-to-end
- ws auth frame now carries the token top-level (docs §3.3); daemon accepts payload.token too - entries route accepts workspaceId/sessionFile so disk-only sessions page history - chat registers session metadata and pages history for non-live sessions - e2e asserts a real ASSISTANT reply (PONG) and waits up to 180s - visual.sh: real daemon + pairing + Playwright screenshots of the four pages
This commit is contained in:
1 parent
721661177c
commit
854d6d2997
8 files changed
+148
-17
No files matched your search
+9
-4
@@ -187,10 +187,15 @@ export function createApp(deps: AppDeps): Hono<Env> {
|
||||
if (before !== undefined) params.before = before;
|
||||
const limit = Number(c.req.query("limit"));
|
||||
if (Number.isFinite(limit) && limit > 0) params.limit = Math.min(500, Math.floor(limit));
|
||||
const ack = await router.relaySessionQuery(c.req.param("sid"), "workspace.query", {
|
||||
...params,
|
||||
kind: "entries",
|
||||
});
|
||||
const workspaceId = c.req.query("workspaceId");
|
||||
const sessionFile = c.req.query("sessionFile");
|
||||
if (sessionFile) params.sessionFile = sessionFile;
|
||||
const ack = workspaceId
|
||||
? await router.relayWorkspaceQuery(workspaceId, "entries", params)
|
||||
: await router.relaySessionQuery(c.req.param("sid"), "workspace.query", {
|
||||
...params,
|
||||
kind: "entries",
|
||||
});
|
||||
return json(200, ack);
|
||||
});
|
||||
|
||||
|
||||
+9
-2
@@ -321,12 +321,19 @@ export function attachWsServer(options: WsServerOptions): WsServerHandle {
|
||||
}
|
||||
const type = typeof message.type === "string" ? message.type : "";
|
||||
if (!state.authenticated) {
|
||||
if (type !== "auth" || typeof message.token !== "string") {
|
||||
const payload = message.payload as Record<string, unknown> | undefined;
|
||||
const authToken =
|
||||
typeof message.token === "string"
|
||||
? message.token
|
||||
: payload && typeof payload.token === "string"
|
||||
? payload.token
|
||||
: undefined;
|
||||
if (type !== "auth" || typeof authToken !== "string") {
|
||||
sendError(state, ERROR_CODES.UNAUTHORIZED, "authenticate first");
|
||||
state.ws.close(CLOSE_UNAUTHORIZED, "unauthorized");
|
||||
return;
|
||||
}
|
||||
if (!authenticate(state, message.token)) {
|
||||
if (!authenticate(state, authToken)) {
|
||||
sendError(state, ERROR_CODES.UNAUTHORIZED, "invalid device token");
|
||||
state.ws.close(CLOSE_UNAUTHORIZED, "unauthorized");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user