Skip to content

(trace): record terminal render-path counters (#175) - #422

Merged
devsuitup merged 2 commits into
mainfrom
feat/175-render-counters
Oct 3, 2026
Merged

devsuitup merged 2 commits into
mainfrom
feat/175-render-counters

Conversation

@devsuitup

@devsuitup devsuitup commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Closes #175.

The activity trace had no category on the terminal render path, so a renderer burning a core could not be told apart as legitimate load or an atlas repaint loop. With Debug mode on, public/terminal-manager.js now counts per session and sends one render.stats line per session per second: ms, chunks, chars, hiddenChunks, writes, writeChars, maxBatchChunks, maxBatchChars, atlasChanges, atlasCanvases.

Cost when off: each site is one window.ATRACE read. No counter object, no timer, no clock read per write. When on, a write costs an integer increment; one timer is armed by the first event of a window and is not re-armed while the session is silent; a report is dropped if the trace was switched off meanwhile.

Docs: docs/activity-trace.md (field table, a reading recipe, the cost paragraph), .ai/contexts/ipc-bridge.md. CHANGELOG entry under New. No change to the flush cap or the WebGL policy.

Tests: test/terminal-render-stats.test.js (9 tests; the first 6 were red before the change). Mutations, each turning the suite red: handleTerminalData guard removed, writes not incremented, atlasChanges not incremented, emit ignoring ATRACE, flush counted with the trace off, hidden flag inverted, replay count deleted, !!entry check dropped. task check green in the worktree.

Not verified: a live Electron run (the atlas events are driven by a stub in jsdom; the real WebGL addon's event firing is assumed from its API).

A renderer that burned a core could not be diagnosed: the activity trace
had nothing on the terminal render path. Add a render.stats line per
session per second, gated on window.ATRACE, with chunks, writes, batch
size and glyph atlas rebuilds. Off, each site is one flag read.

Closes #175
@devsuitup

Copy link
Copy Markdown
Owner Author

Reviewing d3e97f9 (adversarial review in progress).

@devsuitup devsuitup left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review at d3e97f9: 0 blocking. With the trace off, each added site costs one window.ATRACE read. The hoisted isHiddenSingleViewSession call keeps its entry short-circuit, so it adds no work. With the trace on, one timer serves the window and the Map is cleared on every emit. Atlas listeners belong to each addon instance and are disposed with it. Being fixed: no test covers the reveal replay or two sessions in one window, a two-line source comment, and doc precision on hiddenChunks, line volume and rekey.

Tests for the reveal replay write, separate per-session counts and data
for a session without a terminal entry. Trim the comments and document
hiddenChunks, the line volume and a rekey straddling a window.

@devsuitup devsuitup left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 89bcd6a (delta from d3e97f9): 0 blocking. Three tests are added: the reveal replay, two sessions in one window, and a session with no entry. Each goes red under its mutation: deleting the replay count, or dropping !!entry &&. The source comment is down to one pointer line, and the doc gives the hiddenChunks definition, line volume and the rekey case. Ready once CI is green.

@devsuitup
devsuitup merged commit 412afde into main Oct 3, 2026
11 checks passed
@devsuitup
devsuitup deleted the feat/175-render-counters branch October 3, 2026 07:16
@devsuitup devsuitup mentioned this pull request Oct 3, 2026
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.

Nothing measures the terminal render path, so a runaway renderer cannot be diagnosed

1 participant