Skip to content

fix(mobile): stop folder-workspace SC selector_not_found retries - #11184

Closed
innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/mobile-sc-folder-workspace-rpc
Closed

innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/mobile-sc-folder-workspace-rpc

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Description

On mobile Source Control for folder workspaces (folder:<id>), unrouted git RPCs (git.branchCompare, history, sync) throw selector_not_found. The loader treated that as transient and retried, so users hit a slow loop then a bare error.

Focused fix

  • Detect folder: worktree ids on mobile
  • Do not retry selector_not_found for folder workspaces (structural, not create-race)
  • Skip git.branchCompare for folders; fail-fast clear message for unrouted sync/history RPCs
  • Branch card label falls back to “Folder workspace” when head/branch are unset
  • Out of scope: main-process routing for every folder git RPC (desktop still gates SC for folders)

Preserves

  • git.status / routed multi-repo folder status still attempted
  • Git worktree SC path unchanged (retries for real create-race still apply)
  • No new desktop Source Control surface for folder workspaces

Evidence

  • Unit tests: mobile-folder-workspace-selector.test.ts, mobile-git-history.test.ts (33 related tests green)

User-regression-tradeoffs

  • Folder SC history/sync show explicit unsupported instead of hanging on retries — intentional degrade until product routes those RPCs

Closes #11153

Made with Orca 🐋

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Mobile source-control logic now distinguishes synthetic folder: workspaces from real worktrees. Folder workspaces receive restricted Git RPC access, skip unsupported history and branch-comparison requests, and use adjusted retry behavior and branch labels. Tests cover workspace detection, RPC authorization, label formatting, history handling, and loader predicates.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to eac97

Folder workspaces on mobile now fail fast instead of retrying. If folder status cannot be resolved, users may still see a generic error instead of the clear "not available" message. This is a small, low-effort follow-up and is not a merge blocker.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Inconclusive The description follows the repository template in substance. It explains the problem and the fix, and it lists what is preserved and what is out of scope. It links issue #11153 with "Closes #11153". … Restructure the description to use the template headings. Add an ELI5 and a plain-language What Changed section that describes the before and after user experience. Add a Why section that explains why detection and degradation was chosen ov…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title "fix(mobile): stop folder-workspace SC selector_not_found retries" describes the main change: folder workspaces on mobile no longer retry selector_not_found. The changeset also adds branch-c…
Linked Issues check Passed Issue #11153 is the only direct linked issue. Its coding requirements, using the 'detect and degrade' option, are met at head eac97e5:

