Skip to content

Consolidate mobile source control into a single tabbed hub - #7923

Merged
AmethystLiang merged 5 commits into
mainfrom
view-pull-request-on-this-mobile-git-view
Jul 10, 2026
Merged

AmethystLiang merged 5 commits into
mainfrom
view-pull-request-on-this-mobile-git-view

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

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:

  • Consolidated Tabbed Hub: Combines Changes, Pull Request, and History screens under one view with a custom segmented control.
  • Persistent View State: Visited tabs remain mounted in the background to preserve scroll positions, form inputs, and fetched data.
  • Glanceable PR Chip: Introduces MobileSourceControlPrChip in the shared header card, rolling up check statuses, mergeability/conflicts, and unresolved review threads.
  • State and Performance Optimizations: Lazy-loads heavy PR detail queries (comments, description body) until the PR tab is active, and skips expensive git branch identity calls for the session dock icon.
  • Deep-linking and Redirection: Converts old /pr and /history router paths to redirects into the unified source control hub with the correct initial tab parameter.

Screenshots

  • TODO: Add screenshots or a screen recording for the consolidated tabbed source control hub.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Unit tests were added and updated in:

  • mobile/src/session/use-mobile-pr-sidebar-controller.test.ts
  • mobile/src/source-control/mobile-pr-chip-summary.test.ts
  • mobile/src/source-control/mobile-source-control-conflict-abort.test.ts
  • mobile/src/source-control/mobile-source-control-hub-tab.test.ts

AI Review Report

The AI coding agent reviewed the consolidation of panels into the tabbed hub:

  • Checked risks: Memory/rendering regressions from keeping inactive tabs mounted. Verified that lazy rendering of heavy sub-components (like comments WebViews) mitigates memory overhead.
  • Checked risks: Duplicate loading/stale-responses when switching branches or pushing commits. Checked that the controller guards against duplicate requests and correctly handles in-flight phase-2 updates.
  • Confirmed that the review explicitly checked cross-platform compatibility for macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and any Electron-specific platform differences touched by this PR. Since this PR resides in React Native /mobile, layout rendering is cross-platform across iOS and Android.

Security Audit

Reviewed input handling, auth, and command execution:

  • Git command runner interfaces (use-mobile-source-control-runners) were reviewed to ensure safe execution parameters.
  • Pull Request metadata retrieval is gated on GitHub authentication/permission checks, degrading gracefully to a "Pull Request Unavailable" message or sign-in recommendation rather than exposing raw RPC surface.
  • Checked for any input handling, command execution, path handling, auth, secrets, dependency, or IPC risks. No direct user input is passed unsanitised into execution shells.

Notes

  • Deep links targeting /pr or /history will now transparently redirect to /source-control with correct tab parameters.
  • State is preserved during a connection loss, allowing retry attempts without wiping the PR chip or commit messages.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 085cd1f7-0b8e-433c-96f1-135144a1a711

📥 Commits

Reviewing files that changed from the base of the PR and between 9872057 and 6fbfeeb.

📒 Files selected for processing (32)
  • mobile/app/h/[hostId]/history/[worktreeId].tsx
  • mobile/app/h/[hostId]/pr/[worktreeId].tsx
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/h/[hostId]/source-control/[worktreeId].tsx
  • mobile/mock-source-control-hub.html
  • mobile/src/components/pr-sidebar/MobilePrViewPanel.tsx
  • mobile/src/components/pr-sidebar/PRSidebarHeader.tsx
  • mobile/src/components/pr-sidebar/mobile-pr-sidebar-styles.ts
  • mobile/src/session/SessionDockColumn.tsx
  • mobile/src/session/mobile-pr-sidebar-state.ts
  • mobile/src/session/session-panel-host.test.ts
  • mobile/src/session/session-panel-host.ts
  • mobile/src/session/use-mobile-pr-branch-context.ts
  • mobile/src/session/use-mobile-pr-sidebar-controller-probe.test.ts
  • mobile/src/session/use-mobile-pr-sidebar-controller.test.ts
  • mobile/src/session/use-mobile-pr-sidebar-controller.ts
  • mobile/src/source-control/MobileGitHistoryList.tsx
  • mobile/src/source-control/MobileSourceControlBranchCard.tsx
  • mobile/src/source-control/MobileSourceControlContent.tsx
  • mobile/src/source-control/MobileSourceControlHeader.tsx
  • mobile/src/source-control/MobileSourceControlPanel.tsx
  • mobile/src/source-control/MobileSourceControlPrChip.tsx
  • mobile/src/source-control/MobileSourceControlSegments.tsx
  • mobile/src/source-control/mobile-pr-chip-summary.test.ts
  • mobile/src/source-control/mobile-pr-chip-summary.ts
  • mobile/src/source-control/mobile-source-control-conflict-abort.test.ts
  • mobile/src/source-control/mobile-source-control-conflict-abort.ts
  • mobile/src/source-control/mobile-source-control-hub-styles.ts
  • mobile/src/source-control/mobile-source-control-hub-tab.test.ts
  • mobile/src/source-control/mobile-source-control-hub-tab.ts
  • mobile/src/source-control/use-mobile-source-control-runners.ts
  • mobile/src/source-control/use-mobile-source-control-state.ts

📝 Walkthrough

Walkthrough

This 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.89% 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
Title check ✅ Passed The title clearly summarizes the main change: consolidating mobile source control into a single tabbed hub.
Description check ✅ Passed All required sections are present and the PR is mostly well documented, though screenshots and cross-platform review details are still thin.
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.
✨ Finishing Touches
📝 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.

@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: 4

🧹 Nitpick comments (2)
mobile/src/components/pr-sidebar/mobile-pr-sidebar-styles.ts (1)

78-84: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

openWebButton duplicates iconButton — consider reusing the existing style.

openWebButton (lines 78-84) is identical to iconButton (lines 259-265): both are 32×32, centered, with borderRadius: radii.button. Eliminate the duplication by reusing iconButton for 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, replace styles.openWebButton with styles.iconButton (importing the shared styles if not already available).

mobile/src/source-control/MobileSourceControlPanel.tsx (1)

128-143: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Move lastPrBranchRef/lastPrHeadRef mutations 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 to useEffect ensures 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

📥 Commits

Reviewing files that changed from the base of the PR and between 24d7f6b and 9872057.

📒 Files selected for processing (31)
  • mobile/app/h/[hostId]/history/[worktreeId].tsx
  • mobile/app/h/[hostId]/pr/[worktreeId].tsx
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/h/[hostId]/source-control/[worktreeId].tsx
  • mobile/mock-source-control-hub.html
  • mobile/src/components/pr-sidebar/MobilePrViewPanel.tsx
  • mobile/src/components/pr-sidebar/PRSidebarHeader.tsx
  • mobile/src/components/pr-sidebar/mobile-pr-sidebar-styles.ts
  • mobile/src/session/SessionDockColumn.tsx
  • mobile/src/session/mobile-pr-sidebar-state.ts
  • mobile/src/session/session-panel-host.test.ts
  • mobile/src/session/session-panel-host.ts
  • mobile/src/session/use-mobile-pr-branch-context.ts
  • mobile/src/session/use-mobile-pr-sidebar-controller.test.ts
  • mobile/src/session/use-mobile-pr-sidebar-controller.ts
  • mobile/src/source-control/MobileGitHistoryList.tsx
  • mobile/src/source-control/MobileSourceControlBranchCard.tsx
  • mobile/src/source-control/MobileSourceControlContent.tsx
  • mobile/src/source-control/MobileSourceControlHeader.tsx
  • mobile/src/source-control/MobileSourceControlPanel.tsx
  • mobile/src/source-control/MobileSourceControlPrChip.tsx
  • mobile/src/source-control/MobileSourceControlSegments.tsx
  • mobile/src/source-control/mobile-pr-chip-summary.test.ts
  • mobile/src/source-control/mobile-pr-chip-summary.ts
  • mobile/src/source-control/mobile-source-control-conflict-abort.test.ts
  • mobile/src/source-control/mobile-source-control-conflict-abort.ts
  • mobile/src/source-control/mobile-source-control-hub-styles.ts
  • mobile/src/source-control/mobile-source-control-hub-tab.test.ts
  • mobile/src/source-control/mobile-source-control-hub-tab.ts
  • mobile/src/source-control/use-mobile-source-control-runners.ts
  • mobile/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.
@AmethystLiang
AmethystLiang force-pushed the view-pull-request-on-this-mobile-git-view branch from 9872057 to 6fbfeeb Compare July 10, 2026 02:23
@AmethystLiang
AmethystLiang merged commit 43f639d into main Jul 10, 2026
2 checks passed
brennanb2025 added a commit that referenced this pull request Jul 10, 2026
…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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
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.

1 participant