Skip to content

fix(mobile): show child worktrees under a pinned parent in the Pinned section - #20984

Closed
JHXSMatthew wants to merge 1 commit into
stablyai:mainfrom
JHXSMatthew:JHXSMatthew/fix-android-pinned-children-20674
Closed

JHXSMatthew wants to merge 1 commit into
stablyai:mainfrom
JHXSMatthew:JHXSMatthew/fix-android-pinned-children-20674

Conversation

@JHXSMatthew

@JHXSMatthew JHXSMatthew commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

In the Android app, pinning a parent worktree moved only that one row into the Pinned section. Its child worktrees stayed behind, so under the pinned parent the hierarchy was gone and the children could only be found down in the normal list. Now the whole family moves together: the pinned parent appears in Pinned with its children nested underneath, exactly like the desktop app.

What Changed

Mobile-only change (React Native app under mobile/), no wire/RPC changes — the host catalog already carries lineage fields.

  • mobile/src/worktree/pinned-section-worktrees.ts (new): getPinnedSectionWorktrees() — Pinned-section membership mirroring the desktop helper src/renderer/src/components/sidebar/pinned-section-worktrees.ts.
    • Explicitly pinned rows are the seeds; all visible descendants of a pinned ancestor join the Pinned section.
    • A pinned child never pulls its unpinned parent upward.
    • Lineage edges never cross execution hosts (SSH host children are not collected from a locally pinned parent), and stale lineage (worktreeInstanceId mismatch) is rejected.
    • The traversal walks the full catalog (not just the currently filtered rows), so a middle generation hidden by a filter/search still bridges a pinned ancestor to a visible descendant; only visible rows are returned, in visible order.
    • Iterative + cycle-safe (no recursion over a potentially 10k-row catalog).
  • mobile/src/worktree/mobile-workspace-lineage.ts: extracted the existing edge-building logic into buildMobileWorkspaceLineageEdges() (pure refactor, behavior unchanged) so both the flat-list projection and the new pinned membership share one validation path.
  • mobile/src/worktree/workspace-list-sections.ts: the Pinned section is now built from getPinnedSectionWorktrees() instead of sorted.filter(isPinned), and lineage nesting/collapse is applied to it (collapsedGroups) just like every other section. Pinned remains an overlay — rows still appear in their canonical All/repo/status/PR groups too — so no existing grouping behavior changes.

Why

