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.

Selecting & Editing Directly in Diff Views

You can select code directly inside both split and unified diffs:

  1. Drag across lines or use keyboard selection inside the diff viewport. px0 maps diff lines to working tree coordinates (data-l and data-at line anchors).
  2. Press Alt+E (or Option+E on macOS), or right-click the selection.
  3. Enter your prompt in the agent composer to request adjustments.
  4. When the harness finishes 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.

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

  • Manual Commit: Enter a commit message in the monospace commit box and click Commit (or press Cmd+Enter / Ctrl+Enter inside the input).
  • Commit with AI: Select your preferred AI harness from the picker and click Commit with AI. px0 extracts the unified diff of all staged changes, combines it with your instructions from git.commitMessageInstruction in Settings, generates a concise commit message, and executes the commit in a single operation.

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

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.