running and cancel all commands

This commit is contained in:
ari committed 2026-11-01 20:29:39 -05:00
1 parent 917a361370
commit af249326e8
7 files changed
+145 -6

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ flowchart LR
**A message's path:** Slack event (`app_mention`, a DM, or a plain reply in a channel thread set to `all-messages`) → `bot` → `manager.Ensure` (find the container, or place and start it) → `manager.DialAgent` (direct on the master, relayed for slaves) → `acp` session → updates stream back through `bot`'s streamer, which edits the Slack message. While the reply runs, its newest message also has a status line (what the agent is doing, and when it last sent an update) and a **Cancel** button whose value is the placeholder's ts, the key in `Bot.running`. The final edit removes both.
**In-flight turns:** once the placeholder is posted, `bot.converse` records the turn (thread, message and placeholder ts, sender, text, attachments) in `state_dir/in-flight-<channel>.json`, one file per channel keyed by thread, and marks it `prompted` just before `session/prompt`. The record is removed when the turn ends, unless it ended because the bot is shutting down: then the reply ends with a restarting note, and `Bot.Run` waits up to 5s for those last edits. On start, `Bot.Run` resumes every recorded turn through the same path. If the agent already got the prompt, it gets a short "carry on" note in the same session instead of the message again, because goose keeps the partial turn and resending could repeat what it already did. If it didn't (or the session is gone), it gets the original message and attachments. Turns older than an hour, or already resumed 3 times, are dropped with a note asking the user to send them again. A broken file is skipped and left on disk. Super users can read the files with `in-flight` (Slack, answered ephemerally) or the `in_flight` tool.
**In-flight turns:** once the placeholder is posted, `bot.converse` records the turn (thread, message and placeholder ts, sender, text, attachments) in `state_dir/in-flight-<channel>.json`, one file per channel keyed by thread, and marks it `prompted` just before `session/prompt`. The record is removed when the turn ends, unless it ended because the bot is shutting down: then the reply ends with a restarting note, and `Bot.Run` waits up to 5s for those last edits. On start, `Bot.Run` resumes every recorded turn through the same path. If the agent already got the prompt, it gets a short "carry on" note in the same session instead of the message again, because goose keeps the partial turn and resending could repeat what it already did. If it didn't (or the session is gone), it gets the original message and attachments. Turns older than an hour, or already resumed 3 times, are dropped with a note asking the user to send them again. A broken file is skipped and left on disk. Super users can read the files with `in-flight` (Slack, answered ephemerally) or the `in_flight` tool. `running` (tool `running`) lists a channel's recorded turns, and `cancel all` (tool `cancel_all`) calls the `Bot.running` cancel func of each one whose prompt has started, skipping the calling agent's own turn.
**Lifecycle threads:** `manager.EnsureProgress` reports `StartEvent`s (placing, booting, registered) only when it really starts a container. The bot (`bot/lifecycle.go`) turns them into replies in a dedicated top-level message for that container, pins it, and unpins the previous run's message. The message's channel and timestamp are kept on the owner (`lifecycle_channel`, `lifecycle_ts`). The user's thread only gets a link. Stops (`stop`, the button, the idle reaper) post to the same thread, and `manager.WaitStopped` confirms when the machine is gone.