Keep dismissed shell commands and restore them without a time limit

A dismissed run keeps its command, status, times and output within the
usual history bounds. chat_shell_runs lists dismissed runs apart
(chat_shell_dismissed_runs), chat_shell_run_output still reads them, and
the purge timer and startup purge are gone. Rows an older server purged
are listed with purged set and cannot be restored.
This commit is contained in:
2026-11-09 23:29:25 +00:00
parent 371d29224c
commit f2520a09b8
10 changed files with 204 additions and 186 deletions
+13 -13
View File
@@ -1,26 +1,26 @@
package protocol
// Dismissing operator shell commands. Dismissal is per chat, for every client:
// a dismissed run leaves every chat_shell_runs readback and every watcher
// receives a chat_shell_run_event with Dismissed set. A running command cannot
// be dismissed. For ChatShellRunUndoWindow after a dismissal the run can be
// restored (chat_shell_restore); after that the server purges its command,
// output and error, keeping only a tombstone whose id chat_shell_runs reports
// in ChatShellDismissed so a client that missed the event drops the card.
// a dismissed run leaves the transcript (chat_shell_runs' ChatShellRuns) and
// every watcher receives a chat_shell_run_event with Dismissed set. A running
// command cannot be dismissed. A dismissed run is kept, command, status, times
// and output included, within the same history and output bounds as any other
// run: chat_shell_runs lists it in ChatShellDismissedRuns (flagged Dismissed)
// so clients can show it collapsed, chat_shell_run_output still reads it, and
// chat_shell_restore puts it back at any time. Runs dismissed by an older
// server had their command and output purged; they are listed with Purged set
// and cannot be restored.
const (
// ChatShellDismiss dismisses the finished runs named in
// ChatShellRunRequest.RunIDs; the reply lists those it dismissed in
// ChatShellDismissed (running, unknown and already dismissed runs are
// skipped).
ChatShellDismiss = "chat_shell_dismiss"
// ChatShellRestore undoes a dismissal still inside its undo window; the
// reply carries the restored runs (with their list output tail) in
// ChatShellRuns, and every watcher receives their lifecycle frames.
// ChatShellRestore undoes a dismissal; the reply carries the restored runs
// (with their list output tail) in ChatShellRuns, and every watcher
// receives their lifecycle frames. There is no time limit; a purged run
// cannot be restored.
ChatShellRestore = "chat_shell_restore"
// ChatShellRunUndoWindow is how long, in milliseconds, a dismissed run is
// kept restorable before its output is purged. It is longer than the
// clients' Undo notice so a late Undo still succeeds.
ChatShellRunUndoWindow = 30_000
// ChatShellDismissLimit bounds the run ids of one request.
ChatShellDismissLimit = 200
)
+6
View File
@@ -114,6 +114,12 @@ type ChatShellRunRecord struct {
// carriage-return redraws applied): what Copy output copies and Send to
// agent shares. Only chat_shell_run_output carries it.
Text string `json:"text,omitempty"`
// Dismissed is set on a run the operator dismissed (chat_shell_dismiss.go)
// and DismissedAt is when, in epoch milliseconds. Purged is set when an
// older server deleted its command and output: only the tombstone is left.
Dismissed bool `json:"dismissed,omitempty"`
DismissedAt int64 `json:"dismissed_at,omitempty"`
Purged bool `json:"purged,omitempty"`
}
// ChatShellRunEventFrame is one live change to a run. A lifecycle frame sets
+5 -2
View File
@@ -281,8 +281,11 @@ type Message struct {
ChatShellRuns []ChatShellRunRecord `json:"chat_shell_runs,omitempty"`
ChatShellRunEvent *ChatShellRunEventFrame `json:"chat_shell_run_event,omitempty"`
// ChatShellDismissed lists dismissed run ids (chat_shell_dismiss's reply
// and chat_shell_runs' tombstones; chat_shell_dismiss.go).
ChatShellDismissed []string `json:"chat_shell_dismissed,omitempty"`
// and chat_shell_runs' dismissed ids; chat_shell_dismiss.go), and
// ChatShellDismissedRuns carries chat_shell_runs' dismissed runs, oldest
// first, with their list output tail.
ChatShellDismissed []string `json:"chat_shell_dismissed,omitempty"`
ChatShellDismissedRuns []ChatShellRunRecord `json:"chat_shell_dismissed_runs,omitempty"`
// Machine terminals (terminal.go): the request body, one terminal, the
// machine's terminals and the pushed change.
TerminalRequest *TerminalRequest `json:"terminal_request,omitempty"`