Repository navigation
fix(mobile): keep source-control layout steady while Create PR eligibility loads - #11467
Conversation
…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
📝 WalkthroughWalkthroughThe change adds a 64-entry LRU cache for hosted review eligibility. Eligibility identities now include 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
|
@coderabbitai review |
Greptile SummaryThis 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.
Confidence Score: 5/5Safe 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.
|
| 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
Reviews (4): Last reviewed commit: "fix(mobile): derive eligibility state fr..." | Re-trigger Greptile
✅ Action performedReview finished.
|
…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
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:
idleframe renders as loading on the first painted list frame.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.
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
24a2accc3cWhile 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).
After — reviewed head
e62e9a2289The 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.
Full measurements and rig details are in
qa-device-slot/.qa-artifacts/QA-REPORT.mdItem 9.Testing
pnpm lint— full mobile lint cleanpnpm typecheck— mobiletsc --noEmitcleanpnpm test— 355 files passed; 2619 passed / 2 skippedpnpm format:check— all 1028 mobile files correctly formattedhost isolation, same-identity fetch changes, out-of-order responses, and unmount cleanup
pnpm build— not run locally; the mobile workflow validates the pushed headAI 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.