Skip to content

Worktrees setting and a collapsible project picker #785

Closed

Description

@ivanfenenko

Worktrees can be switched off, New session starts on the main checkout without asking, and the project picker stays short and reorderable however many worktrees a project has.

Follow-up to #780. Feedback after it shipped:

  • Being asked where to run every time is noise when you just want main. Start on main, and move to a worktree later when you need one.
  • With every worktree listed inline, the picker can't be reordered properly.
  • With many worktrees (10, say) you have to scroll to reach the next project.

Prototype variant A · Collapsed, expand on demand was chosen. The prototype source is on branch prototype/worktree-mode.

Behaviour (iOS and Android)

Worktrees setting

  • Settings → Home → Worktrees, on by default, so the current behaviour is kept. Copy: "Show each project's worktrees and branches on Home, and let New session pick a worktree when you hold it."
  • Off: rows show the project without branch or folder; the picker lists projects only; there are no worktree scopes; New session never asks; Session Chat's "Move to worktree…" is disabled with the hint "Turn on Worktrees in Settings". Sessions from every worktree stay listed under their project. Grouping by project ID from Group worktrees under one project on Home #780 doesn't change.

New session

  • Tap: start on the main checkout of the current project. If Home is filtered to a worktree, start in that worktree. Nothing is asked. In the All scope, keep today's project choice.
  • Hold: opens the New session sheet. For a project with more than one worktree (and Worktrees on), it shows the Run in list from Group worktrees under one project on Home #780. Reconcile this with the existing long-press project chooser so one hold gesture covers both.

Project picker (variant A)

  • Projects only, as before Group worktrees under one project on Home #780. A project with more than one worktree shows a "N worktrees ⌄" pill on its row.
  • Tapping the pill expands that project's worktrees inline, under the project. Opening another project's worktrees closes the first (one open at a time).
  • With more than 5 worktrees, show 5 and a "Show all N" row.
  • Tapping a project row (not the pill) selects the whole project; tapping a worktree row selects that worktree, as in Group worktrees under one project on Home #780.
  • Edit in the sheet header enters reorder mode: everything collapses and projects get drag handles. Worktrees stay with their project. Swipe-to-remove stays on project rows.

Dock

Move to worktree

  • Session Chat ⋯ → Move to worktree… lists the project's worktrees (branch, "main checkout" or folder name), with the current one checked.
  • v2: POST /api/session/:id/move with the target location. The session's directory, header and Home row update afterwards. Server note: "Move a session to another project directory at the requested delivery boundary". Confirm whether a running turn finishes first.
  • v1 has no move endpoint: show the item disabled with "Needs an opencode v2 server" (controls stay visible).
  • Creating a new worktree stays in Create worktrees from the apps #752.

Acceptance

  • The Worktrees setting exists on both platforms. Turning it off removes worktree rows, branches and scopes, and New session never asks. Turning it back on restores them.
  • Tapping New session starts on the main checkout, or in the filtered worktree, without a sheet. Holding it opens Run in for multi-worktree projects.
  • The picker collapses worktrees behind the pill, one project open at a time, with "Show all N" above 5.
  • Edit reorders projects, with worktrees collapsed, and the order persists.
  • The dock swipe skips worktrees.
  • Move to worktree works on v2 and updates Session Chat and Home. It is disabled with an explanation on v1.
  • Unit tests cover the setting's effect on Home state, the New session target, the picker's expand/collapse and reorder state, and the move action on both platforms.
  • Real-app evidence on iOS and Android, v1 and v2, attached here.

Remaining:

  • iOS implementation
  • Android implementation
  • Real-app evidence on v1 and v2
  • Android: Session Chat follows session.moved in place (same ViewModel). The timeline and scroll stay, the header and branch update in about 1 s, and fast consecutive moves end in the right worktree. Before, a route replace reloaded the chat and could drop moves.
  • Back after a move once exited the app instead of returning to Home. It did not reproduce: clean path, entry through the closing picker, a new session, and nine fast moves from another client all returned to Home. The route replace it went through is gone.

Related: #780 (worktree grouping), #783 (Session Chat header), #752 (create and remove worktrees).

Activity

  1. added
    enhancement
    shared
    todo
    priority: medium
    in-progress
    and removed
    todo
    on Oct 21, 2026
  2. ivanfenenko commented on Oct 21, 2026

    @ivanfenenko
    CollaboratorAuthor

    Real-app evidence (PR #786)

    Real apps against the real opencode v1 (1.19.1) and v2 (dev 4d5965762e) through the scenario harness. The fixture is acme-invoices with 8 worktrees, plus billing-api, and harness data only. v2 was tested cold, right after a server restart. iOS ran on an iPhone 17 simulator and Android on a Pixel 9a emulator, both built from the merged branch bcf935f2.

    Check iOS v1 iOS v2 Android v1 Android v2
    Rows show branch · folder (Worktrees on) ✅ ✅ ✅ ✅
    Picker: projects only, "8 worktrees ⌄" pill ✅ ✅ ✅ ✅
    Pill expands one project; "Show all 8" / "Show fewer" ✅ – ✅ ✅
    Edit: collapse, handles, disabled pill, drag reorder ✅ (persists across relaunch) – – ✅
    Tap New session → main checkout, no sheet – ✅ – ✅
    Hold New session → Run in (+ Other projects) ✅ (session created in the picked worktree) – – ✅
    Dock swipe walks projects only ✅ – ✅ –
    Move to worktree disabled: "Needs an opencode v2 server" ✅ 204 + session.moved; header ~1 s; Home row regroups disabled: "Needs an opencode v2 server" ✅ 204 + session.moved; header 4–8 s; Home row regroups
    Worktrees off: path rows, projects-only picker, Move disabled "Turn on Worktrees in Settings" – ✅ – ✅

    "–" = not run on that protocol; the behaviour does not depend on the protocol, and unit tests cover it on both platforms.

    iOS

    Picker collapsed Expanded Show all 8 Edit Reordered Order after relaunch
    Hold → Run in Tap → main Menu (v1) Menu (v2) Move sheet (v2) After move Home after move
    Setting off Home (off) Picker (off) Menu (off) Dock swipe

    Android

    Home (v2) Picker collapsed Expanded Show all 8 Edit Reordered
    Hold → Run in Other projects Tap → main Menu (v2) Move sheet After move Home after move
    Setting off Home (off) Picker (off) Menu (off) v1 Home v1 Show all v1 Show fewer v1 Menu v1 Dock swipe (All → acme → billing)

    Found during the run (also listed in the PR's Risks):

    • Android header lag: after a move, Android's header caught up 4–8 s after session.moved, because it reopens the session through the session-replace route. iOS updates in about 1 s.
    • Android back, once: back exited the app after a double move that started from a tap through the closing picker. It did not reproduce from a clean Home → session → move → back.
    • Interrupted turn (server behaviour): a move sent during a turn that is then aborted stays queued until the next prompt.
  3. added 2 commits that reference this issue on Oct 22, 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

    enhancementin-progresspriority: mediumshared

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions