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

The games page shows a profile natively: flame graph, slowest ticks, per-mod time, linked findings #18178

opened this

Merged 4h ago, live in production

/games/ /spark/ now shows a stored spark profile on the forge, and the box's Profiles list links to it. I ran the new page test, the existing spark tests, the dead-code, hollow, doorless, feature-doors and empty-states tests, tsc --noEmit, the design lint and the gate; all pass. I did not run the full suite.

Notes

opened this

/games/<box>/spark/<key> now shows a stored spark profile on the forge, and the box's Profiles list links to it. I ran the new page test, the existing spark tests, the dead-code, hollow, doorless, feature-doors and empty-states tests, tsc --noEmit, the design lint and the gate; all pass. I did not run the full suite.

What the page shows

  • Findings: the slowest tick window and the top two mods by time. Each finding links to the frame behind it. The tick finding goes to the frame with the most time of its own. A mod finding goes to its heaviest frame, matched by the mod id appearing in the frame name.
  • Flame graph: one inline SVG for each of the three heaviest threads. A frame links to its own #id, and the target frame is highlighted.
  • The rest: slowest ticks, time per mod, GC, memory and the mod list.
  • Safety:
    • There is no script and no outside fetch.
    • Every name from the profile is escaped.
    • A profile that won't decode, or isn't a sampler profile, gets a plain sentence instead of an error.
    • The raw download stays at /games/<box>/@spark/<key>, and the page links to it.

Terminal door: Enter on a profile in the box's p screen opens src/tui/screens/game_spark_view.ts. It shows the same findings, an indented frame tree, ticks, per-mod time, GC and memory. docs/features/game-spark.md and docs/design/areas/games.md (.flame) are updated.

Reuse and tests

  • Reused: the decoder (spark_profile.ts), boxOf, profileOf, and the existing page components.
  • New code: src/games/spark_view.ts (frame layout and findings, shared by page and terminal), the page, and the terminal screen.
  • Tests: test/game-spark-view.test.ts builds a profile with a <script> in a class name, checks the escaping and the grant check, and checks that every finding link lands on a frame id on the page. The profile builder moved to test/helpers/spark_fixture.ts; games-spark-profile.test.ts now imports it.
  • One existing assertion changed: test/game-spark.test.ts expected the box page to link to /@spark/, and the link is now /spark/. It still checks that the raw URL opens.

Left out or different from the issue

  • No p95: the finding example in the issue quotes a p95, but the profile holds only a median and a maximum per window, so findings quote those.
  • No GC finding link: the GC finding has no frame to link to.
  • No decode cache: the page decodes on every request. Decoding is capped at 64 MiB, and a cache would have needed process-wide state.
  • Heap and health profiles: only sampler profiles are drawn.

Review

[
  {"go": "/games/<box>#spark", "look": "the Profiles list", "expect": "each stored profile links to /games/<box>/spark/<key>"},
  {"go": "/games/<box>/spark/<key>", "look": "Findings, then Flame graph", "expect": "findings list the slowest stretch and top mods; the page loads no outside host"},
  {"go": "/games/<box>/spark/<key>", "look": "click a finding", "expect": "the page jumps to a highlighted frame in the flame graph"},
  {"go": "/games/<box>/spark/<key>", "look": "Slowest ticks, Time per mod, GC and memory", "expect": "rows match the fixture's numbers"}
]

To try it: post a spark profile to a box's upload address, open /games/<box>, and click the profile under Profiles.

Gate notes: a "Looks:" or "No look:" line was suggested for the page change, and I did not add one. Two comment lines over 100 columns in games_routes.ts and games.ts were left for the nightly rewrap.

Closes #18140

16 earlier comments
commented

/games/<box>/spark/<key> now shows a stored spark profile on the forge, and the box's Profiles list links to it. I ran the new page test, the existing spark tests, the dead-code, hollow, doorless, feature-doors and empty-states tests, tsc --noEmit, the design lint and the gate; all pass. I did not run the full suite.

What the page shows

  • Findings: the slowest tick window and the top two mods by time. Each finding links to the frame behind it. The tick finding goes to the frame with the most time of its own. A mod finding goes to its heaviest frame, matched by the mod id appearing in the frame name.
  • Flame graph: one inline SVG for each of the three heaviest threads. A frame links to its own #id, and the target frame is highlighted.
  • The rest: slowest ticks, time per mod, GC, memory and the mod list.
  • Safety:
    • There is no script and no outside fetch.
    • Every name from the profile is escaped.
    • A profile that won't decode, or isn't a sampler profile, gets a plain sentence instead of an error.
    • The raw download stays at /games/<box>/@spark/<key>, and the page links to it.

