Repository navigation
Description
Worktrees of the same repository show up as one project on Home, with the branch on every row, on both v1 and v2 servers.
User report: "Support for parallel worktrees is lacking; the system cannot recognize that multiple worktrees belong to the same project." Prototype variant A · One project, many worktrees was chosen (prototype source on branch prototype/worktree-projects).
Why this works without server changes
The server already gives every worktree of a repo the same project ID (v1 since 1.2.25, all v2). The app groups Home by the folder paths the user added, so two added worktrees of one repo become two sections and two scope entries that, on v2, list the same sessions.
| Need | v2 (/api) |
v1 |
|---|---|---|
| Project ID of an added path | GET /api/location → project.id |
GET /project/current?directory= → id |
| Worktrees of a project | GET /api/worktree?projectID= (+ POST /api/worktree/refresh) |
GET /experimental/worktree?directory= (sandboxes) + project worktree |
| Branch per worktree | GET /api/vcs at that location |
GET /vcs?directory= |
| Sessions of all worktrees | GET /api/session?project=<id> (shipped in #699) |
GET /session?directory= per worktree (works on every v1 version) |
| Live updates | /api/event (all locations) |
/global/event / /event?directory= |
Behaviour (iOS and Android)
Grouping
- Added paths whose current project has the same ID merge into one Home project. Order follows the first member path in the added list.
- Never merge when the project ID is
global(v1 non-git folders, and git repos with no commit or remote). Those stay one project per path. - Separate clones with the same remote share an ID and merge too (same as the desktop app).
- Display name: project
nameif set, else the folder name of the canonical checkout. - Removing a project from Home removes all of its member paths.
Adding a path
- Adding a path whose project is already on Home joins that project instead of creating a second one, and says so ("Same repo as opencode-mobile. Showing it as a worktree there.").
Session rows
- Git projects: subtitle shows the branch (
⑂ feature/723-iphone-duo), plus the worktree folder name when it is not the main checkout. In the All scope the project name comes first. Detached HEAD or unknown branch: folder name only. Non-git projects keep today's path subtitle.
Scope picker
- All projects → one row per project (subtitle "N worktrees" when more than one) → for projects with more than one worktree, an indented row per worktree: branch, folder name or "main checkout", session count.
- Choosing a worktree narrows Home to sessions whose directory is that worktree. The dock pill reads project name /
⑂ branch · folder. - Choosing a project shows all its worktrees; pill subtitle "All N worktrees".
New session
- In a worktree scope, New session starts there.
- In a project scope (or All with the project chosen) where the project has more than one worktree, New session asks where to run: one row per worktree (branch, folder, running count). Creating new worktrees stays in Create worktrees from the apps #752.
v1 fixes needed for parity
- Worktree inventory comes from
GET /experimental/worktree(today the app probes/experimental/workspace, which is a different feature) plus the project's own worktree. - Sessions in non-added worktrees of an added project appear and update live, without waiting for an inventory reload.
Acceptance
- With
~/repoand~/repo-wtboth added, Home shows one project with 2 worktrees, on v1 and v2, iOS and Android. - Sessions from a worktree that was never added (but belongs to an added project) appear under that project, with its branch, on v1 and v2.
- Scope picker lists the project's worktrees; picking one narrows the list and the pill.
- New session from a multi-worktree project asks where to run and creates the session in the chosen worktree.
- Adding a path of an already-added repo joins it.
- Two non-git folders on v1 stay separate projects.
- A session created in a non-added worktree appears on Home live on v1 and v2.
- Unit tests cover grouping (incl.
global), scope filtering, row subtitles, and v1 worktree parsing on both platforms. - Real-app evidence (both platforms, v1 and v2) attached to this issue.
Remaining:
- iOS implementation
- Android implementation
- Real-app evidence on v1 and v2
Related: #752 (create/remove worktrees), #700 / #699 (worktree badge and v2 project= sessions), #421 (Session List Home Mode), #433 (remove project from Home).
PR: #781 · Evidence: #780 (comment)
Activity
ivanfenenko commentedon Oct 21, 2026
Real-app evidence
Both apps were built from
feature/780-group-worktrees-by-projectand run against real opencode servers throughscripts/scenario-harness: v1 1.19.1 and v2 dev (~/Projects/opencode@4d59657). The test repoacme-invoiceshas two git worktrees,acme-invoices-export(feature/csv-export) andacme-invoices-tax(feature/tax-rounding). There are also two non-git folders,notes-workandnotes-personal. At the start onlyacme-invoiceswas added to Home.acme-invoices-taxacme-invoices-tax,acme-invoices-exportiOS · v1
iOS · v2
Android · v2
Android · v1
Bugs found by the real-app run and fixed on the branch
alternateText, which Compose rejects at runtime. It now uses a zero-width space, so screen readers don't announce a placeholder character.GET /api/vcsfor a location returns{"branch":{}}with noprovider, and the branch arrives about 1s later. Non-git folders return that body every time. The apps treated it as a final "no branch", so worktree rows stayed without a branch until pull-to-refresh. An answer without a provider now counts as "not known yet" and is retried after 1s and 3s, then not again until the next worktree-list change or refresh. Both platforms also ignore an older lookup that finishes after a newer one.Notes
/project on the iOS v1 screenshots comes from the debug launch-argument seeding, which adds every server project, including v1'sglobalroot. It is not part of this change.:app:testDebugUnitTest2470 tests passed, and:app:assembleDebugbuilt.#780 Group worktrees under one project on Home (#781)