Skip to content

#785 Worktrees setting and a collapsible project picker - #786

Merged
ivanfenenko merged 8 commits into
mainfrom
feature/785-worktrees-setting-collapsible-picker
Oct 22, 2026
Merged

ivanfenenko merged 8 commits into
mainfrom
feature/785-worktrees-setting-collapsible-picker

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #780: worktrees become opt-in, and the project picker stays short however many worktrees a project has. Prototype variant A, on iOS and Android.

  • Settings → Home → Worktrees (on by default). Off: no branch or folder on rows, a projects-only picker, no worktree scopes, and New session never asks. Sessions from every worktree stay under their project. Grouping by project id is unchanged.
  • New session. Tap starts on the project's main checkout, or in the worktree Home is filtered to, with no sheet. Hold opens the New session sheet: Run in for a multi-worktree project, then Other projects. In the All scope this is today's project chooser, and a held pick goes on to Run in. One hold gesture covers both.
  • Project picker (A). Projects only, with an "N worktrees ⌄" pill that expands one project at a time. Over 5 worktrees it shows 5 and Show all N / Show fewer. Edit/Done in the sheet header collapses everything and adds drag handles; worktrees move with their project and the order persists. Rows only drag in Edit, and in Edit the pill is disabled, not hidden. Swipe-to-remove stays on project rows.
  • Dock swipe walks All and projects only.
  • Session Chat ⋯ → Move to worktree… lists the project's worktrees, with the current one checked. v2: POST /api/session/{id}/move with {"directory": …} (204). Session Chat and the Home row follow the session.moved event. The item always shows and is disabled with a reason: "Needs an opencode v2 server" (v1), "Turn on Worktrees in Settings", or "This project has no other worktrees".
  • Design system, both platforms:
    • a text action in the bottom sheet header;
    • an optional subtitle on overflow menu entries;
    • the expand pill;
    • drag handles on reorderable lists.

Checks

  • Android, from the merged branch: ./gradlew :app:testDebugUnitTest :app:assembleDebug :app:assembleDebugAndroidTest passed: 2513 tests, 0 failures, 1 skipped.
  • iOS, from the merged branch: full unit target with UI tests skipped. 2439 tests in 246 suites passed.
  • New unit tests cover:
    • the setting's effect on Home state (rows, tabs, scope resolution);
    • the New session target for tap and hold, setting on and off;
    • picker state (one project open at a time, Show all over 5, Edit collapsing everything, opening on a worktree scope, reorder output);
    • the dock swipe skipping worktrees;
    • the move action (when it is enabled, the v2 request, session.moved updating Session Chat and Home).
  • v2 move semantics were checked against opencode dev (4d5965762e) and a live server:
    • an idle session moves in about 0.5 s;
    • during a running turn the move waits for the turn to end;
    • the server emits session.moved and no session.updated.

Evidence

Real apps against the real opencode v1 (1.19.1) and v2 (dev) through the scenario harness, with one repo with 8 worktrees plus a second project. Screenshots and a results table are in the evidence comment on #785; the images are on branch evidence/785, harness data only. v2 was tested cold, right after a server restart.

Issue

Fixes #785

