Repository navigation
fix(mobile): honour the desktop pinned-worktree placement setting - #25301
Conversation
Mobile always kept pinned rows in their groups as well as in Pinned. Desktop's showPinnedWorktreesInGroups (default off) shows them only in Pinned. Read that setting with its own settings.get operation, refreshed with the list's view settings, and leave host and device-local pins out of their groups unless it is on. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Under single-location a pinned parent left its group while its unpinned child stayed behind as a root. Visible descendants now follow a pinned ancestor into Pinned, nested under it, as on desktop. Drop the inert host-id half of the pinned-policy stale-reply guard; a host switch replaces the client. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…s sync One "sync from desktop" callback now also reads settings.get for pinned placement, unawaited so a slow read never holds the ui.get merge; the separate callback and its plumbing are gone. Re-record the three host.view-settings goldens, which gain only that settings.get send. The pin expansion walks the lineage children index the renderer now shares, over visible rows only. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…sync Both reads in syncViewSettingsFromDesktop now drop a reply only when the client was replaced; the host-id half compared a captured value with itself. Pin the no-wait invariant: the ui.get merge applies while settings.get never answers. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe host screen now reads and stores the host’s pinned-worktree grouping setting, then passes it to workspace section construction. Pinned worktrees and their lineage descendants appear in the Pinned section. By default, those rows are excluded from canonical groups; the setting can include them in both. The change also adds a helper to build lineage child lists and tests for settings reads, host refresh behavior, grouping modes, and pinned-worktree lineage. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Pinned worktrees can briefly appear in the wrong groups, remain in an outdated placement after returning to the app, or lose their nesting under search. The change is mergeable with these known display issues accepted or scheduled for follow-up. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkResolution Add the linked issue, or clarify that the maintainer exception applies. Include before-and-after visual proof, or state N/A with a reason if there is no visual or interaction change. Complete the testing section with the verification performed and platforms tested.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the whole PR end to end (no prior pullfrog review existed), scoped below to what changed since the previous head ba4c7335 → b805b63:
- Dead stale-reply check removed —
syncViewSettingsFromDesktopno longer compareshostIdto a copy of itself; theclientRef.current !== requestClientcheck is now the only stale guard, andhostIddrops out of the callback deps. A host switch swaps the shared per-host client (useHostClient(hostId)), so this is behavior-neutral. - No-wait invariant pinned — a new case in
host-pinned-display-policy-sync.test.tsasserts theui.getmerge still applies while thesettings.getplacement read never resolves, guarding against reintroducing anawaitthat would hold the view-settings merge. - Local rename —
pending→queueingetPinnedSectionIdentities; no behavior change.
The three touched mobile suites pass (70/70).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Desktop's Pinned section walks lineage over every worktree and keeps the visible descendants, so a grandchild still follows a pinned root when search hides the middle row. Mobile walked visible rows only and left it in its group. Build the children index from the unfiltered list; membership stays visible-only. Drop the hostId arg the view-settings sync no longer reads. Pinned-lineage tests move to their own file to stay under max-lines.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incremental delta b805b63 → d124c79:
- Pins now cross search/filter-hidden rows —
getPinnedSectionIdentitiesbuilds the lineage children index over the full row set and seeds the walk from visible pinned rows, so a visible grandchild follows a pinned root into Pinned even when the middle row is filtered out. Matches desktop'sgetPinnedSectionWorktreesmembership semantics; I confirmed desktop's row-nesting index is also built from the visible list only, so the hidden-middle grandchild renders at depth 0 on both platforms. - Dead
hostIdargument removed —useHostViewSettingsno longer takeshostId, now that the prior commit removed its only use; the controller, recorder adapter and sync test were updated in step. - Placement test matrix widened — a new
describe.eachovernone/repo/workspaceStatus/prStatuscovers host and device-local pins under both policies, and the lineage cases moved intoworkspace-list-pinned-lineage.test.tswith the new hidden-middle-search case.
Mobile typecheck and lint are clean; the three touched suites pass (51/51).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Reject pinned-policy replies after a host switch. · use-host-view-settings.ts:92-112
mobile/src/host-screen/use-host-view-settings.ts:92-112
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winReject pinned-policy replies after a host switch.
When the host screen is reused for another
hostId,clientRef.currentcan still hold the old client untiluseHostScreenIdentityupdates it in an effect. If the old host’ssettings.getreply resolves first, this check can apply its pinned-placement policy to the new host’s list. The policy controls whether pinned workspaces appear in their groups. Compare the reply’s captured host ID with the current host ID.Suggested fix
diff --git a/mobile/src/host-screen/use-host-view-settings.ts b/mobile/src/host-screen/use-host-view-settings.ts --- a/mobile/src/host-screen/use-host-view-settings.ts +++ b/mobile/src/host-screen/use-host-view-settings.ts @@ -import { useCallback, useEffect, useMemo } from 'react' +import { useCallback, useEffect, useMemo, useRef } from 'react' @@ client: RpcClient | null connState: ConnectionState + hostId: string | undefined state: HostScreenState }) { - const { client, connState, state } = args + const { client, connState, hostId, state } = args + const hostIdRef = useRef(hostId) + hostIdRef.current = hostId @@ } const requestClient = client + const requestHostId = hostId const viewReply = hostViewSettingsRead.request(requestClient) @@ - if (clientRef.current === requestClient && policy.accepted) { + if ( + clientRef.current === requestClient && + hostIdRef.current === requestHostId && + policy.accepted + ) { @@ - }, [client, connState, applyViewState]) + }, [client, connState, hostId, applyViewState]) diff --git a/mobile/src/host-screen/use-host-screen-controller.ts b/mobile/src/host-screen/use-host-screen-controller.ts --- a/mobile/src/host-screen/use-host-screen-controller.ts +++ b/mobile/src/host-screen/use-host-screen-controller.ts @@ - const settings = useHostViewSettings({ client, connState, state }) + const settings = useHostViewSettings({ client, connState, hostId, state })
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7ff6f273-8ffa-465e-b81a-df21c7d441fe
📒 Files selected for processing (7)
mobile/src/host-screen/host-pinned-display-policy-sync.test.tsmobile/src/host-screen/use-host-screen-controller.tsmobile/src/host-screen/use-host-view-settings.tsmobile/src/test-support/rpc-recording/adapters/host-screen-mount-adapters.tsmobile/src/worktree/workspace-list-pinned-lineage.test.tsmobile/src/worktree/workspace-list-sections.test.tsmobile/src/worktree/workspace-list-sections.ts
💤 Files with no reviewable changes (3)
- mobile/src/test-support/rpc-recording/adapters/host-screen-mount-adapters.ts
- mobile/src/host-screen/use-host-view-settings.ts
- mobile/src/worktree/workspace-list-sections.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
The placement read was folded into the desktop view-settings sync, so that callback juggled an awaited and an unawaited read and three goldens recorded a settings.get that never answers. useHostShowPinnedInGroups now owns the setting and the catalog refreshes it beside the view-settings sync on connect, focus and mount; the sync, screen state and goldens are back to main. The reader returns desktop's boolean, as its siblings do, so transport no longer imports a worktree type and the two-literal policy union is gone. makeSection always applies lineage, the pinned walk is a Set worklist, and the lineage children index drops a set that duplicated its map's keys.
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
3dce15fe-1582-426b-abba-8edc7a650a1d
📒 Files selected for processing (12)
mobile/src/host-screen/host-worktree-catalog-action-error.test.tsmobile/src/host-screen/use-host-screen-controller.tsmobile/src/host-screen/use-host-show-pinned-in-groups.test.tsmobile/src/host-screen/use-host-show-pinned-in-groups.tsmobile/src/host-screen/use-host-worktree-catalog.tsmobile/src/transport/settings-read-operations.test.tsmobile/src/transport/settings-read-operations.tsmobile/src/worktree/mobile-workspace-lineage.tsmobile/src/worktree/use-workspace-sections.tsmobile/src/worktree/workspace-list-pinned-lineage.test.tsmobile/src/worktree/workspace-list-sections.test.tsmobile/src/worktree/workspace-list-sections.ts
💤 Files with no reviewable changes (1)
- mobile/src/worktree/mobile-workspace-lineage.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the prior pullfrog review (d124c79 → 79c2bc0, the single commit refactor(mobile): read pinned placement in its own hook):
- Pinned placement read moved into its own hook —
useHostShowPinnedInGroupsnow owns both the boolean and thesettings.getread;useHostViewSettingsno longer carries it, so the view-settings merge can't be held by a slow placement read by construction.useHostWorktreeCatalogfires it unawaited beside the existing sync on connect/focus/mount. - Policy type collapsed to a boolean — the
PinnedDisplayPolicystring union is replaced byshowPinnedInGroupsacrossbuildSections,useWorkspaceSections, the controller and state; the type is deleted fromworkspace-list-types.ts. - Lineage children simplified —
getMobileWorkspaceLineageChildrendrops its redundantvisibleIdsguard (theworktreeByIdlookup already rejects an absent parent), andgetPinnedSectionIdentitieswalks descendants with liveSetiteration instead of a mutable worklist queue. makeSectionalways nests lineage — parameter order becomes(key, title, data, collapsedGroups, icon?); the Pinned section now runsapplyMobileWorkspaceLineagelike every other section.- Goldens reverted, tests split — because the extra
settings.getno longer rides the view-settings sync, the three view-settings goldens return to base and the deletedhost-pinned-display-policy-sync.test.tsis replaced by a focuseduse-host-show-pinned-in-groups.test.ts.
Verified locally: the six touched mobile suites pass (75/75), the full RPC-recording golden suite passes (799/799), and mobile tsc --noEmit and oxlint are clean.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
The host screen is reused across hosts, so the previous host's "show in groups" value survived a switch until the new read landed, or for good if it failed. The setting now carries the client that reported it and counts only for that client, which also makes a late reply from a replaced client inert and drops the clientRef plumbing.
There was a problem hiding this comment.
Important
The stale-reply keying added in this commit has an ordering hole: a superseded client's late reply overwrites the current client's already-applied placement, reverting the list to the default until the next focus/connect.
Reviewed changes
Re-reviewed the incremental delta 79c2bc0 → 0dea271 (the single commit fix(mobile): key pinned placement to the client that reported it):
- Placement value keyed to the reporting client —
useHostShowPinnedInGroupsdrops itsclientRefargument and stores{ client, show }in state, exposing the value only while the stored client is the current one; the controller call site no longer passesstate.clientRef. - Hook tests rebuilt around a mount/switch harness — the
clientRef-injection tests are replaced by amountHook/switchToharness, adding cases that the prior host's value is dropped on client change and that a reply landing after the change is ignored.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Keying the value to its client hid a previous host's value but still let that host's late reply overwrite the current host's, reverting the list to the default until the next refresh. Restore the clientRef write guard; the client key still covers the effect-long window before clientRef follows a switch.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the incremental delta 0dea271 → 396258c (the single commit fix(mobile): drop a replaced client's late placement reply), which closes the stale-write hole raised in the prior review:
- Late reply from a replaced client is dropped —
useHostShowPinnedInGroupstakes the screen'sclientRefagain and, after awaitingsettings.get, returns without writing when the captured client is no longer current; the controller passesstate.clientRefback into the hook.clientRefis set byuseHostScreenIdentity's effect, which runs before the catalog's effects fire the sync, so the guard does not drop a current client's reply. - Regression test added — a new case syncs the current client's
truefirst, then resolves the previous host's pendingfalsereply, asserting the current value survives; the earlier "ignores a reply that lands after the client changed" case still covers the reverse order.
Verified locally: the touched mobile suites pass (6/6).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
… state The placement hook kept its own host-switch handling (a client-keyed value plus a clientRef guard) beside the screen's existing one. showPinnedInGroups now lives in HostScreenState, resets with the other host-scoped values in useHostScreenIdentity, and is read in the catalog refresh behind the same clientRef check as the catalog fetch. The hook and the catalog argument go.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the prior pullfrog review (396258c → aee0c09, the single commit refactor(mobile): treat pinned placement like the screen's other host state). The refactor is behavior-preserving:
- Hook folded into host-screen state — the dedicated
useHostShowPinnedInGroupshook is deleted;showPinnedInGroupsbecomes a plain boolean inuseHostScreenStatebeside the screen's other per-host values, anduseHostScreenIdentityresets it tofalsewith the rest when the screen is reused for another host. - Placement read moved into the catalog —
syncShowPinnedInGroups(requestClient)now lives inuseHostWorktreeCatalogand is fired unawaited fromstartWorktreeRefreshnext to the existing view-settings sync. The post-awaitclientRef.current !== requestClientguard that closed the0dea271stale-write hole is preserved verbatim. - Controller wiring simplified —
useWorkspaceSectionsnow receivesstate.showPinnedInGroupsdirectly instead of a hook result. - Test rebuilt around the production hooks —
use-host-show-pinned-in-groups.test.tsis renamed tohost-show-pinned-in-groups.test.tsand now mounts the catalog (for the read + stale-reply guard) and the identity hook (for the reset), keeping exact-value assertions.
The removed read-time setting?.client === client filter is subsumed by the write-time guard plus the explicit identity reset: on a hostId change the identity effect resets to false before the new client's sync applies, and worktrees reset in that same effect, so no frame renders new worktrees under the old policy. On a same-host reconnect the last known placement now survives until the new read instead of briefly reverting to the default, which is at least as correct.
Verified locally: the four touched mobile suites pass (71/71), the full src/host-screen suite passes (34/34), the host-mount RPC goldens pass (7/7), and mobile tsc --noEmit and oxlint are clean.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a23b93a5-40b8-4463-802b-f506c4d585e2
📒 Files selected for processing (5)
mobile/src/host-screen/host-show-pinned-in-groups.test.tsmobile/src/host-screen/use-host-screen-controller.tsmobile/src/host-screen/use-host-screen-identity.tsmobile/src/host-screen/use-host-screen-state.tsmobile/src/host-screen/use-host-worktree-catalog.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
|
@coderabbitai on the outside-diff note about pinned-policy replies after a host switch (use-host-view-settings.ts): that read no longer lives in useHostViewSettings, which is back to main's shape. Since aee0c09 the placement is host-screen state: useHostScreenIdentity resets it when the screen is reused for another host, and the catalog refresh writes it only while the reply's client is still clientRef.current. host-show-pinned-in-groups.test.ts covers both. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
fd 'use-host-view-settings\.ts|use-host-screen-identity\.ts|use-host-worktree-catalog\.ts|host-show-pinned-in-groups\.test\.ts|use-host-screen-state\.ts|use-host-screen-controller\.ts' mobile
for f in $(fd 'use-host-view-settings\.ts|use-host-screen-identity\.ts|use-host-worktree-catalog\.ts|host-show-pinned-in-groups\.test\.ts|use-host-screen-state\.ts|use-host-screen-controller\.ts' mobile); do
echo "===== $f ====="
ast-grep outline "$f" --items all
doneLength of output: 7605 🏁 Script executed: #!/bin/bash
set -euo pipefail
for name in use-host-view-settings.ts use-host-screen-identity.ts use-host-worktree-catalog.ts host-show-pinned-in-groups.test.ts use-host-screen-state.ts; do
f=$(fd -F "$name" mobile | head -1)
echo "===== $f ====="
if [ -n "$f" ]; then nl -ba "$f" | sed -n '1,260p'; fi
doneLength of output: 36528 🏁 Script executed: #!/bin/bash
set -euo pipefail
files=$(fd 'use-host-view-settings\.ts|use-host-screen-identity\.ts|use-host-worktree-catalog\.ts|host-show-pinned-in-groups\.test\.ts|use-host-screen-state\.ts' mobile)
for f in $files; do
echo "===== $f ====="
ast-grep outline "$f" --items all | head -100
nl -ba "$f" | sed -n '1,250p'
doneLength of output: 40983
My outside-diff concern no longer applies. I withdraw it. ✏️ Learnings added
You are interacting with an AI system. |

What
On desktop a pinned workspace shows only in the Pinned section unless Settings → Appearance → Window & Sidebar → "Also show pinned worktrees in their original lists" is on (off by default, #6216). Mobile showed every pinned workspace twice: in Pinned and again in its project group. Mobile now follows the desktop setting.
Cause.
workspace-list-sections.tsalways kept pinned rows in their groups, with a comment from #6786 saying desktop treats Pinned as an overlay. Desktop changed a week later and mobile never read the key.Fix. No wire change and no desktop change:
settings.get, which mobile already calls, carriesshowPinnedWorktreesInGroups. One boolean read operation insettings-read-operations.ts, on the same template as the terminal copy setting; an absent key reads as the desktop default, off. The value is host-screen state like the screen's other per-host values: the worktree catalog reads it beside the existing view-settings sync on connect, focus and mount, behind the same current-client check as the catalog fetch, anduseHostScreenIdentityresets it with the rest when the screen is reused for another host. The view-settings sync and its goldens are untouched.buildSectionstakesshowPinnedInGroups: when off, pinned rows leave their groups, host pins and device-local pins alike, and a repo whose worktrees are all pinned drops its group, as on desktop.Lineage follows the pin, as on desktop. Descendants of a pinned workspace move into Pinned nested under it, walking the same children index the lineage renderer uses, so the edge rule lives once. Like desktop's
getPinnedSectionWorktrees, the walk crosses rows hidden by search or filters, so a visible grandchild still follows a pinned root when the middle row is hidden; only visible rows are placed.Native and the page share this code, so native users get it with the next app release and OTA users with the next desktop daily.
Tests (red first)
workspace-list-sections.test.ts: with the setting off, a host-pinned and a local-pinned workspace are in Pinned and absent from their group in every group mode; with it on, in both places (today's behaviour). Red:expected [ 'pinned', 'repo:repo-1' ] to deeply equal [ 'pinned' ].workspace-list-pinned-lineage.test.ts: an unpinned child of a pinned parent nests under it in Pinned at depth 1 and leaves the group (red showed it as a depth-0 root inrepo:orca); a grandchild whose middle parent is hidden by search still lands in Pinned, as in desktop's "keeps a visible grandchild when the middle parent is absent" test (red: it stayed inrepo:orca).settings-read-operations.test.ts: absent,false, non-boolean and null settings read off;truereads on; a refusal is not accepted.host-show-pinned-in-groups.test.ts: the catalog refresh issues onesettings.getand applies the value, absent reading as off; a reply landing after the screen's client moved on is dropped; reusing the screen for another host resets the value to off.No goldens change.