1. Folder selector detection [#11153]: `isMobileFolderWorkspaceI…
Out of Scope Changes check Passed All changes stay within mobile folder-workspace Source Control handling, as the PR summary describes. The changed files are mobile-folder-workspace-selector.ts and its test, mobile-git-history.ts …
Full details: Title check

Explanation

The title "fix(mobile): stop folder-workspace SC selector_not_found retries" describes the main change: folder workspaces on mobile no longer retry selector_not_found. The changeset also adds branch-compare skipping, fail-fast guards for unrouted git RPCs, and a "Folder workspace" branch label, which the title does not mention. Those are secondary to the primary retry fix. The title is specific and uses a conventional commit prefix.

Full details: Linked Issues check

Explanation

Issue #11153 is the only direct linked issue. Its coding requirements, using the 'detect and degrade' option, are met at head eac97e5:

  1. Folder selector detection [#11153]: isMobileFolderWorkspaceId in mobile-folder-workspace-selector.ts tests the folder: prefix.
  2. No retry for selector_not_found on folder workspaces [#11153]: use-mobile-source-control-loaders.ts retries only when shouldRetryMobileStatusSelectorNotFound(worktreeId) is true. Transient refresh errors keep their existing retry path.
  3. git.branchCompare skipped for folder workspaces [#11153]: loadBranchCompare returns early when shouldLoadMobileBranchCompare is false and leaves the compare state idle.
  4. Fail-fast clear message for unrouted sync and history RPCs [#11153]: useMobileGitRequests sendGitRequest calls mobileFolderWorkspaceGitRpcGuard before client.sendRequest. This covers git.upstreamStatus, git.fetch, git.pull, and git.push. fetchMobileGitHistory throws MOBILE_FOLDER_WORKSPACE_UNSUPPORTED_MESSAGE before sending git.history. The message is 'Not available for folder workspaces'.
  5. Branch card label fallback [#11153]: formatMobileFolderAwareBranchLabel returns 'Folder workspace' when branch and head are unset for a folder id. use-mobile-source-control-state.ts uses this helper.
  6. Automated tests [#11153]: the PR adds mobile-folder-workspace-selector.test.ts and extends mobile-git-history.test.ts. The PR reports 33 related tests green. I did not run them.

Residual uncertainty: the issue names a 'clear not supported state'. The PR shows this through thrown error text and the branch label, not a dedicated sync or history UI state. I did not inspect the sync and history components that display these errors. I also did not inspect mobile-branch-compare.ts, mobile-repo-base-ref-operations.ts, or mobile-git-mutation-operations.ts for direct git.* calls that bypass the guards. The issue-listed RPC paths are covered.

Full details: Out of Scope Changes check

Explanation

All changes stay within mobile folder-workspace Source Control handling, as the PR summary describes. The changed files are mobile-folder-workspace-selector.ts and its test, mobile-git-history.ts and its test, use-mobile-git-requests.ts, use-mobile-source-control-loaders.ts, and use-mobile-source-control-state.ts. Each change supports a #11153 objective: detection, retry gating, branch-compare skip, RPC guard, or branch label. The guard also blocks git.commit and other unrouted git.* methods. This extends the same unrouted-RPC requirement and is not unrelated work. The PR adds no desktop Source Control surface and no main-process routing. Those items are listed as out of scope in the PR description, and the summary shows no such changes.

Residual uncertainty: the diff text could not be read. Both diff calls returned changed blobs as missing. This assessment relies on the whole-PR summary and the head file contents I read.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Description check

Explanation

The description follows the repository template in substance. It explains the problem and the fix, and it lists what is preserved and what is out of scope. It links issue #11153 with "Closes #11153". It does not follow the template headings: there is no ELI5, What Changed, Why, Visual Proof, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, or Checklist section. The author gives no visual before/after for the mobile UI change, although the branch card label changes. The Testing section lists only unit tests and does not state whether the change was tested manually on a device. The description also states that 33 tests are green, but it does not list the commands run (pnpm lint, typecheck, test, build).

Resolution

Restructure the description to use the template headings. Add an ELI5 and a plain-language What Changed section that describes the before and after user experience. Add a Why section that explains why detection and degradation was chosen over routing the RPCs. Add Visual Proof for the branch card label change, either as before and after media or as an explicit N/A with a reason. In Testing, state whether manual testing on mobile was done, and list the commands run (pnpm lint, typecheck, test, build). Complete the AI Disclosure section if AI tools were used. Complete the Agent skill upstream boundary checkbox and the Checklist items.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: Pro Plus

Run ID: 4a841d65-3950-4ec9-b4c0-0f1866709a3a

📥 Commits

Reviewing files that changed from the base of the PR and between 0404f27 and ef424da.

📒 Files selected for processing (7)
  • mobile/src/source-control/mobile-folder-workspace-selector.test.ts
  • mobile/src/source-control/mobile-folder-workspace-selector.ts
  • mobile/src/source-control/mobile-git-history.test.ts
  • mobile/src/source-control/mobile-git-history.ts
  • mobile/src/source-control/use-mobile-git-requests.ts
  • mobile/src/source-control/use-mobile-source-control-loaders.ts
  • mobile/src/source-control/use-mobile-source-control-state.ts

@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (ab629eec9)

Address CodeRabbit: allowlist routed folder git RPCs (status/diff only)

innocarpe and others added 2 commits October 29, 2026 11:50
CodeRabbit: replace denylist with allowlist (git.status/git.diff) so
git.commit and other unrouted methods fail closed for folder workspaces.

Co-Authored-By: Grok Companion <[email protected]>
@innocarpe
innocarpe force-pushed the fix/mobile-sc-folder-workspace-rpc branch from ab629ee to eac97e5 Compare October 29, 2026 02:50
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect mobile Source Control for folder workspaces.

The PR appears safe to merge, with a non-blocking gap in tests for the loader's request behavior.

Findings

  1. P2 Loader behavior is not tested ▶

Summary

Mobile Source Control now stops retrying missing folder selectors and skips unsupported folder comparisons.

  • Folder workspaces stop retrying status errors and skip branch comparison.
  • Unsupported Git actions now fail clearly for folder workspaces.
  • Folder workspaces get a clear branch-card label when Git identity is missing.

The author innocarpe explicitly marks unsupported folder history and sync as intentional until those requests are supported.

Reviews (1) · Last reviewed commit: "fix(mobile): allowlist routed folder SC ..." · Reviewed by Greptile

Comment on lines +27 to +43
describe('shouldRetryMobileStatusSelectorNotFound', () => {
it('retries for real worktrees (selector may still be registering)', () => {
expect(shouldRetryMobileStatusSelectorNotFound('wt-123')).toBe(true)
})

it('does not retry for folder workspaces (structural, never resolves)', () => {
expect(shouldRetryMobileStatusSelectorNotFound('folder:group-1')).toBe(false)
})
})

describe('shouldLoadMobileBranchCompare', () => {
it('loads branch compare for real worktrees', () => {
expect(shouldLoadMobileBranchCompare('wt-123')).toBe(true)
})

it('skips branch compare for folder workspaces (unrouted RPC)', () => {
expect(shouldLoadMobileBranchCompare('folder:group-1')).toBe(false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Loader behavior is not tested

These tests check the helpers, but never run useMobileSourceControlLoaders with a folder workspace. They would still pass if the loader stopped using either helper, letting repeated requests return unnoticed.

Add loader tests that assert a folder selector_not_found causes exactly one git.status request, successful folder status sends no git.branchCompare request, and real worktrees still retry.

@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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b6dcea72-051b-4d85-87d5-f8b9b799d6c4
Commits

Reviewing files that changed from the base of the PR and between ab629ee and eac97e5.

Files selected for processing: 5
  • mobile/src/source-control/mobile-git-history.test.ts
  • mobile/src/source-control/mobile-git-history.ts
  • mobile/src/source-control/use-mobile-git-requests.ts
  • mobile/src/source-control/use-mobile-source-control-loaders.ts
  • mobile/src/source-control/use-mobile-source-control-state.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment on lines +225 to +226
(refusal.code === 'selector_not_found' &&
shouldRetryMobileStatusSelectorNotFound(worktreeId)) ||

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.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '195,260p' mobile/src/source-control/use-mobile-source-control-loaders.ts
rg -n "shouldRetryMobileStatusSelectorNotFound|MOBILE_FOLDER_WORKSPACE_UNSUPPORTED_MESSAGE" mobile/src

Repository: stablyai/orca

Length of output: 4768


Script executed:

set -u
printf '%s\n' '--- selector helper ---'
nl -ba mobile/src/source-control/mobile-folder-workspace-selector.ts
printf '%s\n' '--- loader imports and function context ---'
nl -ba mobile/src/source-control/use-mobile-source-control-loaders.ts | sed -n '1,275p'
printf '%s\n' '--- loader state consumers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useMobileSourceControlLoaders' -e "kind === 'error'" -e "screenState.message" -e "screenState.kind" mobile/src/source-control mobile | sed -n '1,240p'
printf '%s\n' '--- relevant diff ---'
git diff --no-ext-diff --unified=30 15c9dfc702c90efaeafe8deb069757b2b1721454 eac97e5182f496d440b0a86a1bd8e2f3fcb0b8a7 -- mobile/src/source-control/use-mobile-source-control-loaders.ts mobile/src/source-control/mobile-folder-workspace-selector.ts mobile/src/source-control/mobile-git-history.ts

Repository: stablyai/orca

Length of output: 41145


Map folder status refusals to the unsupported message.

When folder git.status returns selector_not_found, the loader stops retrying but displays the raw refusal.message or generic fallback. Use MOBILE_FOLDER_WORKSPACE_UNSUPPORTED_MESSAGE for this folder-specific failure while preserving worktree retries and the existing status attempt.

Suggested fix
 import {
+  isMobileFolderWorkspaceId,
+  MOBILE_FOLDER_WORKSPACE_UNSUPPORTED_MESSAGE,
   shouldLoadMobileBranchCompare,
   shouldRetryMobileStatusSelectorNotFound
 } from './mobile-folder-workspace-selector'
...
-            throw new Error(refusal.message || 'Unable to load source control')
+            const message =
+              refusal.code === 'selector_not_found' && isMobileFolderWorkspaceId(worktreeId)
+                ? MOBILE_FOLDER_WORKSPACE_UNSUPPORTED_MESSAGE
+                : refusal.message || 'Unable to load source control'
+            throw new Error(message)

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for keeping this up to date. I'm closing it along with #11153: the phone hides Source Control for folder workspaces, so these retries can't happen on main, and an allowlist would guard a path the phone never takes. If folders get Source Control on the phone later, we'll come back to it.

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]: Mobile Source Control retries selector_not_found for folder-workspace git RPCs that were never routed

3 participants