Skip to content

Inbox: resume an ended session from your saved answer - #4186

Merged
backnotprop merged 22 commits into
mainfrom
feat/inbox-resume-ended-session
Nov 29, 2026
Merged

backnotprop merged 22 commits into
mainfrom
feat/inbox-resume-ended-session

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

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

  • The saved line for an ended session is now one quiet card, the same for every agent (the icon and card background the Inbox already uses for a reply that can't go in sooner). The sentence is word for word the same, and Take back stays at the end of it, where it is today. Under it, one row: Resume OpenCode (only where that agent can resume the session) and the existing Send to another session, side by side. The card does not change shape when the launch information loads.
  • On a phone the two buttons stay on one row with their icons dropped. Only a long agent name is shortened with "…"; the word Resume never is.
  • One press brings the same session back under the same id, with its memory, and it takes the answer that was waiting. Any answer written while it starts goes after it, once, in order.
  • One thing at a time: while Resume starts, Send to another session and Take back are busy (their usual disabled look), and while a move or a take-back is on its way, Resume is busy.
  • The busy button is the only sign while it starts: no run line and no new header line. Once the start has succeeded (the session exists), the thread shows the ordinary run line the Inbox shows for any agent it started, with Stop: "Starting…" until it connects, and "Started, but not connected to the Inbox…" if it never does. Once the session took the answer, the thread and the list row show "Delivered to OpenCode" at once, as for any delivered reply.
  • If the start failed because the session was still running somewhere else, and that session then takes the answer by itself, the failure goes away: the answer arrived, so no "didn't start" line, no "not delivered" row.
  • Delete on a resumed session stops the Inbox's own process for it and removes the Inbox's own log folder, but never asks the agent to remove the session: it is the person's own session.
  • A start that fails leaves the answer exactly as before the press: still saved for that session, Take back available, every button usable. It shows the run line's existing sentence under the buttons ("OpenCode didn't start. Your message is kept."). Pressing Resume again starts once more.
  • A thread on a linked computer: the press goes to that computer through the outbox, with the same held status as Send to another session.
  • Send to another session works as before.

Hosts

  • OpenCode: the button shows, on a computer where the process list can be read. Its host resumes any ses_ id with opencode2 serve.
  • Claude Code, Pi, Codex and the rest: no button. The card is the same, with Send to another session alone.
  • Where the process list can't be read (no 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_session on a launch, the two-writer guard (adoptHeld), the resume in run, 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 the to.launch.resume request 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), and prepare's refusals.
  • The folder is the one the window shows: the session's own folder when it is already a project, else the thread's project. The route never makes a project.
  • Until the start took, the reply is still only saved (inboxSavedResume in packages/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.resumeSavedLaunch checks, 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).
  • No request field names a session to resume: to.launch.resume on a reply or on New message is ignored, as main ignores any field to.launch does not know.
  • The outbox route is set and is in startsAgentThere. On the device door it is machineOnly, as Try again is.
  • packages/shared/inbox/store.ts is shared, but the Pi server has no Inbox, and nothing Pi reads changes.
  • Thread.tsx stays 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.resume is 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.
  • Also run: 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

oorestisime and others added 7 commits November 23, 2026 16:04
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.
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 28, 2026
…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.
- 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
backnotprop marked this pull request as ready for review November 29, 2026 00:21
@backnotprop
backnotprop merged commit c3a077d into main Nov 29, 2026
73 of 75 checks passed
DuongCoder04 pushed a commit to DuongCoder04/plannotator that referenced this pull request Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run the full browser suite (Inbox window e2e) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants