Repository navigation
Conversation
There was a problem hiding this comment.
The fix works for the case it targets. I reproduced it in the TUI with the simulated model: a prompt with ID msg_sch_0001 came before the revert boundary. After the commit, dev dropped that prompt and its reply even though the server kept them. With this PR the TUI matches the server (screenshots below). Unit tests for util, client, app (src/session) and the TUI pass. App and client type-check clean, and the TUI has the same errors as base.
Public API is unchanged. The client now also calls the existing session.message.get endpoint.
One case should change before merge. A boundary that is not loaded is always treated as older than everything loaded. When the client already holds the whole history, a missing boundary means it is already gone: a commit that a sync already applied, or a stale revert pointer like #63282. A staged revert in that state now blanks the timeline for good (base showed most of it). A late session.revert.committed wipes the transcript and reloads it. Details are in the inline comments.
| ) { | ||
| if (!boundary) return messages | ||
| const index = messages.findIndex((message) => message.id === boundary) | ||
| return index === -1 ? [] : messages.slice(0, index) |
There was a problem hiding this comment.
A boundary that is not loaded is only older than everything when older pages exist. If the whole history is loaded, the boundary has already been deleted. Two ways that happens: a commit that a sync already applied, or a leftover revert.messageID like #63282. Returning [] then hides the whole transcript in both the app and the TUI with no way out. The base hid only the messages with a higher ID. Could callers pass whether older pages exist (the client already tracks this) and treat a missing boundary as no boundary when there are none? #57581 handles it that way.
| // do not sort in that order. A boundary that is not loaded is older than every loaded message. | ||
| if (loaded) | ||
| message.update(sessionID, (draft, index) => { | ||
| for (const item of draft.splice(index.get(event.data.to) ?? 0)) { |
There was a problem hiding this comment.
Same case here. With the whole history loaded and no event.data.to in the index, ?? 0 removes every loaded message and reloads the transcript. That happens when the event arrives after a sync that already applied the commit, e.g. on reconnect. The reload brings the messages back, but the timeline flashes blank. When no older page exists, a missing boundary should cut nothing.
There was a problem hiding this comment.
The new commit leaves composer/todos.ts as it is on dev and only adds blank lines to a test. That is fine, and the TUI fix I verified earlier is unchanged. App tests pass and tsc -b is clean. Public API is unchanged.
Both earlier threads are still open. When the revert boundary is not loaded, beforeRevert and session.revert.committed still treat it as older than every loaded message, even when the whole history is loaded.
There was a problem hiding this comment.
Both earlier points are fixed. beforeRevert and session.revert.committed now treat a boundary that is not loaded as older than everything only while older pages remain. With the whole transcript loaded, nothing is hidden or cut. I re-ran the TUI repro on the new head and the scheduled prompt and its reply still show after the commit. Util, client, app and TUI tests pass, and app and client type-check clean. Public API is unchanged. Nothing new to flag.


Problem
core/src/session/projector.ts).msg_sch_…), automations (msg_aut_…) and watch notices (msg_watch_…) sort after every other message.session.revert.committedat "Rename the helper"dev: the earlier scheduled prompt and its reply are gone tooHow common
42 sessions (four long ones whole, and the newest 1,000 messages of the 38 most recent): 30,067 messages, 1,376 prompts.
msg_watch_…is in 26 of the 42 sessions,msg_aut_…in 4,msg_sch_…in 1.Fix
Order comes from a message's place in the transcript, never from the text of its ID.
flowchart TD A[session.revert.committed] --> B{Is the boundary loaded?} B -- yes --> C[Remove it and every message after it, by place] B -- no --> D[Every loaded message came after it: remove them all] C --> E{Is a message left?} D --> E E -- yes --> F[Done: the cursor names a kept message] E -- no --> G[Clear the cursor, read the newest page again] C --> H{Was an input waiting?} D --> H H -- yes --> I[Drop the inputs whose rows went, read the inbox again]session.message.get) before history pages toward it. Before, the ID decided, so a link to an older scheduled prompt was dropped.client/src/solid/data.ts, committed revertid >= boundaryclient/src/solid/data.ts, waiting inputsid < boundaryapp/src/session/timeline/controller-projection.tsid < boundaryapp/src/session/session-domain.tsid < boundaryapp/src/session/revert-machine.ts, 3 placesid < boundaryapp/src/session/commands/dialog-jump-to-message.tsxid < boundaryapp/src/session/timeline/cursor-machine.tstarget >= boundary,target >= oldest loadedapp/src/session/timeline/cursor.tslast > previoustui/src/routes/session/rows.tsid < boundarytui/src/util/todo.ts,tui/src/routes/session/index.tsxcli-rs/crates/store(messages.rs,sessions.rs) has the same two comparisons asdata.ts.parity/deviations/O89-revert-order.mdrecords the difference.app/src/session/composer/todos.tsgoes by place, but still takes an unloaded boundary as no boundary. A change to that file must first rewrite its parser for the lint.Before and after
A real page of 40 messages whose earliest message is a scheduled prompt; the revert is at message 29, so the server keeps 28. The events were delivered to the page only; no revert ran on the session. 3 runs on each timeline:
devTests
e2e/regression/timeline-stream.spec.ts, "revert": a staged and a committed revert on a transcript whose IDs do not sort in its order, on both timelines. Ondevthe staged case shows["msg_0002", "msg_0004"]where["msg_sch_0001", "msg_0002"]belong, and the committed case shows[].packages/client/test/solid-revert.test.ts: removal by place, a boundary that is not loaded or is the oldest loaded message, and waiting inputs.packages/util/src/session-revert.test.ts, and cases in the tests of each app module in the table.No flag: a fix.
Added by the opencode bot (AI-generated).
Fixes #61189
Related: #63282, #57581