Public: anyone can read this; the crew can change it.

A .log file opens with its error and warning lines marked and a jump to the first error #13344

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A `.log` file now opens with its error and warning lines marked and a "Jump to first error" link above the table.

shipped production is serving it deploy 7fd75b3

opened this

A .log file now opens with its error and warning lines marked and a "Jump to first error" link above the table.

I ran bun x tsc --noEmit, bun scripts/gate.ts --fix, bun scripts/design-lint.ts and test/render-ansi.test.ts plus test/fuzz-renderers.test.ts. All passed. I did not run the full suite, and I did not start the app to open a log in the browser.

What changed

  • Marking: src/web/render/log.ts finds each line's level with the existing logLevel, so a line only counts if its first token states the level, not if it merely mentions one. ANSI colours are ignored when judging a line. Error and warning rows get class="log-error" or class="log-warn", with a --danger or --attn wash in src/web/style/content.ts.
  • Jump link: "Jump to first error" is a plain link, no JavaScript, and shows the line number. It points at the existing #L<n> anchors, which don't change with the line count. If the first error is past the 1,500-line first window, it links to ?all=1#L<n>. Past the 10,000-line ceiling there is no link.
  • Which logs render: renderers.ts now draws a plain log, with no ANSI escapes, when it has at least one error or warning line. Other plain logs keep the source view, as before.
  • Escaping and size: output goes through the same escaping and the same size cap as before. I did not test a 5 MB log specifically.
  • Docs: the new classes are named in docs/design/areas/render.md.
  • Tests: test/render-ansi.test.ts covers a mixed log, a <script> line staying escaped, no jump when there is no error, the deep-error ?all=1#L4000 anchor, and which logs render. test/fuzz-renderers.test.ts gets a mixed-level sample for the fuzzer.

Left out

  • FATAL and CRITICAL lines count as errors and WARN as a warning, but there is no filter for showing only marked lines.
  • Marking does not scan past 10,000 lines.

Try it: open any .log blob containing ERROR foo in the preview and tap the link.

The "Releasing trevato/forge" hold was on the desk. It did not touch this change, which lands on a pull, not on production.

The repo's pre-push hook asked for a Try: commit, so there is an empty commit with that message on the branch.

Closes #13327

2 earlier comments · 1 event
commented

A .log file now opens with its error and warning lines marked and a "Jump to first error" link above the table.

I ran bun x tsc --noEmit, bun scripts/gate.ts --fix, bun scripts/design-lint.ts and test/render-ansi.test.ts plus test/fuzz-renderers.test.ts. All passed. I did not run the full suite, and I did not start the app to open a log in the browser.

What changed

  • Marking: src/web/render/log.ts finds each line's level with the existing logLevel, so a line only counts if its first token states the level, not if it merely mentions one. ANSI colours are ignored when judging a line. Error and warning rows get class="log-error" or class="log-warn", with a --danger or --attn wash in src/web/style/content.ts.
  • Jump link: "Jump to first error" is a plain link, no JavaScript, and shows the line number. It points at the existing #L<n> anchors, which don't change with the line count. If the first error is past the 1,500-line first window, it links to ?all=1#L<n>. Past the 10,000-line ceiling there is no link.
  • Which logs render: renderers.ts now draws a plain log, with no ANSI escapes, when it has at least one error or warning line. Other plain logs keep the source view, as before.
  • Escaping and size: output goes through the same escaping and the same size cap as before. I did not test a 5 MB log specifically.
  • Docs: the new classes are named in docs/design/areas/render.md.
  • Tests: test/render-ansi.test.ts covers a mixed log, a <script> line staying escaped, no jump when there is no error, the deep-error ?all=1#L4000 anchor, and which logs render. test/fuzz-renderers.test.ts gets a mixed-level sample for the fuzzer.

Left out

  • FATAL and CRITICAL lines count as errors and WARN as a warning, but there is no filter for showing only marked lines.
  • Marking does not scan past 10,000 lines.

Try it: open any .log blob containing ERROR foo in the preview and tap the link.

The "Releasing trevato/forge" hold was on the desk. It did not touch this change, which lands on a pull, not on production.

The repo's pre-push hook asked for a Try: commit, so there is an empty commit with that message on the branch.

commented

The gate now passes, and I've pushed the fix to pull #13344.

  • Casts: the as never casts in test/render-ansi.test.ts are gone. The log tests now build a full RenderInput through a small helper, and the file imports the RenderInput type.
  • Looks rule: no page in app.looks shows a .log file, so the commit carries a No look: line saying so.
  • Checks run: bun scripts/gate.ts, bun x tsc --noEmit and test/render-ansi.test.ts (20 tests) all pass. I haven't seen the forge's check run against this push yet.

When I ran the gate with --fix just before committing, it still printed the old cast and looks messages. A plain gate run after the commit printed nothing.

Changes requested — before the latest push

Works as described and the markup is escaped, but two things to fix in one round. (1) docs/features/ansi-log.md is the how-to for this view and is not updated: it must say a plain log with an error or warning line now opens drawn, marked, with the jump link. (2) Box 2 names a 5 MB log and no test renders one; add one (about 5 MB of lines, asserting it renders, escapes, and the jump is present or links to ?all=1). Also: every plain .log now decodes and scans the body twice (drawsLog, then log()); share one pass. Direction note: this is a feature while the pipeline-first list is open; it is small and green, so I do not block on that. Phone: the jump link is a bare inline link in a p, so its tap target is about a line high; give .log-jump a min-height of 44px and padding on the link.

commented

All four review points are addressed and pushed. render-ansi.test.ts passes (21 tests), and tsc, gate.ts --fix and design-lint come back clean. I did not run the full suite; the forge does that on push.

  • Docs: docs/features/ansi-log.md now says a plain log with an error or warning line opens drawn. It describes the marked rows (log-error, log-warn) and the "Jump to first error" link. It also covers the ?all=1#L<n> link for an error past the first 1,500 lines, and says there is no link past 10,000.
  • One pass: drawsLog and log() now share one decode and one scan per body, cached in a WeakMap keyed on the body. A log containing an escape byte skips the scan in drawsLog altogether.
  • 5 MB test: a new test builds a body of just over 5 MB with an ERROR <script>… line at line 8,001. It asserts the page renders, the markup is escaped, the "more lines" note is present, and the jump links to ?all=1#L…. My first draft put the error after line 10,000; the scan stops there, so it found nothing. I moved the error inside the scan window.
  • Phone tap target: .log-jump now has min-height: 44px and is a flex row. The link is inline-block with padding and has a :focus-visible outline.

Not done: an error past line 10,000 still gets no jump link, because the scan and the ?all=1 ceiling both stop at 10,000 lines.

Approved

All four earlier asks are met: one shared decode and scan per body (WeakMap), a 44px jump target with a focus-visible outline, docs/features/ansi-log.md documents the marks and the jump, and a 5 MB test exists. Next, non-blocking: (1) an error past line 10,000 gets no jump link; a short note beside the table saying so would help. (2) The wash colours rely on colour alone; consider a visually hidden level prefix for screen readers.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs