feat: session-scoped entries query, session title tree and message stream updates
This commit is contained in:
1 parent
bef8a35632
commit
e910e75849
37 files changed
+1409
-75
No files matched your search
+8
-7
@@ -287,15 +287,16 @@ 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 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",
|
||||
});
|
||||
// `workspaceId` only routes the read (a disk-only row has no live owner);
|
||||
// the sid still rides along so the plugin can answer from its registry.
|
||||
const ack = await router.relaySessionQuery(
|
||||
c.req.param("sid"),
|
||||
"workspace.query",
|
||||
{ ...params, kind: "entries" },
|
||||
c.req.query("workspaceId"),
|
||||
);
|
||||
return json(200, ack);
|
||||
});
|
||||
|
||||
|
||||
+16
-2
@@ -124,13 +124,27 @@ export class CommandRouter {
|
||||
return this.relay(workspaceId, undefined, "workspace.query", { ...params, kind });
|
||||
}
|
||||
|
||||
/** Relayed read used by `GET /sessions/:sid/entries`. */
|
||||
/**
|
||||
* Relayed read used by `GET /sessions/:sid/entries`.
|
||||
*
|
||||
* The sid travels on the envelope even when `workspaceIdHint` routes the read
|
||||
* to an instance that does not own the session (a disk-only row): the plugin
|
||||
* resolves the file from its registry, so `params.sessionFile` is a fallback,
|
||||
* never a requirement. Dropping the sid here forced every workspace-scoped
|
||||
* read to carry a session file, which a session does not have before its
|
||||
* first entry is persisted.
|
||||
*/
|
||||
async relaySessionQuery(
|
||||
sessionId: string,
|
||||
method: string,
|
||||
params: Record<string, unknown> = {},
|
||||
workspaceIdHint?: string,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const workspaceId = this.resolveWorkspace(sessionId, params);
|
||||
const hint =
|
||||
typeof workspaceIdHint === "string" && workspaceIdHint !== ""
|
||||
? { workspaceId: workspaceIdHint }
|
||||
: {};
|
||||
const workspaceId = this.resolveWorkspace(sessionId, { ...params, ...hint });
|
||||
return this.relay(workspaceId, sessionId, method, params);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,6 +199,13 @@ export interface SessionState {
|
||||
visible?: boolean;
|
||||
/** List metadata only: the subagent task description carried by the list row. Never emitted by the reducer. */
|
||||
task?: string;
|
||||
/**
|
||||
* List metadata only: the first user message of the session file, carried by
|
||||
* the list row's disk projection. The web client shows it as the provisional
|
||||
* display name while the session has no name of its own (pi2.nvim's
|
||||
* `first_message` fallback). Never emitted by the reducer.
|
||||
*/
|
||||
firstMessage?: string | null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
Reference in new issue
Block a user