Repository navigation
feat(widgets): show a percent widget's level as a glyph - #43
Draft
eric-engberg wants to merge 63 commits into
Draft
eric-engberg wants to merge 63 commits into
eric-engberg wants to merge 63 commits into
Conversation
Setting a widget's glyph meant typing it, which needs a way to type emoji or Nerd Font icons. In the glyph editor, → now opens a picker: - 17 groups of glyphs, paged with Tab/Shift+Tab or PgDn/PgUp: folders and files, dev tools, git and status, weather and time, nature, objects, faces and hearts, arrows, shapes, text symbols, then Nerd Font groups (folders, git, languages, OS and apps, status, weather) and Powerline glyphs. - The arrow keys move through a group's grid, the highlighted glyph's name shows below it, Enter picks it and ESC goes back. Each group's glyphs all draw at one width so the grid lines up: emoji that terminals show two cells wide by default, and one-cell symbols and Nerd Font icons. Names come from Unicode and the Nerd Fonts glyph names. Typing a glyph still works.
The percent widgets (Context %, Context % (usable), Session and Weekly Usage, Extra Usage Utilization) get one more style for (p): a single glyph for how high the used percent runs, 🟢 under 20%, ⚡ from 20%, 🔥 from 70% and 🚨 from 90%. It replaces the number; a second copy of the widget merged beside it shows both, e.g. `⚡ 42.0%`. The glyph always measures what's used, so (u) isn't offered in this mode. (g) sets the glyph for each level in the glyph editor, picker included, and (l) the three break points. Settings store only what differs from the defaults: `levelGlyph<Level>` and `levelFrom<Level>`.
A row's glyphs are unique within its group, so they make a stable key where the row's position doesn't.
The curated groups hold about 280 of Nerd Fonts' 10,600 icons, so many, like the pull request created, merged, closed and draft icons, weren't there. Typing in the picker now searches every glyph by name: the curated groups' and all of Nerd Fonts', matching every word of the search (`pull req draft`). The groups stay for browsing; a long list of matches scrolls. The full set comes from Nerd Fonts' glyph names (`scripts/generate-nerd-font-glyphs.ts` regenerates it), with aliases sharing a codepoint merged into one entry. The picker loads all its glyph data when it opens, from its own build chunk, so the status line's render path no longer loads even the curated groups.
The full Nerd Font set was only reachable by searching. After the 17 curated groups, the picker now has a group for each icon set: Codicons, Devicons, Font Awesome, Material Design (6,896 icons), Octicons, Weather Icons and the rest, 33 groups in all. PgUp/PgDn move a page within a group and Tab/Shift+Tab switch groups (PgUp/PgDn switched groups before).
A break point held one above its neighbor, or typed, kept its odd offset on every later step (21, 26, 31...), so it never landed on a multiple of 5 again. Steps now go to the next multiple of 5 in that direction.
The arrow and paging keys now work out where the highlight goes in one function, so the key handler only decides between picking, going back, moving and typing. The Nerd Font name format builds its alias list first, and the generator script reads glyphnames.json from the current directory instead of taking a path.
The picker's search found every Nerd Font icon but only the curated emoji and symbols, so most emoji (🤡 clown, 🤢 nauseated) couldn't be found at all. It now also searches every fully-qualified Unicode 18.0 emoji, without the skin tone variants, and every character in the Unicode symbol blocks (arrows, box drawing, math, dingbats and more), plus a few common ones from elsewhere (§ ± × ÷ π ...). scripts/generate-unicode-glyphs.ts generates the data from Unicode's emoji-test.txt and UnicodeData.txt, as the Nerd Font data is generated from glyphnames.json. It loads with the rest of the picker's data, so the status line still never loads it. A glyph is listed once, under its first name, and found by any of its names; an emoji's text and emoji forms (❤ and ❤️) stay separate glyphs.
Ctrl+T in the glyph picker cycles the emoji skin tone: the default, then light, medium-light, medium, medium-dark and dark. Every emoji that takes a tone (332 of them) shows and picks in it, in the groups and in search, with both people toned in a two-person emoji. The tone is a new optional setting, emojiSkinTone, so it's remembered next time; an unknown value falls back to the default rather than invalidating the settings. The Unicode generator records each such emoji's light tone version, worked out from Unicode's own toned versions (the emoji selector goes when a tone comes in, and both people take it), keeping only emoji that have all five tones. The picker turns that into the chosen tone. It reads and saves the tone through a small context that the line editor provides, so the widget editors in between don't change. The glyph editor now shows a multi-part emoji whole (👍🏾, 👩💻). Ink lays out each part as its own character, so the "(default: …)" text after it overwrote the tone or the rest of the emoji; the two are one Text now.
…el-glyphs # Conflicts: # src/tui/App.tsx
A new object on every app render made everything reading the context redraw with it; the value is memoized on the tone now.
This was referenced Oct 6, 2026
# Conflicts: # src/widgets/shared/symbol-override.tsx
# Conflicts: # src/widgets/ExtraUsageUtilization.ts # src/widgets/shared/context-percentage-widget-base.ts # src/widgets/shared/symbol-override.tsx
The picker's groups are now a hand-picked list of 388 glyphs, chosen
from every Unicode emoji, the Unicode symbol blocks and the Nerd Font
icon sets. There are many more faces (115 in Smileys & Emotion), so a
widget can show a good or a bad mood, along with thumbs up and down,
pointing hands, keycaps and colored squares. Emoji follow Unicode's
categories, then come the one-cell arrows and symbols, then one Nerd
Font group that includes the Powerline glyphs. Names are Unicode's emoji
names ("thumbs up", not "thumbs up sign"). Country flags are left to
search.
A group can now be longer than one page, and the IEC power symbol sits
with the Nerd Font icons, since many terminal fonts lack it.
The 16 Nerd Font icon sets are no longer groups to page through after the curated ones, so tiny sets like Indentation (one glyph) and Material Design's 6,896 icons are gone from Tab. The curated Nerd Font group holds the useful icons, and searching still finds all 10,617. PgUp/PgDn still move a page within a group, which the bigger groups need.
…n it The picker opened on the emoji a toned glyph is made from, but showed it in the saved skin tone. With 👍🏾 set and the default tone saved, it highlighted 👍, and Enter picked 👍: opening the picker and confirming dropped the tone the glyph had. The picker now opens in the current glyph's own tone when it has one, so Enter keeps 👍🏾, and both people of a two-person emoji (🧑🏾🤝🧑🏾) that search finds keep theirs. That tone stays in the picker: the saved tone changes only on Ctrl+T, which cycles on from the tone shown. A glyph without a tone opens in the saved tone as before.
Changing a widget's type keeps its metadata, so a percent widget in its level glyph mode keeps display: 'glyph' when it becomes Block Timer, Block Reset Timer or Weekly Reset Timer. The timers have no glyph and render their time, but Block Timer and Block Reset Timer named the mode "(level glyph)" on the editor row, and on all three the first (p) only rewrote the mode to the time, so it seemed to do nothing. The shared modifier text and (p) cycle now honor the glyph only for the widgets that offer it, as the cycle already did when choosing what comes after the slider. The others read a stored glyph as the time, as they render it: the editor row shows the time's modifiers, and (p) goes on to the block bar.
A folder is the natural glyph for the directory widgets (Current Working Dir, Git Root Dir), but the Objects group had no folder emoji: the curation left out Unicode's whole office subgroup. Search found them, but browsing didn't. Add 📁 file folder and 📂 open file folder to Objects, in the curated page order (after the money glyphs, before the locks). The groups now hold 390 glyphs.
Nerd Fonts draw their zap icon (nf-oct-zap) on U+26A1, the high voltage emoji. In a terminal set to a Nerd Font, the font's own glyph wins, so the picker's ⚡ showed as a flat icon rather than the color emoji. The curated ⚡ now carries the emoji selector (U+FE0F), which asks the terminal for the emoji. ⚡ is an emoji by default, so the selector makes no new glyph: search keeps one entry for it, as before, found by "high voltage", "high voltage sign" or "zap". An emoji whose plain form is text, like ❤ and ❤️, still lists both forms.
The level glyph's medium default was a bare ⚡ (U+26A1), where Nerd Fonts draw their zap icon. In a terminal set to a Nerd Font, the status line showed that flat icon between the color 🟢 and 🔥. Default to ⚡ with the emoji selector (U+FE0F), as the glyph picker now offers it, so the terminal draws the emoji. A glyph someone set themselves is kept as they typed it.
Custom Symbol has its own editor rather than the glyph editor, so → did nothing there and its symbol could only be typed. → now opens the same picker, on the current symbol: Enter picks the highlighted glyph and ESC goes back without changing it. Typing, Backspace and Enter still work as before.
# Conflicts: # src/tui/App.tsx # src/widgets/CustomSymbol.tsx # src/widgets/shared/symbol-override.tsx
…glyphs # Conflicts: # docs/USAGE.md # src/tui/App.tsx # src/widgets/shared/symbol-override.tsx
…el-glyphs # Conflicts: # src/tui/App.tsx
…dgets Session Usage is Block Usage on main now, and the new Spend Limit Usage shares the usage percent widgets' styles, level glyph included.
The glyph data loads from its own build chunk the first time a picker opens, and the chunk's file name is a content hash that changes with almost every release. If ccstatusline's install is replaced while the TUI is open (the TUI's own Updates action runs a global install, or an npx status line render reinstalls a newer release into the same cache), the running bundle still imports the old chunk name. Opening any glyph picker then showed "Loading glyphs…" and the process exited with "Cannot find module …/glyph-catalog-<hash>.js", losing every unsaved edit: nothing handled the import's rejection. The rejected promise also stayed cached, so every later picker in the session failed the same way. The picker now says it couldn't load the glyph list and to restart ccstatusline, and ESC goes back to the editor with its edits intact. A failed load is no longer cached, so the next picker that opens tries again.
# Conflicts: # src/widgets/ExtraUsageUtilization.ts # src/widgets/shared/context-percentage-widget-base.ts # src/widgets/shared/usage-percent-widget.ts
…xt one The glyph picker tests wait for the picker's grid to show before pressing the next key, but their wait returned as soon as the text appeared. Ink's useInput attaches the grid's key handler in an effect React runs after it draws the frame, on a later setImmediate turn. On a busy machine the poll could see the frame first and send the key straight away; the key then reached the loading screen's ESC-only handler and was dropped, and the test failed with "No redraw after ...", a different test each run. waitForOutput now waits with wait-for-ink's waitFor, which retries the check and then gives React two setImmediate turns, as the editor harness already does after every key.
# Conflicts: # docs/USAGE.md # src/tui/App.tsx # src/widgets/shared/symbol-override.tsx
# Conflicts: # docs/USAGE.md # src/tui/App.tsx # src/widgets/shared/symbol-override.tsx # src/widgets/shared/usage-display.ts
# Conflicts: # docs/USAGE.md
↑ and ↓ each spelled out the wrap-around in the editor's key handler, which the picker key and the Shift+Tab toggle had already made long. One helper keeps it short; a test now covers the wrap in both directions.
The level glyph stays the last style (p) cycles to, now after the line: text, block, slider, line, glyph on the percent widgets, and percentage, slider, line, glyph on Context %. The timers still go from the line back to text.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Stacked on #14 (
feat/bar-width) and merges #42 (glyph picker): review the two non-merge commits after the merges. It needs #14's (p) styles and #42's picker, so it goes upstream after both.What
The percent widgets get one more style for p: a single glyph for how high the used percent runs, instead of the number:
To show the number as well, add a second copy of the widget and merge them, e.g.
⚡ 42.0%.This covers Context %, Context % (usable), Block Usage, the Weekly Usage widgets, Spend Limit Usage and Extra Usage Utilization. The timers share the display code but don't get it yet.
Why
The status line in AKCodez's Claude Code status line guide puts a glyph in front of its context bar that changes with usage (🟢 → ⚡ → 🔥 → 🚨). It reads faster than a number at a glance. Making it a display style of the widget that already measures the value means one widget shows one thing: a glyph, a percentage or a bar. You combine them with a merge, which already exists, and no widget needs a leading-glyph option.
How
display: "glyph",levelGlyphLow|Medium|High|CriticalandlevelFromMedium|High|Critical. Break points out of range or out of order fall back to the defaults together, so the levels never overlap.next, where the merge does this. Whichever of feat(usage): color Extra Usage Used, Today and Utilization by break points or a gradient #41 and feat(widgets): show a percent widget's level as a glyph #43 goes upstream second carries it, with a test.level-glyph.tsholds the levels and settings, andlevel-glyph-editor.tsxthe break point editor and the routing of g and l. Extra Usage Utilization's render moves its "bar or percent" step into one function, now also handling the glyph.Demo
On Context %: two Context % widgets, the first raw and merged into the second. p twice turns the first into the level glyph, l moves the High break point to 80%, and g picks 💀 as the Critical glyph from the picker, which opens on 🚨 in Travel & Places; Shift+Tab goes back to Smileys & Emotion and PgDn pages to 💀. The preview samples 90% used.
Powerline
Plain
Piped at 10%, 42%, 75% and 95% context used. Each line has a glyph merged into a percentage, then a glyph on its own.
Powerline
Plain
Testing
level-glyph.test.ts(16): every level's edges, the widget's own glyphs and break points, the fallback for bad break points, the slot labels, stepping (including back onto the fives from an odd value) and typed break points with their errors, and the keys.level-glyph-editor.test.ts(7 Ink tests): the break points and sample; ← and → stepping; a typed value; a rejected one and ESC; cancelling; and g editing the glyph per level.bun test: 2826 pass, 0 fail (Bun 1.4.2).bun run lintis clean.runtime-check.sh -c level-glyphs-levelson the built CLI: Bun 1.4.2 and Node 26.10.0 agree byte-for-byte in plain and Powerline modes, and the TUI opens and exits under both.(level glyph)with keys(p) bar style, (g)lyphs, (l)evels. l shows the levels. Raising High to 75% relabels the g editor's rows toMedium (20-74%)andHigh (75-89%).