Git Awareness, Diffs & Everyday Operations

In modern software development, coding agents, background formatters, and compilers continuously modify files on disk. Developers spend a significant portion of their time auditing what changed and committing verified edits.

px0 serves as an ultra-fast, zero-overhead review cockpit and day-to-day Git controller. It keeps your workspace in continuous synchronization with your working tree through real-time Server-Sent Events (SSE) streaming and sub-millisecond Git CLI detection, while providing a streamlined sidebar panel for staging, committing, pushing, and pulling without leaving the browser.

Real-Time Git Status Streaming

px0 connects to a lightweight Server-Sent Events stream (/api/stream or /api/git/stream) running on the Go backend. When files are modified, staged, or removed:

  • Automatic Badge Updates: File explorer status badges (M, A, D, U, R) update in place immediately.
  • Dirty Folder Propagation: Collapsed parent directories display dirty indicator dots as soon as a nested descendant changes.
  • Zero Full-Tree Re-indexing: Updates patch existing DOM elements without re-walking directories on disk, preserving your expanded folders and scroll position.
  • Live Gutter Synchronization: Active editor line gutters and diff views refresh instantly without requiring manual page reloads.
Working Tree Event -> Go GitWatcher -> SSE Stream (/api/stream) -> In-Place DOM Patch

Sub-Millisecond Terminal Awareness

When you run Git commands in your terminal (git checkout, git reset, git add, git commit, git restore, git stash), px0 detects the change in sub-milliseconds:

  1. Every terminal Git operation updates Git internal control files (.git/index, .git/HEAD, or .git/packed-refs) via an atomic rename.
  2. px0’s fast-path watcher checks the metadata timestamps of these control files once per second.
  3. Because this check only inspects metadata without scanning repository files, px0 detects CLI branch switches and checkouts instantaneously, even in repositories containing over 100,000 files.

To remove visual noise and focus exclusively on pending edits:

  1. Click the Changes segment in the sidebar header switch.
  2. The tree collapses untouched folders, displaying only files that contain uncommitted modifications, additions, or deletions.
  3. Click Files to return to the full project hierarchy.

Automatic Explorer Fallback

If you discard or commit all changes while viewing the Changes filter, px0 automatically switches back to the standard file explorer mode. You will never be left stranded on an empty tree view when your working copy becomes clean.

Auto-Closing Discarded Diff Tabs

When reviewing code generated by AI agents or git branches, you often keep several modified files open in diff view (Cmd/Ctrl+D).

If you discard changes to a file from your terminal:

git checkout -- src/core/auth.go

px0 detects that src/core/auth.go is now clean and automatically closes its open diff tab. It reconciles tabs in reverse order and maintains your active tab index so the editor does not jump unexpectedly.

Live File Status Badges

Changed files display color-coded status badges in the file tree:

Badge Status Description
M (Yellow) Modified Existing tracked file modified in the working tree.
A (Green) Added New file staged in the Git index.
D (Red) Deleted File removed from the working tree.
U (Cyan) Untracked New file not yet tracked by Git.
R (Purple) Renamed File renamed or moved.

Ancestor Dirty Propagation

When a deeply nested file is modified (for example src/api/v2/auth/handler.go), every parent directory node (src/, api/, v2/, auth/) automatically displays a dirty dot marker. This ensures modifications are instantly visible even when directory branches are collapsed.

Toggling Diff View (Ctrl+D or Cmd+D)

Open any modified file and press:

Ctrl+D    (or Cmd+D on macOS)

This toggles the active editor between standard code view and the interactive Diff Viewer against HEAD.

Split vs Unified Diffs

  • Split View (Side-by-Side): Displays original HEAD content on the left and modified working tree content on the right, pairing replacement blocks side by side.
  • Unified View (Inline): Displays changes sequentially with green additions (+) and red deletions (-).
  • Clean Hunk Headers: Diffs feature clean hunk boundaries without distracting metadata.
  • Persistent Preferences: Use the toggle in the editor toolbar to switch between Split and Unified modes. px0 stores your layout preference in localStorage.

Syntax-Highlighted Diffs (Powered by Chroma)

In px0 v0.1.10, diff code lines feature server-side syntax highlighting powered by Chroma:

  • Language Token Preservation: Keywords, function signatures, types, comments, and strings retain full theme token colors across both split and unified views.
  • Diff Contrast: Subtle green (--gi-bg) and red (--gd-bg) background tinting highlights additions and deletions while keeping syntax colors sharp and legible.
  • Zero Client Overhead: Highlighting is executed during server-side hunk parsing and delivered via /api/diff, avoiding heavy client-side tokenizers.

Selecting, Editing & Starting Threads from Diff Views

You can interact directly with code lines inside both split and unified diffs:

  1. Selection Anchoring: Drag across lines or use keyboard navigation inside the diff viewport. px0 maps diff lines to working tree coordinates (data-l and data-at line anchors).
  2. Start a Thread (Alt+T): Press Alt+T (Option+T on macOS) to open a multi-turn conversation with your agent anchored to those diff lines.
  3. Inline Agent Edits (Alt+E): Press Alt+E to open the comment box and stage an edit instruction for your coding harness.
  4. Live Reload: When the harness completes writing, px0 reloads the file while maintaining your diff view mode and exact scroll position.

Gutter Diff Markers in Normal View

Even when viewing standard code without full diff mode enabled, the editor line number gutter indicates modifications in real time:

  • Green bar: Added line.
  • Blue bar: Modified line.
  • Red triangle: Deleted line marker positioned where deleted lines originally sat.
  • Thread Icon: Hovering any line number displays a thread icon to start a thread or stage an inline edit.

px0 includes a dedicated Git panel at the base of the left sidebar, providing complete control over everyday Git actions without opening a terminal:

1. Per-File Staging Ticks & Stage All

  • Every changed row in the file tree features a stage tick next to its status badge. Clicking it stages or unstages that specific file (git add or git reset).
  • Click Stage All in the Git panel to stage every modified and untracked file at once.
  • The panel displays live counts: X staged / Y changed.

2. Manual Commit & Commit with AI

  • Collapsible Monospace Input: The commit message textarea is hidden by default to keep the sidebar compact. Click the toggle link to reveal it for manual typing, or let it auto-expand when generating a message.
  • Standalone AI Generation & Pre-Commit Review: Click Generate to draft a commit message with your configured AI harness (Claude Code, Antigravity, Gemini CLI, Cursor Agent) without committing immediately. This lets you review and tweak the text before clicking Commit.
  • 1-Click Commit with AI: Alternatively, click Commit with AI to generate a message and commit the staged changes in a single action.
  • Data-Loss Protection: If a commit fails (for instance due to pre-commit hooks or git conflicts), the generated message remains in the textarea so you never lose your draft.
  • Curated Diff Context: px0 supplies the agent with the list of staged file paths, a diffstat summary, and the staged diff capped at 32 KB while excluding lockfiles and minified assets.
  • Custom Commit Instructions: Set git.commitMessageInstruction in Settings (Cmd+, or Ctrl+,) to enforce custom team guidelines (such as Conventional Commits format, ticket prefixes, or emoji rules).

3. Safe Fast-Forward Pull

  • Clicking Pull invokes git merge --ff-only FETCH_HEAD.
  • If the remote branch has diverged or if uncommitted changes exist locally, px0 refuses the pull immediately with a clear explanatory message. It never initiates an ambiguous merge or creates detached conflict states on disk.

4. Direct Push

  • Clicking Push uploads committed changes to your configured upstream branch.
  • If no upstream tracking branch is set yet, px0 automatically offers to configure it on the first push (git push -u origin <branch>).

5. Reviewing Unpushed Commits

  • In the Changes view beneath the file tree, px0 lists all local commits ahead of your tracking branch (@{u}..HEAD), labelled with the upstream ref they precede (such as origin/main).
  • Interactive Commit Hover Cards: Hover over any commit in the unpushed list to view its author, full commit message, colored diffstat (+green / -red), and a Copy SHA button.
  • Commit-Scoped Diffs: Click any commit row to expand the files it touched, badged identically to working-tree modifications. Clicking a file opens that commit’s isolated diff directly in the diff viewer, unaffected by subsequent edits.
  • Clean Working Tree Retention: Committing no longer hides your work. The Git changes toggle remains accessible even when your working copy is clean whenever unpushed commits exist.

6. Throttled Status Refresh & Flicker-Free Tabs

  • Background git status syncs are throttled with an adaptive cooldown window and deduplication to avoid eating CPU during rapid disk operations.
  • Open tabs apply an onlyIfChanged guard during background synchronizations: untouched files are never repainted, eliminating cursor jumps or visual tab flickering.

Tab Context Menu & Batch Closing

Managing many open diffs and files is simplified with the tab context menu:

  • Right-click any tab in the tab bar to access Close, Close Others, Close to the Right, Close to the Left, or Close All.
  • Actions without matching tabs are automatically disabled.
  • Closing tabs in bulk triggers batched backend cache evictions (Promise.allSettled) to keep memory minimal.

File Tree Context Menu

Right-click any folder or file row in the explorer (or click the three-dots action button) to:

  • Copy Relative Path: Copies the project-relative path (e.g. src/internal/diff.go).
  • Copy File Name / Folder Name: Copies just the filename or directory name.
  • Copy Absolute Path: Copies the full filesystem path on the host machine.

GitHub Pull Request Review

In addition to local repository operations, px0 features native GitHub pull request reviews. By passing any PR URL directly to the CLI (px0 https://github.com/owner/repo/pull/123), you can inspect merge-base diffs, draft inline line comments, run Batch Apply with local AI harnesses, submit reviews, and push commits straight back to the PR’s head branch.

For full details, see the GitHub Pull Request Review Guide.

Battery and Focus Awareness

To conserve laptop battery and CPU cycles:

  • Background Pause: When the browser tab is hidden (document.visibilityState === 'hidden'), px0 disconnects the SSE stream. The backend detects zero active listeners and pauses background worktree polling completely.
  • Instant Focus Wakeup: When you switch back to px0, the client reconnects and immediately dispatches a request to /api/git/refresh to catch any changes made while you were working in another window.
  • Manual Shortcut: You can also force a complete refresh at any time using Mod+Shift+R.