Repository navigation
feat(sidebar): the phone reads its workspace list from the sidebar inputs (dark) - #30462
Conversation
…ries the desktop's focused host and host names (dark)
…mpares the phone list to the desktop sidebar (dark)
A collapsed or worktree.ps-failing feed list no longer shows an empty or error state; a queued worktree read uses the latest client; a superseded option change does not report a refusal; the window shadow leaves the focused host to main's test (focus-read ratchet).
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
115a3ea3-afe6-4ac0-b8e0-0c81252fb1bf
📒 Files selected for processing: 55
config/scripts/build-mobile-web-app-bundle.mjsmobile/src/host-screen/host-screen-secondary-styles.tsmobile/src/host-screen/host-sidebar-feed-inputs.tsmobile/src/host-screen/host-sidebar-feed-operations.tsmobile/src/host-screen/host-sidebar-feed-reader.test.tsmobile/src/host-screen/host-sidebar-feed-reader.tsmobile/src/host-screen/host-sidebar-feed-sections.test.tsmobile/src/host-screen/host-sidebar-feed-sections.tsmobile/src/host-screen/host-sidebar-feed.test-fixture.tsmobile/src/host-screen/host-view-pending-changes.tsmobile/src/host-screen/host-workspace-list-action-error.test.tsxmobile/src/host-screen/host-workspace-list-row-memo.test.tsxmobile/src/host-screen/host-workspace-list.tsxmobile/src/host-screen/use-host-list-sections.tsmobile/src/host-screen/use-host-pending-view-changes.test.tsmobile/src/host-screen/use-host-pending-view-changes.tsmobile/src/host-screen/use-host-project-sections.tsmobile/src/host-screen/use-host-repo-icon-data-urls.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-sidebar-feed.tsmobile/src/host-screen/use-host-view-settings.tsmobile/src/host-screen/use-host-worktree-actions.tsmobile/src/host-screen/use-host-worktree-catalog.tsmobile/src/host-screen/workspace-options-sheet.test.tsxmobile/src/host-screen/workspace-options-sheet.tsxmobile/src/worktree/host-workspace-list-states.tsxmobile/src/worktree/host-worktree-refresh.test.tsmobile/src/worktree/host-worktree-refresh.tsmobile/src/worktree/project-sections-operations.tsmobile/src/worktree/workspace-list-types.tssrc/main/runtime/mobile-rpc-allowlist.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-paired-desktop-methods.tssrc/main/runtime/runtime-store-contract.tssrc/main/runtime/sidebar-inputs/desktop-sidebar-facts.test.tssrc/main/runtime/sidebar-inputs/desktop-sidebar-facts.tssrc/main/runtime/sidebar-inputs/repo-icon-data-urls.test.tssrc/main/runtime/sidebar-inputs/repo-icon-data-urls.tssrc/main/runtime/sidebar-inputs/sidebar-inputs-feed-domains.tssrc/renderer/src/lib/sidebar-shadow/desktop-facts-shadow.test.tssrc/renderer/src/lib/sidebar-shadow/desktop-facts-shadow.tssrc/renderer/src/runtime/sync-runtime-graph/project-section-catalog.test.tssrc/renderer/src/runtime/sync-runtime-graph/project-section-catalog.tssrc/shared/mobile-project-sections-contract.tssrc/shared/sidebar-list/desktop-sidebar-facts.tssrc/shared/sidebar-list/repo-icon-data-urls-contract.tssrc/shared/sidebar-list/section-order.tssrc/shared/sidebar-list/sidebar-feed-domains.tssrc/shared/sidebar-list/sidebar-feed-rows.tssrc/shared/sidebar-list/sidebar-row-plan.tssrc/shared/sidebar-list/worktree-group-keys.tstests/e2e/helpers/phone-feed-list.tstests/e2e/sidebar-phone-feed-list.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| const reply = await setCollapsedWrite.request(client, { | ||
| key: change.key, | ||
| collapsed: change.collapsed, | ||
| opId: { writer, seq: change.opId } | ||
| }) | ||
| const unavailable = | ||
| readHostMethodReply(reply, setCollapsedWrite.interpret).kind === 'unavailable' | ||
| outcome = unavailable ? 'unavailable' : reply.ok ? 'settled' : 'refused' |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C8 "applied\s*[:=]" --type=ts -g '!mobile/**' | rg -n -C8 -i "collaps" | head -150
rg -nP -C5 "'ui\.setCollapsed'" --type=ts -g '!**/*.test.ts' | head -80Repository: stablyai/orca
Length of output: 20624
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- mobile hook ---'
nl -ba mobile/src/host-screen/use-host-pending-view-changes.ts | sed -n '1,180p'
printf '%s\n' '--- operation definition ---'
nl -ba mobile/src/host-screen/host-sidebar-feed-operations.ts | sed -n '1,90p'
printf '%s\n' '--- reply reader and relevant consumers ---'
rg -n -F --glob '*.ts' -e 'function readHostMethodReply' -e 'const readHostMethodReply' -e 'readHostMethodReply' -e 'outcome ===' -e "outcome === 'refused'" mobile/src/host-screen src/shared | head -120
printf '%s\n' '--- host handler and collapse writer ---'
nl -ba src/main/runtime/rpc/methods/sidebar-inputs.ts | sed -n '115,140p'
nl -ba src/main/runtime/workspace-view-collapse-writes.ts | sed -n '1,80p'Repository: stablyai/orca
Length of output: 20013
🏁 Script executed:
#!/bin/bash
set -eu
nl -ba mobile/src/host-screen/use-host-view-settings.ts | sed -n '110,285p'
printf '%s\n' '--- collapse state update callers ---'
rg -n -F --glob '*.ts' -e 'toggleCollapsed' -e 'sendCollapse' -e 'refused' mobile/src/host-screen | head -120Repository: stablyai/orca
Length of output: 11578
Treat a mismatched collapse reply as refused.
ui.setCollapsed can return ok: true with applied: false and a collapsed value that differs from the requested state. The current code checks only reply.ok, so it marks the change as settled. The phone then keeps its optimistic state and does not call refused() to resync.
Compare the returned collapsed value with the requested value. Do not require applied: true; an already-settled retry is valid when the returned state matches.
🐛 Suggested fix
- const unavailable =
- readHostMethodReply(reply, setCollapsedWrite.interpret).kind === 'unavailable'
- outcome = unavailable ? 'unavailable' : reply.ok ? 'settled' : 'refused'
+ const read = readHostMethodReply(reply, setCollapsedWrite.interpret)
+ outcome =
+ read.kind === 'unavailable'
+ ? 'unavailable'
+ : read.kind === 'answered' && read.value.collapsed === change.collapsed
+ ? 'settled'
+ : 'refused'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const reply = await setCollapsedWrite.request(client, { | |
| key: change.key, | |
| collapsed: change.collapsed, | |
| opId: { writer, seq: change.opId } | |
| }) | |
| const unavailable = | |
| readHostMethodReply(reply, setCollapsedWrite.interpret).kind === 'unavailable' | |
| outcome = unavailable ? 'unavailable' : reply.ok ? 'settled' : 'refused' | |
| const reply = await setCollapsedWrite.request(client, { | |
| key: change.key, | |
| collapsed: change.collapsed, | |
| opId: { writer, seq: change.opId } | |
| }) | |
| const read = readHostMethodReply(reply, setCollapsedWrite.interpret) | |
| outcome = | |
| read.kind === 'unavailable' | |
| ? 'unavailable' | |
| : read.kind === 'answered' && read.value.collapsed === change.collapsed | |
| ? 'settled' | |
| : 'refused' |
| // Switch point: a feed-built list takes pins from the host alone. | ||
| if (!hostId || ORCA_SIDEBAR_INPUTS_IS_MAIN) { |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Reset hostProjectGroups when the screen switches hosts.
The host-change effect clears every other per-host catalog field, such as setServedProjectSections(null) and setDesktopRepos([]). It does not clear the new hostProjectGroups state. Expo Router can reuse this screen for another hostId. If the new host serves no projectGroups and projectGroup.list fails or is unavailable, buildHostFeedCatalog keeps the previous host's groups. The feed-built list then files folder workspaces under the wrong host's groups. Add the reset to the reset effect (unchanged lines 63-77), next to the other per-host resets.
setServedProjectSections(null)
setDesktopRepos([])
setHostProjectGroups([])setHostProjectGroups must also be destructured from state.
| // Switch point: a feed-built list keeps no pin cache of its own. | ||
| if (ORCA_SIDEBAR_INPUTS_IS_MAIN) { | ||
| return | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use the row's own isPinned once the pin cache stops updating.
With ORCA_SIDEBAR_INPUTS_IS_MAIN, three changed paths stop maintaining pinnedIds:
updateLocalPinsreturns early.- The load in
use-host-screen-identity.tsis skipped. - The server sync in
use-host-worktree-catalog.tsis skipped.
pinnedIds therefore stays an empty Set. togglePin (unchanged lines 139-144) still computes currentlyPinned from worktrees.find(...) and falls back to pinnedIds.has(worktreeId). A feed-only row is drawn from the feed before worktree.ps lists it. For such a pinned row, worktree is undefined, currentlyPinned is false, and the toggle sends isPinned: true again. The user cannot unpin that row until worktree.ps catches up. The feed row already has the authoritative value in item.isPinned, which buildHostFeedSections sets.
Proposed fix in togglePin
- const currentlyPinned = worktree
- ? isWorktreePinned(worktree, pinnedIds)
- : pinnedIds.has(worktreeId)
+ const currentlyPinned = ORCA_SIDEBAR_INPUTS_IS_MAIN
+ ? item.isPinned
+ : worktree
+ ? isWorktreePinned(worktree, pinnedIds)
+ : pinnedIds.has(worktreeId)…the native runtime types Mobile test fixtures fill the fields the test project's types require; the feed trigger type lives with the feed reader, so the e2e helper's imports stop dragging react-native globals into the e2e program; React Doctor's two blocking findings.
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 · 🎯 Functional Correctness · sidebar-feed-rows.ts:137-145
src/shared/sidebar-list/sidebar-feed-rows.ts:137-145
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6110252c-5482-47fa-a8dd-25ce5d0aa2d8
📒 Files selected for processing: 10
mobile/src/host-screen/host-server-workspaces-wiring.test.tsmobile/src/host-screen/host-sidebar-feed-reader.tsmobile/src/host-screen/host-sidebar-feed-sections.tsmobile/src/host-screen/host-sidebar-feed.test-fixture.tsmobile/src/host-screen/use-host-pending-view-changes.test.tsmobile/src/host-screen/use-host-project-sections.test.tsxmobile/src/host-screen/use-host-sidebar-feed.tsmobile/src/host-screen/use-host-worktree-catalog.tsmobile/src/worktree/host-worktree-refresh.tsmobile/src/worktree/project-section-catalog.test.ts
🚧 Files skipped from review as they are similar to previous changes: 1
- mobile/src/host-screen/use-host-pending-view-changes.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
…reads-feed # Conflicts: # src/renderer/src/lib/sidebar-shadow/desktop-facts-shadow.ts # src/shared/sidebar-list/sidebar-feed-domains.ts
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:
3ef3196d-e7fd-4737-8142-8bb489f2721b
📒 Files selected for processing: 6
src/main/runtime/sidebar-inputs/sidebar-inputs-feed-domains.tssrc/renderer/src/components/sidebar/worktree-list/listing/use-main-list-model.tssrc/renderer/src/lib/sidebar-pending-layer.test.tssrc/shared/sidebar-list/sidebar-feed-domains.tssrc/shared/sidebar-list/sidebar-feed-rows.tstests/e2e/sidebar-phone-feed-list.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| await waitForSessionReady(orcaPage) | ||
| const activeId = await waitForActiveWorktree(orcaPage) | ||
| const repoId = activeId.split('::')[0] | ||
| const phone = pairMobileClient(await createDesktopMobilePairingOffer(orcaPage)) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Start cleanup immediately after acquiring each client.
If either worktree RPC or openPhoneFeedList() fails in the first test, phone.dispose() is skipped. If openPhoneFeedList() fails in the paired-server test, dispose() is skipped and the host and desktop remain running. Move these setup calls inside cleanup scopes that begin immediately after acquisition.
Also applies to: 173-173
ELI5
Today the phone works out its own workspace list from several separate reads, so it can disagree with the desktop sidebar. With this change (only in builds that turn on the sidebar inputs switch), the phone builds its list from the same inputs and the same list builder the desktop uses, so the two match row for row. Normal builds are unchanged.
What Changed
Everything below is behind the build switch
ORCA_SIDEBAR_INPUTS=main. With the switch off, the phone page and the desktop behave as before.With the switch on, the phone page:
sidebarInputs.read). It reads again when the event stream is ready, when the app comes to the foreground, and on every change notice. Older answers are ignored.buildSidebarFeedRows): the same groups, order, labels, pinned section, nesting, and a single highlight.ui.setCollapsed. If the host does not have that method, it falls back to writing the whole collapsed list.sidebarInputs.repoIcons(a newrepoIconsinput lists each repo's icon id). Paired-server repos keep the phone's badge.On the host side:
Old pages that are already open, or that were reopened from cache after a failed download, keep using
worktree.psand the other existing reads, unchanged.The phone's own list code is switched off, not deleted. Deleting it is left for when the switch becomes the default (see Notes).
Why
The design asks for one list builder and one set of inputs for every reader, so the phone cannot drift from the desktop. The alternative, patching the phone's own list logic to match each desktop rule, is what led to drift in the first place. Keeping the work behind the build switch lets it land with no visible change while the rest of the sidebar work finishes.
Linked Issue
N/A (maintainer, part of the sidebar list series)
Visual Proof
There is no visible change in normal builds.
Switch-on Android emulator next to a desktop screenshot taken over the debugging protocol:
main(highlighted), then the repo section with feed-c, feed-b, feed-a and e2e-secondary, in the same order on both.These screenshots are kept locally rather than attached.
Testing
What I ran:
sidebar-phone-feed-list.spec.tscompares the phone list to the desktop sidebar for these cases, each with zero shadow mismatches:paired-server-rows-shadow.spec.tsalso passes.Review
I ran an elegance and bug review on the change and on each round of fixes, and applied the findings that held up.
Agent skill upstream boundary
Notes
Left for when the switch becomes the default:
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)