Skip to content

Group worktrees under one project on Home #780

Closed

Description

@ivanfenenko

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 name if 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 ~/repo and ~/repo-wt both 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

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

    @ivanfenenko
    CollaboratorAuthor

    Real-app evidence

    Both apps were built from feature/780-group-worktrees-by-project and run against real opencode servers through scripts/scenario-harness: v1 1.19.1 and v2 dev (~/Projects/opencode @ 4d59657). The test repo acme-invoices has two git worktrees, acme-invoices-export (feature/csv-export) and acme-invoices-tax (feature/tax-rounding). There are also two non-git folders, notes-work and notes-personal. At the start only acme-invoices was added to Home.

    Check iOS v1 iOS v2 Android v1 Android v2
    One project, sessions from every worktree, branch on each row ✅ ✅ ✅ ✅
    Scope picker lists worktrees; picking one narrows the list and the dock pill ✅ ✅ ✅ ✅
    New session: worktree scope starts there; project scope asks "Run in" ✅ (same code path) (same code path) ✅
    Session created in the chosen worktree (checked on the server) ✅ acme-invoices-tax – – ✅ acme-invoices-tax, acme-invoices-export
    Adding a worktree path of the same repo joins the project ✅ – – ✅
    Two non-git folders stay separate projects ✅ n/a (each folder has its own ID on v2) ✅ n/a
    Session created by another client in a worktree that was never added appears live ✅ ✅ ✅ ✅
    Branches show on first load straight after a server restart ✅ (v1 answers correctly when cold) ✅ after fix – ✅ after fix
    Remove from Home (with confirmation) – – ✅ –

    iOS · v1

    Home: one project, 3 worktrees Scope picker Project scope New session → Run in
    Created in the chosen worktree Join message Non-git folders stay separate

    iOS · v2

    Home on a cold server Scope picker Worktree scope (project name stays in the dock) Live session in that worktree

    Android · v2

    Home Scope picker Worktree scope New session in that worktree
    Project scope → Run in Live session in a worktree that was never added Join message

    Android · v1

    Home Live session in a worktree that was never added Non-git folders stay separate

    Bugs found by the real-app run and fixed on the branch

    • Android: crash on Home. The new inline branch icon passed an empty alternateText, which Compose rejects at runtime. It now uses a zero-width space, so screen readers don't announce a placeholder character.
    • iOS: in worktree scope the dock pill showed the branch instead of the project name.
    • Both: right after a v2 server (re)start, the first GET /api/vcs for a location returns {"branch":{}} with no provider, 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

    • The / project on the iOS v1 screenshots comes from the debug launch-argument seeding, which adds every server project, including v1's global root. It is not part of this change.
    • Unit suites: iOS 2374 tests in 238 suites passed, with UI tests skipped. Android :app:testDebugUnitTest 2470 tests passed, and :app:assembleDebug built.
  3. added a commit that references this issue on Oct 21, 2026
  4. removed
    in-progress
    on Oct 21, 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

    enhancementpriority: mediumshared

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions