Skip to content

#833 Restore archived sessions - #977

Merged
ivanfenenko merged 12 commits into
mainfrom
feature/833-restore-archived-sessions
Nov 4, 2026
Merged

ivanfenenko merged 12 commits into
mainfrom
feature/833-restore-archived-sessions

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Part 1 of #833: restore archived sessions, on Android and iOS.

  • Archived sessions screen.
    • Shows Home's current scope as the subtitle, and lists sessions grouped This week / Earlier by archive time, newest first, in Home's session row.
    • A trailing one-tap Unarchive removes the row and shows a snackbar ("Unarchived “title”") with Undo.
    • Tapping a row opens a sheet with Unarchive, Open and Delete… (confirmed in a dialog).
    • Empty state: "No archived sessions", plus Show all projects when other projects have some.
    • The list refreshes live on session.archived / session.unarchived / session.deleted.
  • Session Chat. An archived session shows an "Archived " banner with Unarchive, read on open and kept current by the same events.
  • Domain.
    • SessionRepository.listArchivedSessions / unarchiveSession (v2: GET /api/session?archived=true, PATCH /api/session/{id} {archived:false}).
    • The shared ArchivedSessionList helper (load across directories, dedupe, newest first) is there for Search's "Include archived" to reuse.
  • v1. 1.19.5 can set time.archived but has no way to clear it, so the new supportsArchivedSessions capability (v2 with archive only) hides the feature. On v1 the banner shows without Unarchive.
  • Design system.
    • Android's compact list row gains the trailing slot iOS already had.
    • Home's session row is reusable on both platforms (SessionListRow).
    • New unarchive icon (lucide archive-restore).
  • Not in this PR. The screen is not yet reachable: the Home ⋯ menu entry ("Archived sessions", second after Search sessions, subtitle "N in ") comes after the Search sessions on Home #929 menu foundation merges.

Checks

  • Android: unit tests pass: ArchivedSessionsModelTest, plus new cases in SessionProtocolRepositoryTest and ServerProtocolClassifierTest. assembleDebug / assembleDebugAndroidTest OK. ktlint is clean for the changed files.
  • iOS: build-for-testing (generic simulator) succeeds. ArchivedSessionsViewModelTests and the new SessionProtocolRepositoryTests / ServerProtocolClassifierTests cases are not run yet.
  • node scripts/check-string-keys.mjs passes. gitleaks found nothing.

Evidence

Pending: device verification runs on the shared simulator and emulator once the menu entry lands.

Issue

#833 (part 1. Part 2, worktree removal, is a separate PR that finishes the issue.)

Risks / Follow-ups

  • The Home ⋯ menu entry and its archived count follow once Search sessions on Home #929's menu is on main.
  • Not verified on a device yet: unarchive/undo against a real v2 server, live refresh, the banner, and the entry being hidden on v1.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
New session lifecycle APIs and optimistic list/undo state on both platforms; incorrect gating or refresh could hide or duplicate archived rows, though behavior is covered by repository and view-model tests.

Overview
Adds list and restore archived sessions for v2 servers with archive support (supportsArchivedSessions), wired through listArchivedSessions / unarchiveSession and shared ArchivedSessionList loading/sorting.

Archived sessions screen (Android route + iOS HomeRoute.archivedSessions): sessions for the current Home scope, grouped This week / Earlier, reusing Home SessionListRow with a trailing Unarchive, snackbar Undo, and sheet actions (Open, Delete). Live refresh on archive/unarchive/delete events. Empty state can widen to Show all projects.

Session Chat shows an Archived <time> banner; Unarchive when the server supports restore. Archive state reloads on open and on session.archived / session.unarchived.

v1 still archives via time.archived but cannot list/restore—the UI gates on the new capability (banner without Unarchive on v1). Design: compact list rows get a trailing slot on Android; new unarchive icon.

Navigation destinations exist; the PR description notes the Home ⋯ menu entry may land separately after menu foundation work.

Reviewed by Cursor Bugbot for commit cd742c7. Bugbot is set up for automated code reviews on this repo. Configure here.

ivanfenenko and others added 2 commits November 3, 2026 22:02
Home's Settings button becomes a ⋯ menu that holds Settings for now.
HomeMenu (iOS and Android) puts feature entries first, in order, and
adds Settings last behind a divider, so Search sessions, Archived
sessions and Worktrees each add one entry. The shared overflow menu
gains a dividerAbove slot, and on iOS a whole menu row now takes the
tap, not just its icon and text. ⌘, / Ctrl+, still open Settings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add an Archived sessions screen on Android and iOS: Home's scope, grouped
This week / Earlier by archive time, with one-tap Unarchive (snackbar with
Undo), an actions sheet (Unarchive, Open, Delete…) and a live refresh on
session.archived / unarchived / deleted. Session Chat shows an "Archived
<time>" banner with Unarchive.

v2 lists with ?archived=true and restores with PATCH {archived: false}.
v1 can archive but cannot clear time.archived, so a new
supportsArchivedSessions capability hides the feature there.
ArchivedSessionList is shared so search can reuse it for archived results.

