Skip to content

fix(inbox): a refused archive or unarchive puts the session back - #1211

Merged
Hona merged 9 commits into
devfrom
upstream-f/archive-put-back
Nov 25, 2026
Merged

Hona merged 9 commits into
devfrom
upstream-f/archive-put-back

Conversation

@Hona

@Hona Hona commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #1189: a session the server refuses to archive or unarchive goes back where it was.

The fault

Ours shows an archive or an unarchive at once and then asks the server. When the server refused, the toast said so, but the session kept showing as moved for the rest of the run: nothing put it back, and the archived list is read once per run. Official asks the server first and moves the session only when it has answered, so a refused session stays where it is (packages/app/src/session/commands/use-session-commands.tsx:359-391, packages/app/src/shell/titlebar/inbox-model.ts:476-492, recent-sessions.tsx:914).

What changes

The move at once stays, with its Undo toast. A refusal now puts the session back:

  • A refused archive: the session is listed again, its tab is back in its place, and the Undo offer goes with its toast. If the tab was the page shown, the page is on it again; if it was not (the archive came from its card's menu, on Home or on another session's page), the page stays where it is, as official's does, which moves nothing before the server has answered (inbox-model.ts:476-487). The server's refusal shows as a toast, as before.
  • A refused unarchive: the session is filed under Archived again, with the time it was archived at.
  • A write that could not be sent (no connection) is a refusal at once.
  • The refusal's toast is titled Request failed. An archive and an unarchive go as the session's PATCH, which a rename is too, and the toast was titled by the call alone: Failed to rename session. Official's title for both is common.requestFailed (use-session-commands.tsx:367, :383).
  • A move made on top of a refused one (Undo pressed before the server answered) puts nothing back of its own: the session ends where it stood before the refused move.

How

  • apps/desktop/src/session/inbox/moves.rs: one explicit machine for the moves in flight (Moves, Event::Sent / Replied, Effect::PutBack), with what each move changed (Was::Listed { tab }, where TabWas is Absent, Behind or Shown; Was::Archived(at)).
  • apps/desktop/src/session/inbox/model.rs: archive_session and unarchive_session record their move. apps/desktop/src/shell/tabs/actions.rs put_back_closed: a closed tab back at its index without showing it.
  • The archive's answer comes back to the window as the unarchive's already did: crates/opencode-kit/src/client/worker.rs (kind archive), features/session-menu/src/lib.rs and host.rs (on_archive_replied), apps/desktop/src/session/menu.rs.
  • apps/desktop/src/session/composer/undo.rs: withdraw_archived.
  • features/session-menu/src/lib.rs session_write_replied names the toast by the write's kind (toast_wire_error_titled, shown by the existing status_toast::failed_wire).

How it differs from official

  • When the move shows. Official shows it when the server has answered; ours at once, as before this change. On a refusal both end with the session where it was. Waiting for the answer, as official does, is the alternative; it was not taken because ours' other session writes (Delete, with its own Undo) also show at once and put back.

Run

A PR build is of the PR's own head. Both heads named here hold the Rune pin bump #1192.

On 2ca9d2f2f (Windows x64 CI build, run 45645976319; headless, a fixture file and no server, so each write is refused at once as one that could not be sent). Before: #1192's own PR build, head cc991c6505, run 45629508899: dev on the same pin without this change. 11 passes, every exit 0.

  • Archive by the card's menu. After: the card is back among the recent rows at the same place, there is no Archived group, and one toast reads "Not connected to an OpenCode server"; no "Session archived" toast. Before: the card is gone, an Archived group has appeared, the same toast.
  • Archive by the keys, Ctrl+Shift+S on the session's own page. After: the card is back, selected, and the page is that session. Before: the card is under Archived and the page went to another session.
  • Unarchive by the card's menu. After: the card is still under Archived at the same place. Before: it moved up among the recent rows and the Archived group is gone.
  • A fault of this change, seen in that run and fixed in b9b406382. The archive by the menu was pressed on Home. The put-back showed the session; on the before build the page stays Home. The put-back reopened the tab the way Reopen closed tab does, which shows it. It now shows it only when it was the page shown.

On b9b406382, the head that merges (Windows x64 CI build, run 45651897076; the same fixture file, no server; 5 passes, every exit 0; the before passes are those above on cc991c6505). The put-back's three arms:

  • A tab that was behind, archived from Home by its card's menu: the page is still Home, no card is selected, the card is back at its place, no Archived group, the one toast. The fault above is gone.
  • A tab that was behind, archived from another session's page: the page is still that other session; the card is back, not selected; the one toast.
  • The tab that was the page, archived by the keys: its card is back, selected, and the page is that session, as on 2ca9d2f2f.
  • A session with no tab, archived from Home by its card's menu: the card is back, the page is still Home, the one toast.

Not run on any head (each needs a server):

  1. A server that refuses the archive call: the row leaves its group, then comes back; its tab is back; the Undo toast is gone and the refusal's toast shows, titled Request failed.
  2. A server that refuses the unarchive call: the row leaves Archived, then is back under Archived.
  3. Both moves on a server that takes them: as before this change (archive: the row goes, the tab closes, Undo offered; unarchive: the row is back).

Not run either: a real window; macOS; Linux. The unarchive was not repeated on b9b406382: its code did not change between the two heads.

Hona added 2 commits November 26, 2026 01:30
The put-back reopened the session's tab the way Reopen closed tab does, which shows it: a session archived from Home, or from another session's page, by its card's menu took the page when the server refused. Desktop moves nothing until the server has answered (packages/app/src/shell/titlebar/inbox-model.ts:476-487), so the page stays where it is. The archive now notes whether the tab it closed was the page shown: that one comes back shown, as before; one that was behind goes back to its place in the strip and the page stays.
@Hona
Hona marked this pull request as ready for review November 25, 2026 17:19
@Hona
Hona merged commit 1c3fda1 into dev Nov 25, 2026
7 checks passed
@Hona
Hona deleted the upstream-f/archive-put-back branch November 25, 2026 17:20
Hona added a commit that referenced this pull request Nov 25, 2026
…d; UP-230 after #1211 (#1248)

One official commit since 0caad64533: opencode#66396, a bare /rename asks the server for a new session title: UP-240, missing, in work. UP-230's open difference (a refused archive or unarchive was not put back) is closed by #1211, with what ran and what did not.
Hona added a commit that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant