文件历史

提交图

129 次代码提交

作者 SHA1 备注 提交日期
Jarrod Watts ee7562fc02 fix(render): only pad progress labels when lines stack 2026-04-20 18:53:58 +10:00
Nandana Dileep 4b4506997b fix: show initial context tokens when used_percentage is 0
On a fresh session Claude Code emits used_percentage=0 before any user
input, while current_usage already holds the real initial-context tokens
(system prompt, tools, memory files — ~9% on a 200k model).  The HUD
was treating 0 as a valid native value and skipping the token-based
fallback, so the context bar stayed at 0% even though /context showed 9%.

Treat used_percentage=0 the same as null: fall through to the manual
calculation from current_usage.  When tokens are present the bar now
reflects the true initial usage; when both are zero it still shows 0%.

Fixes #417
2026-04-20 18:48:07 +10:00
kagura-agent 2233a8537c test: update assertions for paddedLabel alignment padding
Adjust two test expectations to account for the trailing spaces
that paddedLabel() adds when aligning shorter labels (Usage, Weekly)
to the width of the longest label (Context = 7 chars).
2026-04-20 18:46:07 +10:00
kagura-agent 8e771def92 fix: align progress-bar labels to equal visual width (fixes #437)
When Context, Usage, and Weekly lines wrap to separate rows on narrow
terminals, their progress bars now align vertically. A shared
paddedLabel() helper pads each label with spaces to the maximum visual
width across the three labels, accounting for CJK double-width chars.

- Add src/render/lines/label-align.ts with paddedLabel() utility
- Update identity.ts and usage.ts to use paddedLabel()
- Add tests for English and Chinese label alignment
2026-04-20 18:46:07 +10:00
d 🔹 64262f680c fix: invalidate version cache when claude binary target changes 2026-04-20 18:34:42 +10:00
Jarrod Watts 20d771f83e fix: label default agents as agent 2026-04-20 18:32:00 +10:00
simran91 338a761b3b fix(transcript): label default subagent_type as 'general-purpose'
When the Agent/Task tool is called without an explicit subagent_type
parameter, Claude Code's runtime defaults to the general-purpose agent
(per the Agent tool spec). The HUD only sees the transcript input and
previously fell back to the literal string 'unknown', which made
perfectly normal Agent launches look broken or untracked in the HUD's
agents line.

Flip the fallback to 'general-purpose' so the displayed label matches
the tool's actual runtime behavior.

Before: `✓ unknown: Build phase 2 agents`
After:  `✓ general-purpose: Build phase 2 agents`
2026-04-20 18:32:00 +10:00
kagura-agent 4f2775b2bd fix(stdin): use env var instead of model ID to detect Bedrock provider
getProviderLabel was string-matching `anthropic.claude-` in model IDs,
which false-positived on cross-region IDs like `us.anthropic.claude-sonnet-4-6`.
Now checks `CLAUDE_CODE_USE_BEDROCK=1` env var instead.

Fixes #466

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-20 18:29:58 +10:00
Jarrod Watts 029cca67dd fix: export width override and prefer COLUMNS for HUD layout 2026-04-20 18:23:39 +10:00
墨泪 e74af045ef fix(render): skip width-dependent layout when terminal width is unknown
When running as a CC statusLine subprocess, stdout/stderr are piped and
COLUMNS may not be set. getTerminalWidth() falls back to
UNKNOWN_TERMINAL_WIDTH (40), which is not a real measurement.

Previously, this fallback value was treated as real terminal width in two
places:
- canCombine in renderExpanded(): context + usage lines were always split
  because combined width exceeded 40 columns
- wrapLineToWidth in render(): all output lines were forcefully wrapped
  at 40 characters, breaking the layout

Fix: introduce a widthIsReal guard that checks whether the resolved width
is the UNKNOWN_TERMINAL_WIDTH sentinel. When width is unknown:
- canCombine defaults to true (combine lines optimistically)
- wrapLineToWidth is skipped (wrapWidth=0 → no-op)

The host process (Claude Code) handles final display layout, so wrapping
at an arbitrary fallback value is harmful rather than helpful.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 18:23:39 +10:00
Jarrod Watts 017041ed0d Merge pull request #381 from Yimaha/feat/native-cost-field
feat: use cost.total_cost_usd from stdin instead of manual token estimation
2026-04-05 11:01:40 +10:00
Jarrod Watts 565154d5cd fix(cost): prefer native stdin cost with safe fallback 2026-04-05 10:59:33 +10:00
Jarrod Watts 0d331e0ade fix(render): keep compact usage windows labeled on wrap 2026-04-05 10:59:33 +10:00
Yimaha b263939c73 feat: use cost.total_cost_usd from stdin instead of manual estimation
Replace the hardcoded Anthropic pricing table and estimateSessionCost()
logic with a direct read of stdin.cost.total_cost_usd — the native field
Claude Code provides after each API response.

- Add cost.* fields to StdinData type
- Extract costUsd in index.ts and pass through RenderContext
- Simplify renderCostEstimate to read ctx.costUsd directly
- Rename i18n key label.estimatedCost → label.cost
- Update label to "Cost ($USD)" / "耗油量(美元)" (zh)
- Remove dead estimateSessionCost, pricing table, and related helpers
- Update tests to use costUsd; add index.test.js coverage for the field
- Update README to reflect native field behavior

Closes #380

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 11:33:17 -04:00
Jarrod Watts dad7ade968 fix: bound stdin reads to avoid statusline hangs 2026-04-04 18:06:06 +11:00
Jarrod Watts 6dddf2ed1b feat: add offline estimated cost display (#305) (#374) 2026-04-04 17:38:30 +11:00
Jarrod Watts b36a4977fa fix: stabilize CI version cache tests (#373) 2026-04-04 17:25:55 +11:00
Jarrod Watts 2cc8f28d21 feat: add git push count threshold coloring (#292) (#372) 2026-04-04 15:24:07 +11:00
Jarrod Watts 1d8b1ac491 fix: keep context and usage visible on narrow terminals (#314) (#371) 2026-04-04 15:20:33 +11:00
Jarrod Watts 1816b98fa9 feat: add output style display toggle (#343) (#370) 2026-04-04 15:18:42 +11:00
Jarrod Watts 37711c6c27 Merge pull request #369 from jarrodwatts/maintainer/pr-317-git-files
feat(git): add per-file diffs and files HUD line
2026-04-04 15:00:43 +11:00
Jarrod Watts f8c05371f9 test: cover git file diff rendering 2026-04-04 15:00:05 +11:00
Jarrod Watts 64de69c5cd Merge pull request #336 from krushnamegh/patch-1
Refactor agent rendering and status icon logic
2026-04-04 14:55:16 +11:00
Jarrod Watts 5d923d75ca test: cover agent elapsed formatting 2026-04-04 14:55:08 +11:00
Jarrod Watts dc329fcad7 Merge remote-tracking branch 'origin/main' into feat/session-token-usage 2026-04-04 14:53:18 +11:00
Jarrod Watts 1668b9ca50 test: harden session token usage parsing 2026-04-04 14:50:57 +11:00
Jarrod Watts 728fe8da99 Merge pull request #325 from devy1540/feat/label
feat: add styled Weekly label for 7-day usage window
2026-04-04 14:38:48 +11:00
Jarrod Watts 50128ce2f0 Merge remote-tracking branch 'origin/main' into feat/label
# Conflicts:
#	src/render/lines/usage.ts
#	src/render/session-line.ts
#	tests/render.test.js
2026-04-04 14:38:25 +11:00
Jarrod Watts dd804fb8e4 Merge pull request #367 from jarrodwatts/maintainer/pr-337-vmstat
fix: use vm_stat for accurate macOS memory percentage
2026-04-04 14:29:56 +11:00
Jarrod Watts 9113b138f1 fix: use vm_stat for accurate macOS memory percentage 2026-04-04 14:29:25 +11:00
Jarrod Watts 7ab8421514 Merge pull request #311 from RisingV/perf/config-cache
perf: add mtime-based disk cache for countConfigs()
2026-04-04 14:27:01 +11:00
Jarrod Watts e1f76c17c7 fix: harden config cache invalidation 2026-04-04 14:26:26 +11:00
Jarrod Watts c7ef7520f7 Merge remote-tracking branch 'origin/main' into fix/osc8-visual-length
# Conflicts:
#	tests/render-width.test.js
2026-04-04 14:20:20 +11:00
Jarrod Watts 96a94d0858 fix: cover OSC hyperlink width handling 2026-04-04 14:17:57 +11:00
Jarrod Watts b41250b538 Merge pull request #332 from amfibiotik/fix/detect-agent-tool-name
fix: detect agents recorded as "Agent" in transcript
2026-04-04 14:10:13 +11:00
Jarrod Watts 24d6c50d00 test: cover Agent tool name in transcripts 2026-04-04 14:09:18 +11:00
Jarrod Watts 7ea5f331d9 fix: wrap HUD output when terminal width is unavailable 2026-04-04 13:59:08 +11:00
Jarrod Watts f223562354 test: align reset countdown expectation for i18n 2026-04-04 13:51:04 +11:00
Jarrod Watts 6c863b2f02 Merge main into i18n branch and keep English default 2026-04-04 13:50:24 +11:00
Jarrod Watts 03c394825c fix: stop guessing auth mode from env vars 2026-04-04 13:28:03 +11:00
Jarrod Watts 0786f4c50b Merge pull request #357 from kagura-agent/fix/preserve-taskid-map-across-todowrite
fix: preserve taskIdToIndex map across TodoWrite operations (#345)
2026-04-04 13:25:59 +11:00
kagura-agent 9955880815 fix: preserve taskIdToIndex map across TodoWrite operations (#345)
When TodoWrite is called, the taskIdToIndex map was cleared and
rebuilt from scratch. However, TodoItem objects only contain content
and status fields — no taskId. This meant all taskId mappings from
prior TaskCreate calls were permanently lost, causing subsequent
TaskUpdate operations to silently fail.

Fix: Before clearing the map, build a reverse lookup of content →
taskIds from the existing state. After replacing latestTodos with the
new TodoWrite items, re-register taskId mappings for items whose
content matches a previously-known task. Stale mappings (for content
no longer present) are naturally dropped.

Adds two tests:
- TaskCreate → TodoWrite → TaskUpdate flow preserves taskId
- TodoWrite-only regression test (no TaskCreate involved)
2026-04-03 17:19:49 +08:00
Zane Wang e6ed4aa1a6 test: add render tests for modelFormat and modelOverride
Cover both rendering paths (expanded + compact) to verify that:
- modelFormat compact/short correctly strips context suffix and prefix
- modelOverride completely replaces the model name in the badge
- modelOverride takes precedence over modelFormat
- loadConfig structural test validates new display fields
2026-04-03 06:49:40 +08:00
Zane Wang ab4c564892 feat: add display.modelOverride for custom model display names
Users can now set a fully custom model name in their config:

  { "display": { "modelOverride": "zane's intelligent opus 4.6" } }

When set, the override completely replaces the auto-detected model
name (while preserving the provider qualifier like "| Bedrock").

Follows the same pattern as customLine: string type, max 80 chars,
empty string means disabled (falls through to modelFormat).
2026-04-03 06:42:25 +08:00
Zane Wang 5676041f19 feat: add configurable modelFormat option (full/compact/short)
Redesign from mandatory stripping to user-configurable display format.
Adds display.modelFormat with three levels:

  full:    Show raw display name as-is (default, backward-compatible)
  compact: Strip redundant context-window suffix
  short:   Strip context suffix AND "Claude " prefix

Examples with Bedrock model "Opus 4.6 (1M context)":
  full:    [Opus 4.6 (1M context) | Bedrock]
  compact: [Opus 4.6 | Bedrock]
  short:   [Opus 4.6 | Bedrock]

Examples with API model "Claude Sonnet 3.5 (200k context)":
  full:    [Claude Sonnet 3.5 (200k context)]
  compact: [Claude Sonnet 3.5]
  short:   [Sonnet 3.5]
2026-04-03 06:37:26 +08:00
Zane Wang c12e514465 feat: strip redundant context-window suffix from model display names
Claude Code may include the context window size in display_name
(e.g. "Opus 4.6 (1M context)"), but the HUD already shows context
usage via the context bar — making the parenthetical redundant.

This adds stripContextSuffix() which removes any parenthetical
containing the word "context" from the display name. It handles
common variants like "(1M context)", "(200k context)",
"(with 1M context)", and "(extended context window)" while
preserving non-context parentheticals like "(beta)" or "(preview)".

Before: [Opus 4.6 (1M context) | Bedrock]
After:  [Opus 4.6 | Bedrock]
2026-04-03 06:25:24 +08:00
xiaodream 7895941b8b fix: address code review findings for i18n
- Fix detectLanguage() to follow POSIX priority: LC_ALL > LC_MESSAGES > LANG
- Fix Chinese format.resetsIn from broken wrap-around grammar to prefix form
- Fix loadConfig() to call mergeConfig({}) when no config file exists,
  ensuring detectLanguage() runs for auto-detection
- Add setLanguage('en') guard to render.test.js for locale-independent tests
- Add dedicated i18n test suite (tests/i18n.test.js) covering t(),
  detectLanguage(), and mergeConfig language handling

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 17:03:53 +08:00
xiaodream c8d9e809ed feat: add Chinese (zh) language support (#334)
Add i18n infrastructure with automatic language detection from system
locale (LANG/LC_ALL/LC_MESSAGES) and manual override via config.json.
Translates all user-facing HUD labels, status messages, and format
strings. English remains the default.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 16:39:45 +08:00
윤혁준 7752a901ee feat: add styled Weekly label for 7-day usage window
When both 5h and 7d usage windows are displayed, the 7d gauge had no
label prefix. This adds a dim-styled "Weekly" label (matching the
Context/Usage label style) and removes colons from usage window labels
for consistency with other HUD labels.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 14:08:59 +09:00
francis yun 21809d51a0 perf: add mtime-based disk cache for countConfigs()
countConfigs() performs ~15 file I/O operations on every invocation.
Since the statusLine plugin spawns a new process ~every 300ms, this means
~50 filesystem ops/sec per session. With multiple concurrent sessions,
this scales to ~1500 ops/sec for config data that rarely changes.

Add a sentinel-based mtime cache (following the pattern established in
transcript.ts) that stats ~4-10 sentinel paths and serves cached results
when no config files have changed. Steady-state cost drops from ~15
syscalls to ~4-10 stat calls + 1 cache read.

Cache files are stored under ~/.claude/plugins/claude-hud/config-cache/
with SHA-256 hashed keys for cwd+configDir isolation. Cache misses
trigger a fresh recompute and cache write.

Known limitation: nested rules/ subdirectory changes are not monitored
(only the top-level rules/ directory mtime is checked).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 23:02:37 +08:00