The Home ⋯ menu entry lands after the #929 menu foundation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@ivanfenenko
ivanfenenko marked this pull request as ready for review November 3, 2026 21:30

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cd742c7. Configure here.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: no finding that 2+ of 2 passes agreed on.

3 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/ArchivedSessionsModel.kt:337 medium: Undo-restored row dropped when directory is unknown (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Archived/ArchivedSessionsViewModel.swift:307 medium: Undo-restored row dropped when directory is unknown (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/ArchivedSessionsModel.kt:637 low: Undo-restored rows can be dropped from the list when the session directory maps to no Home project (glm-5.3-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.152 · 1 pass(es) failed

ivanfenenko and others added 2 commits November 3, 2026 22:46
The ⋯ menu lists "Archived sessions" with "N in <scope>", counted when the
menu opens and left out on servers that cannot restore archived sessions.
It opens the Archived sessions screen for Home's current scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko changed the base branch from main to feature/929-home-overflow-menu November 3, 2026 22:00
@ivanfenenko
ivanfenenko marked this pull request as draft November 3, 2026 22:00
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 3, 2026 22:17
ivanfenenko added a commit that referenced this pull request Nov 3, 2026
Both branches add a Home route, menu entry, analytics names and a Container factory; all kept. Menu order: Archived sessions, Worktrees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: no finding that 2+ of 2 passes agreed on.

6 finding(s) from a single pass, not posted
  • ios/OpenCode Mobile/OpenCode Mobile/Domain/Session/ArchivedSessionList.swift:24 medium: iOS archived load swallows task cancellation (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/ArchivedSessionsModel.kt:268 medium: One failing project fails the whole archived list (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/ArchivedSessionsModel.kt:335 low: Undo row dropped when its directory matches no project (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Domain/Session/V2SessionRemote.swift:94 low: Unarchive unconditionally clears archived state (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Region/SessionInfo.swift:234 low: Stale archived banner persist across rebind when loadArchiveState GET fails (glm-5.3-flash)
  • android/app/src/main/java/dev/opencode/mobile/domain/session/ArchivedSessionList.kt:63 low: Archived time of 0 (null archivedAt) formats epoch 0 caption (glm-5.3-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.191 · 1 pass(es) failed

ivanfenenko and others added 3 commits November 3, 2026 23:39
- Home menu: recount the Archived sessions entry once Home's server probe
  finishes, so it shows on the first open after launch (both apps).
- Android overflow menu: size the panel to its widest entry; a divider no
  longer stretches it to the window. Gallery gains the Home menu shape.
- iOS: archived rows drop the long-press overlay that covered the trailing
  Unarchive button; a tap still opens the actions.
- Delete confirmation names the session and says it is deleted from the
  server for good, from a target the closing sheet cannot clear.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Undo the overflow menu width change; #976 fixes the divider there.
- Session Chat: session.unarchived clears the banner directly, and an
  archive change since a session read began wins over that read, so a
  lagging GET no longer brings the banner back (both apps). iOS also
  clears the banner on rebind.
- Archived list: unarchived or deleted rows stay gone while a list still
  carries their old archive time; Undo rows keep their project, so an
  unknown directory no longer drops them; one failing project keeps the
  others listed (both apps).
- iOS: subscribe to events before the first load, and report
  cancellation from ArchivedSessionList.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HorizontalDivider fills the width it is offered, and the panel offered
the popup window's width, so a divider stretched the menu across the
screen. The panel column now takes its widest row's intrinsic width,
and every row fills it, so the whole row takes the tap as on iOS.
Adds a grouped preview (subtitles plus divider) on both platforms and
an instrumented layout test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Triage of the single-pass findings in the automated review summaries:

Fixed in d09e0a3:

  • ArchivedSessionsModel.kt:335/337/637, ArchivedSessionsViewModel.swift:307: an Undo-restored row was dropped when its directory matched no Home project. Undo rows now keep the project whose list carried them (undoKeepsARowWhoseDirectoryIsUnknown).
  • ArchivedSessionsModel.kt:268: one failing project failed the whole list. A failing project now keeps its last list while another project answers; the error state shows only when every project fails (aFailingProjectKeepsTheOthersListed). The same change is on iOS.
  • ArchivedSessionList.swift:24: cancellation was swallowed. load now calls Task.checkCancellation() after the group.
  • SessionInfo.swift:234: a stale banner could survive a rebind when the read failed. bind now clears it.

Not changed:

  • V2SessionRemote.swift:94 ("unarchive unconditionally clears archived state"): this is on purpose. A successful PATCH {archived:false} means the server restored the session, and the follow-up GET can lag. Android behaves the same; archive mirrors it by stamping now.
  • ArchivedSessionList.kt:63 ("archived time 0 formats an epoch caption"): this can't happen. sorted() keeps only isArchived sessions, so every row has a non-null archive time.

@ivanfenenko
ivanfenenko marked this pull request as draft November 3, 2026 23:05
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 4, 2026 07:46
@ivanfenenko
ivanfenenko marked this pull request as draft November 4, 2026 07:47

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: no finding that 2+ of 2 passes agreed on.

7 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/domain/session/V2SessionRemote.kt:89 medium: Unarchive hides row forever if server keeps listing it (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/ArchivedSessionsModel.kt:302 medium: Stale load can overwrite a newer load on Android (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/HomeArchivedMenu.kt:71 medium: Stale archived-count overwrites newer scope (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/domain/session/V2SessionRemote.kt:29 low: Project lookup swallows coroutine cancellation (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/domain/session/ArchivedSessionList.kt:55 low: Dedupe keeps first duplicate instead of newest (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Archived/HomeArchivedMenu.swift:54 low: recheck recounts with stale projects snapshot (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/ArchivedSessionsModel.kt:306 low: Archived list marks itself loaded with zero projects and never re-reads the projects flow (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.139 · 1 pass(es) failed

Home's Done pill is server unread state. Unarchive from the Archived
screen must not acknowledge it; only opening the session does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Device evidence: Archived sessions (real app, scenario harness, fixture project)

Shared iPhone 17 simulator and Pixel 9a emulator, opencode v2 (dev) through the scenario harness; v1.19.5 checked for gating (entry hidden, archived sessions stay off Home).

Android iOS
Home ⋯ menu with Archived sessions on first open Archived sessions list
Archived sessions list Unarchive snackbar with Undo
Unarchive snackbar with Undo Delete confirmation naming the session
Row sheet: Unarchive, Open, Delete Archived banner with Unarchive in Session Chat

Checked: menu entry with scope count on first open, compact menu width, one-tap Unarchive and Undo (both apps; server state confirmed), sheet actions, Delete copy, Session Chat banner and its Unarchive, live archive/unarchive from another client (Android). The Android menu capture comes from the stacked search head, which includes this PR, so it also shows Search sessions.

Base automatically changed from feature/929-home-overflow-menu to main November 4, 2026 08:18
main's only new commit is the #976 squash, whose tree matches fa295aa,
already merged here in a9d2fac, so this branch's tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 4, 2026 08:19

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: no finding that 2+ of 2 passes agreed on.

3 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/ui/archived/ArchivedSessionsModel.kt:248 low: Undo-then-unarchive-again stores a fabricated archive time, so a lagging server list brings the unarchived row back (glm-5.3-flash)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Archived/ArchivedSessionsViewModel.swift:224 low: Same fabricated archive-time bug as Android in the undo path (glm-5.3-flash)
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/region/SessionInfo.kt:475 low: loadArchivedAt captures archive generation inside the launched coroutine (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.179 · 1 pass(es) failed

- Dedupe archived sessions after sorting, so a duplicate keeps its newest copy.
- A row Undo put back settles against any archive time when unarchived
  again, since the app never saw the server's time for it.
- Android: capture the archive generation before launching the read;
  the v2 project lookup rethrows cancellation.
- iOS: recheck the menu entry with Home's current projects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Triage of the single-pass findings in the two latest automated reviews:

Fixed in d6c2f29:

  • ArchivedSessionList.kt:55 (and the iOS twin): dedupe kept the first copy of a duplicate. It now dedupes after sorting, so the newest copy wins.
  • ArchivedSessionsModel.kt:248 / ArchivedSessionsViewModel.swift:224 (Undo, then unarchive again, then a lagging list): when a row put back by Undo is unarchived again, it now settles against any archive time, because the app never saw the server's time for it.
  • SessionInfo.kt:475: loadArchivedAt now receives the generation that was captured before launch.
  • V2SessionRemote.kt:29: the project lookup rethrows cancellation instead of swallowing it.
  • HomeArchivedMenu.swift:54: recheck now counts with Home's current projects instead of the snapshot from the last refresh.

Not changed:

  • V2SessionRemote.kt:89 ("unarchive hides a row forever if the server keeps listing it"): a row stays hidden only while the server keeps listing it with the same archive time after a successful PATCH {archived:false}. That would mean the server ignored the restore, and servers without archive support never show this screen. The entry clears as soon as the session drops off the list, and a re-archive with a new time shows again.
  • ArchivedSessionsModel.kt:302 ("a stale load can overwrite a newer load"): load() cancels the job before it, and both run on the main dispatcher, so an older load can't finish after a newer one starts.
  • HomeArchivedMenu.kt:71 ("a stale count overwrites a newer scope"): refresh() cancels the previous count, and the assignment runs on the same single-threaded scope, so a cancelled count can't write afterwards.
  • ArchivedSessionsModel.kt:306 ("loaded with zero projects; never re-reads projects"): the screen is only reachable from Home's menu, after Home has published its projects to the snapshot this screen reads.

@ivanfenenko
ivanfenenko merged commit dc50b57 into main Nov 4, 2026
@ivanfenenko
ivanfenenko deleted the feature/833-restore-archived-sessions branch November 4, 2026 09:27
ivanfenenko added a commit that referenced this pull request Nov 4, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	android/app/src/main/java/dev/opencode/mobile/domain/session/V2SessionRemote.kt
ivanfenenko added a commit that referenced this pull request Nov 4, 2026
main's tree equals #977's final commit f30175e, merged in the parent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ivanfenenko added a commit that referenced this pull request Nov 4, 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