Skip to content

fix: JJ Bookmarks on merges, speed k-boundary, and time cursor on timers - #688

Open
eric-engberg wants to merge 5 commits into
sirmalloc:mainfrom
eric-engberg:fix/widget-edge-cases
Open

eric-engberg wants to merge 5 commits into
sirmalloc:mainfrom
eric-engberg:fix/widget-edge-cases

Conversation

@eric-engberg

Copy link
Copy Markdown
Contributor

What

  • JJ Bookmarks lists bookmarks on different heads separately: 🔖 feature-a, feature-b instead of 🔖 feature-afeature-b when @ sits on a merge of two bookmarked heads.
  • Input, Output and Total Speed switch to k where the value would round up to 1000: 999.96 t/s shows 1.0k t/s instead of 1000.0 t/s.
  • Block Timer, Block Reset Timer and Extra Usage Utilization no longer say "time cursor" in the editor after the widget picker turns a usage bar with the time cursor on into one of them. They never draw a cursor and have no key to turn it off.

Why

  • JJ Bookmarks runs jj log --no-graph -r 'heads(::@ & bookmarks())' --template bookmarks. jj log prints each commit's template output back to back, with nothing in between, so two heads give feature-afeature-b. The widget splits on whitespace, which only separates bookmarks on the same commit.
  • Speed: formatSpeed compared against exactly 1000, then rendered with one decimal, so 999.95–999.99 rounded up inside the "t/s" range: formatSpeed(999.96) returned 1000.0 t/s. The same happens at any precision: with whole numbers, 999.6 rendered as 1000 t/s. formatTokens already moves up a unit at the rounding boundary (999,950 tokens is 1.0M, not 1000.0k).
  • Time cursor: the cursor is the cursor metadata flag of the usage bars (Session Usage, Weekly Usage and the per-model weekly widgets). Changing a widget's type in the picker keeps its metadata, and the shared modifier text listed "time cursor" for any widget in a bar mode with the flag set. So after turning a Session Usage long bar with the cursor on into a Block Timer, the editor row read Block Timer (long bar, time cursor), with no cursor drawn and no (t) key to clear it.

How

  • JJ Bookmarks: the template is now bookmarks ++ "\n", so each head's output ends with a newline. The whitespace split then works across heads as it already did within one, and the output for a single head is unchanged.
  • Speed: formatSpeed switches to k at 1000 - 0.5 / 10 ** decimals, using the effective decimals of the widget's number format: 999.95 by default, 999.5 for whole numbers, 999.995 at two decimals. This is the same boundary formatTokens uses for M. Values below the boundary and all k values render as before. There's no M tier for speeds, so values from 999,950 t/s up still read 1000.0k t/s and above, as before.
  • Time cursor: the modifier text now takes an includeCursor option, like includeCompact and includeDate, and only the usage percent widgets pass it, since they are the ones that draw the cursor. The metadata itself is left alone, so changing back to a usage bar keeps the cursor setting. The editor row of the usage bars is unchanged.

Demo

The status line piped from a sample transcript (99,996 output and 99,994 input tokens over 100 s) with a stub jj standing in for a repo where @ is a merge of two bookmarked heads. jj isn't installed here; the stub prints what jj log --no-graph prints for each template, one head's output after the other. Input Speed (999.9 t/s) and Total Speed (2.0k t/s) are unchanged.

Powerline: before

Speed widgets and JJ Bookmarks before the fix, Powerline mode

Powerline: after

Speed widgets and JJ Bookmarks after the fix, Powerline mode

Plain: before

Speed widgets and JJ Bookmarks before the fix, plain mode

Plain: after

Speed widgets and JJ Bookmarks after the fix, plain mode

In the TUI, a Session Usage long bar with the time cursor on is changed to Block Timer in the type picker (sample preview data):

Powerline: before

Session Usage with time cursor changed to Block Timer, before the fix, Powerline mode

Powerline: after

Session Usage with time cursor changed to Block Timer, after the fix, Powerline mode

Plain: before

Session Usage with time cursor changed to Block Timer, before the fix, plain mode

Plain: after

Session Usage with time cursor changed to Block Timer, after the fix, plain mode

Testing

  • New tests, each failing on main first: JJ Bookmarks on two heads (the template and the parsed output); speeds at the boundary by default (999.96, 999.99 vs 999.94), with whole numbers (999.6 vs 999.4) and at two decimals (999.996 vs 999.994); the modifier text of Block Timer, Block Reset Timer and Extra Usage Utilization with carried-over cursor metadata. The existing test for the usage bars' "time cursor" modifier still passes.
  • bun test: 2788 pass, 0 fail. bun run lint passes.
  • The changed test files under Node (Vitest): 108 pass (102 on main).
  • Built CLI under Bun 1.4.2 and Node 26.10.0 with the speed and JJ Bookmarks line above, the sample transcript and the stub jj: all runtimes give identical output in plain and Powerline modes, and it differs from main only in Output Speed and JJ Bookmarks. With a Session Usage bar with the cursor on, and with the baseline line, the output matches main. The TUI opens and exits cleanly under both.

JJ Bookmarks lists the bookmarks of heads(::@ & bookmarks()) with the
template "bookmarks". jj log --no-graph prints each commit's template
output back to back with nothing in between, so when @ sits on a merge
of two bookmarked heads the names ran together: "feature-afeature-b".
The template now ends each head's output with a newline, which the
whitespace split already handles; bookmarks on one commit were always
space-separated and still are.
formatSpeed switched to "k" at exactly 1000 t/s, but values just below
round up when shown: 999.96 t/s rendered as "1000.0 t/s" instead of
"1.0k t/s" (and 999.6 as "1000 t/s" with whole numbers). It now
switches once the value would round to 1000 at the shown precision,
1000 - 0.5 / 10^decimals, the same boundary formatTokens uses for "M".
The time cursor is a usage bar setting (cursor metadata), and the
widget picker keeps metadata when it changes a widget's type. After
changing a usage bar with the cursor on to Block Timer, Block Reset
Timer or Extra Usage Utilization, the editor row said "time cursor",
though those widgets never draw one and have no key to turn it off.

The modifier text now lists the cursor only for widgets that ask for
it, as it already does for compact and date: the usage percent widgets,
which draw it. The metadata itself is left alone, so changing back to a
usage bar keeps the setting.
String.raw shows the template exactly as jj reads it, "\n" included,
instead of a doubled backslash.
The three time-cursor tests compared the whole modifier text, so they'd
also break on any change to how the bar mode itself is described. They
now check the part they're about: the bar mode still shows, and the
time cursor doesn't.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant