From 20cbd62897519355d4680267064711d829ef5800 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 00:38:01 -0300 Subject: layers: `Churn [window]` (slice 7): for each declaration of a file's pane (tree-sitter's innermost, as TreeContext finds them: `f.context.declarations`), how many of the window's changes touched it, shown in this view as a heat lane after the line number (a half block, before the changes' lanes, which stay next to the text they mark: `File.Layers.heat`, one cell) and as a strip by the scroll thumb (a rail row each, the hottest of its lines: the rail's second cell in a terminal, `Surface.heat` for a window, drawn beside the track by gui.zig's paneDecor), smooth from the line numbers' grey to the theme's red (`jj.themeRed`) in Oklab on a log scale of the count against the file's hottest (`heatColour`); the window a revset, or a span of time back from now (`3d`, `2w`, `6m`, `1y`: `::(REV) & author_date(after:"N units ago")`), bare shown here or not and with none counted yet the file's whole history `::(REV)`; jj's data as `Changes`' is: one `jj log` of the window and the changes after it to the shown revision with their hunks (the same query and marks, `Ask.kind` `.churn`) and `jj file show` of the revision (to line the counts up with the pane's text, `Moved.of`), on the worker, its raw answer an input; kept raw in the session's jj state (`jj.Heat`, `Session.heats`) until the text's declarations are there, then counted in every process (`heatOf`, `parsed`): a big file's parse is a worker's (`Stream.parseFor`, its landing tells `jj.parsed`), never the loop's (counted on the loop, core/replica.zig held a Debug loop 1,211 ms; now its longest hold is 10.7 ms; the counting itself 1 ms); a change counts once a declaration, a hunk's lines carried to the shown revision through the later changes' hunks; the counts ride with the lines through edits (`spliceValues`, shared with `Changes`' lines); a later ask of the other kind no longer drops an answer (the stale check is per kind); tests: f three changes, g two: `3 3 3 0 2 2 2`, the cell red on f, `mixOklab(grey, red, ln 3 / ln 4)` on g, none on the blank line, the strip's first row red, in a terminal and a window, bare off and on without asking jj; `@--::@` one each, `1w` all, a refusal in jj's words; on a worker, counted when the worker's parse lands, the client equal; a line deleted takes its count, the client and digest equal; core-test 912/1072 (160 skipped), shell-test 1114/1117 (3 skipped) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/gui/gui.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'dev/gui') diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 47fd14d5..c4a460ca 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -4875,7 +4875,7 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g else => {}, } else false; if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, win_w, win_h); - try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], chrome, layout, surface.cols, surface.rows, win_w, win_h); + try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], surface.heat.items, chrome, layout, surface.cols, surface.rows, win_w, win_h); // The changes' lanes (jj.paint): a strip a level in the gutter's // lane cells, each a third of a cell wide with half that of air // before it, so three take one and a half cells (the ruled @@ -4918,7 +4918,7 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g /// Each pane's rule between its tag and body, and its scroll rail: a page /// coloured gutter with a thin track and its thumb, running down through the /// pixels past the last whole row. -fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void { +fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, heat: []const pardes.RailHeat, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void { const page = chrome.page orelse bg_default; for (regions) |rail| { if (rail.kind != .rail or rail.rect.h == 0) continue; @@ -4997,6 +4997,14 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti const ty = y0 + std.math.clamp(at * track_px, 0, track_px - h); try addDecor(g, gpa, column[0], ty, column[1], ty + h, if (tick.current) chrome.match_current else chrome.match_tick, 1, win_w, win_h); }; + // Churn's strip (jj.railHeat): beside the track, at the rail's + // right edge, a rail row each. + const strip_x1 = x0 + @as(f32, @floatFromInt(config.GUTTER)) * layout.w - dp(1); + const strip_x0 = @max(column[1], strip_x1 - dp(2)); + for (heat) |h| if (h.owner == rail.owner and h.row < rail.rect.h) { + const hy = y0 + @as(f32, @floatFromInt(h.row)) * layout.h; + try addDecor(g, gpa, strip_x0, hy, strip_x1, hy + layout.h, h.rgb, 1, win_w, win_h); + }; } } -- cgit v1.3