Make a command a thing the app knows, and hold it until it can run
Typing "/" now suggests what this app understands -- `/compact` and `/rename <name>` -- with a line each about what they do, and anything else beginning with a slash is passed to whatever runs the session, because a dialect's own vocabulary grows without this list. None of them are messages, and that is the substance of the change. A line written into a running turn is read by the *model*, so a command sent mid-turn either does nothing or arrives as text somebody has to puzzle over. They now wait for the turn to end. The waiting is done once for every provider, in the pump that already watches every event for the boundary, rather than in each driver where a new provider could get it wrong by leaving it out. Waiting is a state, so it is on screen: the command sits at the reader's end of the conversation in blue, with a spinner and "waiting for this turn to end", and becomes an ordinary blue row when it goes. Blue because these are about the session rather than about the task -- the same blue a compaction already used, which is now one colour with one name rather than two. Renaming from the settings screen sends exactly this, so it waits and draws the same way. The name itself is not held: it is this server's own datum, so the list and the header change at once and only telling the session waits. Echo grew the same split, which is where the bug in it showed: its commands are its messages, so running one announced a `MessageTaken` as well, and the same line drew twice -- once blue, once purple. A command owes no announcement; the manager has already recorded that it was sent. Watched rather than reasoned about: `/compact` during a 25 second turn held with its bubble up, went out when the turn ended, and the compaction that followed reported what it recovered.
This commit is contained in:
1 parent
bebaae7a94
commit
749b2db287
13 files changed
+678
-93
No files matched your search
@@ -561,6 +561,23 @@ fun setSessionPermissionMode(settings: ServerSettings, sessionId: String, mode:
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the session to run one of its own commands.
|
||||
*
|
||||
* Sent as typed. The server turns the two it understands into its own operations -- a compaction, a
|
||||
* rename, which is also what the settings screen sends -- and passes anything else to whatever runs
|
||||
* the session. Either way it waits for the turn to end if one is in flight, and says so on the
|
||||
* event stream, which is where the waiting bubble comes from.
|
||||
*/
|
||||
fun runCommand(settings: ServerSettings, sessionId: String, text: String) {
|
||||
requestFromServer(
|
||||
settings,
|
||||
"/sessions/$sessionId/command",
|
||||
method = "POST",
|
||||
jsonBody = JSONObject().put("text", text).toString(),
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the session to summarise its own history and carry on from the summary.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user