Staging, Committing, and Viewing Diffs in Tempest
Tempest provides a visual staging and commit workflow through the Diff pane, allowing you to review changes, stage files selectively, and commit with custom messages. This page covers every git operation Tempest offers for staging, committing, and viewing diffs, along with how the UI represents git state.The Staging Workflow in Tempest UI
The staging workflow is centered in the Diff pane, a two-column layout accessed from the main sidebar or via the Eye icon in the RightSidebar.Left Column: File Lists and Commit Form
The left side shows two sections:- Staged files: Files you have explicitly staged for the next commit (via
git add). - Unstaged changes: Modified and untracked files not yet staged.
- A count of files (
Staged 3,Unstaged 5) - A list of files with their status badge (M, A, D, R, ?)
- Action buttons to stage, unstage, or discard individual files
- A header button to stage/unstage all files at once
- Title input (required)
- Description textarea (optional)
- Co-author checkbox (toggles
Co-authored-by: Tempest <tempest@local>) - Commit button (disabled until files are staged and title is non-empty)
Right Column: Per-File Diff Viewer
Clicking a file shows its unified diff on the right side:- File header showing the file path and section (staged/unstaged)
- Diff lines with old and new line numbers
- Four line types: hunk headers (@@), added (+), removed (-), context ( )
- Color coding: added lines green, removed lines red, context lines gray
Branch Picker and Push Controls
The Diff pane header includes:- Branch picker: Shows current branch, allows switching to other branches or deleting branches.
- Reload button: Refreshes the file list and all counts.
- Push button: Pushes the current branch to remote (does not auto-commit; use only if all changes are already committed).
- New Branch button: Creates a new branch and pushes it (useful for creating a PR without committing first).
Git Operations: The Complete Command Set
Tempest exposes seven core git staging operations plus diff viewing and committing.1. Stage a Single File
UI action: Click the+ button next to a file in the Unstaged section.
Tauri command:
src/components/Button.tsx is now staged for the next commit.
2. Unstage a Single File
UI action: Click the- button next to a file in the Staged section.
Tauri command:
src/index.ts is no longer staged, but your edits remain in the working tree.
3. Discard Changes to a File
UI action: Click theX button next to a file in the Unstaged section. Confirm the warning dialog.
Tauri command:
- If tracked (modified or deleted in index): reverts the file to the HEAD version. All uncommitted changes are lost.
- If untracked (new file): deletes the file entirely.
4. Stage All Files
UI action: Click theStage All button in the Unstaged section header (only visible if unstaged files exist).
Tauri command:
.gitignore).
This is equivalent to running git add -A in the working tree. All files move from Unstaged to Staged.
5. Unstage All Files
UI action: Click theUnstage All button in the Staged section header (only visible if staged files exist).
Tauri command:
6. Commit Staged Files
UI action: Type a title in the commit form, optionally add a description, ensure at least one file is staged, then click theCommit button.
Tauri command:
Co-authored-by: Tempest <tempest@local> is appended.
Message format:
- Title must be non-empty after trimming whitespace.
- At least one file must be staged.
7. View a File’s Diff
UI action: Click a file in either the Staged or Unstaged section to view its diff on the right. Tauri command:- Line numbers for old and new versions
- Hunk headers (
@@ -old_start,count +new_start,count @@) - Added lines (green, prefixed
+) - Removed lines (red, prefixed
-) - Context lines (gray, prefixed
)
The Commit Flow: Complete Journey
Here is the exact sequence when you commit via the Diff pane:- User enters title and optional description in the commit form.
- User clicks Commit button (only enabled if title is non-empty and at least one file is staged).
-
Tempest builds the commit message:
-
Tempest invokes
git_commit_staged: - Git writes the commit object and updates the branch ref. The working tree is now clean (all staged files are in history).
-
UI updates:
- Commit message fields are cleared.
- Selected file is deselected.
- Diff viewer is hidden.
- File lists are reloaded via
git status. - Commit button shows a green check for 1.5 seconds (success feedback).
- If git commit fails, the error is displayed in the Diff pane and the user can fix the issue and retry.
Viewing Diffs: The DiffPane Component
The DiffPane component is Tempest’s unified diff viewer. It takes a file’s raw git diff output and renders it with syntax-aware line numbers and color coding.Diff Parsing
The unified diff parser (inlib.rs lines 889-940) processes git’s raw diff output and extracts:
- File status (M, A, D, R for modified, added, deleted, renamed)
- File path
- Hunk headers (start line numbers for old and new)
- Line types (added, removed, context)
- Line content (including the leading
+,-, or) - Added and deleted counts per file
Diff Display
The DiffPane displays the parsed diff as:- File header: Shows the file path and which section (staged/unstaged).
- Diff scroll area: Renders lines in a monospace font.
- Line numbers: Shows old line number (left) and new line number (right).
- Color coding:
- Hunk headers (
@@): Gray background - Added lines (
+): Green background - Removed lines (
-): Red background - Context lines (
): No background
- Hunk headers (
Empty Diff
If a file has no diff (no changes, or file is staged but has no unstaged changes), the diff area shows “No diff to display”.The RightSidebar: File Tree and Changes Panel
The RightSidebar is Tempest’s secondary view for files and changes. It has two tabs:All Files Tab
Displays the full project directory tree, collapsed by default. Click folders to expand and browse files. Click files to open them in the editor (ifonOpenFile is provided).
This is for navigating your project; it does not show git status.
Changes Tab
Displays git status output as a flat list of changed files:- Status label: Single character (M, A, D, R, C, ?)
- File path: Relative path from the project root
- Color coding: Each status has a distinct color (modified blue, added green, deleted red, etc.)
Git Status Representation
Git status is fetched via:M= Modified in working tree onlyM= Modified in index only (staged)MM= Modified in bothA= Added to working tree (untracked)A= Added to index (staged)D= Deleted from working treeD= Deleted from indexR= RenamedC= Copied??= Untracked
xy value is captured and used to determine whether a file is staged or unstaged:
- If
x != ' 'andx != '?': file is in the index (staged) - If
y != ' 'orxy == "??": file has working tree changes or is untracked
Auto-Commit Behavior in git_push_branch
Tempest has one special auto-commit behavior in thegit_push_branch command (used when pushing via the “Push & PR” button in a new branch).
When you create a new branch and push without committing, Tempest checks if there are uncommitted changes:
git_push_branch (the “Push & PR” flow). The regular git_push_current_branch command does not auto-commit; it pushes only what is already committed.
Git Status States and What They Mean
The RightSidebar and Diff pane display files with status codes. Here is what each means:| Status | Meaning | Editable? | Stageable? |
|---|---|---|---|
| M | Modified | Yes (edited in working tree) | Yes (stage to index) |
| A | Added | Yes (new tracked file) | Yes (stage to index) |
| D | Deleted | Yes (deleted in working tree, tracked before) | Yes (stage deletion) |
| R | Renamed | Yes (file moved/renamed) | Yes (stage rename) |
| C | Copied | Yes (file copied, tracked) | Yes (stage copy) |
| ? | Untracked | Yes (new file not in any commit) | Yes (stage as new file) |
- Staged section: Files with changes in the index (ready to commit).
- Unstaged section: Files with changes in the working tree (not yet staged).
Pushing Changes
Tempest provides two push commands via the Diff pane header:Push to Current Branch
UI: Click thePush button in the header.
Tauri command:
-u creates it. If the branch already exists and is behind the remote, the push fails (no force).
Create New Branch and Push
UI: Click theNew Branch button in the header, enter a branch name, then click Push & PR.
Tauri command: