Repository navigation
Consolidate mobile source control into a single tabbed hub - #7923
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (32)
📝 WalkthroughWalkthroughThis PR consolidates mobile Changes, Pull Request, and History experiences into a tabbed Source Control hub. Legacy PR and history routes redirect to the hub with a selected tab. New hub components, history loading, PR-chip derivation, conflict controls, and tab parsing support the interface. PR sidebar loading now separates repository probing, state loading, and detail loading. Session and dock routing now use the unified panel, and a static interactive HTML mock plus unit tests were added. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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.
Actionable comments posted: 4
🧹 Nitpick comments (2)
mobile/src/components/pr-sidebar/mobile-pr-sidebar-styles.ts (1)
78-84: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
openWebButtonduplicatesiconButton— consider reusing the existing style.
openWebButton(lines 78-84) is identical toiconButton(lines 259-265): both are32×32, centered, withborderRadius: radii.button. Eliminate the duplication by reusingiconButtonfor the open-web affordance.♻️ Proposed refactor to reuse iconButton
- openWebButton: { - minWidth: 32, - minHeight: 32, - alignItems: 'center', - justifyContent: 'center', - borderRadius: radii.button - },Then in
PRSidebarHeader.tsx, replacestyles.openWebButtonwithstyles.iconButton(importing the shared styles if not already available).mobile/src/source-control/MobileSourceControlPanel.tsx (1)
128-143: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMove
lastPrBranchRef/lastPrHeadRefmutations from render body to an effect.These refs are written during render (lines 136–141) and then read in the same render pass (lines 142–143) to derive
prBranch/prHeadSha. React 19's concurrent renderer may execute speculative renders that are discarded; a discarded render could leave the ref with a value from a branch that never committed, causing the fallback to briefly serve stale identity to the PR controller. Moving the writes touseEffectensures they only apply after commit, keeping the fallback consistent.♻️ Proposed refactor: move ref writes to an effect
const lastPrBranchRef = useRef<string | null>(null) const lastPrHeadRef = useRef<string | null>(null) useEffect(() => { lastPrBranchRef.current = null lastPrHeadRef.current = null }, [worktreeId]) const statusBranch = status?.branch ?? null const statusHead = status?.head ?? branchCompareResult?.summary.headOid ?? null - if (statusBranch) { - lastPrBranchRef.current = statusBranch - } - if (statusHead) { - lastPrHeadRef.current = statusHead - } + useEffect(() => { + if (statusBranch) { + lastPrBranchRef.current = statusBranch + } + if (statusHead) { + lastPrHeadRef.current = statusHead + } + }, [statusBranch, statusHead]) const prBranch = statusBranch ?? lastPrBranchRef.current const prHeadSha = statusHead ?? lastPrHeadRef.current
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 344fd206-2a32-4f57-baeb-32c749058da0
📒 Files selected for processing (31)
mobile/app/h/[hostId]/history/[worktreeId].tsxmobile/app/h/[hostId]/pr/[worktreeId].tsxmobile/app/h/[hostId]/session/[worktreeId].tsxmobile/app/h/[hostId]/source-control/[worktreeId].tsxmobile/mock-source-control-hub.htmlmobile/src/components/pr-sidebar/MobilePrViewPanel.tsxmobile/src/components/pr-sidebar/PRSidebarHeader.tsxmobile/src/components/pr-sidebar/mobile-pr-sidebar-styles.tsmobile/src/session/SessionDockColumn.tsxmobile/src/session/mobile-pr-sidebar-state.tsmobile/src/session/session-panel-host.test.tsmobile/src/session/session-panel-host.tsmobile/src/session/use-mobile-pr-branch-context.tsmobile/src/session/use-mobile-pr-sidebar-controller.test.tsmobile/src/session/use-mobile-pr-sidebar-controller.tsmobile/src/source-control/MobileGitHistoryList.tsxmobile/src/source-control/MobileSourceControlBranchCard.tsxmobile/src/source-control/MobileSourceControlContent.tsxmobile/src/source-control/MobileSourceControlHeader.tsxmobile/src/source-control/MobileSourceControlPanel.tsxmobile/src/source-control/MobileSourceControlPrChip.tsxmobile/src/source-control/MobileSourceControlSegments.tsxmobile/src/source-control/mobile-pr-chip-summary.test.tsmobile/src/source-control/mobile-pr-chip-summary.tsmobile/src/source-control/mobile-source-control-conflict-abort.test.tsmobile/src/source-control/mobile-source-control-conflict-abort.tsmobile/src/source-control/mobile-source-control-hub-styles.tsmobile/src/source-control/mobile-source-control-hub-tab.test.tsmobile/src/source-control/mobile-source-control-hub-tab.tsmobile/src/source-control/use-mobile-source-control-runners.tsmobile/src/source-control/use-mobile-source-control-state.ts
Unify the changes list, pull request details, and commit history into a single multi-segment panel. This improves navigation and state sharing across different lenses of a worktree's source control. - Add a segmented control to switch between Changes, PR, and History - Introduce a persistent branch status card with an integrated PR chip - Redirect standalone PR and history routes to the new unified hub - Extract reusable UI and logic for the history list and PR summary
* Keep PR and History segments mounted (using display: 'none' when hidden) to preserve fetch, scroll, and expand states during tab switches. * Decouple the History list from blocking on Git status loading. * Support deep linking directly into the history tab of the main panel instead of using a standalone route. * Enable retrying failed loads by reviving the transport loop if parked. * Fix PR chip accessibility label and comment check.
- Lazy-load heavy PR comments and descriptions (Phase 2) only when the PR tab is active, using fast metadata (Phase 1) for the branch chip. - Unmount the PR body when inactive to avoid unnecessary comment tree re-renders and preserve WebView resources during commit text editing. - Implement soft-refresh on HEAD advancement to keep the ready UI visible while re-fetching checks post-commit. - Display the "Aborting..." label only when a merge or rebase abort is actively in flight. - Memoize the git history list and skip branch identity RPCs when gating the dock icon.
- Pass the `origin` parameter through history and PR redirect routes. - Move source control panel ref updates to `useEffect` to prevent side effects during concurrent renders. - Resolve commit file changes to empty if disconnected to avoid a stuck loading spinner. - Standardize PR sidebar header button styling and accessibility labels.
Previously, checking if a repository is a GitHub remote required an active branch. In a detached HEAD or mid-rebase state (where the branch is null), the probe never resolved, leaving the PR panel on a forever spinner. Decouple the repository probe from the branch presence so the panel can correctly display the "Current branch unavailable" state. Also, hide the PR status chip when no branch is active to avoid a spinner on the chip.
9872057 to
6fbfeeb
Compare
…ts-to-mobile Take main's side of the mobile session-screen PR probe: the source-control hub (#7923) now loads branch identity inside MobileSourceControlPanel, so the session screen only gates the dock icon on the GitHub remote probe. Co-authored-by: Orca <[email protected]>
…7923) * Consolidate mobile source control into a single tabbed hub Unify the changes list, pull request details, and commit history into a single multi-segment panel. This improves navigation and state sharing across different lenses of a worktree's source control. - Add a segmented control to switch between Changes, PR, and History - Introduce a persistent branch status card with an integrated PR chip - Redirect standalone PR and history routes to the new unified hub - Extract reusable UI and logic for the history list and PR summary * Keep mobile source control tabs mounted to preserve view state * Keep PR and History segments mounted (using display: 'none' when hidden) to preserve fetch, scroll, and expand states during tab switches. * Decouple the History list from blocking on Git status loading. * Support deep linking directly into the history tab of the main panel instead of using a standalone route. * Enable retrying failed loads by reviving the transport loop if parked. * Fix PR chip accessibility label and comment check. * Optimize and integrate mobile PR view within source control hub - Lazy-load heavy PR comments and descriptions (Phase 2) only when the PR tab is active, using fast metadata (Phase 1) for the branch chip. - Unmount the PR body when inactive to avoid unnecessary comment tree re-renders and preserve WebView resources during commit text editing. - Implement soft-refresh on HEAD advancement to keep the ready UI visible while re-fetching checks post-commit. - Display the "Aborting..." label only when a merge or rebase abort is actively in flight. - Memoize the git history list and skip branch identity RPCs when gating the dock icon. * Improve mobile git views and concurrent rendering safety - Pass the `origin` parameter through history and PR redirect routes. - Move source control panel ref updates to `useEffect` to prevent side effects during concurrent renders. - Resolve commit file changes to empty if disconnected to avoid a stuck loading spinner. - Standardize PR sidebar header button styling and accessibility labels. * Resolve PR repo probe without active branch to avoid forever spinner Previously, checking if a repository is a GitHub remote required an active branch. In a detached HEAD or mid-rebase state (where the branch is null), the probe never resolved, leaving the PR panel on a forever spinner. Decouple the repository probe from the branch presence so the panel can correctly display the "Current branch unavailable" state. Also, hide the PR status chip when no branch is active to avoid a spinner on the chip.
Summary
Consolidates the mobile source control panel, pull request panel, and commit history panel into a single tabbed hub (
MobileSourceControlPanel). This unifies and optimizes state management across these panels, keeping the view states mounted to prevent redundant network fetches or layout shifts, and introduces a persistent summary/branch card with a glanceable PR status chip at the top.Key improvements:
MobileSourceControlPrChipin the shared header card, rolling up check statuses, mergeability/conflicts, and unresolved review threads./prand/historyrouter paths to redirects into the unified source control hub with the correct initial tab parameter.Screenshots
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildUnit tests were added and updated in:
mobile/src/session/use-mobile-pr-sidebar-controller.test.tsmobile/src/source-control/mobile-pr-chip-summary.test.tsmobile/src/source-control/mobile-source-control-conflict-abort.test.tsmobile/src/source-control/mobile-source-control-hub-tab.test.tsAI Review Report
The AI coding agent reviewed the consolidation of panels into the tabbed hub:
/mobile, layout rendering is cross-platform across iOS and Android.Security Audit
Reviewed input handling, auth, and command execution:
use-mobile-source-control-runners) were reviewed to ensure safe execution parameters.Notes
/pror/historywill now transparently redirect to/source-controlwith correct tab parameters.