Repository navigation
Description
Summary
In OpenCode v2.4.2 TUI, pressing Esc (double-Esc) to interrupt a running session sometimes deletes not just the latest prompt, but a large portion of prior messages, ruining the session. This started happening after v2.4.2 introduced automatic revert.stage + revert.commit on interrupt (#65505).
Environment
- opencode version: 2.4.2
- Client: TUI
- Model and provider: Observed across multiple sessions (not model-specific)
- OS: Linux 7.0.0-44-generic suggestion: Permission Required -> Approve / Request Changed / Deny #44-Ubuntu SMP PREEMPT_DYNAMIC x86_64 GNU/Linux
- Terminal: TERM_PROGRAM=tmux, TERM=tmux-256color, COLORTERM=truecolor
- Shell: /bin/bash
- Install/channel: latest (release)
- Active plugins:
~/.config/opencode/plugins/alice-and-bot/index.js(no terminal plugins in~/.config/opencode/cli.json; no local.opencode/plugins/)
Reproduction
- Run a multi-turn session in the TUI on v2.4.2.
- While the session is running (for example, after steering/queuing a prompt while an earlier turn is still producing messages, or interrupting during active work with an empty composer), press
Esctwice to interrupt. - Observe
session.revert.stage (files=false)followed immediately bysession.revert.commitfiring on the server. - Sometimes only the last prompt is removed, and other times many messages are deleted from the session with no way to
/redo.
Expected Behavior
Pressing Esc during a running process should safely interrupt execution without deleting earlier conversation messages or permanently destroying session history.
Actual Behavior
Pressing Esc during active processes triggers an immediate committed revert (session.revert.stage with files=false + session.revert.commit), which sometimes deletes just the last message and in several cases deleted many messages and ruined the session. Because the revert is committed immediately, there is no staged revert / /redo recovery.
Additional Context
Relevant opencode.log excerpt
Repeated session.revert.stage (files=false) + session.revert.commit pairs triggered by Esc interrupts on v2.4.2 (the files=false path introduced in #65505):
timestamp=2026-11-26T11:36:53.389Z level=INFO run=38fe594a message=session.revert.stage sessionID=ses_de85b1fadffeezi7dYbG80YYYC messageID=msg_217a4e057001dRtEW3xHrKdgex files=false http.span=1 role=server
timestamp=2026-11-26T11:36:53.393Z level=INFO run=38fe594a message=session.revert.commit sessionID=ses_de85b1fadffeezi7dYbG80YYYC http.span=1 role=server
timestamp=2026-11-26T13:51:06.788Z level=INFO run=38fe594a message=session.revert.stage sessionID=ses_deaab203cffevKIcxpXHmT5dIg messageID=msg_2181fbbcc001D7ku86hD169be5 files=false http.span=1 role=server
timestamp=2026-11-26T13:51:06.790Z level=INFO run=38fe594a message=session.revert.commit sessionID=ses_deaab203cffevKIcxpXHmT5dIg http.span=0 role=server
timestamp=2026-11-27T11:27:27.880Z level=INFO run=38fe594a message=session.revert.stage sessionID=ses_de34ee8ddffeL562xAY9oo6NRc messageID=msg_21cc28077001R1Pzo5pTneGL6v files=false http.span=1 role=server
timestamp=2026-11-27T11:27:27.884Z level=INFO run=38fe594a message=session.revert.commit sessionID=ses_de34ee8ddffeL562xAY9oo6NRc http.span=1 role=server
timestamp=2026-11-27T13:40:00.083Z level=INFO run=38fe594a message=session.revert.stage sessionID=ses_de2f3756bffe80E9QQ3E5XtTpQ messageID=msg_21d3bd4bf001Z7hvvBtMGyLosc files=false http.span=2 role=server
timestamp=2026-11-27T13:40:00.097Z level=INFO run=38fe594a message=session.revert.commit sessionID=ses_de2f3756bffe80E9QQ3E5XtTpQ http.span=0 role=server
timestamp=2026-11-27T14:21:31.212Z level=INFO run=38fe594a message=session.revert.stage sessionID=ses_deb0f4baeffeHQQi2kIslSYaPk messageID=msg_21d61cff9001m9SGAi6m1PpF2a files=false http.span=1 role=server
timestamp=2026-11-27T14:21:31.215Z level=INFO run=38fe594a message=session.revert.commit sessionID=ses_deb0f4baeffeHQQi2kIslSYaPk http.span=0 role=server
Possible root causes spotted in v2.4.2
- ID string comparison in
session.revert.committed(packages/client/src/solid/data.ts):session.inbox.deliveredmoves a delivered queued/steered user message to the end ofdraftwhile keeping its earlier admissionid(which sorts before assistant messages produced while it waited).session.revert.committedthen splices usingdraft.findIndex((item) => item.id >= event.data.to)instead of the boundary's position (index.get(event.data.to)), dropping every message in between from the client store. (Related open PR: fix(app): order messages by position, not by ID string #57581.)- Once the client message list is truncated, a subsequent
Escor/undoselects an earlier user message fromdata.session.message.list(sessionID)and commits a server-side revert to that earlier boundary.
- Unrecoverable auto-commit in
packages/tui/src/component/prompt/index.tsx(feat: undo when interrupting before the model answers #65505):interrupt()immediately callsrevert.stage(..., files: false)+revert.commit()with no/redoand no way to disable it.- Its
answeredcheck inspects client-sidedata.session.message.list(sessionID)right aftersession.wait()(potential race before final SSE deltas arrive) and does not account for non-user/non-assistant message types such asskill.
Frequency
Intermittent (multi-message deletion happened a couple of times since updating to v2.4.2; single-message take-back happens frequently on Esc).
Activity
opencodejr commentedon Nov 27, 2026
Thanks for the detailed report and the logs. I couldn't reproduce the multi-message loss yet.
On 2.4.2 I tried this in the TUI with a simulated model:
Only the second prompt was taken back and put back in the composer. The first prompt and its command result stayed, both in that TUI and in a second TUI that loaded the session fresh from the server. That is the take-back working as #65505 intended. I couldn't produce the message ordering that the ID-string comparison in
session.revert.committedwould need to cut more than that.A few things would help narrow it down:
alice-and-botplugin add messages to the session (for example synthetic messages with its ownmsg_...IDs)? A comment on fix(app): order messages by position, not by ID string #57581 reports that plugin-made message IDs trigger this kind of client-side cut.msg_21d3bd4bf001Z7hvvBtMGyLosc) would help a lot.Related:
session.revert.committedopencodejr commentedon Nov 27, 2026
We haven't heard back on the questions above, so I'm closing this issue for now.
I tried this on 2.4.2: a prompt steered in while a turn was running, then Esc pressed twice with an empty composer. Only that last prompt was taken back. I couldn't reproduce earlier messages being lost, and without your answers I can't narrow down what is different in your sessions. The questions were whether the prompt was steered or queued, whether
alice-and-botadds messages, and whether the messages come back after you reopen the session.If it happens again, please send those details. The ordered message IDs and types around the revert boundary would help most. The open PR #57581 changes the code that decides which messages a committed revert removes, so it is worth watching too.
Replying here reopens this issue.
Guembri01 commentedon Nov 27, 2026
Fixed root cause 1 from your analysis, on branch
revert-transcript-order(4f7c4d9-ish head, pushed).You were right about the scan.
session.revert.committeddid:but
session.inbox.deliveredmoves a steered prompt to the end of the transcript and keeps the id it was admitted with, so the transcript can hold a later-id assistant turn before an earlier-id prompt. A revert at that prompt then started at the assistant turn in front of it and removed it too — the client list loses messages the server never reverted. From there the next interrupt takes the last user message of the shortened list as its boundary, which is the multi-message revert you saw.It now splices at the boundary's position from the same index the other handlers use, and leaves the list alone when the boundary is not loaded.
New test in
packages/client/test/solid-revert-order.test.tsbuilds exactly that state with events (enqueued→step.started→delivered) and asserts a committed revert at the steered prompt leaves the assistant turn. Withdata.tsreverted it fails (list empty, both removed); with the change it passes.packages/clientis 290 pass,packages/tuidata.test.tsx50 pass, typecheck and oxlint clean.I did not touch root cause 2:
interrupt()committing instead of leaving a staged revert is the behaviour #65505 chose, and changing that is a product decision. This removes the client-side truncation that made the take-back over-reach.PR creation is returning 404 for this account right now, so it waits as a branch with the body written.
4rt3mi5 commentedon Nov 30, 2026
Answers to the three questions above, from a case on v2.4.3 (TUI, Ubuntu 24.04 / WSL2) where the transcript lost 109 messages after an Esc interrupt while the server kept all of them.
Was the prompt steered or queued? Did the earlier turn involve tool calls?
The earlier turn had finished normally (
idle, outcomesucceeded) after many tool calls and two subagents. The prompt that got taken back was sent after that, as its own turn. I pressed Esc with an empty composer about two minutes later, while the model was still thinking. No shell command had run in that turn (no output files were written, and the revert reportedfiles=false), so the take-back itself was the intended #65505 behaviour. The damage is entirely the client-side cut.Does a plugin add messages with its own
msg_…IDs?Yes.
oh-my-opencode-sliminjects synthetic<subagent-update …>notices whose IDs look likemsg_omos_7a3e6130-3831-463d-91f0-e8aaa2905c77(UUID suffix,metadata: {"oh-my-opencode-slim.internalInitiator": true}). They sort after every time-basedmsg_22…ID.Are the missing messages back after reopening the session?
Yes. They never left the server: the rows were still in
session_message, andGET /api/session/<id>/messagestill returned them. After closing and reopening the TUI, all 109 messages were back, and the log shows no further revert.Ordered IDs around the boundary (local time, UTC+8):
msg_22cf727ab001SP3f72HKKLCcRMmsg_omos_7a3e6130-3831-463d-91f0-e8aaa2905c77msg_22d7c223d001PomlRcZe3H3hV0msg_22d7e035c001JvyuhemLKvk5yQLog:
After this, the TUI showed the transcript ending at seq 6597, right before the first
msg_omos_…in the loaded list (the session had been compacted at 09:43, so the list starts after that). That is exactly wherefindIndex((R) => R.id >= to)lands when the boundary ismsg_22d7e035…and amsg_omos_…message sits earlier in the list. The boundary message is gone from the DB as intended; seq 6600–7644 are all still there.This is still the code in the v2.4.3 binary and on
dev(packages/client/src/solid/data.ts):Plugin-supplied IDs like
msg_omos_…are one more family of IDs that sort out of transcript order, next tomsg_aut_…/msg_sch_…. Comparingseqas in #66888 (or position as in #66168 / #57581) covers it.Worth having in this issue too: with the client list cut like this, the next Esc or
/undopicks the last visible user message (22:55 in my case) as the boundary and would commit a server-side revert of three hours of real history. That is probably the "multiple messages" case in the title.