mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
feat(tui): append git branch to cwd label in status bar
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).
This commit is contained in:
parent
0175ff7516
commit
ff2aa7ccd7
4 changed files with 160 additions and 3 deletions
|
|
@ -4,3 +4,14 @@ export const shortCwd = (cwd: string, max = 28) => {
|
|||
|
||||
return p.length <= max ? p : `…${p.slice(-(max - 1))}`
|
||||
}
|
||||
|
||||
export const fmtCwdBranch = (cwd: string, branch: null | string, max = 40) => {
|
||||
if (!branch) {
|
||||
return shortCwd(cwd, max)
|
||||
}
|
||||
|
||||
const b = branch.length > 16 ? `…${branch.slice(-15)}` : branch
|
||||
const tag = ` (${b})`
|
||||
|
||||
return `${shortCwd(cwd, Math.max(8, max - tag.length))}${tag}`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue