Repository navigation
Inbox: resume an ended session from your saved answer - #4186
Merged
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.
POST /api/inbox/messages/:id/resume puts a launch that adopts the ended session on the saved reply, with no placeholder, so the reply stays that session's to deliver. The start runs as the contributor's resume does; a second press never starts a second process, and a press after a failed start starts once more. No run line speaks for it until the session took it.
Where the ended session's agent on the thread's machine resumes a session it never started (OpenCode), the saved line is a card with Resume beside Send to another session; the words stay. Busy from the press until the session took the reply; a failed start says the run line's words and both buttons work again; a press held for a linked computer shows its status. The reply list's Resume row is no longer offered. Thread.tsx shrinks by three lines (two name helpers move out) and its ceiling follows.
…ake back Until the resumed session took the reply, the reply is still only saved: a move or a take-back drops the resume and wins, and the start then writes nothing back (a session it started only for that reply is stopped). A failed resume leaves the reply as it was, with Take back. Two presses at once start once; the second is a quiet no-op. A press after a failed start is checked again (the switch, the session back by itself), and the write re-checks the reply. The folder is an existing project, never one made from the agent's words. No run line until the session took the reply. Where the process list can't be read, Resume is not offered and the route refuses. A request's to.launch.resume is ignored on a reply and on New message, as any field to.launch does not know; only the saved line's route builds a resume, from the saved reply's own session.
The words keep Take back at their end, as the plain line has them; under them one row holds Resume (where the agent can resume) and Send to another session, side by side. On a phone their icons go and only a long agent name is cut, never the word Resume. The card no longer switches from the plain line when the launch block loads, and only one look remains. One thing at a time on a saved reply: while Resume starts, Send to another session and Take back are busy, and while a move or a take-back is on its way, Resume is. A failed resume leaves Take back as it was. The button and the failure line name the agent the same way. The thread's header no longer says 'You resumed'; a resume not taken yet is no launch in the window. The reply list's unused Resume row is gone (its row title, the recipient branches and the recipient list's resume).
…device door Another site's POST is refused with 403 before the route and nothing is written; the window's POST reaches the route. The device door takes it from a linked machine's window only, never a phone, and a linked machine's press counts as a start there.
…fter it arrived, the ordinary run line once started - A respawn check queued for a reply whose Resume a move or a take-back dropped finds no launch and does nothing. - A Resume that failed goes once the reply is delivered (the session came back by itself). - Once the start succeeded, the thread shows the ordinary run line of a launch (Starting, not connected, Stop); once the session took the answer, it reads as delivered at once. - Delete of a resumed session stops the Inbox's own process and never removes the session. - Docs say what the code does.
…ox-resume-ended-session
- inboxSavedResume no longer sits between isInboxNote's doc comment and isInboxNote. - An agent with no host here is named by its display name in the refusal. - The log says taken back or moved, as it was.
…ords' line; no Delete for a resumed session The button row wraps inside the card when Resume and Send to another session do not fit side by side; only the agent's name in Resume shrinks with an ellipsis (the full label is its title) and Send is never cut. The card has no width cap of its own, so Take back stays at the end of the words where they fit, as on main. A session the Inbox only resumed (adopted_session) is treated as one it did not start: the thread's menu and the sidebar agent offer no Delete session for it. The agents list carries launch.adopted for the sidebar (Inbox only); the mobile contract is regenerated for the new field.
…n; a later reply's restart never runs beside the session reopened elsewhere A press of Resume after a start that failed is that session's first real start, as Try again already treats one. A reply's restart or Try again on a resumed session now checks first that no process runs it elsewhere, and fails with the same line as the first start when one does.
The check for a process running the session elsewhere now applies to a resumed session's restart in the background only. In Rex the Inbox's own tab can't be told apart from another process, and Rex's own check before every restart there already holds the restart while any process runs the session, with its own words.
…esume while it starts; a restart stopped during its process check starts nothing
…ed-session # Conflicts: # tests/inbox-size-ceilings.json
…ed-session # Conflicts: # apps/mobile/contract/generated/swift/Wire.swift # apps/mobile/contract/parity/ledger.json # apps/mobile/contract/parity/surface.json # apps/mobile/contract/schema/wire.schema.json # packages/core/inbox-types.ts # packages/inbox/agents/AgentsSection.tsx # packages/inbox/components/Thread.tsx # packages/server/inbox-agents-list.ts # packages/server/inbox-launch.ts # packages/shared/inbox/store.ts
backnotprop
marked this pull request as ready for review
November 29, 2026 00:21
This was referenced Nov 29, 2026
DuongCoder04
pushed a commit
to DuongCoder04/plannotator
that referenced
this pull request
Nov 29, 2026
Move the marker from f00a501 to b74c769 and list the additive ./inbox-* changes core 0.25.37 carries from backnotprop#4161, backnotprop#4172, backnotprop#4194, backnotprop#3595, backnotprop#4186, backnotprop#3676 and backnotprop#3598.
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.
What a person meets today
They answer an agent's question in the Inbox after that agent's session has ended. Under their answer the thread says "Saved for OpenCode. That session has ended; it gets this only if it's resumed." in one grey line, with Take back at its end and "Send to another session" under it. Nothing in the Inbox brings the same agent back.
What changes
Hosts
ses_id withopencode2 serve.ps), the Inbox can't tell whether the session is running somewhere else, so it offers no Resume there.Built on #3937
This builds on #3937 ("Inbox: resume an ended OpenCode session from the reply box"). Its four commits are merged into this branch with their authorship kept:
LaunchHost.adopts,adopted_sessionon a launch, the two-writer guard (adoptHeld), the resume inrun, and the run line re-read fix. The reply list's "Resume this OpenCode session" row from that PR is not offered: the owner chose the button under the saved answer. Later commits here remove that row's leftover window code and theto.launch.resumerequest field.How it works
POST /api/inbox/messages/:id/resume(packages/server/inbox-resume-saved.ts, Bun only). It puts a launch that adopts the ended session on the saved reply, with no placeholder, so the reply stays that session's to deliver. The route builds the resume itself from the saved reply's own session (launch.resumeTarget). Refused before anything is written:window_only,launch_off,session_still_live,validation_error(an agent that can't resume a session it did not start, or no process list), andprepare's refusals.inboxSavedResumeinpackages/core/inbox-types.ts). Send to another session (store.readdressMessage) and Take back (store.takeBack) drop that launch and win. When the start then finishes it writes nothing, and a session it started in the background only for that reply is stopped. The answer goes to exactly one session, and the record matches the delivery.store.resumeSavedLaunchchecks, at the moment it writes, that the reply is still saved, not moved, not taken back and not delivered. Two presses at the same moment start once; the second is a quiet no-op. A press after a failed start is checked again (starting agents still on, the session not back by itself).to.launch.resumeon a reply or on New message is ignored, as main ignores any fieldto.launchdoes not know.setand is instartsAgentThere. On the device door it ismachineOnly, as Try again is.packages/shared/inbox/store.tsis shared, but the Pi server has no Inbox, and nothing Pi reads changes.Thread.tsxstays at 5608 lines (main: 5611). The mobile contract is in step.Tests
packages/server/inbox-resume-saved.test.ts(20): with two answers saved, moving the last one while its Resume starts, or after it failed, throws nothing and the moved answer goes to the chosen session once; a failed start that the session then answers by itself leaves no failure; Delete of a resumed session never removes it; once started, the ordinary run line, including "not connected" and Stop; once taken, delivered at once, with no "Starting" line. Earlier tests: the same session under its id, delivered once; two presses and a second answer while starting give one start; a failure keeps the answer saved and a press starts once more; nothing for a host that can't adopt, a live session, or a linked machine's bare call; the device door's allowlist; Send to another session during a start and after a failed one; Take back during a start; a failed start leaves Take back; two presses at once; a press after a failed start re-checked; the folder never a new project; no process list gives no Resume and a refusal; a session still running elsewhere is never started twice. With the server change reversed, 9 of the new tests fail.packages/server/inbox-resume-saved-route.test.ts(1, starts an Inbox, so CI runs it): through the real handler, a cross-origin POST gets 403 and nothing is written; the window's POST reaches the route.packages/server/inbox-reply-launch.test.ts(13):to.launch.resumeis ignored on a reply and on New message (both fail with the change reversed).packages/inbox/savedLineResume.test.tsx(4, DOM): the card for every agent, with Take back at the end of the sentence and Resume only where it works; busy while it starts, with Send and Take back busy too; the header unchanged; a failed start with Take back and both buttons usable. All 4 fail with the window change reversed.packages/inbox/heldControls.test.tsx(31, DOM): held for Laptop; refused there; a held move and a take-back keep Resume busy. 4 fail with the window change reversed.replyStart.test.ts,endedSession.test.tsx,takeBack.test.tsx,heldTakeBack.test.tsx,sendAlwaysEnds.test.tsx,replyBoxParity.test.tsx,inbox-outbox.test.ts,tests/inbox-api-table.test.ts,tests/inbox-structure.test.ts, the DOM allowlist, and tsc for core, shared, server and inbox.Not verified
Open: the Delete confirm for a resumed session still reads "It stops, and its session files are removed." Nothing of the session is removed; the wording waits on a decision.
No real OpenCode was run for this PR. The contributor checked Inbox: resume an ended OpenCode session from the reply box #3937's resume by hand against OpenCode 2.4.0.
New pictures of this revision are still to be made.
The resumed session's first wake may still carry the "launched" lines of a new launch (as in Inbox: resume an ended OpenCode session from the reply box #3937). This was not checked against a real agent.