Skip to content

feat(cli): add workspace folder and git branch to status bar#12277

Closed
timfewi wants to merge 2 commits into
NousResearch:mainfrom
timfewi:feat/status-bar-workspace-git-branch
Closed

feat(cli): add workspace folder and git branch to status bar#12277
timfewi wants to merge 2 commits into
NousResearch:mainfrom
timfewi:feat/status-bar-workspace-git-branch

Conversation

@timfewi

@timfewi timfewi commented Apr 18, 2026

Copy link
Copy Markdown

What does this PR do?

This PR enhances the Hermes CLI status experience by adding workspace context (current folder + current git branch) to both the TUI status bar and the hermes status command output. It also adds width-aware rendering logic so the status bar remains readable on narrow terminals (avoiding wrapping / duplicate rows).

Related Issue

Fixes #12267 (workspace folder + git branch context in status UI)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Updated TUI status bar snapshot to include workspace context:

    • cli.py
      • Adds workspace_short and git_branch fields to _get_status_bar_snapshot()
      • Adds short path formatting and a small TTL cache for git branch lookup
      • Updates status bar text rendering to be width-sensitive and avoid wrapping on narrow terminals
  • Updated hermes status command output to display workspace context:

    • hermes_cli/status.py
      • Adds “Current Folder” and “Git Branch” lines (or “(not a git repo)” when not available)
  • Added tests for the new status fields and layout behavior:

    • tests/cli/test_cli_status_bar.py
    • tests/hermes_cli/test_status.py

How to Test

  1. Run: hermes status
  2. In the TUI, observe the footer/status bar while switching directories (inside and outside a git repo).
  3. Resize the terminal to a narrow width and verify the status bar remains single-line / readable (workspace/branch labels should adapt).

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A
image

Copilot AI review requested due to automatic review settings April 18, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances Hermes’ CLI/TUI status reporting by adding workspace context (current folder + git branch) and improving status bar behavior on narrow terminals to avoid wrapping.

Changes:

  • Adds workspace folder + git branch detection to the TUI status bar snapshot and hermes status output.
  • Introduces width-sensitive status bar text assembly plus a short TTL cache for git branch lookup.
  • Extends tests to cover the new snapshot fields and layout behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
cli.py Adds workspace/branch snapshot fields, git-branch caching, path shortening, and width-aware status bar rendering.
hermes_cli/status.py Prints “Current Folder” and “Git Branch” lines in hermes status, with best-effort git detection.
tests/cli/test_cli_status_bar.py Adds TUI status bar tests for workspace/branch inclusion and width-dependent visibility.
tests/hermes_cli/test_status.py Adds hermes status output tests for current folder + git branch / non-git fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli.py
Comment on lines +2310 to +2317
workspace_label = snapshot.get("workspace_short") or ""
branch_label = snapshot.get("git_branch") or ""
context_parts = [f"⚕ {snapshot['model_short']}", context_label]
if workspace_label:
context_parts.append(workspace_label)
if branch_label:
context_parts.append(branch_label)
context_line = " │ ".join(context_parts)

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In _get_status_bar_fragments() (wide layout), workspace + branch are always appended when present, but _build_status_bar_text() uses _select_status_context_labels() to drop one/both on tighter widths. This mismatch can cause frequent overflow → fallback to a single trimmed fragment (losing the per-fragment styling and context bar coloring). Consider reusing _select_status_context_labels(width, workspace_label, branch_label) here too so the fragment layout is width-aware before trimming.

Copilot uses AI. Check for mistakes.
Comment on lines +438 to +439
monkeypatch.setattr(cli_mod, "subprocess", sp)
monkeypatch.setattr(sp, "run", fake_run)

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test helper monkeypatches subprocess.run on the global stdlib subprocess module (sp.run). That can unintentionally affect any other code executed during the test run (including inside _make_cli() or other helpers) that calls subprocess.run, creating hidden coupling/flakiness. Prefer patching only the cli module’s reference (e.g., cli_mod.subprocess.run) or injecting a small stub object with a run attribute, rather than mutating the global module.

Suggested change
monkeypatch.setattr(cli_mod, "subprocess", sp)
monkeypatch.setattr(sp, "run", fake_run)
monkeypatch.setattr(cli_mod.subprocess, "run", fake_run)

Copilot uses AI. Check for mistakes.
Comment thread hermes_cli/status.py
Comment on lines 114 to 115
from hermes_constants import is_termux as _is_termux

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from hermes_constants import is_termux as _is_termux is now placed after new helper function definitions, which splits the import block and makes module load order harder to follow. Consider moving it up with the other imports at the top of the file for readability and to align with typical Python import organization.

Copilot uses AI. Check for mistakes.
OutThisLife added a commit that referenced this pull request Apr 18, 2026
Adds useGitBranch hook (async, cached, 15s TTL) and fmtCwdBranch
helper so the footer shows `~/repo (main)` instead of just `~/repo`.
Degrades silently when git is unavailable or cwd is outside a repo.

Partial fix for #12267 (TUI portion; #12277 covers the Python side).
man209111-cpu pushed a commit to man209111-cpu/hermes-agent that referenced this pull request Apr 18, 2026
Adds useGitBranch hook (async, cached, 15s TTL) and fmtCwdBranch
helper so the footer shows `~/repo (main)` instead of just `~/repo`.
Degrades silently when git is unavailable or cwd is outside a repo.

Partial fix for NousResearch#12267 (TUI portion; NousResearch#12277 covers the Python side).
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Apr 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Partially overlaps with merged #12305 which already appends git branch to cwd label in the TUI status bar. Please verify what this PR adds beyond that.

ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
Adds useGitBranch hook (async, cached, 15s TTL) and fmtCwdBranch
helper so the footer shows `~/repo (main)` instead of just `~/repo`.
Degrades silently when git is unavailable or cwd is outside a repo.

Partial fix for NousResearch#12267 (TUI portion; NousResearch#12277 covers the Python side).
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
Adds useGitBranch hook (async, cached, 15s TTL) and fmtCwdBranch
helper so the footer shows `~/repo (main)` instead of just `~/repo`.
Degrades silently when git is unavailable or cwd is outside a repo.

Partial fix for NousResearch#12267 (TUI portion; NousResearch#12277 covers the Python side).
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
Adds useGitBranch hook (async, cached, 15s TTL) and fmtCwdBranch
helper so the footer shows `~/repo (main)` instead of just `~/repo`.
Degrades silently when git is unavailable or cwd is outside a repo.

Partial fix for NousResearch#12267 (TUI portion; NousResearch#12277 covers the Python side).
@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by #12305.

Triage notes (high confidence):
Merged PR #12305 'feat(tui): append git branch to cwd label in status bar' (2026-04-18) implements the same status-bar branch/workspace feature.

Thanks for the contribution — the underlying problem this PR addresses has been resolved by the linked PR on current main. If you believe this was closed in error, please comment and we'll reopen.

(Bulk-closed during a CLI PR triage sweep.)

@teknium1 teknium1 closed this May 24, 2026
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Adds useGitBranch hook (async, cached, 15s TTL) and fmtCwdBranch
helper so the footer shows `~/repo (main)` instead of just `~/repo`.
Degrades silently when git is unavailable or cwd is outside a repo.

Partial fix for NousResearch#12267 (TUI portion; NousResearch#12277 covers the Python side).
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
Adds useGitBranch hook (async, cached, 15s TTL) and fmtCwdBranch
helper so the footer shows `~/repo (main)` instead of just `~/repo`.
Degrades silently when git is unavailable or cwd is outside a repo.

Partial fix for NousResearch#12267 (TUI portion; NousResearch#12277 covers the Python side).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show workspace folder + git branch in Hermes status

4 participants