Start a stopped session's process for a command too
Same reasoning as the message path a commit ago, and the same objection
to leaving it out: a command is something somebody asked the session to
do, and answering "its process has exited" hands back the work of
starting one. `/compact` on a stopped session is the case that shows it
-- what is being asked for is exactly what a stopped session needs
before it is useful again.
`POST /sessions/{id}/command` and `/compact` now go through
`SessionManager::run_command`. A rename is deliberately not one of them:
it is persisted and listed whether or not a process ever hears about it,
so starting a CLI to tell it a name would be spending a resume on
nothing. It stays a forward to a process that happens to be there.
A command needs one thing a message did not. `Commands::submit` refuses
on `Exited`, and a driver that has just started a process announces
`Idle` through the sink rather than writing it -- so a command judged
against the session's own status would be refused by the word the start
had just replaced, in a window narrow enough that only a test reliably
hits it. `start_if_exited` returning `Exited` is what says a process was
started, so the status the command is judged against comes from there
rather than from a re-read the pump may not have caught up with. The
test fails without it.
`LiveSession::compact` went with this: `/compact` the route and
"/compact" the typed command were two ways to the same command, and now
there is one.
Verified over the API against a stand-in CLI: with the session reporting
`exited`, both `/clear` and `POST /compact` started the process and were
delivered -- transcript order `idle`, `commandSent`, `running`, `idle`,
with no "this session's process has exited" anywhere.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4a122f7b25
commit
1a132b4de3
4 files changed
+115
-36
No files matched your search
@@ -291,12 +291,15 @@ day:
|
||||
which keeps the session and its transcript, and `POST .../start` brings
|
||||
the process back on the same conversation — or delete the session, which
|
||||
ends the conversation too.
|
||||
- **Sending a message to a stopped session starts it.** `POST
|
||||
.../message` goes through `SessionManager::send_message`, which starts a
|
||||
process first when the session is known to have exited and then delivers
|
||||
the message to the driver that has one behind it. Only on `exited`:
|
||||
`unknown` has a process that may well be reading its fifo. So the Start
|
||||
button is for when you want a process and nothing to say to it yet.
|
||||
- **A message or a command sent to a stopped session starts it.** `POST
|
||||
.../message`, `.../command` and `.../compact` go through
|
||||
`SessionManager::send_message` and `::run_command`, which start a process
|
||||
first when the session is known to have exited and then hand the thing to
|
||||
the driver that has one behind it. Only on `exited`: `unknown` has a
|
||||
process that may well be reading its fifo. `/rename` is the exception —
|
||||
the name is persisted and listed either way, so it is forwarded to a
|
||||
process that happens to be there and never starts one. So the Start button
|
||||
is for when you want a process and nothing to say to it yet.
|
||||
- **Each session directory now holds `process.json`, `stdin.fifo`,
|
||||
`stdout.log` and `stderr.log`.** `stdout.log` is the driver's input, read
|
||||
from the byte offset in `process.json`; removing either by hand while the
|
||||
|
||||
Reference in new issue
Block a user