Fetch the transcript instead of replaying it one event at a time
**The five seconds of loading top-down.** Opening a session subscribed to the event stream from sequence zero, so the backlog arrived as one SSE frame per event -- 864 of them for an imported conversation, rendered as they landed. That is not a slow list; it is a conversation being replayed at network speed, and it looks like loading from the top because it is. The newest page now comes as one request, and the stream starts from where that page ended, carrying live events only -- which is what a stream is good at. Scrolling back fetches the page before it, so history costs something only when somebody actually reads it. 80 events instead of 864, and the first frame is already the end of the conversation. I had called this fixed after anchoring the list at the bottom, on the strength of an emulator on the same machine as the server. That test could not have shown the problem: the whole backlog arrived in one frame's worth of time over loopback. Iris's phone, over a tunnel, took five seconds. **Send disappearing while running.** It was never conditional -- the row simply ran out of width. A Row hands out intrinsic widths in order and clips the overflow, so when Stop appeared the pickers I had added pushed Send off the screen: the app's central control, gone at exactly the moment the app is most in use. The settings now share what is left after the actions have taken what they need. While a turn is in flight the button says **Queue**, because that is what sending then does -- the message is injected at the next tool boundary rather than starting a turn of its own. The backend has always done this; the button was describing something else. **And the model picker no longer dismisses the keyboard**, which it did by taking focus. Changing the model mid-sentence is an aside, not a departure from what you were typing. Verified on the 864-event import: at the newest message within a second, history paging back continuously past the first page, and Stop beside Queue while running.
This commit is contained in:
1 parent
ba25a5cacf
commit
dcb158ee44
4 files changed
+203
-22
No files matched your search
@@ -64,6 +64,7 @@ pub fn router(manager: Arc<SessionManager>) -> Router {
|
||||
.route("/sessions", get(list_sessions).post(spawn_session))
|
||||
.route("/sessions/{id}", delete(delete_session))
|
||||
.route("/sessions/{id}/events", get(events))
|
||||
.route("/sessions/{id}/transcript", get(transcript))
|
||||
.route("/sessions/{id}/message", post(message))
|
||||
.route("/sessions/{id}/answer", post(answer))
|
||||
.route("/sessions/{id}/interrupt", post(interrupt))
|
||||
@@ -720,6 +721,41 @@ struct EventsQuery {
|
||||
/// cursor from the transcript, then live events as they happen. An SSE
|
||||
/// auto-reconnect sends the last event id it saw as `Last-Event-ID`, which
|
||||
/// takes precedence over `after` -- same cursor, native mechanism.
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct TranscriptQuery {
|
||||
/// Page backwards from this sequence number; absent means the newest.
|
||||
#[serde(default)]
|
||||
before: Option<u64>,
|
||||
#[serde(default = "default_window")]
|
||||
limit: usize,
|
||||
}
|
||||
|
||||
fn default_window() -> usize {
|
||||
80
|
||||
}
|
||||
|
||||
/// A page of a session's transcript, newest first to open with.
|
||||
///
|
||||
/// One request rather than one stream frame per event. The SSE stream
|
||||
/// stays as it is and remains the right shape for *live* events, which
|
||||
/// arrive one at a time by nature; it is only the backlog that has to
|
||||
/// stop pretending to be live.
|
||||
async fn transcript(
|
||||
State(manager): State<Arc<SessionManager>>,
|
||||
UrlPath(id): UrlPath<String>,
|
||||
Query(query): Query<TranscriptQuery>,
|
||||
) -> Result<axum::Json<Vec<crate::session::transcript::SeqEvent>>, ApiError> {
|
||||
let session = lookup(&manager, &id)?;
|
||||
let events = crate::session::transcript::read_window(
|
||||
session.transcript_path(),
|
||||
query.before,
|
||||
query.limit,
|
||||
)
|
||||
.map_err(bad_request)?;
|
||||
Ok(axum::Json(events))
|
||||
}
|
||||
|
||||
async fn events(
|
||||
State(manager): State<Arc<SessionManager>>,
|
||||
UrlPath(id): UrlPath<String>,
|
||||
|
||||
Reference in new issue
Block a user