Skip to content

Review local git diffs with optional tool mode - #100

Merged
oddur merged 4 commits into
mainfrom
feat/local-git-review
Apr 22, 2026
Merged

Review local git diffs with optional tool mode#100
oddur merged 4 commits into
mainfrom
feat/local-git-review

Conversation

@oddur

@oddur oddur commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a DiffSource abstraction so the review pipeline runs against either a GitHub PR or a local git repository (any sha/branch/tag/HEAD~n, three-dot diff semantics matching GitHub's PR view).
  • New LocalRepoDialog with repo picker, branch datalist, default base that prefers origin/main over stale local refs, live file-count preview, humanized validation errors, and last-used path recall.
  • Optional tool mode: when the reviewer opts in, Claude runs with cwd = repo so it auto-discovers the project's own .mcp.json, .claude/settings.json, and skills. Read-only + test tools (Bash, Read, Grep, Glob) are allowed; Edit/Write stay off to protect the working tree. Project context is served unfiltered in this mode since the agent can reach every entry via tools anyway.
  • Renderer + IPC gated: GitHub-only features (submit review, freshness poll, CI/review status, proactive watching) are hidden or return { supported: false } for local: URLs.
  • PRSummaryBanner shows the actual base → head range inline instead of an "Open on GitHub" link for local reviews.

Test plan

  • Paste a GitHub PR URL → review generates identically to before (no regressions on the GitHub path).
  • Click "review a local git diff" under the URL input, pick a repo, accept defaults → review runs to completion.
  • Validation errors: pick a non-repo directory, unknown ref, same base/head → each shows targeted recovery copy, no raw git: messages leak.
  • Branch datalist populates both local + remote refs; default base resolves to origin/main (or whatever origin/HEAD points at) rather than stale local main.
  • Live file-count preview warns (red copy) when the diff exceeds 500 files.
  • Dirty working tree with HEAD as a ref → "Working tree has uncommitted changes" phase message appears.
  • Enable "Run project tools during review": confirm the CLI runs in the repo's cwd (check main-process logs), the repo's .mcp.json / skills are available, and the phase banner surfaces the tool-mode notice.
  • Open a local review from history → submit-to-GitHub / CI / freshness UI stay hidden; banner shows base → head.
  • pnpm tsc --noEmit clean; pnpm eslint . introduces zero new errors (pre-existing warnings on src/main.ts / src/pages/HomePage.tsx untouched).

🤖 Generated with Claude Code

oddur and others added 4 commits April 22, 2026 10:23
Site: add @aptabase/web to the shared Base layout with a pageview
event per load. Uses app key A-EU-1996018704 (separate from the
Electron app's key so site and app traffic stay distinct).

App: move initialize() to module scope so it runs BEFORE
app.whenReady() — the Aptabase Electron README requires this, and
with init inside the whenReady handler we were silently dropping
every event including app_started. Reads prefs early (safe — only
touches app.getPath('userData') which works pre-ready) and skips
init if analytics is off. The existing enableAnalyticsIfAllowed
fallback is kept so users who opt in mid-session still get tracked.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Squirrel fires update-downloaded on a timer that routinely beats the
renderer to its IPC subscription, so the "will install on next restart"
banner was being lost — users had no idea an update was waiting. Cache
the ready version in the main process and expose it via a pull IPC so
the banner can replay it on mount.

Also add GNOSIS_FAKE_UPDATE_READY env var that seeds the cache at
startup, letting the banner be tested in dev without a real download.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add a DiffSource abstraction so the review pipeline can run against either
a GitHub PR or a local git repository. Local reviews take a repo path and
two refs (any sha/branch/tag/HEAD~n), produce a three-dot diff matching
GitHub PR semantics, and feed the existing slideshow pipeline.

When the reviewer opts in to tool mode, the CLI runs with cwd = repo so
Claude auto-discovers the project's own .mcp.json, .claude/settings.json,
and skills. Allowed tools expand to Bash/Read/Grep/Glob for running tests
and searching the tree, while Edit/Write stay off to keep the working
tree clean. The Claude project context is served unfiltered in this mode
since the agent can reach every entry via tools anyway.

Key pieces:
- lib/diffSource.ts: DiffSource interface + createDiffSource factory.
- lib/localGit.ts: LocalGitDiffSource backed by git subprocesses.
- lib/claude-context.ts: shared .claude/** probe used by both sources.
- components/LocalRepoDialog.tsx: repo picker with branch datalist,
  default-base detection (prefers origin/main over stale local main),
  live file-count preview, humanized validation errors, tool-mode
  opt-in checkbox, and last-used path recall.
- src/main.ts: routes runBackgroundGeneration through the factory;
  gates GitHub-only IPC handlers (submit-review, freshness, CI) on
  local URLs; adds pick-repo-dir / list-repo-refs / validate-local-repo
  IPCs; wires cwd + read-only tool allow-list when local tools are on.
- Renderer gating: hides submit dialog, freshness poll, and PR status
  calls for local reviews; PRSummaryBanner shows the base→head range
  inline instead of a github.com link.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Rework the unauthenticated welcome into two equal paths: sign in with
GitHub, or review any local git repo with no account needed. Choosing
the local path flips a new `guestMode` preference so the home screen
unlocks and returning visits skip the gate. The masthead surfaces a
"Guest · connect GitHub" affordance for a one-click upgrade when the
user is ready.

Guest-mode renderer gating:
- Compose-form prose hides "browse your pull requests" (requires a
  token); "review a local git diff" stays.
- OnboardingRepoSetup gains a line pointing users at local review as
  an alternative to repo-watching.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oddur
oddur merged commit 09f8c64 into main Apr 22, 2026
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