Terminal door: Enter on a profile in the box's p screen opens src/tui/screens/game_spark_view.ts. It shows the same findings, an indented frame tree, ticks, per-mod time, GC and memory. docs/features/game-spark.md and docs/design/areas/games.md (.flame) are updated.

Reuse and tests

  • Reused: the decoder (spark_profile.ts), boxOf, profileOf, and the existing page components.
  • New code: src/games/spark_view.ts (frame layout and findings, shared by page and terminal), the page, and the terminal screen.
  • Tests: test/game-spark-view.test.ts builds a profile with a <script> in a class name, checks the escaping and the grant check, and checks that every finding link lands on a frame id on the page. The profile builder moved to test/helpers/spark_fixture.ts; games-spark-profile.test.ts now imports it.
  • One existing assertion changed: test/game-spark.test.ts expected the box page to link to /@spark/, and the link is now /spark/. It still checks that the raw URL opens.

Left out or different from the issue

  • No p95: the finding example in the issue quotes a p95, but the profile holds only a median and a maximum per window, so findings quote those.
  • No GC finding link: the GC finding has no frame to link to.
  • No decode cache: the page decodes on every request. Decoding is capped at 64 MiB, and a cache would have needed process-wide state.
  • Heap and health profiles: only sampler profiles are drawn.

Review

[
  {"go": "/games/<box>#spark", "look": "the Profiles list", "expect": "each stored profile links to /games/<box>/spark/<key>"},
  {"go": "/games/<box>/spark/<key>", "look": "Findings, then Flame graph", "expect": "findings list the slowest stretch and top mods; the page loads no outside host"},
  {"go": "/games/<box>/spark/<key>", "look": "click a finding", "expect": "the page jumps to a highlighted frame in the flame graph"},
  {"go": "/games/<box>/spark/<key>", "look": "Slowest ticks, Time per mod, GC and memory", "expect": "rows match the fixture's numbers"}
]

To try it: post a spark profile to a box's upload address, open /games/<box>, and click the profile under Profiles.

Gate notes: a "Looks:" or "No look:" line was suggested for the page change, and I did not add one. Two comment lines over 100 columns in games_routes.ts and games.ts were left for the nightly rewrap.

commented

I merged main into the branch and pushed it. The only conflict was docs/features/game-spark.md, and I kept both sides there. The paragraph describing the new profile page stays, and so does main's "Installed with the mod (#18138)" section.

tsc --noEmit passes. So do the spark tests (20 pass, 0 fail), which include the new profile-page tests. I did not run the full suite; the forge's check does that on push.

The config written when spark is installed still sets viewerUrl to /games/<box>/@spark/. That path serves the raw download, so a link spark builds from it opens the bytes rather than the new page. I left it alone because it belongs to #18138. Pointing it at /games/<box>/spark/ would be a one-line change in src/games/spark.ts, plus whichever test pins it.

commented

<!-- look-pages 272feeff9f61 --> Look pages for 272feef, from the gate:

  • look pages (none): this pull changes src/web/pages/games.ts, src/web/pages/games_spark_view.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

I fixed the three check failures and pushed. pages-budget, unreached and no-polling pass locally, and tsc --noEmit and the gate are clean. I did not re-run the rest of the suite.

  • Route walk: the new route /games/:box/spark/:key wasn't in the list of pages the seed can't fill. I added it to NOT_WALKED in test/no-polling.test.ts and added test/budgets/unfixtured/games-box-spark-view-key.json. Both point at test/game-spark-view.test.ts as the test that covers it.
  • Unreached list: src/games/spark_profile.ts is now imported by the page, so I removed it from scripts/unreached-allow.json.

The first run of test/no-polling.test.ts timed out on "the owner's main pages poll nowhere" at 5 seconds. It passed when I re-ran it.

commented

<!-- look-pages c7f768d0e7cb --> Look pages for c7f768d, from the gate:

  • look pages (none): this pull changes src/web/pages/games.ts, src/web/pages/games_spark_view.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

The only open item was the look-pages note. I added an empty commit whose message carries Looks: /games/<box>, and pushed it as 89a6e00d1. The forge couldn't trace the route behind games.ts and games_spark_view.ts, so it asked for a named page; the reviewer can now see which one to open.

bun scripts/gate.ts --explain reads 37 rules with 0 failures. That covers the three others the forge listed:

  • both doors
  • dead code (every export under src/ has a caller or is allowed)
  • no process-wide state that requests write to

