Skip to content

fix(serving): Patchy gets a favicon and patch tabs show the patch's title - #660

Merged
allisonmahmood merged 4 commits into
mainfrom
t3/fix-patch-page-metadata
Oct 13, 2026
Merged

allisonmahmood merged 4 commits into
mainfrom
t3/fix-patch-page-metadata

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Patchy had no favicon anywhere: the dashboard, sign-in pages and every patch tab showed a blank square. Tier 1 and 2 patch tabs also showed the address name (launch-queue) instead of the page's title, because publish only read <title> for tier 0. The patch's own <title> sits inside the iframe, where it never reaches the tab.

Favicon. Every Patchy page and patch tab now shows the mark from patchyhq.com. It's inlined as a data: URL in htmlPage and the patch shell, so there's no new route. The scripted shell's CSP gains img-src data: for it; the other pages already allowed data: images. The look preview is left alone, because it must pass tier 0 validation, which refuses <link>.

Titles. Tier 1 and 2 publish and patchy dev take the title from the page's <title>, as tier 0 already did, and fall back to the name. One rule, documentTitle, now serves every tier: the first HTML <title>, as browsers pick it (an icon's SVG <title> doesn't count, and an empty one falls back to the name). Scripted bundles are read only to 64 KiB, because Vite builds put <title> before the inlined code and a full parse of a 10 MB bundle blocks for ~650 ms; a title cut by that limit falls back to the name. Tier 0 keeps reading its whole (512 KiB) page. Rollback now restores the title the version published with, which tier 0 lacked too. patchy init writes the patch's name (Launch queue) instead of Notes / My patch, and the patchy-loop skill tells agents that <title> names the tab. Existing patches pick up their title on their next publish. The portal card is unchanged for these patches: a title that only differs from the name by case and dashes isn't shown as a second line.

Checked on a local instance: a fresh tier 1 launch-queue patch publishes with "title":"Launch queue". In Chromium and Firefox (which applies img-src to favicons), the sign-in page, portal, tier 1 patch and not-found page all carry the icon, it decodes, and no CSP violations are logged:

firefox | sign-in page  | 200 | {"title":"Sign in to Patchy","decoded":"300x300"} | csp: none
firefox | portal        | 200 | {"title":"launch-queue","decoded":"300x300"}      | csp: none
firefox | tier 1 patch  | 200 | {"title":"Launch queue","decoded":"300x300"}      | csp: none
firefox | missing patch | 404 | {"title":"Patch not found","decoded":"300x300"}   | csp: none

pnpm check passes. New tests cover how the title is picked (SVG, empty, 20,000-deep markup and a title cut by the read limit) and a tier 1 publish that falls back to the name and gets its title back on rollback. GPT 6.1 Sol reviewed it; the findings and fixes are in the comments.

Made by Claude Opus 5.5 via Claude Code in T3 Code

…itle

Every Patchy page and patch tab shows the patchyhq.com mark, inlined as a
data: URL; the scripted shell's policy admits data: images for it. Tier 1
and 2 publish and `patchy dev` take the tab title from the page's <title>,
as tier 0 already did, and init starts that title from the patch's name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added area:server Touches the server area area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:s Under 100 changed lines labels Oct 13, 2026
…llback

Review found the title walk recursed (deep markup threw), a near-cap
bundle took ~650 ms to parse on every publish and dev shell load, an empty
first <title> fell through to the next one, and rollback kept the newer
version's title. The title now comes from the first 512 KiB, walked
iteratively; tier 0 shares the same rule; patchy dev reads it once per
build; rollback restores the title the version published with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 1

1. should-fix: the title walk recursed, so deep markup threw ("<div>".repeat(12000) made a scripted publish fail with Maximum call stack size exceeded). Fixed in 0f493f0: documentTitle walks the tree with an explicit stack. Covered by a 20,000-deep test.

2. should-fix: patchy dev reparsed the whole bundle on every shell load (0.6–2.9 s near the 10 MB cap). Fixed: the title is computed once per build. The same cost also hit the hosted server on every publish, so documentTitle now parses only the first 512 KiB, where Vite builds put <title> ahead of the inlined bundle. A 9.2 MB bundle went from ~650 ms to ~30 ms. Past that bound the name is used.

3. should-fix: rollback kept the newer version's title. Fixed: rollback sets the title from the target version's stored publish response. That also fixes the same existing gap for tier 0. The new publish test rolls back to v1 and fails without the fix. Not changed: a historical address (/~v/n) shows the patch's current title. That's existing tier 0 behaviour, and the tab names the patch, not the version.

4. nit: an empty first <title> fell through to a later one. Fixed: the first HTML <title> wins, as in browsers; empty means fall back to the name. Tier 0's validateHtml now uses the same documentTitle rule.

Not in this PR: validateHtml's security walk for tier 0 is still recursive. That's existing behaviour, bounded by tier 0's 512 KiB cap.

pnpm verify on the first commit: everything passed except one cliRepoBuild timeout, which ran alongside a test worker that was SIGKILLed under load. Both files pass when run alone (14/14). pnpm check passes on 0f493f0.

@github-actions github-actions Bot added size:m 100-500 changed lines and removed size:s Under 100 changed lines labels Oct 13, 2026
…e name

Review found a title cut at the read limit could publish truncated
(`Fish &am`). A cut document now counts only a title whose end tag
survived. parse5's cost grows with the square of nesting depth, so
scripted bundles read 64 KiB, where Vite puts the title, and tier 0 takes
its title from the document validateHtml already parsed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 2

Sol confirmed the round 1 fixes: template, script, style and comment handling were checked in a browser; rollback restore and fallback were checked against SQL; all 19 HTML fixtures keep their titles and warnings. Sol agreed with leaving historical addresses as they are. One finding:

should-fix: a title cut at the read limit came out truncated. If the 512 KiB prefix ended inside <title>Fish &amp; chips</title>, publish used Fish &am. Fixed in 300ff41: when the document was cut, only a title whose end tag survived counts; otherwise the name is used. A new test fails without the fix (expected 'Fish &am' to be null).

Found while fixing it: parse5's cost grows with the square of nesting depth. 40,000 nested <div>s take 6.8 s, so a crafted 512 KiB page can block the event loop for close to a minute. To avoid widening that:

  • Scripted bundles now read only the first 64 KiB. Vite puts <title> in the first few hundred bytes. The worst case is under a second, and a 9.2 MB bundle takes ~10 ms.
  • Tier 0 takes its title from the document validateHtml already parsed, so tier 0 is not parsed twice.
  • The deep-markup test uses <b>, which stays fast at any depth (25 ms instead of 2 s).

Not in this PR: tier 0 publish already fully parses up to 512 KiB, so it has had that quadratic worst case since before this change. It needs a nesting cap or a cheaper check of its own.

Local pnpm check: format, lint, typecheck and synth pass. The only test failures were timeouts while the shared machine was at load ~19, and those files pass when run alone. CI was green on 0f493f0.

Review found `patchy dev` read every tier's title through the scripted
64 KiB limit, so a tier 0 page with an embedded font before its <title>
showed its name locally but its title once published. Tier 0 dev now takes
the title from validateHtml, on the first build and each rebuild.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 3

Sol confirmed 300ff41. endTag tells an explicit close from an EOF close in all 87 probes (</TITLE >, titles in body, titles after foreign content). The Vite single-file layout puts the head title before module code, CSS and fonts, so 64 KiB covers it comfortably. Tier 0 validation matches round 2 across the 19 fixtures and 49 more cases. One finding:

should-fix: patchy dev read tier 0 titles through the scripted 64 KiB limit. A tier 0 page with an embedded font before <title> showed its name in dev but its title once published. Fixed: dev takes a tier 0 title from validateHtml, as publish does, on the first build and on each rebuild (they share one helper). The tier 0 dev test now puts a 70 KB base64 font before the title and fails without the fix.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 4

Clean: no findings left worth fixing. 93c4887 handles tier 0 titles on the first build and on rebuilds. The dev manifest's tier is fixed until restart, and watched builds enforce the 512 KiB cap before reading the title. The title, favicon, escaping and CSP probes all passed.

@allisonmahmood
allisonmahmood merged commit b867439 into main Oct 13, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the t3/fix-patch-page-metadata branch October 13, 2026 14:54
allisonmahmood added a commit that referenced this pull request Oct 13, 2026
…s and Company pages are easier to use (#667)

Release 11's What's new entry, written through `a253cb2`. It ships as
`patchy` `0.11.0`.

**Changes**
- New: Tools can show your PostHog data (#662, #664)
- Improved: The Connections page stays clear with one connection or
thirty (#657)
- Improved: Find anyone on the Company page (#661)
- New: Invite many people at once (#661)
- Fixed: Browser tabs show Patchy's icon and your tool's name (#660)

**Behind the scenes**
- Each version of Patchy now skips kinds of connection it doesn't know,
so going back to an earlier version stays safe (#657)

**Deploying in two steps.** `c1e7de9` (#657 and everything before it) is
released first, with no entry of its own. Then main is released with
this entry. A rollback from the PostHog release therefore lands on a
release that hides PostHog connections and dev-read calls instead of
failing on them. Global CLIs and patch repos on `0.10.0` are told to
upgrade, as on any release.

Made by Claude Opus 5.5 via Claude Code in T3 Code

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 15, 2026
…#684)

The shared first-party shell (`htmlPage`) painted a fixed `feTurbulence`
noise texture behind every page. On every page whose policy allowed it,
body's opaque background covered it. On the HTML 404, the strict
fallback CSP blocked it and logged a violation. Since #660 added
`img-src data:` to that fallback for the favicon, the 404 no longer logs
the violation. Instead, the grain now shows faintly in the strip below
the 404's short body, the only place it ever renders.

This PR deletes the `body::before` rule from `htmlPage`'s stylesheet. No
content-security-policy changes. `examples/plan.html` keeps its copy
because it isn't served, and the 404's layout is #618.

One note against the brief: its "no CSP violation on `dev shot
/nothing`" criterion was already true on main because of #660. On the
404, this PR changes the lower strip, which goes back to plain paper.
That is how the 404 looked when the brief was written.

**Tested by hand** (`pnpm dev up team`, then `pnpm dev down`):

- `pnpm dev shot ada /nothing`: the before shot had faint grain below
the body; the after shot is plain paper. Both runs reported only one
browser error, the document's own 404.
- Playwright, with fresh contexts for the signed-out sign-in door `/`
and, as Ada, `/`, `/company`, `/company/connections`, `/whats-new`,
`/~shell/notice/access_denied` and `/nothing`, at 390×844, 900×600 and
1600×1400. I compared each page as served against the same page with the
deleted rule injected back. The screenshots are byte-identical
everywhere except `/nothing`.
- curl: none of those responses contain `feTurbulence`. The `/nothing`
`content-security-policy` is byte-identical to the one captured before
the change.
- vitest for core, serving `Pages`, portal and auth: 271 tests passed on
the rebased branch. CI runs the full suites.

**Hit every surface:** only *Served pages* applied. The `ui-consistency`
spec says nothing about the overlay, and the fixtures under
`packages/core/fixtures` are patch HTML, so neither changes. The company
look's `LOOK.md` already records the noise overlay as dropped. Wire
contract, CLI, dev loop, vocabulary, migrations, company resources,
reverse states and repo layout don't apply.

Closes #591

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant