Repository navigation
Inbox: resume an ended OpenCode session from the reply box - #3937
Merged
backnotprop merged 4 commits intoNov 29, 2026
Merged
Conversation
A reply to an OpenCode session that ended could only wait for the
person to reopen it in a terminal, or go to a brand-new session. The
Inbox already resumes sessions it launched itself; one the person
started in a terminal had no launch record, so nothing resumed it.
When the session asked has ended and its agent on the thread's machine
can resume a session the Inbox never started (LaunchHost.adopts; OpenCode,
whose `opencode2 serve` takes any ses_ id), the recipient list offers
"Resume this OpenCode session" above the start row. Picked, Send posts
`to: { launch: { agent, project_id, resume } }` through the existing
reply-launch path. The reply's launch records `adopted_session`, and its
start resumes that session (host.resume, or Rex's resume command) instead
of making one, then settles the reply on the same session: a plain wake,
the session keeps the thread, and later replies respawn it like any
launch. It never starts while a process still runs that session.
The ended session stays the default; nothing resumes unpicked. An older
machine sends no `adopts`, so it offers no Resume row.
The Resume row keeps its words in the list ("Resume this OpenCode
session"), but once picked the pill, the reply box and the sent line say
the agent's name instead of the row's words. The thread header reads
"You resumed OpenCode in <project>" for a resumed session.
The window read an open thread's run line again ("Starting <agent>…",
"Working") only when the thread's root carried the launch. A reply that
starts a session (the New session row) or resumes one carries the launch
itself, so its line stayed on "Starting…" until a reload. Any message
with a launch now counts.
The reply list's start and Resume rows come from one call in thread/replyStart.ts (replyStartsOf), so Thread.tsx stays at the line ceiling tests/inbox-structure.test.ts holds it to.
Owner
|
Your four commits went in with #4186, with your authorship kept: the resume itself, the two-writer guard and the run-line fix. The one change from this PR is where the person finds it: a "Resume OpenCode" button under the saved answer, in place of a row in the reply list. Thank you; it goes out in 0.29.8. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A reply to an OpenCode session that has ended can now resume that same session from the Inbox, history and all, instead of waiting for the person to reopen it in a terminal or handing the thread to a brand-new session.
The Inbox already restarts sessions it launched itself ("Your reply continues it"). A session the person started in a terminal had no launch record, so nothing ever restarted it, and a reply sat in the Inbox until the person went and resumed it by hand. Picked from the reply's recipient list, the new "Resume this OpenCode session" row (between the ended session and "New OpenCode session", added in 47b10b7) goes through the existing reply-launch path. The reply's launch records
adopted_session, and its start runs the host'sresumeon that session instead ofstart. For OpenCode that isopencode2 servewithPLANNOTATOR_INBOX_LAUNCHED_SESSION, which works on anyses_id. From then on it behaves like any launched session (Stop, Open in Terminal, respawn on the next reply). The ended session stays the default, and nothing resumes unpicked.Checked by hand against real OpenCode 2.4.0: a scratch Inbox from this branch, a terminal-started
opencode2 runsession that posted and exited, a reply with Resume picked. The sameses_id was resumed under the Inbox, took the reply, and answered in the thread.Where review is worth the time:
run()ininbox-launch.ts. The adopted branch passes{ ...launch, session_ref: adopted_session }tohost.resume(or to Rex's resume command) and settles the reply on that same session. Settling on the same session is why the wake is a plain reply (noredirected_from) and the session keeps the thread.adoptHeld). It refuses to start while any process's argv names the session, and also whenpscan't be read, following the Rex resume rule. It can't see a TUI the person opened with plainopencodeand then picked the session in its picker. Such a session would be polling, though, and so wouldn't read as ended.LaunchHost.adopts; only OpenCode implements it. I didn't check whether Claude Code'sclaude respawnor Pi's resume work on a session the Inbox didn't start, so those can follow separately.adopts: true. An older machine never shows it, so its reply-launch never sees aresumeit would drop.Also fixed here, since it showed up on the first try of this: the status line under a reply that started a session stayed on "Starting …" until a reload.
openThreadReads.tsandpanes/shownReads.tstreated a thread as launched only when its first message carried the launch, so a reply-launch's line was never read again. This affected the existing "New … session" row the same way. Now any message with a launch counts (separate commit).e2e: inbox-ended-session.spec.ts