Risks / Follow-ups

  • Android, after a move (fixed in 8dc4869): Session Chat now follows session.moved in place in the same ViewModel. The timeline and scroll stay, and the header and branch pill switch about 1 s after the tap (request trace: rebind requests start 250 ms after the event, and the transcript is not refetched). The old route replace also dropped moves that arrived while the new ViewModel started: after nine quick moves the header showed the wrong worktree. Now it ends on the right one. The composer reloads the model catalog for the new directory and falls back with "Selected model is unavailable" when that directory doesn't offer the model.
  • Android back stack, once: back exited the app instead of returning to Home. Retried on v2 with the harness: clean path, entry through the closing picker, a new session, and nine fast moves from another client all returned to Home. It never reproduced, and the route replace it went through is gone.
  • Android Session context after a move: it still opens with the route's original directory. v2 message requests ignore the directory, but I did not check this screen on a device.
  • Interrupted turn: a move sent during a turn that is then aborted stays queued on the server until the next prompt. The apps do not show that it is pending.
  • Move sheet without Home data: the sheet takes the session's project from Home's grouped list, so a chat with no matching Home project shows "This project has no other worktrees".
  • Turning Worktrees off on a worktree scope: the scope falls back to its project, and turning it back on does not restore the worktree scope.
  • Setting key: showsWorktrees on iOS, shows_worktrees on Android (each follows its store's style).
  • Not checked on devices: iPad / iPhone Duo layouts, landscape, the dock swipe starting from a worktree scope (covered by unit tests only), and VoiceOver/TalkBack.
  • Creating worktrees stays in Create worktrees from the apps #752.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith with what you need.

ivanfenenko and others added 7 commits October 21, 2026 23:42
…rag handles

Bottom sheet headers take a trailing text action (Edit / Done) before Close;
header actions can be disabled and carry an accessibility identifier.
Overflow menu entries get an optional subtitle under the title. The expand
pill ("3 worktrees ⌄") shows or hides rows nested under a row. Reorderable
lists can start a drag from a leading handle and keep a trailing part whose
controls stay tappable. Gallery entries for each.

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

Home display preferences gain showsWorktrees (key "showsWorktrees", on by
default, cleared with the other Home prefs). Home scopes resolve a worktree
scope to its project and row locations drop branches while it is off; a
project knows its main checkout directory.

The session repository moves a session with POST /api/session/{id}/move and
body {"directory": ...} on v2; v1 has no endpoint and throws. Capabilities
say whether the server can move sessions, and the event adapter reads the
new directory from session.moved.

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

Settings → Home → Worktrees switches Home's worktree presentation: off, rows
show the project without branch or folder, the picker lists projects only,
worktree scopes read as their project and New session never asks. Sessions of
every worktree stay under their project either way.

Tapping New session starts on the main checkout of the current project, or in
the filtered worktree; in All it still asks which project. Holding it opens
Run in for a multi-worktree project (with Other projects below), else the
project list, where a multi-worktree pick opens its Run in list.

The picker lists All and projects. A "N worktrees" pill expands one project's
worktrees at a time, five at most before "Show all N". Edit collapses
everything and reorders projects with drag handles; swipe-to-remove stays on
project rows. The dock swipe walks All and projects only; from a worktree it
steps out to its project or on to the next one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Session Chat ⋯ → "Move to worktree…" lists the session's project worktrees
in Home order with the current one checked. It stays visible but disabled
with "Needs an opencode v2 server", "Turn on Worktrees in Settings" or "This
project has no other worktrees". A move of a busy session says it applies
after this turn; a failure shows the server's message. When session.moved
arrives the chat rebinds to the new directory, so the header and directory
requests follow; Home refetches on the same event and regroups the row.

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

- Settings → Home → Worktrees (HomeDisplayPreferences.showsWorktrees, on by
  default). Off is presentation only: rows lose branch/folder, the picker and
  dock list projects only, worktree scopes resolve to their project, and New
  session never offers Run in.
- Tap New session starts on the project's main checkout (or the filtered
  worktree); hold opens Run in for a multi-worktree project, with
  "Other projects" below it, or the project list.
- Project picker variant A: "N worktrees" pill expands one project at a time,
  "Show all N" / "Show fewer" past five, Edit/Done reorders projects with drag
  handles, swipe-to-remove stays on project rows.
- Dock swipe walks All and projects; a worktree scope sits inside its project.
- Design system: bottom sheet header text action, overflow entry subtitle,
  reorderable row drag handle, worktrees pill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Session Chat ⋯ → "Move to worktree…" after Fork session, disabled with
  "Needs an opencode v2 server" / "Turn on Worktrees in Settings" /
  "This project has no other worktrees"; sheet lists the project's worktrees
  in Home order with the current one checked.
- v2 POST /api/session/{id}/move {"directory": …} behind SessionRepository
  (moveSession; v1 throws), gated by ServerCapabilities.supportsSessionMove.
  A busy session shows "Moves to <title> after this turn."; failures show
  "Couldn't move the session: <server message>".
- session.moved: Session Chat reopens the session in its new directory, and
  Home patches the row's directory so it regroups at once.
- HomeProjectsSnapshot shares Home's grouped projects with Session Chat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-setting-collapsible-picker

# Conflicts:
#	android/app/src/main/java/dev/opencode/mobile/ui/main/MainScreenViewModel.kt
#	android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/SessionChatViewModel.kt
#	android/app/src/test/java/dev/opencode/mobile/ui/sessionchat/SessionChatViewModelTest.kt
@ivanfenenko
ivanfenenko marked this pull request as ready for review October 22, 2026 03:11
Session Chat answered v2 session.moved by replacing its route, which built a
new ViewModel: the timeline reloaded, the scroll reset, and moves that landed
while the new ViewModel was being created were lost (nine quick moves left
the header on the wrong worktree).

The open Session Chat now rebinds its directory in place. The transcript
keeps its key (v2 scopes messages by session), so the timeline and scroll
stay; the header identity, repo strip (seeded with Home's branch), composer
(draft, model, commands, agents, file search, per-directory catalog), inbox,
session status and commands follow the new directory. A route rebind that
still names the old worktree keeps the new one, and Files, Review changes,
tool groups and child sessions open in the current directory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit 71b2b39 into main Oct 22, 2026
@ivanfenenko
ivanfenenko deleted the feature/785-worktrees-setting-collapsible-picker branch October 22, 2026 08:32
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.

Worktrees setting and a collapsible project picker

1 participant