Skip to content

fix(mobile): keep source-control layout steady while Create PR eligibility loads - #11467

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/repro-8411-scm-jump
Jul 31, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/repro-8411-scm-jump

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #8411. On iOS, source control painted the changed-files list before the
serialized Create PR eligibility request completed, then inserted the action above
the list.

The final implementation keeps that area stable without relying on cached visibility:

  • A fetch-imminent idle frame renders as loading on the first painted list frame.
  • Every connected branch outcome uses one fixed 42pt row: loading, Create PR/MR,
    blocked, existing-review, unsupported-provider, and error states only replace the
    row's contents. Blocked guidance is rendered inside the row, so hints cannot grow it.
  • Request acceptance is scoped to the paired host, worktree, branch, and full fetch
    inputs. Superseded requests are rejected synchronously, and effect cleanup invalidates
    requests from unmounted panels.

What the user sees before and after

Before

The changed-files list appears first, then suddenly moves downward when the Create PR
button loads. A user already tapping the list can hit the wrong item.

After

A disabled review-status row is present when the file list first appears. Its contents
update in place when eligibility resolves, so the changed-files list stays stationary.

Screenshots

Reviewed-head Android simulator A/B at e62e9a22898a9bb3daf0edefe8aeb64fac569f25, using the same device, host, fixtures, and 12-second eligibility delay in both halves. Only the Metro-served client bundle changed.

Before — parent 24a2accc3c

While eligibility is pending, there is no reserved review-status row and the changed-files list paints high. When eligibility resolves, the list moves down 141 px (~54 dp).

Eligibility pending Eligibility resolved
Parent: no reserved row while eligibility is pending Parent: Create Pull Request row appears and shifts the list

After — reviewed head e62e9a2289

The disabled “Checking review status…” row occupies the final footprint immediately. Eligibility resolves to “Create Pull Request” in place, so the changed-files list moves 0 px.

Eligibility pending Eligibility resolved
Reviewed head: reserved loading row is present immediately Reviewed head: row updates in place without moving the list

Full measurements and rig details are in qa-device-slot/.qa-artifacts/QA-REPORT.md Item 9.

Testing

  • pnpm lint — full mobile lint clean
  • pnpm typecheck — mobile tsc --noEmit clean
  • pnpm test — 355 files passed; 2619 passed / 2 skipped
  • pnpm format:check — all 1028 mobile files correctly formatted
  • Regression coverage includes loading-to-creatable, loading-to-hidden/error,
    host isolation, same-identity fetch changes, out-of-order responses, and unmount cleanup
  • pnpm build — not run locally; the mobile workflow validates the pushed head

AI Review Report

The review loop covered the full PR four times. The first two passes found and fixed
reverse collapse, cross-host identity leakage, stale response ordering, hint-height
growth, unmount races, and the blank-spacer/cache tradeoff. The fourth pass was clean at
e62e9a22898a9bb3daf0edefe8aeb64fac569f25.

Provider copy remains explicit: GitLab uses Merge Request labels, GitHub uses Pull
Request labels, and unsupported providers show a neutral unavailable state. The change
does not add Git commands or assume a local worktree; paired hosts, SSH-backed repos,
and folder workspaces use the same host-scoped request path.

Security Audit

No input handling, command execution, path handling, auth, secrets, dependency, or IPC
changes. The implementation only changes mobile render state and request-result
acceptance for an existing RPC.

…ility loads

The Create PR entry unmounted until the first hostedReview.getCreationEligibility
answer arrived, so on a cold open the changed-files list painted first and then
shifted down 54pt (createPrBlock marginTop 12 + createPrButton minHeight 42)
when the button appeared — while the user was already tapping (#8411).

- buildMobileCreatePrAction: cold loading now reserves the row with a disabled
  placeholder instead of unmounting it.
- useMobileHostedReviewEligibility: a fetch-imminent idle frame renders as an
  in-flight load, so the reservation is present on the first painted frame.
- New per-worktree+branch memory of the last resolved eligibility seeds cold
  loads, so branches whose answer is hidden (existing review, unsupported
  provider) do not get a placeholder that collapses on every reopen.

Fixes #8411
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds a 64-entry LRU cache for hosted review eligibility. Eligibility identities now include hostId. The eligibility hook recalls cached results, preserves reservation state, stores successful responses, and handles out-of-order requests. Create-review actions expose reserveSpace, and cold loading produces a disabled loading placeholder. Hidden actions can render reserved space using a new style. Source-control hooks pass hostId through the create-review flow. Tests cover cache behavior, rendering transitions, request ordering, host scoping, and layout stability.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: stabilizing the mobile source-control layout during Create PR eligibility loading.
Description check ✅ Passed The description covers the summary, user-visible behavior, screenshots, testing, AI review, and security audit, and explains why the build check was not run.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a layout-jump bug (issue #8411) on iOS where the changed-files list would shift downward by ~54pt when the Create PR eligibility response arrived after the first paint. The fix ensures a fixed-height 42pt row is always present when a connected branch is visible, with its contents updating in place.

  • Snapshot-based request tracking replaces the old generation+ref approach: renderedMobileHostedReviewEligibilityState maps the initial idle state to loading for fetch-imminent frames, so the row is reserved on first paint. The active flag handles unmount cleanup and out-of-order response rejection. hostId is now part of both the identity and fetch keys to scope requests correctly to the paired host.
  • All connected-branch outcomes now use one visible-disabled row (loading, blocked, unsupported-provider, error) instead of hiding — only idle (disconnected/no-branch) returns null. The hint text is collapsed into the button Text element so the block height never changes from a second element appearing below it.
  • createPrButton switches from minHeight:42 to height:42 and the separate hint Text is removed, making the footprint strictly constant regardless of which state resolves.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to mobile render state and request-result acceptance for one existing RPC call, with no shared state, auth, or IPC modifications.

The snapshot-based tracking correctly handles all ordering edge cases (out-of-order responses, unmount races, identity vs. fetch key splits), and the layout-stability invariant is verified by dedicated test suites covering loading, blocked, error, unsupported-provider, and unmount paths. The active flag cleanly supersedes the old generation+ref approach without introducing new shared state. Fixed-height styling and hint-inside-button consolidation are straightforward.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
mobile/src/source-control/use-mobile-hosted-review-eligibility.ts Replaces generation+ref tracking with a snapshot-based approach; adds hostId to identity and fetch keys; exposes renderedMobileHostedReviewEligibilityState to map idle→loading for fetch-imminent frames, resolving the layout-jump bug
mobile/src/source-control/mobile-create-pr-action.ts Removes HIDDEN_BLOCKED_REASONS and replaces hidden returns with visible-disabled rows for error/loading/unsupported-provider/blocked states; only idle and no-branch remain hidden
mobile/src/source-control/MobileSourceControlCreatePrEntry.tsx Collapses the separate hint Text element into the button Text, using hint ?? label so the button maintains one fixed-height layout regardless of whether hint or label is displayed
mobile/src/source-control/mobile-source-control-styles.ts Switches createPrButton from minHeight:42 to height:42 for a strictly fixed row, removes gap from createPrBlock, and renames createPrHint to createPrButtonHint with updated styling (centered, flexShrink:1)
mobile/src/source-control/use-mobile-hosted-review-eligibility.test.ts Substantially expanded: adds snapshot/key type helpers, host-scoping tests, renderedMobileHostedReviewEligibilityState unit tests, and full React-renderer integration tests for out-of-order responses and unmount cleanup
mobile/src/source-control/mobile-create-pr-action.test.ts Updated existing tests to reflect new visible-disabled semantics and adds a dedicated cold-mount layout stability suite covering all resolved states (creatable, blocked, unsupported, error)
mobile/src/source-control/use-mobile-source-control-create-pr-action.ts Threads hostId through from params to useMobileHostedReviewEligibility so the hook can scope its identity key to the paired host
mobile/src/source-control/use-mobile-source-control-state.ts One-line change: passes hostId into useMobileSourceControlCreatePrAction to complete the hostId propagation chain

Sequence Diagram

sequenceDiagram
    participant R as React render
    participant H as useMobileHostedReviewEligibility
    participant S as renderedMobileHostedReviewEligibilityState
    participant E as useEffect
    participant API as fetchMobileHostedReviewEligibility

    R->>H: render (branch present, connected)
    H->>S: "snapshot={identity:'',fetch:''}, key=K1, shouldFetch=true"
    S-->>H: "{kind:'loading', eligibility:null} idle→loading promotion"
    H-->>R: loading state, row visible+disabled (stable footprint)

    E->>E: effect fires
    E->>E: "setSnapshot({key:K1, state:{kind:'loading', eligibility:null}})"
    E->>API: fetchMobileHostedReviewEligibility(...)
    API-->>E: eligibility result

    E->>E: "active=true, setSnapshot({key:K1, state:{kind:'ready', eligibility}})"
    R->>H: re-render
    H->>S: "snapshot={K1,ready}, key=K1, shouldFetch=true"
    S-->>H: "{kind:'ready', eligibility}"
    H-->>R: ready state, row contents update in place (no layout shift)

    Note over R,API: Unmount or fetch-key change sets active=false, superseded responses are silently dropped
Loading

Reviews (4): Last reviewed commit: "fix(mobile): derive eligibility state fr..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@brennanb2025
brennanb2025 merged commit c6d2180 into main Jul 31, 2026
43 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ility loads (stablyai#11467)

* fix(mobile): keep source-control layout steady while Create PR eligibility loads

The Create PR entry unmounted until the first hostedReview.getCreationEligibility
answer arrived, so on a cold open the changed-files list painted first and then
shifted down 54pt (createPrBlock marginTop 12 + createPrButton minHeight 42)
when the button appeared — while the user was already tapping (stablyai#8411).

- buildMobileCreatePrAction: cold loading now reserves the row with a disabled
  placeholder instead of unmounting it.
- useMobileHostedReviewEligibility: a fetch-imminent idle frame renders as an
  in-flight load, so the reservation is present on the first painted frame.
- New per-worktree+branch memory of the last resolved eligibility seeds cold
  loads, so branches whose answer is hidden (existing review, unsupported
  provider) do not get a placeholder that collapses on every reopen.

Fixes stablyai#8411

* fix(mobile): harden source-control layout reservation

* fix(mobile): keep review status row footprint fixed

* fix(mobile): derive eligibility state from keyed snapshots
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 view is “jumping” after open

1 participant