The same commit message also names issue #18140 and says the terminal side landed earlier in this pull. The gate does not run bun x tsc --noEmit or the rest of the suite here, and I didn't run them, so the forge's check is the first to run them on this push. This push changed no code.

What this pull changes

  • The games page (/games/<box>) now shows a stored spark profile natively: a flame graph, the slowest ticks, time per mod, and findings linked to their frames. It is the new src/web/pages/games_spark_view.ts, fed by src/games/spark_view.ts.
  • The terminal shows the same view (src/tui/screens/game_spark_view.ts), and docs/features/game-spark.md and docs/design/areas/games.md cover it.
  • test/game-spark-view.test.ts covers the new view.

What I chose not to do

  • The page has no JavaScript beyond what it already shipped.
  • Profiles are still stored in the same place, with no new tables or dependencies.

How to try it Open /games/<box> on the preview and pick a profile under Profiles. Follow a finding to its frame.

[
  {"go": "/games/<box>", "look": "Profiles section, select a stored profile", "expect": "flame graph, slowest ticks and per-mod time render from the stored profile"},
  {"go": "/games/<box>", "look": "a finding in the selected profile", "expect": "following it highlights the frame it names", "ask": "Does the finding land on the right frame?"}
]

🤖 Generated with Claude Code

commented

The branch already holds the fixes for what this comment lists, and I changed nothing locally. Another push to mason/18140-the-games-page-shows-a-profile-natively landed first with 7d22101f9 and 89a6e00d1. After merging main, I reset to that tip.

What the page does: /games/<box>/spark/<key> server-renders a stored spark profile's summary, flame graph, slowest ticks and per-mod time. Each finding links to its frame. The terminal shows the same data through src/tui/screens/game_spark_view.ts, and the decoder is src/games/spark_profile.ts. Nothing is fetched from outside the forge, and every name is escaped.

The three checks and the test the failing check named:

  • Unused exports: decodeSparkProfile now has callers on the page and in the terminal, so 7d22101f9 takes it off scripts/unused-exports-allow.json. test/unused-exports.test.ts passes.
  • Both doors: the page and the terminal screen ship together, and the gate's both-doors rule passes.
  • Name the issue: the gate's name-the-issue rule passes, and the commits cite #18140.
  • Module state: the page adds no module-level Map, Set or array. test/module-state.test.ts passes.
  • test/talk-follow.test.ts: this is the "follows, pauses, lets go" test from the failure. It is a Chromium test of the talk page, and this pull doesn't touch it. It was skipped here because Chromium won't start in the sandbox, so I could not run it. Its failure on #18178 is not explained by this change. If it fails again on the merged branch, it needs its own look.

Checks I ran: tsc --noEmit is clean. The spark view, spark profile, unused-exports and module-state tests pass. The gate lists no failures, only notes.

Left alone:

  • Looks line: the gate notes that "Looks: /games/<box>," is not a page in app.looks. The page needs a box and a stored profile, so it can't be a fixed look path. The reviewer decides, or a No look: <why> line can replace it.
  • Long comments: two comment lines over 100 columns in src/http/games_routes.ts and src/web/pages/games.ts are left for the nightly rewrap.

Try it: open /games/<box>, pick a profile under Profiles, then follow a finding to its frame.

[
  {"go":"/games/<box>","look":"Profiles list","expect":"a stored spark profile is listed with a link to its page"},
  {"go":"/games/<box>/spark/<key>","look":"summary, flame graph, slowest ticks, per-mod time","expect":"all four render server-side with no outside request"},
  {"go":"/games/<box>/spark/<key>","look":"a finding such as tick time p95 or chunk generation share","expect":"it links to the slow frame in the flame graph","ask":"Does the link land on the frame the finding names?"}
]

🤖 Generated with Claude Code

commented

<!-- look-pages 89a6e00d10a3 --> Look pages for 89a6e00, from the gate:

  • look pages (none): "Looks: /games/<box>," is not a page of app.looks in forge.json; this pull changes src/web/pages/games.ts, src/web/pages/games_spark_view.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

The look-pages note is answered: my Looks: line named /games/<box>, which isn't a page in forge.json app.looks, so the gate refused it. I've replaced it with a No look: line and pushed it as 4a0a24ec3.

The line says /games/<box> needs a game box with a stored profile, and no page in app.looks has one. I did not add a page to app.looks: that would mean seeding a fixture box with a profile, which is more than this pull is about. If you'd rather have one, tell me which box to seed.

The gate now reads 37 rules with 0 failures. That includes the three you listed: both doors, dead code, and no process-wide state that requests write to. The forge's check runs tsc and the test suite, which I did not run here. This push changed no code.

What changed

  • The games page (/games/<box>) now shows a stored spark profile natively: a flame graph, the slowest ticks, time per mod, and findings linked to their frames.
  • The terminal shows the same view (src/tui/screens/game_spark_view.ts).
  • docs/features/game-spark.md and docs/design/areas/games.md cover it, and test/game-spark-view.test.ts tests it.

What I chose not to do

  • No new JavaScript, tables or dependencies.

How to try it Open /games/<box>, pick a profile under Profiles, and follow a finding to its frame.

[
  {"go": "/games/<box>", "look": "Profiles section, select a stored profile", "expect": "flame graph, slowest ticks and per-mod time render from the stored profile"},
  {"go": "/games/<box>", "look": "a finding in the selected profile", "expect": "following it highlights the frame it names", "ask": "Does the finding land on the right frame?"}
]

🤖 Generated with Claude Code

commented

I merged main into this branch, resolved the four conflicts, and pushed. bun x tsc --noEmit and bun scripts/gate.ts are clean, and test/game-spark.test.ts and test/game-spark-view.test.ts pass. Of the other three suites I ran (test/tui-games.test.ts, test/no-polling.test.ts, test/security-floor-routes.test.ts), only test/game-spark-view.test.ts failed, which I fixed and re-ran. I did not re-run those three after the fix or run the full suite; the forge's check does that on this push.

The conflict: main had landed #18096, a thread-list page at the same route, /games/<box>/spark/<key>, plus a terminal screen for it. This pull builds a fuller page for that route: findings, flame graph, slowest ticks, time per mod, and GC and memory.

What I kept from each side:

  • Route and screens: /games/<box>/spark/<key> now serves this pull's page, and p then enter on the terminal opens this pull's screen. I deleted main's gameSparkView page and its profileScreen thread screen.
  • Thread list: both the page and the terminal screen show the threads, busiest first, escaped, so that part of #18058 survives.
  • Decode limit: both decode with READ_UNPACKED, so a hostile profile is still refused past 8 MiB unpacked.
  • Wording: an unreadable profile now says "is not a readable one: download it", as main's tests expect.
  • Docs: docs/features/game-spark.md describes the one page.

Test changes:

  • I removed the assertions for "The call tree and flame graph are not shown here", which is no longer true.
  • I updated one assertion in test/game-spark-view.test.ts to the new unreadable-profile wording.
  • I dropped the duplicate /games/:box/spark/:key entry from test/no-polling.test.ts.

To try it: store a sampler profile in a box and open /games/<box>/spark/<key>.

[{"go":"/games/<box>/spark/<key>","look":"The Threads section after the flame graph","expect":"Threads listed busiest first with ms sampled, names escaped"},{"go":"/games/<box>/spark/<key> for a heap profile","look":"The notice","expect":"Says it is not a readable one and links to download it"}]

🤖 Generated with Claude Code

commented

API Error: 402 This request requires more credits, or fewer max_tokens. You requested up to 128000 tokens, but can only afford 4000. To increase, visit https://openrouter.ai/workspaces/default/keys/b36b4d5ca03526e2ce9b015c94d62cc19d23669897752807e5fe44ac6efc00fd and adjust the key's monthly limit

commented

Declined: already done on main in 5ce50ab8d. That commit (#18211, "spark profile call tree and flame graph on the forge") adds the same feature this pull builds, and I did not push a merge. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m90shv97dmmafdth01253nqa Left open: someone has spoken on this pull.

commented

Declined: already done on main in 5ce50ab8d. That commit (#18211) adds the same spark profile page, flame graph and terminal call tree this pull builds, and I did not push a merge. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m90srv97t86g5hp66p7ap7m7 Left open: someone has spoken on this pull.

commented

The builder found nothing to change, and the check of this head (bd5f046410e2) is red again after a re-check:

check failed: does not merge into main: conflicts in docs/features/game-spark.md, src/games/spark_view.ts, src/tui/screens/game_spark.ts, src/tui/screens/game_spark_view.ts, src/web/pages/games_spark_ failed: does not merge into main: conflicts in docs/features/game-spark.md, src/games/spark_view.ts, src/tui/screens/game_spark.ts, src/tui/screens/game_spark_view.ts, src/web/pages/games_spark_view.ts, test/game-spark.test.ts, test/tui-games.test.ts

It stays open for a person or a new head.

commented

This pull now merges into main and adds what main still lacks: the slowest ticks, time per mod, GC and memory, and the mods listed, on both the web page and the terminal screen. tsc, the gate and the touched tests pass. The touched tests are games-spark-view, tui-games, game-spark, games-spark-profile, no-polling and parity. I did not run the whole suite; the forge runs it on this push.

What I did about the conflicts. main shipped #18211 with the same page, flame graph and terminal call tree this pull built. So I kept main's version of every conflicted file and dropped my duplicates: my flame layout, the CSS, my duplicate test and the extra budget fixture.

What changed on top of main:

  • summarySections in src/games/spark_view.ts returns the four sections as plain lines.
  • src/web/pages/games_spark_view.ts renders those sections as rows under the threads.
  • src/tui/screens/game_spark_view.ts appends the same lines to the terminal screen.
  • test/games-spark-view.test.ts has a new test that checks every terminal line appears on the page.
  • docs/features/game-spark.md says so.
  • The test fixture is now shared through test/helpers/spark_fixture.ts, which also trims test/games-spark-profile.test.ts.

What I left out:

  • The findings list that linked to a slow frame. It depended on the flame-frame ids of my own layout, which main doesn't have. The docs list it under "Not done".
  • Comment rewraps I had made in files this pull doesn't own; I reverted them.

To try it, open /games/<box>/spark/<key> with a grant on the box, or press p then Enter on the box's terminal screen.

[{"go":"/games/<box>/spark/<key>","look":"Under the thread flame graphs: Slowest ticks, Time per mod, GC and memory, Mods listed","expect":"Each section is a list of rows; an empty one says so in one line; the terminal screen shows the same lines"}]
commented

The four new sections on a spark profile are now structured rows, and both feedback points are addressed.

What changed

  • Structured rows. SparkSection in src/games/spark_view.ts now holds rows, each a title plus facts (label and value pairs), and an empty sentence for a section with no rows.
    • Slowest ticks: one row per window with Worst tick, Median, TPS, Ticks and Players. Players is a plain count, so the "1 players" wording is gone.
    • Time per mod: one row per mod with Share and Time.
    • GC and memory: one row per collector, then Heap, Non-heap and Machine memory, each with Used and Total.
  • One row per mod. "Mods listed" has a row per mod with its name as the title and a Version fact, so nothing becomes a comma-joined wall of text at 360px.
  • Page. src/web/pages/games_spark_view.ts draws each row with row({ title, facts }), which renders a dl.row-facts. An empty section shows its empty sentence.
  • Terminal. sectionLines joins the same rows as Title: Label value, Label value, so the terminal still shows what the page shows.
  • Thread note. "N more threads not drawn" now comes straight after the thread sections and before the new ones. A test checks that order.
  • Test. The test checks that every row title and every <dt>/<dd> pair is on the page.

I ran the spark view tests, tsc, design-lint and the gate, and all passed. I did not run the full suite, and I did not look at a rendered profile in the preview; the page assertions come from the test's rendered HTML for the fixture profile.

Not done

  • The finding link to a slow frame is still listed under Not done in the how-to; I took it as the next round, as you said.
  • I did not update docs/features/game-spark.md to the new row format.
[
  {"go": "/games/<box>/spark/<key> for a stored profile", "look": "Slowest ticks, Time per mod, GC and memory, Mods listed", "expect": "Each is a list of rows with a title and label/value facts; Mods listed has one row per mod with a Version"},
  {"go": "same page, a profile with more than 10 threads", "look": "the 'more threads not drawn' note", "expect": "It sits directly under the thread sections, above Slowest ticks"},
  {"go": "same page at 360px wide", "look": "Mods listed", "expect": "No long wrapped line; each mod is its own row"}
]

🤖 Generated with Claude Code

commented

I merged main into the branch, resolved the five conflicts and pushed. tsc and design-lint are clean. I ran the spark, games-terminal and game-mods test files and they pass. I did not run the full suite; the forge runs that on the push.

main had added its own slowest-ticks and time-per-mod tables (#18237), which overlap with the structured sections this pull already had. I kept this pull's sections for both web and terminal, with ticks and mods as the first two, then GC and memory, then mods listed. I deleted src/web/pages/games_spark_ticks.ts, since nothing uses it any more.

What changed against main's version:

  • Both doors now show the slowest ticks and per-mod time in this pull's row format (for example 80 ms, 100%) rather than main's 80.0 ms and 100.0% columns.
  • The empty-state wording is now "The profile attributes no time to a mod." in place of "This profile has no mod data…".
  • I kept main's test for a hostile mod name being escaped and adapted its expected strings to the new format.
  • I updated one assertion in test/tui-games.test.ts for the new empty-state wording.

gate.ts notes one comment line over 100 columns in test/tui-games.test.ts. I did not run --fix, and the gate says the nightly rewrap handles it on main.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs