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

The forge toolbar in an app shows the app's state word and the last landed change in one line #13177

Merged opened this

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

Merged

The toolbar panel now has a line reading live · · , or live · no change yet · when no change is known for the running commit. It shows for any running environment the viewer may read. No query on the request path: src/apps/landed.ts holds a small in-memory map from app and environment to the commit subject.

Notes

shipped production is serving it deploy 59903fa

opened this

The toolbar panel now has a line reading live · <subject of the commit being served> · <ago>, or live · no change yet · <ago> when no change is known for the running commit. It shows for any running environment the viewer may read.

  • No query on the request path: src/apps/landed.ts holds a small in-memory map from app and environment to the commit subject. The deploy swap-in in src/apps/runtime.ts fills it. It already reads git there for the release subject, so this adds one commitLog read there and nothing per page. pillWhere in src/apps/proxy.ts reads the map and passes the subject to the toolbar tag as data-change. The map is empty after a restart until the next swap-in. A running app then reads "no change yet" until it deploys again.
  • Escaping and size: the tag attribute is escaped with escapeAttr, and the client sets it as textContent. The subject is cut to its first line and 60 characters. The script grows by about 78 bytes and the tag by under 300, which the test checks.
  • Changed existing test: toolbar-serving.test.ts expected the old ", live 4 min ago" suffix on the "Serving <sha>" line. I removed that suffix because it now repeats the new line, and the script was 2 bytes over its 24 KB budget with both. I updated that assertion to the new line.
  • Left out: the line shows live state only, not deploying, failed or asleep. A preview shows the subject of the commit it runs, not the pull title.

Verification:

  • bun x tsc --noEmit, bun scripts/design-lint.ts and the toolbar tests I ran all pass. That covers the nonce/CSP test, the budget test, toolbar-live, apps-toolbar, toolbar-serving and the new test/apps-toolbar-state.test.ts.
  • scripts/gate.ts and scripts/fast.ts are not in this clone, so I did not run them.
  • I did not run the full suite and I did not boot the app.

Closes #13163

7 earlier comments · 2 events
commented

The toolbar panel now has a line reading live · <subject of the commit being served> · <ago>, or live · no change yet · <ago> when no change is known for the running commit. It shows for any running environment the viewer may read.

  • No query on the request path: src/apps/landed.ts holds a small in-memory map from app and environment to the commit subject. The deploy swap-in in src/apps/runtime.ts fills it. It already reads git there for the release subject, so this adds one commitLog read there and nothing per page. pillWhere in src/apps/proxy.ts reads the map and passes the subject to the toolbar tag as data-change. The map is empty after a restart until the next swap-in. A running app then reads "no change yet" until it deploys again.
  • Escaping and size: the tag attribute is escaped with escapeAttr, and the client sets it as textContent. The subject is cut to its first line and 60 characters. The script grows by about 78 bytes and the tag by under 300, which the test checks.
  • Changed existing test: toolbar-serving.test.ts expected the old ", live 4 min ago" suffix on the "Serving <sha>" line. I removed that suffix because it now repeats the new line, and the script was 2 bytes over its 24 KB budget with both. I updated that assertion to the new line.
  • Left out: the line shows live state only, not deploying, failed or asleep. A preview shows the subject of the commit it runs, not the pull title.

Verification:

  • bun x tsc --noEmit, bun scripts/design-lint.ts and the toolbar tests I ran all pass. That covers the nonce/CSP test, the budget test, toolbar-live, apps-toolbar, toolbar-serving and the new test/apps-toolbar-state.test.ts.
  • scripts/gate.ts and scripts/fast.ts are not in this clone, so I did not run them.
  • I did not run the full suite and I did not boot the app.
commented

The forge's gate failed on one line in test/apps-toolbar-state.test.ts: the header comment on line 1 was 109 columns, over the 100-column limit. I rewrapped it onto three lines and pushed.

After the fix, bun scripts/gate.ts, bun x tsc --noEmit and bun test test/apps-toolbar-state.test.ts (4 tests) all pass locally. Nothing else changed; the toolbar behaviour from the earlier commit is as before. I haven't seen the forge's check run on the new push yet.

commented

The gate's comment-wrapping rule failed again, this time on four files I had touched. I merged the latest main into the branch and ran bun scripts/gate.ts --fix. It rewrapped comments in src/apps/proxy.ts, src/apps/runtime.ts, src/apps/toolbar.ts and test/toolbar-serving.test.ts. Those are the only changes in the commit, and I pushed it.

bun scripts/gate.ts and bun x tsc --noEmit pass. The two toolbar test files, test/apps-toolbar-state.test.ts and test/toolbar-serving.test.ts, pass (8 tests).

Before the merge, --fix found nothing to rewrap on the branch alone. So the failing check was probably judging the merged tree, not my branch.

I did not run the wider fast tier. After the merge, scripts/fast.ts listed far too many files, and that run timed out here, so I stopped it. The forge's own check will run it. The forge's check has not yet run on this push.

commented

I merged main into this branch and pushed. The toolbar and proxy test files pass (162 tests), tsc is clean, and gate.ts --fix changed nothing. I did not run the full suite: scripts/fast.ts named 2685 files, over its 5-minute budget, so I ran only those toolbar and proxy tests. Chromium doesn't start in this sandbox, so test/toolbar-keyboard.test.ts was skipped.

  • Conflict in src/apps/toolbar.ts: only the PillWhere.serving type conflicted. I kept this branch's change?: string field, since the pill's "live · change · ago" line reads it, and main didn't use it.
  • Byte budget: the merge put the toolbar script 13 bytes over its 24 KB limit, which failed test/toolbar-budget.test.ts and test/apps-toolbar.test.ts. I shortened the ago helper by using | 0 instead of Math.floor. Its output is the same.
  • Left out: I made no other changes to the pull's behaviour.
commented

I pushed a fix for the module-state failure. The other failing test, "an entry still waiting for its answer stays out of the fold" in test/thread-window.test.ts, I didn't change, and it passes when I run it here.

  • Cause: src/apps/landed.ts kept the last-landed-change notes in a module-level Map, which test/module-state.test.ts refuses (state belongs to a forge, not the process).
  • Fix: the notes are now a WeakMap keyed by the forge's app object. noteLanded and landedChange take that object first, and runtime.ts and proxy.ts pass the same key (this.app and runtime.app). The test in test/apps-toolbar-state.test.ts passes a forge object too.
  • Checked here: tsc is clean and gate.ts --fix changed nothing. module-state, the toolbar tests and thread-window all pass (96 tests).
  • Not checked: the full suite, so the thread-window failure is only judged by its passing locally, not by a repeat of the shard run. It touches nothing this pull changed, so I took it for a shard flake. If it fails again on this push, it needs a separate look.
Changes requested — before the latest push

Security is fine: the subject is escaped with escapeAttr and set as textContent, and it is read only behind the reads gate. Four things to fix in one round:

  1. Nothing tests the wiring. No test fails if pillWhere stops passing change, or if the swap-in stops calling noteLanded. Add a test that drives pillWhere (a reader gets serving.change, a non-reader gets none) and one for the runtime swap-in.
  2. The 'no change yet' test only greps the script source for a string. Execute the toolbar script as toolbar-serving.test.ts does and assert the rendered text for both cases.
  3. Unrelated edits: remove the deleted comment in toolbar.ts and the comment rewraps that are not forced by the gate. The comment in runtime.ts is now above the wrong block.
  4. After every restart the map is empty, so every running app says 'no change yet', which is false. Fall back to reading the subject lazily outside the request path, or omit the line when unknown.
commented

Pushed to the same branch. I addressed all four points, with one disagreement on point 3. The toolbar, landed-change and module-state tests pass (168 pass, 4 skipped) and tsc is clean. I did not run the full suite.

1. Wiring tests. New test/apps-landed-wiring.test.ts runs a real deploy on a private app:

  • Swap-in: after the swap-in, the served commit's subject is noted. This fails if noteLanded is dropped.
  • pillWhere: a reader gets serving.change, and a stranger gets no serving at all. This fails if pillWhere stops passing change.
  • Teardown: the note is gone afterwards.

I did not mutation-test these, so I haven't seen them fail with the wiring removed.

2. Rendered text. test/apps-toolbar-state.test.ts now runs the script through boot and asserts the rendered line, with and without a change. A change containing markup renders as plain text.

3. Unrelated edits.

  • Deleted comment: restored in toolbar.ts.
  • Runtime comment: the new block now sits above the "same statement…on the bus" comment, and a new comment says why the empty catch {} is safe: a git read failure must not fail an already-live deploy.
  • Comment rewraps (disagree): the two rewrapped comments in runtime.ts stay. gate.ts --fix rewrites them to the wrapped form whenever they differ, and the check runs the gate.

4. Empty map after a restart. I took your "omit the line" option. With no change known, the pill says live · 4 min ago, so it never claims "no change yet". I did not add a lazy git read after a restart, so an app shows no change until its next deploy.

Entries never removed. forgetLanded is called from AppsRuntime.teardown, so retired previews no longer accumulate in the map.

commented

The check failed on a rule that bans as never in tests. I fixed it and pushed. Locally the gate, tsc --noEmit and test/apps-landed-wiring.test.ts (3 tests) all pass. I didn't wait for the forge's re-run of the check.

What changed: only test/apps-landed-wiring.test.ts.

  • pillWhere now gets a full GrantWho (id, name, role: "user") built from forge.alice, instead of { id } as never.
  • The target() helper is typed as AppTarget, which drops the as AppTarget cast that sat beside the flagged one.

Nothing changed in src, and no assertions were weakened. The rest of the pull is as before: the toolbar shows the served commit's subject, only for a reader, and a torn-down environment forgets it.

Try it: bun test test/apps-landed-wiring.test.ts.

Changes requested — before the latest push

Reviewed from the source and tests; I did not exercise the preview, which only shows the line inside an app page.

Two changes, both on the same line.

  1. Fix first: the issue (box 2) says an app with no landed change reads no change yet. This head drops the segment and shows live · 4 min ago instead, and the test asserts that. Restore the issue's wording: live · no change yet · <ago>.
  1. The map is empty after every restart or rollout, and it is only refilled at the next swap-in. Every running app then shows no change, and that is the common state in production. That is exactly what #6611 (the queue survives a rollout) is about. Note the subject where the runtime adopts or boots an already-running environment too, not only at the swap-in. Alternatively read it once, off the request path, on first sight of that commit. Add a test for the boot case.

Smaller points, not blocking on their own: the empty catch {} in runtime.ts swallows every error, so log one line there. test/apps-landed-wiring.test.ts ends with a stray blank line.

The security, escaping, no-query-on-request-path and CSP/nonce points are fine. This is also a feature pull while the direction says pipeline first, so keep it small.

commented

The forge toolbar inside an app now reads live · <last landed change> · <ago>, with a link to the commit it serves. Each environment's last landed change is the first line of the commit message it serves, noted outside the request path: at the swap-in and when the forge boots. When nothing is noted, it reads live · no change yet · <ago>, as the issue asks. The change rides in the page escaped, and only for someone who can read the app.

This revision answers the review:

  • no change yet (src/apps/toolbar.ts): the line now prints the issue's wording instead of dropping the segment. test/apps-toolbar-state.test.ts and test/toolbar-serving.test.ts asserted the old wording, so both were wrong and now assert the issue's text.
  • After a restart or rollout (src/apps/runtime.ts): a new noteChange helper reads the commit's subject. The swap-in calls it, and so does reconcileApp at boot: once for each production tip and once for each preview it brings back asleep. A preview woken later serves that same commit, so the note made at boot covers it. A dormant preview is redeployed when roused, so the swap-in notes it. This adds one git read per environment at boot, never on a request.
  • Boot test (test/apps-landed-wiring.test.ts): a new test stops the runtime, clears the note to mimic a fresh process, and starts a new runtime. The note is there as soon as start() returns, before any swap-in. With the boot call removed, the test fails.
  • Errors: a failed git read now logs one warn line instead of an empty catch {}.
  • Earlier check failure: the earlier commit on this branch replaced the as never cast in the wiring test with a real identity object, and the stray blank line at the end of that file is gone.

I left out branches the app keeps running from the boot note. They still get their note at their first swap-in, which keeps the change small.

Checks run locally: bun scripts/gate.ts --fix, bun x tsc --noEmit, and these tests: every test/toolbar- suite, test/apps-idle, test/apps-rollout, test/apps-sleep, test/apps-landed-wiring and test/apps-toolbar-state (109 pass, 4 skip, 0 fail). The 4 skipped suites need unix sockets, which this sandbox can't bind; the forge's check runs them. scripts/fast.ts named 2,686 files for this diff (about 226 minutes), so I chose these suites by hand.

To try it: run bun test test/apps-landed-wiring.test.ts test/apps-toolbar-state.test.ts, or open an app page on the preview and restart the forge.

🤖 Generated with Claude Code

Approved

Earlier asks are met. The wording is now the issue's live · <change> · <ago> / no change yet. A boot-time note covers a restart, so apps do not all say "no change yet" falsely. A git failure logs a warning instead of an empty catch. Wiring tests drive the swap-in, pillWhere (reader vs stranger), boot and teardown. The rendered text is asserted by running the script. The change is escaped via escapeAttr and set as textContent, read only behind the reads gate, with no query on the request path. The toolbar is not a feature with its own screen, so there is no TUI or docs obligation.

Two things I would do next:

  1. Non-blocking: note the change at boot for kept-running variant branches too; they say "no change yet" until their first swap-in.
  2. Non-blocking: the 60-char subject truncation counts UTF-16 units, so it can split a surrogate pair; truncate by code point.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs