Skip to content

Restore archived sessions and remove worktrees #833

Closed

Description

@ivanfenenko

Follow-up to #749 and #752, which were closed with one piece left each.

1. Restore an archived session (v2)

Archiving shipped in #758, but there's no way back, so a session archived by mistake is lost from the app.

  • Show archived sessions (GET /api/session?archived=true), e.g. an "Archived" filter or section on Home.
  • Add an Unarchive action that sends PATCH /api/session/{id} with {archived: false}.
  • Handle the session.unarchived event so the session reappears.
  • Gate it on 2.1.0+ servers, the same way archive is.

2. Remove a worktree

Creating worktrees shipped in #788, but they can't be removed, so they pile up.

  • v2: the worktree remove route. v1: the /experimental/worktree remove route. Check the exact routes against the current specs.
  • Ask for confirmation first, and warn if the worktree has uncommitted changes or sessions attached.
  • Refresh the Home worktree grouping afterwards.

Done when

  • On both Android and iOS, an archived session can be restored and a worktree can be removed.

Activity

  1. ivanfenenko commented on Nov 3, 2026

    @ivanfenenko
    CollaboratorAuthor

    Part 2 (remove a worktree): settled design

    Settled with the Home menu prototype shared with #929. Same design on iOS and Android, built from existing design-system components (top-bar overflow menu, OpenCodeBottomSheet, OpenCodeDialog, OpenCodeSnackbar).

    Entry. Home's ⋯ menu (from #929): Search sessions, Archived sessions, Worktrees (subtitle "N across M projects"), divider, Settings. Worktrees pushes a screen titled "Worktrees", subtitle "N worktrees · M projects".

    Worktrees screen. Grouped by project. Each group header shows the project badge, name and worktree count. First row: "Main checkout" with its path and "Can't be removed" (not tappable). Then one row per worktree: branch icon, name, path · session count, a "Running" pill when one of its sessions is running, an "N changed" pill when the server reports uncommitted changes, and a trailing ⋯. A project without worktrees says so and points at New session → choose worktree. The footer says removing deletes the folder on the server and sessions stay.

    Actions (row tap or ⋯, bottom sheet headed by the worktree name and "project · N sessions"): Show sessions on Home (sets Home's existing scope picker to that worktree), New session here (existing new-session flow), Remove worktree… (destructive).

    Confirmation.

    • Clean: "Remove worktree “x”?" / "Deletes on the server." / Cancel + Remove.
    • Uncommitted changes: warning "N uncommitted changes will be lost". Sessions attached: note that they stay on Home but can't run there again. The button becomes "Remove anyway".
    • A running session: "Can't remove “x” yet", with OK + Show session.

    Removing. The row shows "Removing…" with a spinner and is disabled. Success: the row leaves, snackbar "Removed worktree “x”", Home's worktree grouping refreshes. Failure: the row comes back and an error snackbar offers Retry. Sessions from a removed worktree stay on Home with the worktree name struck through and "worktree removed".

    Server API (checked against the specs):

    • v2: GET /api/worktree?projectID=, DELETE /api/worktree with {projectID, directory, force} (204). Without force a dirty checkout fails with 400 WorktreeError and data.forceRequired: true. POST /api/worktree/refresh afterwards.
    • v1: GET /experimental/worktree?directory=<project>, DELETE /experimental/worktree?directory=<project> with {directory} (200 true).
    • Uncommitted changes: both servers report them. v2 GET /api/vcs/status at the worktree's location, v1 GET /vcs/status?directory=<worktree>. The count drives the pill and the warning. v2 sends force: true only after "Remove anyway". If the count could not be read and the server answers forceRequired, the app shows the dirty confirmation again before forcing.
  2. ivanfenenko commented on Nov 3, 2026

    @ivanfenenko
    CollaboratorAuthor

    Part 1 (restore archived sessions): settled design

    Settled with the Home menu prototype shared with #929. Part 2 (worktree removal) is tracked separately.

    Entry point. Home's top bar gets a ⋯ menu (#929). Its second entry, after Search sessions, is Archived sessions, with the subtitle "N in ". The entry is hidden on servers that can't restore archived sessions.

    Archived sessions screen (pushed from the menu):

    • The title is "Archived sessions" and the subtitle is Home's current scope.
    • Sessions are grouped This week / Earlier by archive time, newest first. Rows use Home's session row, captioned with the archive time.
    • Each row has a trailing one-tap Unarchive button.
    • Tapping a row opens a bottom sheet with the title and "Archived ". The sheet offers Unarchive, Open and Delete…; Delete is red and is confirmed with a dialog.
    • Unarchive removes the row and shows a snackbar, "Unarchived “title”", with Undo (which archives it again). On Home the session returns at the top, because the server bumps its update time.
    • Empty state: "No archived sessions". When the scope is one project and other projects have archived sessions, it adds Show all projects.
    • The list refreshes live on session.archived, session.unarchived and session.deleted.

    Session Chat. An archived session opened from the list (or later from search) shows a banner, "Archived ", with Unarchive.

    Protocols:

    • v2: GET /api/session?archived=true lists archived sessions per project, and PATCH /api/session/{id} with {archived: false} restores one. The UI is gated on the same contract probe as Archive (sessionArchive, 2.1.0+).
    • v1: archive sets time.archived through PATCH /session/{id}. The schema only accepts a number, so there is no way to clear it, and v1 has no archived listing apart from /experimental/session?archived=true. v1 servers therefore hide Archived sessions. A new supportsArchivedSessions capability carries this gate. If you open an archived session on v1, the banner shows without Unarchive.

    Domain. The repository adds listArchivedSessions(directory:) and unarchiveSession(id:directory:). A shared ArchivedSessionList helper (load across directories, dedupe, newest first) is meant for Search's "Include archived" to reuse.

  3. added 12 commits that reference this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions