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

Merged opened this

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

Merged

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

opened this

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 new src/looks/main_looks.ts. That folder is outside looks/, so the sweep that removes a closed pull's folder never touches it, and the app-level pruning of looks/ 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.merged branch of the looks service in src/looks/service.ts calls keepAsMain just before it forgets the pull's environment. A failure there is logged and never blocks the landing. A pull.closed without 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.ts lands two pulls, deletes the first pull's looks/ 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. tsc and scripts/gate.ts are clean.
  • Pre-existing failures: test/looks.test.ts has 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.

Closes #9668

commented

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 new src/looks/main_looks.ts. That folder is outside looks/, so the sweep that removes a closed pull's folder never touches it, and the app-level pruning of looks/ 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.merged branch of the looks service in src/looks/service.ts calls keepAsMain just before it forgets the pull's environment. A failure there is logged and never blocks the landing. A pull.closed without 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.ts lands two pulls, deletes the first pull's looks/ 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. tsc and scripts/gate.ts are clean.
  • Pre-existing failures: test/looks.test.ts has 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.

Changes requested — before the latest push

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.

commented

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 in test/main-looks.test.ts starts the real looks service on an app with a recorded look. It feeds the service a pull.merged event and checks that mainLook returns 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 a pull.closed event and checks that mainLook returns nothing. The folder is still swept.
  • Wiring check: I removed the keepAsMain call from src/looks/service.ts and the pull.merged test failed. I then restored the call.
  • Synchronous copy: I added a note in the src/looks/main_looks.ts header 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.

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs