Conversation
The redo command looked for the next user message with `id > revert.messageID`. Message IDs only sort chronologically when they were minted in order, so on a session whose IDs are out of chronological order the lookup can return a message that sits BEFORE the revert boundary, moving the boundary backwards over history that was never undone. The next turn then commits that revert and the messages are deleted. Use the position of the revert message in the (chronologically ordered) list instead, matching the web client's redo and the other revert paths converted in anomalyco#40994.
No blocking issues found. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #43034
Type of change
What does this PR do?
The TUI redo command picked its target with
x.id > revert.messageID. The messagelist is ordered by
time.created(#40994), so on a session whose IDs are not inchronological order that lookup can return a message before the revert boundary.
Redo then stages the revert further back than it already was, and the next turn
commits it — the messages in between are deleted.
The fix looks the revert message up by position and takes the next user message
after it, which is what the web client's redo already does
(
packages/app/src/pages/session/use-session-commands.tsx) and what/undoandrevertRevertedMessagesin the same TUI file were converted to in #40994. If therevert message isn't in the loaded list we bail instead of guessing, same as the
web client.
Three lines, no behaviour change on sessions with in-order IDs: there, the first
user message with a higher ID is the next one positionally.
How did you verify your code works?
bun run --cwd packages/tui typecheck— clean.bun testinpackages/tui— 193 pass, 1 skip, 0 fail (same as before the change).relative to
time.created: the old predicate returns index 0 (before theboundary), the new one returns the next user message after the boundary, or
nothing when the boundary is already the last user message (so redo clears the
revert, which is correct).
bunx oxlintandbunx prettier --checkon the touched file: no new warnings.I did not add a test: the redo command lives inside the
Session()routecomponent, and there is no fixture in
packages/tui/testthat mounts a route(the existing tests cover the sync store, utils and exported pure helpers). #40994
added tests for the same reason only where the code was already reachable. Happy to
add one if you'd like the selection pulled into a testable helper.
Screenshots / recordings
Not a visual change.
Checklist