Skip to content

Conversation

@dreamiurg
Copy link

@dreamiurg dreamiurg commented Jan 12, 2026

Motivation

I wanted a way to see at a glance whether I have staged or unstaged changes in my git repo, but without the line counts that git-changes displays. My screen real estate is limited and I just need a quick visual indicator - not the full details.

Solution

This PR adds a new git-indicators widget that shows minimal git status indicators:

  • + for staged changes (green when preserveColors is enabled)
  • * for unstaged changes (red when preserveColors is enabled)

When there are no changes, the widget displays nothing, keeping the status line clean.

Configurability

  • preserveColors (p keybind): When enabled, widget outputs hardcoded ANSI colors (green +, red *). When disabled, outputs plain text and user can set color via Edit Colors.
  • hideNoGit (h keybind): When enabled, hides the widget entirely when not in a git repo (instead of showing empty space).

Example Configuration

{
  "id": "git-indicators",
  "type": "git-indicators",
  "preserveColors": true,
  "metadata": {
    "hideNoGit": "true"
  }
}

Changes

New Widget

  • Add GitIndicatorsWidget in src/widgets/GitIndicators.ts
  • Register widget in src/widgets/index.ts and src/utils/widgets.ts

Renderer Enhancement

The preserveColors property was already defined in the WidgetItem schema, but the renderer only honored it for custom-command widgets. I extended this to work with all widget types by removing the widget.type === 'custom-command' check. This allows any built-in widget to output ANSI color codes and have them preserved, rather than being stripped and replaced with the widget's color property.

Build Enhancement

Added prepare script to package.json so the TypeScript gets built when installing from GitHub via npx github:owner/repo.

Tests

  • Add focused test suite (5 tests) covering core indicator logic, non-git-repo handling, ANSI color output, preview mode, and editor action handling

Testing

All 45 tests pass. Tested extensively on my machine - works great!

dreamiurg and others added 8 commits January 12, 2026 10:22
Shows git status indicators:
- + for staged changes
- * for unstaged changes

Configurable via widget color property.
Supports hiding when not in a git repo.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Widget outputs ANSI color codes (green +, red *) when preserveColors is enabled
- Extended renderer to support preserveColors for all widget types, not just custom-command

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add comprehensive test suite (22 tests)
- Fix modifier text to match sibling widgets: "hide 'no git'"
- Fix keybind label to match sibling widgets
- Mark unused settings parameter with underscore

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Reduced from 22 tests to 4 focused tests that cover:
- Core indicator logic (+, *, +*, empty)
- Non-git-repo handling
- ANSI color output
- Preview mode

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add colorMode toggle (raw/custom) via 'm' keybind
- Add stagedColor cycling via 's' keybind (green, brightGreen, cyan, etc.)
- Add unstagedColor cycling via 'u' keybind (red, brightRed, yellow, etc.)
- Raw mode uses hardcoded green/red ANSI codes
- Custom mode uses getColorAnsiCode() for configurable colors
- Update tests to cover new color configuration

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add (p) keybind to toggle preserveColors in TUI
- When preserveColors ON: widget outputs ANSI colors (green +, red *)
- When preserveColors OFF: user can override via Edit Colors
- Update getEditorDisplay to show color configuration state
- Add test for toggle-preserve-colors action

Co-Authored-By: Claude Opus 4.5 <[email protected]>
When installing from GitHub via npx, the prepare script runs
after npm install, building the TypeScript to dist/.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Remove custom color cycling (m/s/u keybinds) - color configuration
belongs in Edit Colors, not widget-specific keybinds.

Widget now has two modes:
- preserveColors OFF: plain +* output, user sets color via Edit Colors
- preserveColors ON: widget outputs green + and red *

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@dreamiurg dreamiurg marked this pull request as ready for review January 12, 2026 21:09
zoonderkins added a commit to zoonderkins/ccstatusline that referenced this pull request Jan 21, 2026
Merged PRs:
- sirmalloc#138: fix: support bare repo worktrees in GitWorktree widget
- sirmalloc#135: feat: add git-indicators widget
- sirmalloc#132: fix: Windows terminal width detection
- sirmalloc#131: feat: Task Timer widget
- sirmalloc#123: feat: Add backups for settings.json
- sirmalloc#121: feat: Add configurable context warning alerts
- sirmalloc#120: feat: Add Mercurial support
- sirmalloc#119: feat: Add Git Root Dir widget
- sirmalloc#58: feat: Add support for local/project settings

Fixes Issues:
- sirmalloc#117: Windows tput cols creates null file
- sirmalloc#122: claude's settings.json deleted/lost
- sirmalloc#112: Add mercurial support

Additional fixes:
- Resolved circular dependency in renderer.ts/widgets.ts
- Fixed lint errors in multiple files
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