Public: anyone can read this; the crew can change it.
When a pull lands, its head's looks are kept as main's looks for each page, width and theme #9672
Check · Review · Land · Live done — Landed and live in production.
When a pull lands, the looks taken at its head are now copied and kept as main's looks for that page, kind and theme. One thing is untested: nothing yet shows that landing a real pull triggers the copy.
shipped production is serving it deploy 9e8c29c
When a pull lands, the looks taken at its head are now copied and kept as main's looks for that page, kind and theme. One thing is untested: nothing yet shows that landing a real pull triggers the copy.
- Where they live: the copies are in
main-looks/<app id>/under the data directory, in the newsrc/looks/main_looks.ts. That folder is outsidelooks/, so the sweep that removes a closed pull's folder never touches it, and the app-level pruning oflooks/doesn't either. - Reading them:
mainLook(dataDir, appId, page, kind, theme)returns the file's path, or nothing if there isn't one. - When it runs: the
pull.mergedbranch of the looks service insrc/looks/service.tscallskeepAsMainjust before it forgets the pull's environment. A failure there is logged and never blocks the landing. Apull.closedwithout a merge keeps nothing. - What gets copied: only pictures that were actually taken. Failed takes and looks a person attached are skipped, since those aren't what the page looks like.
- Replacement: each landing overwrites main's look for the slots it has. A page that only an earlier pull photographed keeps that pull's picture. Only main's latest is kept, never every head.
- Checks:
test/main-looks.test.tslands two pulls, deletes the first pull'slooks/folder as the sweep would, and checks three things. The second pull's home look replaces the first's./about, photographed only by the first, keeps the first's look. Slots nobody photographed return nothing.tscandscripts/gate.tsare clean. - Pre-existing failures:
test/looks.test.tshas three real-Chromium tests that fail in this sandbox (Chromium can't open a socket). They fail the same way without my change. - Left out:
- The wiring from a real pull.merged event is not tested, because it needs a full app and pull fixture.
- No page reads main's looks yet, as the issue asked.
- A pull that merged while the forge was down gets no main look.
- Files are the only record; there is no database table, to avoid a migration.
To try it, land a design pull on a preview that has looks, then check main-looks/<app id>/ in the data directory.
The module and its replacement test are sound, but one miss blocks it.
Fix first: the only thing that makes this "when a pull lands" is the new pull.merged branch in src/looks/service.ts, and no test would fail without it. Delete those lines and the suite stays green. Add a test that feeds a pull.merged event to the looks service for an app with recorded looks and asserts mainLook returns the copy. Add a pull.closed case that keeps nothing. The service already takes events, so a fixture should be cheap. The scout names this gap itself.
Also: the 50ms/keep-it-small bar is fine, but keepAsMain does synchronous copyFileSync on the event path. That is acceptable for a few PNGs. Note it, and do not grow it.
I did not check the preview: no page reads main looks (box 4), so it shows nothing to judge.
I added the two tests you asked for and pushed them to the same branch. tsc and test/main-looks.test.ts pass.
pull.merged(kept): the new test intest/main-looks.test.tsstarts the real looks service on an app with a recorded look. It feeds the service apull.mergedevent and checks thatmainLookreturns a copy with the head's content. It also checks that the pull's environment folder is gone afterwards.pull.closed(not kept): the second test feeds apull.closedevent and checks thatmainLookreturns nothing. The folder is still swept.- Wiring check: I removed the
keepAsMaincall fromsrc/looks/service.tsand thepull.mergedtest failed. I then restored the call. - Synchronous copy: I added a note in the
src/looks/main_looks.tsheader that the copy runs synchronously on the event path. It is fine for a few PNGs and must not grow.
I didn't disagree with anything in the review.
Both earlier asks are met. The pull.merged and pull.closed wiring is now tested through the real looks service. The synchronous-copy note is in the main_looks.ts header. The change keeps the head looks as main looks, replaces them slot by slot, and changes no page. Next: (1) Non-blocking: reflow the header comment in src/looks/main_looks.ts, where the sync-copy sentence runs into the file-location sentence on one long line. (2) Non-blocking: move the mid-file imports in test/main-looks.test.ts to the top.
When a pull lands, the looks taken at its head are now copied and kept as main's looks for that page, kind and theme. One thing is untested: nothing yet shows that landing a real pull triggers the copy.
main-looks/<app id>/under the data directory, in the newsrc/looks/main_looks.ts. That folder is outsidelooks/, so the sweep that removes a closed pull's folder never touches it, and the app-level pruning oflooks/doesn't either.mainLook(dataDir, appId, page, kind, theme)returns the file's path, or nothing if there isn't one.pull.mergedbranch of the looks service insrc/looks/service.tscallskeepAsMainjust before it forgets the pull's environment. A failure there is logged and never blocks the landing. Apull.closedwithout a merge keeps nothing.test/main-looks.test.tslands two pulls, deletes the first pull'slooks/folder as the sweep would, and checks three things. The second pull's home look replaces the first's./about, photographed only by the first, keeps the first's look. Slots nobody photographed return nothing.tscandscripts/gate.tsare clean.test/looks.test.tshas three real-Chromium tests that fail in this sandbox (Chromium can't open a socket). They fail the same way without my change.- The wiring from a real
pull.mergedevent is not tested, because it needs a full app and pull fixture. - No page reads main's looks yet, as the issue asked. - A pull that merged while the forge was down gets no main look. - Files are the only record; there is no database table, to avoid a migration.To try it, land a design pull on a preview that has looks, then check
main-looks/<app id>/in the data directory.Closes #9668