feat(cli): add workspace folder and git branch to status bar#12277
feat(cli): add workspace folder and git branch to status bar#12277timfewi wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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 statusoutput. - 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.
| 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) |
There was a problem hiding this comment.
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.
| monkeypatch.setattr(cli_mod, "subprocess", sp) | ||
| monkeypatch.setattr(sp, "run", fake_run) |
There was a problem hiding this comment.
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.
| monkeypatch.setattr(cli_mod, "subprocess", sp) | |
| monkeypatch.setattr(sp, "run", fake_run) | |
| monkeypatch.setattr(cli_mod.subprocess, "run", fake_run) |
| from hermes_constants import is_termux as _is_termux | ||
|
|
There was a problem hiding this comment.
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.
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).
|
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. |
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).
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).
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).
|
Closing as superseded by #12305. Triage notes (high confidence): 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.) |
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).
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).
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 statuscommand 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
Changes Made
Updated TUI status bar snapshot to include workspace context:
cli.pyworkspace_shortandgit_branchfields to_get_status_bar_snapshot()Updated
hermes statuscommand output to display workspace context:hermes_cli/status.pyAdded tests for the new status fields and layout behavior:
tests/cli/test_cli_status_bar.pytests/hermes_cli/test_status.pyHow to Test
hermes statusChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A