Desktop already implements this exact behavior (and the desktop feature request #5255 remains open separately). The mobile Pinned section was constructed from pinned rows alone and never ran the lineage projection, so a pinned parent was rendered as a leaf. The mobile code already had all the lineage data and the nesting projection; only the Pinned section bypassed it. Reusing the shared, proven edge validation keeps mobile/desktop semantics identical with a minimal diff and requires no protocol change.

Linked Issue

Fixes #20674

Visual Proof

On-device verification passed on a physical Android phone running the 0.0.50 build of this commit (overwrite-installed over 0.0.48): the pinned parent now renders its children nested in the Pinned section. This is a mobile-only interaction change:

  • Before: pinning a parent worktree shows only the parent row in Pinned; its children are absent there.
  • After: the pinned parent shows in Pinned with children nested (indentation + "Child" badge), the "N children" expand/collapse control works, and tapping a child opens its session. Unpinning the parent restores the plain list.

Automated coverage of the before/after data shape is in mobile/src/worktree/pinned-section-worktrees.test.ts and the buildSections cases added in mobile/src/worktree/workspace-list-sections.test.ts.

Testing

Automated (run locally on macOS, Node 22 + pnpm 12):

  • New unit tests for pinned membership: descendants included, unpinned parent not pulled up, dedupe when a descendant is also pinned, filtered-out middle generation bridges, invisible pinned root collects nothing, client-side local pins honored, SSH host isolation, stale lineage rejected, cyclic lineage terminates, 6,000-deep chain.
  • New buildSections integration tests: pinned parent nests child + grandchild in Pinned with depths [0,1,2] while the overlay keeps them in All; client-side pin; pinned child alone; collapse via the shared lineage collapse state.
  • Full mobile suite: pnpm test → 597 files / 5625 tests passed (6 pre-existing skips).
  • pnpm typecheck clean; pnpm lint only pre-existing warnings in unrelated files; pnpm format:check clean.

A release-configured Android APK was built locally from this exact commit (expo prebuild + ./gradlew assembleRelease, JDK 17): package com.stably.orca.mobile, version 0.0.50 (versionCode 16), all ABIs. Its signing certificate uses the identical signing certificate as the official published release APK (verified against the GitHub Releases 0.0.48 APK: same cert SHA-256 fac61745…), so it overwrite-installs over a Play/sideloaded official build without clearing data.

Manual Android verification — passed on a physical device (overwrite install 0.0.48 → 0.0.50, pairing/data preserved):

  1. Pinned a parent worktree that has children → the parent appears under Pinned with its children nested beneath it.
  2. Expand/collapse via the parent's control works; tapping a child opens its session.
  3. An independently pinned child appears in Pinned alone (its unpinned parent stays out).
  4. Unpinning the parent restores the unchanged plain list.
  • I manually tested these changes locally — verified on a physical Android device (0.0.50 build of this commit): pinned parent shows nested children in Pinned, expand/collapse + open child works, an independently pinned child appears without its parent, and unpin restores the plain list
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new IPC, auth, or secret handling; pure client-side list projection.
  • Cross-platform: mobile-only JS; behavior identical regardless of Android/iOS and unchanged for desktop.
  • Remote SSH / mixed-host data: membership is host-qualified via the existing row identity; lineage cannot cross execution hosts, including same-id worktrees on different hosts.
  • Folder workspaces: unaffected — only git worktrees carry lineage edges.
  • Mixed client/server versions: no wire change; lineage fields are already sent by current hosts and absent fields simply produce no nesting (legacy fallback preserved by the shared edge builder).
  • Backwards compatibility: Pinned remains an overlay; canonical sections and their counts are unchanged.
  • Performance: with no pins (common case) the helper returns before scanning; with pins present the projection is two O(n) scans over the ≤10k-row catalog, per memoized section build.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes — on-device behavior verified; screenshot can be attached on request
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… section

The mobile Pinned section was built from explicitly pinned rows only and
skipped lineage nesting, so children of a pinned parent never appeared.

Mirror desktop's getPinnedSectionWorktrees: an explicitly pinned row carries
its visible descendants into Pinned, a pinned child never pulls its unpinned
parent in, edges never cross hosts, stale instance lineage is rejected, and
the walk is iterative for deep chains. The edge universe is the full catalog
so filtered-out middle generations still bridge to visible descendants.
Lineage nesting and collapse now apply to the Pinned section like every
other section.

Fixes stablyai#20674
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change exports lineage-edge construction and adds getPinnedSectionWorktrees. The pinned section now includes visible descendants of pinned worktrees, including descendants across filtered generations. Traversal rejects invalid lineage edges, prevents cycles, and supports deep chains. The section also applies shared collapse state while the canonical All section retains each worktree.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to fe751

When a filtered child sits between a pinned parent and visible grandchild, the grandchild can render outside its parent hierarchy and remain visible after collapse. Resolve this before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed For #20674, the PR adds getPinnedSectionWorktrees to seed the Pinned section from explicitly pinned visible rows and traverse validated descendants from the full lineage map. `workspace-list-section…
Out of Scope Changes check ✅ Passed The changes stay within #20674. They refactor lineage-edge construction, add the Pinned-section helper, update section composition, and add focused automated tests. The summary states that canonical s…
Title check ✅ Passed The title clearly and concisely describes the main change: showing child worktrees under a pinned parent in the mobile Pinned section.
Description check ✅ Passed The description is complete and aligned with the template. It explains the user impact, implementation, rationale, linked issue, testing, compatibility, and performance considerations. The Visual Proo…
  • Fix all pre-merge checks with AI

Warning

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 5391290c-25eb-4528-a988-61498006898f

📥 Commits

Reviewing files that changed from the base of the PR and between 16ac901 and fe7517a.

📒 Files selected for processing (5)
  • mobile/src/worktree/mobile-workspace-lineage.ts
  • mobile/src/worktree/pinned-section-worktrees.test.ts
  • mobile/src/worktree/pinned-section-worktrees.ts
  • mobile/src/worktree/workspace-list-sections.test.ts
  • mobile/src/worktree/workspace-list-sections.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • New mobile/src/worktree/pinned-section-worktrees.ts — getPinnedSectionWorktrees(allWorktrees, visibleWorktrees, isPinnedWorktree) seeds from visible pinned rows, then pulls in visible descendants of a pinned ancestor through the full-catalog lineage edges, so a filtered-out middle generation still bridges. Pinned child does not pull its unpinned parent; host-qualified edges and stale-instance guards are inherited from the shared edge builder. Iterative and seen-guarded.
  • mobile/src/worktree/mobile-workspace-lineage.ts — pure extraction of the edge-building loop into buildMobileWorkspaceLineageEdges(), consumed by applyMobileWorkspaceLineage. Ordering, host isolation, and stale-instance rejection are unchanged.
  • mobile/src/worktree/workspace-list-sections.ts — Pinned membership now comes from the helper over (worktrees, sorted, predicate) and is nested/collapsed through makeSection(..., collapsedGroups). Pinned remains an overlay: canonicalGroupWorktrees is still sorted, so canonical sections and counts are untouched.
  • Tests — pinned-section-worktrees.test.ts (11 cases) plus 4 buildSections cases. Assertions are exact toEqual on ids/depths, so each would fail without the change (descendants, no parent pull-up, dedupe, bridge, invisible root, client-side pin, SSH-host isolation, stale lineage, cycles, 6,000-deep chain).

I verified parity against desktop's getPinnedSectionWorktrees / appendWorktreeRows: desktop also rebuilds edges only among the rows in the pinned subset, so a bridged descendant whose middle parent is absent lands at depth 0 — mobile's applyMobileWorkspaceLineage on the pinned subset behaves identically. Consumers were checked: the section count is rawSection.data.length (now includes descendants, matching desktop's pinned header count), and no consumer assumes every pinned-section row carries isPinned (only isWorktreePinned(actionTarget, pinnedIds) reasons about pin state).

Locally: cd mobile && pnpm vitest run src/worktree/pinned-section-worktrees.test.ts src/worktree/workspace-list-sections.test.ts → 52 passed; pnpm oxlint on the changed sources → clean. On-device Android verification is still noted as pending in the PR body.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@JHXSMatthew JHXSMatthew changed the title fix(mobile): show child worktrees under a pinned parent in the Pinned section (#20674) fix(mobile): show child worktrees under a pinned parent in the Pinned section Sep 17, 2026
@JHXSMatthew

Copy link
Copy Markdown
Contributor Author

Verification result — passed on device

Automated (local, macOS / Node 22 / pnpm 12):

  • New unit tests for pinned-section membership + buildSections integration tests
  • Full mobile suite: 597 files / 5625 tests passed
  • typecheck clean; lint only pre-existing unrelated warnings; format:check clean

Android manual verification: built a release APK from fe7517af0 (expo prebuild + gradlew assembleRelease, JDK 17), package com.stably.orca.mobile 0.0.50 (versionCode 16). Confirmed its signing certificate is identical to the official 0.0.48 release APK (cert SHA-256 fac61745…), then overwrite-installed over 0.0.48 on a physical Android phone — pairing/app data preserved.

  • Pinned a parent with children → parent and nested children all show in Pinned ✅
  • Expand/collapse + opening a child session works ✅
  • Independently pinned child appears in Pinned without its unpinned parent ✅
  • Unpin restores the unchanged canonical list ✅

Ready for review.

@JHXSMatthew

Copy link
Copy Markdown
Contributor Author

Hi @Jinwoo-H — would you have time to review this mobile fix? You've handled most of the recent mobile worktree changes, so it seemed like the right fit.

What it does: the Android Pinned section was built from explicitly pinned rows only and skipped the lineage projection, so a pinned parent showed without its children (#20674). It now mirrors desktop's getPinnedSectionWorktrees semantics (descendants follow a pinned ancestor; a pinned child doesn't pull its parent up; host-qualified edges; stale-lineage and cycle guards; iterative walk), and the Pinned section gets the same nesting/collapse treatment as every other section. Mobile-only, no wire changes — lineage fields already arrive in the catalog.

Verification:

  • New pinned-membership unit tests (11) + buildSections integration cases (4); full mobile suite green locally (597 files / 5625 tests), typecheck/lint/format clean.
  • Built a release APK from the head commit and verified it on a physical Android device (overwrite install 0.0.48 → 0.0.50, same signing cert as the official release, data preserved): nested children in Pinned, expand/open child, independent pinned child, and unpin all behave correctly.
  • The one CodeRabbit major comment is intentional desktop parity (replied in-thread with the desktop test + pullfrog's independent confirmation).

One housekeeping note: as this comes from a fork, Mobile Checks / PR Checks are waiting on a maintainer's "Approve and run workflows" — thank you!

@JHXSMatthew

Copy link
Copy Markdown
Contributor Author

Closing as superseded: #20674 was fixed upstream by #25301 (shipped in the Android app from 0.0.55), which moves child worktrees into Pinned with their pinned parent. This branch now conflicts with main and is no longer needed. Thanks for the fix!

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.

[Bug]: Android app does not show child worktrees under a pinned worktree

1 participant