web: background-tasks bar — running shells, capped list, bounded output (C11)
Add the background-tasks bar to an open conversation: heading
"Background tasks" plus "{n} running", shown only while at least one
shell is running. Rows are capped at 3 (BACKGROUND_TASK_VISIBLE_ROWS)
and the list scrolls beyond; each row is a play glyph, "Running", a
one-line shellCommandSummary and "Details" while selected. Tapping a
row toggles its detail pane ("Command"/"Task identity"/"Status:
running" plus the bounded output: spinner, error + "Retry",
"Output unavailable for this task.", "No output yet.", or the
monospace output and "Output is bounded to 64 KiB." with "Refresh").
Fold shell frames without ever marking the turn running, merge a blank
command from the previous frame, list only running shells (an exited
shell is never a task) and drop/relearn shells on reconnect via
chat_shells. Refresh always rereads the bounded 64 KiB page from cursor
0. Update PARITY.md C11 with its captures and the replayed-vs-real note.
Checks: node --check on every touched file; cd web && node --test test/
(456 pass).
This commit is contained in:
@@ -7,6 +7,14 @@ import { ProtocolError } from "./client.js";
|
||||
/** The server default history page the app asks for (CHAT_HISTORY_LIMIT, 200). */
|
||||
export const CHAT_HISTORY_LIMIT = 200;
|
||||
|
||||
/**
|
||||
* The largest shell-output page the server accepts (ChatShellOutputLimit,
|
||||
* 64 KiB). The browser always reads from the page's start and never sends more
|
||||
* than this, so a background task's output can never grow unbounded on the
|
||||
* client.
|
||||
*/
|
||||
export const SHELL_OUTPUT_LIMIT = 64 << 10;
|
||||
|
||||
export class PipelinesRepository {
|
||||
#client;
|
||||
|
||||
@@ -240,6 +248,57 @@ export class PipelinesRepository {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists the currently verified shells this operator chat session owns (C11),
|
||||
* so the conversation can show a background-tasks bar while one is running.
|
||||
* The body is the session-scoped `chat_query` (like chat_messages); the reply
|
||||
* is `chat_shells`, and an older server that returns none answers with an empty
|
||||
* list. A blank session id is refused here, exactly like
|
||||
* PipelinesRepository.chatShells.
|
||||
*/
|
||||
async chatShells(sessionId) {
|
||||
if (!String(sessionId ?? "").trim()) {
|
||||
throw new ProtocolError("Select a chat session first.");
|
||||
}
|
||||
const response = await this.#client.call({
|
||||
type: Protocol.CHAT_SHELLS,
|
||||
[ChatKeys.QUERY]: { session_id: sessionId },
|
||||
});
|
||||
return response[ChatKeys.SHELLS] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads one bounded output page from a verified shell (C11), mirroring
|
||||
* PipelinesRepository.chatShellOutput. The body is exactly
|
||||
* `chat_shell_output_query` — {session_id, shell_id, cursor, limit}, **not** the
|
||||
* `chat_query` the other session commands use — with the cursor always sent so
|
||||
* a refresh rereads from the page's start rather than appending. A blank
|
||||
* session/shell, an out-of-bounds cursor/limit or a reply with no page is
|
||||
* refused with the same reason the Android client uses.
|
||||
*/
|
||||
async chatShellOutput(sessionId, shellId, { cursor = 0, limit = SHELL_OUTPUT_LIMIT } = {}) {
|
||||
if (!String(sessionId ?? "").trim() || !String(shellId ?? "").trim()) {
|
||||
throw new ProtocolError("Select a shell first.");
|
||||
}
|
||||
if (!(cursor >= 0) || !(limit > 0) || limit > SHELL_OUTPUT_LIMIT) {
|
||||
throw new ProtocolError("Shell output bounds are invalid.");
|
||||
}
|
||||
const response = await this.#client.call({
|
||||
type: Protocol.CHAT_SHELL_OUTPUT,
|
||||
[ChatKeys.SHELL_OUTPUT_QUERY]: {
|
||||
session_id: sessionId,
|
||||
shell_id: shellId,
|
||||
cursor,
|
||||
limit,
|
||||
},
|
||||
});
|
||||
const page = response[ChatKeys.SHELL_OUTPUT];
|
||||
if (!page) {
|
||||
throw new ProtocolError("The server returned no shell output page.");
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes a session and records it closed on the server (nothing is
|
||||
* deleted). The reply echoes the updated session (`chat_session`) and the
|
||||
|
||||
Reference in New Issue
Block a user