Skip to content

feat(git): git.history pages a branch's own commits with pushed state - #36962

Merged
AmoabaKelvin merged 1 commit into
mainfrom
git-history-branch-only
Nov 1, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
git-history-branch-only

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​77 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​207 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​193

ELI5

The desktop can now answer "which commits does this branch add on top of main, and which of those haven't been pushed?" It answers a page at a time, so a phone can scroll past 50. Nothing on screen changes in this PR. The mobile Commits screen that uses it comes next.

What Changed

  • git.history takes two new optional params:
    • branchOnly (with the existing baseRef): the page lists only the commits HEAD has and the base lacks (git log HEAD ^<base>).
    • skip: the page starts that many commits in (--skip).
  • A branch-only page also carries:
    • per-commit statistics (files, insertions, deletions), parsed from --shortstat;
    • per-commit pushed, from git rev-list HEAD ^<upstream> ^<base> (that set is bounded by the branch's own commits). The upstream is the same effective upstream git.upstreamStatus uses, so this matches the Sync and Push state. With no upstream, nothing counts as pushed;
    • branch: { baseRef, ahead, behind, unpushed }. ahead and behind come from one rev-list --left-right --count base...HEAD.
  • skip is echoed back when sent, so a client can tell a host that pages from one that ignores the param.
  • A checkout of the base's own branch (main with base origin/main) has nothing to cut out, so it keeps HEAD's full history instead of returning an empty page. Remote names containing / are split at a configured remote.
  • The desktop IPC and web preload adapters forward the new options too, so every route behaves the same.
  • The log parser picks up the --shortstat line that git prints after a record's NUL, at the start of the next record.
  • Mobile may now call git.remoteCommitUrl, the same call desktop's "Open on GitHub" uses (GitHub, GitLab and Bitbucket).

Why

On mobile, the Commits tab lists the repo's last 50 commits from HEAD with no paging. It doesn't stop where the branch began, and it can't tell pushed commits from unpushed ones. The approved Source Control mocks replace it with a "this branch only" screen: Not pushed / On origin groups, a "Branched from main" marker and paging. The loader is shared by every route (local, WSL, SSH and runtime hosts), so the rule goes there once, and the client only lays out what the host returns.

Alternatives I ruled out:

  • Cutting the list at the merge base on the client: it can't page past 200, and it gets the pushed state wrong when a merge commit interleaves pushed and unpushed lines in topo order.
  • A new RPC: this is the same query with a range, so extending git.history keeps a single owner.

Mixed versions:

  • Every new param and field is optional.
  • Older hosts strip unknown params (GitHistory is a non-strict z.object) and reply as before. Clients detect that by the missing branch / skip echo and show the full history.
  • Older clients send neither param and get byte-for-byte the same reply.

Linked Issue

None. This is the backend half of the approved mobile Source Control redesign (the Commits screen). The mobile PR stacks on it.

Visual Proof

N/A: there is no UI in this PR. The mobile Commits screen PR that uses it carries the before/after.

Testing

  • src/shared/git-history-real-repository.test.ts adds a real-git regression test. It checks that the page:

    • stops at the base and marks the commits the upstream has;
    • pages with skip, which is echoed back;
    • parses statistics;
    • keeps the full history when the base is HEAD's own branch, including origin/<branch> on that branch;
    • splits a remote named gh/team correctly;
    • follows the effective upstream for a branch pushed without tracking. The test fails on main.
  • These pass locally: git-history.test.ts, git.test.ts, the mobile allowlist/routing tests, and the request-authorization and local-git-provider suites.

  • Platforms: macOS, with real git. The loader is platform-neutral and uses git's English-pinned output.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Four review rounds (Codex and Claude). Accepted and fixed:

  • Empty page on the base's own branch: with main checked out and base origin/main, the page came back empty.
  • Remote names with slashes: these are now split at a configured remote.
  • Pushed state: it follows the same effective upstream as git.upstreamStatus. This covers legacy worktrees that track origin/main but publish to origin/<branch>, and agents that pushed with git push origin HEAD.
  • Adapters: the desktop IPC and web adapters now forward branchOnly and skip.
  • Local upstream names: a local upstream name is resolved directly.

Left as is:

  • A detached HEAD reports every branch-only commit as not pushed (P3: there is no upstream to compare against).
  • An empty repo doesn't echo skip (P3: there is nothing to page).
  • The branch-only git calls run one after another rather than in parallel (P3).

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: skip is a validated non-negative int. The base and upstream reach git only as resolved OIDs.
  • SSH and remote: these hosts run the same handler on the remote side, and older remote hosts degrade as described above.
  • Folder workspaces: unchanged. A non-git folder still fails the same way.
  • Performance: --shortstat and the two rev-list calls run only on branch-only pages, and they're bounded by the branch's own commits.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

git.history gains optional branchOnly and skip params. A branch-only page
lists only commits the base lacks, with per-commit stats and whether the
upstream has each one, plus ahead/behind/unpushed counts. Older clients
send neither param and get the same reply as before; older hosts ignore
them, so clients detect support from the echoed branch and skip fields.

Mobile may now call git.remoteCommitUrl to open a commit on its host.
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: 8ca7770b-d61f-4da0-a549-3042d27275aa
Commits

Reviewing files that changed from the base of the PR and between d77a49d and 88d6303.

Files selected for processing: 11
  • src/main/ipc/filesystem/filesystem-git-status-handlers.ts
  • src/main/runtime/rpc/methods/git.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-mobile-method-routing.ts
  • src/renderer/src/web/preload-api/web-git-api.ts
  • src/shared/git-effective-upstream.ts
  • src/shared/git-history-branch-range.ts
  • src/shared/git-history-log-parser.ts
  • src/shared/git-history-real-repository.test.ts
  • src/shared/git-history-types.ts
  • src/shared/git-history.ts
  • src/shared/rpc-contract/git-params.ts

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

Walkthrough

Git history requests now forward branchOnly and skip. Branch-only history can return branch-range counts, pushed state, and commit statistics. The result includes the clamped skip value when requested. The execution-host RPC method list now includes git.remoteCommitUrl.

Merge Risk: Minimal · up to 88d63

The reviewed history and mobile-routing changes have no identified issue that needs resolution before merge. Normal checks remain appropriate.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.18% 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. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: paginated branch-only git history with pushed-state information.
Description check Passed The description is detailed and covers the required change summary, rationale, testing, visual proof, compatibility, security, performance, and checklist sections. The linked issue is marked as unavai…
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.
Full details: Description check

Explanation

The description is detailed and covers the required change summary, rationale, testing, visual proof, compatibility, security, performance, and checklist sections. The linked issue is marked as unavailable, but the description explains the related mobile redesign and is otherwise complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 18.18% 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 11 functions across 11 files.

Resolution

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

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • 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

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