testsAndMisc/docs/superpowers/evidence/i3bar-claude-usage-icons-cleanup-2026-08-10.json
Krzysztof kuhy Rudnicki 58c1df573c
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Python tests / test (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
i3blocks: add Claude usage block, fix icon rendering, drop dead blocks
Add a [claude_usage] block showing the 5h and 7d rate-limit windows. It
reads ~/.claude/cache/limit-state/*.json, which Claude Code's statusLine
hook already writes to disk, so the data costs nothing to display: the
script only runs jq against a local file and makes no API call. Limits
are account-wide while the cache is sharded one file per project, so it
takes the newest file and ignores cwd. Percentages arrive as floats and
are truncated; a stale cache is labelled rather than shown as current,
and a rolled-over window reads "?%" instead of a misleading value.

Replace Font Awesome private-use-area icons with plain Unicode. Both
fonts named in the bar's pango string ("System San Francisco Display",
"FontAwesome") are not installed, so PUA codepoints fell through to
whatever font claimed them: ethernet rendered as a star, wifi as
Cyrillic, gpu as Hangul, disk as a chess pawn. Emoji resolve through
fontconfig consistently, which the pre-existing volume block already
relied on, and need no change to ~/.config/i3/config.

Remove the bluetooth, battery, wifi, activitywatch, warp and
network_monitor blocks: this desktop has no BT adapter, no battery, no
wireless interface, and no warp-cli. This also removes a rendering bug,
since activitywatch_status.sh and warp_status.sh were interval=persist
yet emitted three lines per update, leaking their colour line into the
bar as literal "#FF0000" text.

Fix ethernet reporting "down" on a live wired link:
find_ethernet_interface returned the first non-loopback interface, which
with docker installed is a br-* bridge (permanently down, and sorted
before enp*). It now requires a real /sys/class/net/*/device and prefers
an interface that is up.

Tests drop the assertions and fixtures for the removed blocks and add
claude_usage coverage (fresh, warn, critical, stale, rolled-over, null
reset, unparsable, missing dir), a guard that removed blocks cannot
return, a repo-wide check that no block script uses a PUA codepoint, and
an ethernet physical-NIC regression check. The fork budget is asserted
against a populated cache directory, which caught a stat call inside the
scan loop that cost one fork per cached project (170 -> 2 execs).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YQLwdquDCNmWtvgi3Lk72J
2026-08-10 15:14:34 +02:00

49 lines
4.9 KiB
JSON

{
"intent": "Show Claude Code's 5h/7d rate-limit usage in the i3 bar, make the status icons render as the symbols they are meant to be, and stop displaying blocks for hardware this desktop does not have.",
"scope": [
"linux_configuration/scripts/periodic_background/i3-configuration/i3blocks/ (config + block scripts)",
"linux_configuration/tests/test_i3blocks_efficiency.sh",
"Non-goal: ~/.config/i3/config and its font line are deliberately untouched (drifted from repo by three live-only exec lines)",
"Non-goal: installing fonts"
],
"changes": [
"Added claude_usage.sh: interval=60, 3-line i3blocks protocol, reads the newest ~/.claude/cache/limit-state/*.json (limits are account-wide but the cache is sharded per-cwd, so newest-by-mtime wins and cwd is ignored). Truncates float percentages, tolerates a null seven_day_resets_at, labels stale data, and reports '?%' for a rolled-over window instead of a misleading cached value.",
"Replaced Font Awesome private-use-area codepoints with plain Unicode emoji in cpu_monitor, gpu_monitor, motherboard_temp, memory, disk, ethernet and time. Root cause: both fonts named in the bar's pango string ('System San Francisco Display', 'FontAwesome') are not installed, so PUA codepoints fell through to arbitrary fonts - ethernet rendered as a star, wifi as Cyrillic, gpu as Hangul, disk as a chess pawn.",
"Removed the bluetooth, battery, wifi, activitywatch, warp and network_monitor blocks and their scripts, plus the dangling ~/.config/i3blocks symlinks they left behind. This also removed a rendering bug: activitywatch_status.sh and warp_status.sh were interval=persist yet emitted three lines per update, so their trailing colour line was displayed as literal '#FF0000' text in the bar.",
"Fixed a pre-existing ethernet bug: find_ethernet_interface returned the first non-loopback interface, which on a machine with docker installed is a br-* bridge (permanently 'down' and alphabetically before enp*), so the bar showed 'down' on a live wired link. It now requires a real /sys/class/net/*/device and prefers an interface that is actually up.",
"Updated test_i3blocks_efficiency.sh: dropped assertions and fixtures for the removed blocks, added claude_usage behaviour/fork-budget tests (fresh, warn, critical, stale, rolled-over, null reset, unparsable, missing dir), a guard that removed blocks do not return, a repo-wide check that no block script contains a PUA codepoint, and an ethernet physical-NIC regression check."
],
"verification": [
{
"command": "bash linux_configuration/tests/test_i3blocks_efficiency.sh",
"result": "pass",
"evidence": "EXIT=0; 'All i3blocks efficiency regression tests passed.' Includes the new 'Checking Claude usage block behavior and fork count' and 'Checking status icons avoid Font Awesome private-use codepoints' sections."
},
{
"command": "i3blocks -c ~/.config/i3blocks/config -o i3bar",
"result": "pass",
"evidence": "Emitted blocks: cpu 🖥 57°C | gpu 🎮 70°C | mobo 🌡 58°C | memory 🧠 13.8GiB/30.4GiB | disk 💾 1.3T/3.6T | volume 🔊 100% | ethernet 🌐 192.168.1.43/24 | claude_usage 🤖 5h 38% · 7d 55% | pc_startup PC:warn | shutdown ⏻ 23:00 | time 🕑 2026-08-10 15:07. No PUA glyphs, no literal colour text, no removed blocks."
},
{
"command": "./claude_usage.sh vs jq -s 'max_by(.updated_at)' ~/.claude/cache/limit-state/*.json",
"result": "pass",
"evidence": "Script printed '🤖 5h 36% · 7d 55%' while the cache reported five_hour_pct=36, seven_day_pct=55.00000000000001. Edge cases exercised with a synthetic LIMIT_STATE_DIR: stale -> '(stale)' grey, rolled window -> '5h ?%', null seven_day reset -> normal render, corrupt/missing/empty -> '🤖 no data'."
},
{
"command": "pre-commit run --files <changed-files>",
"result": "pass",
"evidence": "shellcheck, codespell, polling-antipattern, binary-file and secret-leak hooks all pass after fixing SC2016 and a codespell hit."
}
],
"risks": [
"Emoji are rendered by Segoe UI Emoji via fontconfig fallback; if that font were removed the icons would degrade to tofu. Mitigated by the fact that the pre-existing 🔊 and ⏻ blocks already depended on the same path and render correctly.",
"claude_usage only refreshes while a Claude Code session is open, because the underlying cache is written by the statusLine hook. Handled explicitly by the stale label rather than silently showing an old number.",
"Config-stanza changes need i3blocks to be respawned (i3blocks has no config-reload signal). Script edits are live immediately via the symlinks."
],
"rollback": [
"git revert the commit; the deleted block scripts return with it.",
"Recreate the ~/.config/i3blocks symlinks for any restored scripts (ln -sf into the repo i3blocks dir) and remove the claude_usage.sh symlink.",
"Run i3-msg restart, then confirm the bar renders and bash linux_configuration/tests/test_i3blocks_efficiency.sh exits 0."
]
}