chat: a verification chat can never appear in the operator's list

The operator's chat list showed ~99 stray "New chat" entries. The listing
was already fail-closed (registry-only); the fault was what got recorded: an
automated UI check drives the real page, so its throwaway chat was recorded as
an operator chat exactly like a manually created one and stayed in the list for
ever (each run added one).

Server: chat_create takes an optional ephemeral flag. The session is created,
bootstrapped, usable, closable and reopenable exactly like any other, but its
registry row is hidden, so chat_sessions never lists it. operator_sessions gains
an ephemeral column (idempotent migration, existing rows default to listed) and
the list query filters it; the single-row lookup does not, so close/reopen keep
working. RecordVerificationSession is the hidden recorder.

Web: the page marks a create ephemeral only when automation asks for it
(__pipelinesEphemeralChat, set by the UI smoke for its throwaway chat), so the
smoke's own runs stop polluting while a manual create is unchanged.

Tests: a hidden row is never listed yet is still looked up and closable; a
normal re-record of the same id lists it again; a pre-ephemeral database
migrates with every existing chat still listed. Live data pruned separately
(107 -> 8 registry rows, backed up).
This commit is contained in:
2026-10-19 13:15:08 +01:00
parent 94c802a147
commit 2fe63012f9
10 changed files with 233 additions and 18 deletions
+6 -1
View File
@@ -4582,7 +4582,12 @@ function applyChatCommandEffect(sessionId, session, effect) {
async function startChatSession(directory) {
const from = state.chatActiveId;
try {
const created = await repo.chatCreate("New chat", directory);
// An automated check (the UI smoke) can mark its throwaway chat ephemeral, so
// creating one for verification never adds a stray "New chat" to the
// operator's list. Set only by test tooling; a normal page leaves it unset.
const created = await repo.chatCreate("New chat", directory, undefined, {
ephemeral: globalThis.__pipelinesEphemeralChat === true,
});
// The list is the server's; insert the created session so the row is present
// before the conversation opens, then refresh from the server.
state.chatSessions = [created, ...state.chatSessions.filter((s) => s.id !== created.id)];
+7 -2
View File
@@ -389,11 +389,16 @@ export class PipelinesRepository {
* never created in whatever directory the server happens to be running in. The
* reply's `chat_session` is returned, or a `ProtocolError` when the server did
* not return one.
*
* `ephemeral` creates a verification chat: the server makes and bootstraps the
* session but records no operator-registry row, so the chat never appears in
* `chat_sessions` for the operator. Automated checks that drive this real page
* set it, so a run can never leave a stray "New chat" in the operator's list.
*/
async chatCreate(title, directory, operationId = newChatOperationId()) {
async chatCreate(title, directory, operationId = newChatOperationId(), { ephemeral = false } = {}) {
const response = await this.#client.call({
type: Protocol.CHAT_CREATE,
[ChatKeys.CREATE]: { title, directory, operation_id: operationId },
[ChatKeys.CREATE]: { title, directory, operation_id: operationId, ...(ephemeral ? { ephemeral: true } : {}) },
});
const session = response[ChatKeys.SESSION];
if (!session) {