Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .fork/customizations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,41 @@
- apps/desktop/src/app/DesktopClerk.test.ts
verify:
- apps/web/src/__fork_guards__/forkClerkLaunchResilience.test.ts

- id: geist-typography
intent: >
The app's typefaces are Geist (UI) and Geist Mono (code), bundled as
Fontsource variable faces and imported from the fork's own theme layer —
web and Electron renderer only; mobile and marketing still ship DM Sans.
The stacks live in theme.custom.css as --fork-font-sans / --fork-font-mono
and index.css's @theme block reads them through
var(--fork-font-sans, <upstream stack>); that indirection is load-bearing,
not ceremony. The block is @theme inline, so Tailwind bakes font values
literally into .font-sans / .font-mono and their variants, and a compiled
utility cannot see a variable overridden in a later stylesheet — the same
constraint that forces the sidebar-v2 palette registrations to live in
index.css. Routing through --fork-font-* keeps the values scoped under the
fork marker while the fallbacks leave an unmarked build on DM Sans.
Two further decisions are non-obvious. Geist Mono is listed AHEAD of SF Mono:
upstream puts SF Mono first, which means on macOS its bundled mono webfont
never renders at all, so preserving upstream's order would make shipping
Geist Mono pointless. And body / pre, code are re-declared under the fork
marker because upstream hardcodes the literal stacks on those selectors
(index.css:964, index.css:1022) instead of reading its own @theme tokens,
so overriding --font-sans / --font-mono alone does not reach them. The
terminal resolves --font-mono by hand at mount, since xterm reads its font
from an option rather than the cascade, and re-measures its cell grid on
document.fonts.ready — xterm sizes columns at open(), and unlike the
always-resident SF Mono a webfont can land after that, leaving the grid
measured against the fallback. DM Sans / JetBrains Mono deps and their
main.tsx imports are deliberately left in place: an unreferenced family is
never fetched, so removing them would be an upstream edit for no gain.
tier: 4
files:
- apps/web/src/theme.custom.css
shadows: []
watch:
- apps/web/src/index.css
- apps/web/src/components/ThreadTerminalDrawer.tsx
verify:
- apps/web/src/__fork_guards__/geistTypography.test.ts
2 changes: 2 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"@dnd-kit/utilities": "^3.2.2",
"@effect/atom-react": "catalog:",
"@fontsource-variable/dm-sans": "^5.2.8",
"@fontsource-variable/geist": "^5.3.0",
"@fontsource-variable/geist-mono": "^5.3.0",
"@fontsource/jetbrains-mono": "^5.2.8",
"@formkit/auto-animate": "^0.9.0",
"@legendapp/list": "3.2.0",
Expand Down
95 changes: 95 additions & 0 deletions apps/web/src/__fork_guards__/geistTypography.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// @effect-diagnostics nodeBuiltinImport:off
/**
* Fork guard — see `.fork/README.md` §4b and
* `.fork/customizations.yaml#geist-typography`.
*
* A rebase can succeed and still silently drop a customization: upstream
* rewrites the surrounding code, git resolves "cleanly", and the fork hunk
* evaporates with a green checkmark. These tests turn that into a red one.
* Guards assert outcomes, not implementation details.
*/

import * as NodeFS from "node:fs";
import * as NodeURL from "node:url";
import { describe, expect, it } from "vite-plus/test";

import { FORK_MARKER_ATTRIBUTE, FORK_MARKER_VALUE } from "../custom/forkMarker";

function readSibling(relativePath: string): string {
return NodeFS.readFileSync(NodeURL.fileURLToPath(new URL(relativePath, import.meta.url)), "utf8");
}

const MARKER = `:root[${FORK_MARKER_ATTRIBUTE}="${FORK_MARKER_VALUE}"]`;

describe("fork guard: geist-typography", () => {
it("bundles both Geist faces as dependencies", () => {
const manifest = JSON.parse(readSibling("../../package.json")) as {
dependencies?: Record<string, string>;
};
expect(manifest.dependencies?.["@fontsource-variable/geist"]).toBeDefined();
expect(manifest.dependencies?.["@fontsource-variable/geist-mono"]).toBeDefined();
});

it("loads both Geist faces from the fork's own theme layer", () => {
const theme = readSibling("../theme.custom.css");
expect(theme).toContain('@import "@fontsource-variable/geist/index.css"');
expect(theme).toContain('@import "@fontsource-variable/geist-mono/index.css"');
});

it("declares the Geist stacks scoped to the fork marker", () => {
const theme = readSibling("../theme.custom.css");
const block = theme.slice(theme.indexOf(`${MARKER} {`));
expect(block).toContain("--fork-font-sans:");
expect(block).toContain('"Geist Variable"');
expect(block).toContain("--fork-font-mono:");
expect(block).toContain('"Geist Mono Variable"');
});

it("keeps upstream's @theme tokens reading through the fork indirection", () => {
// `@theme inline` bakes font values literally into `.font-sans` /
// `.font-mono` and their variants, so a compiled utility can never see a
// variable overridden in a later stylesheet. Lose this indirection and
// every `font-mono`-classed element silently reverts to SF Mono while the
// rest of the app stays on Geist.
// Whitespace-tolerant: the formatter decides whether these wrap.
const upstream = readSibling("../index.css");
expect(upstream).toMatch(/--font-sans:\s*var\(\s*--fork-font-sans\s*,/u);
expect(upstream).toMatch(/--font-mono:\s*var\(\s*--fork-font-mono\s*,/u);
});

it("keeps Geist Mono ahead of SF Mono, inverting upstream's order", () => {
// Upstream lists SF Mono first, so a bundled mono webfont never renders on
// macOS. Lose this ordering and Geist Mono silently stops appearing.
const theme = readSibling("../theme.custom.css");
const monoStack = theme.slice(theme.indexOf("--fork-font-mono:"));
expect(monoStack.indexOf('"Geist Mono Variable"')).toBeGreaterThanOrEqual(0);
expect(monoStack.indexOf('"Geist Mono Variable"')).toBeLessThan(monoStack.indexOf('"SF Mono"'));
});

it("re-declares the selectors where upstream hardcodes a font literal", () => {
// `body` and `pre, code` in index.css name the stacks literally instead of
// reading the @theme tokens, so the variable override alone misses them.
const theme = readSibling("../theme.custom.css");
expect(theme).toContain(`${MARKER} body`);
expect(theme).toContain(`${MARKER} :is(pre, code)`);
});

it("gives xterm the resolved --font-mono instead of a hardcoded stack", () => {
const drawer = readSibling("../components/ThreadTerminalDrawer.tsx");
expect(drawer).toContain('getPropertyValue("--font-mono")');
expect(drawer).toContain("fontFamily: terminalFontFamily");
// Quoted, so this matches a CSS family literal rather than any passing
// mention of the name in prose.
expect(drawer).not.toContain('"JetBrains Mono"');
expect(drawer).not.toContain('"DM Sans"');
});

it("keeps the terminal's webfont re-measure hook", () => {
// Nothing else fails if this goes: the terminal just opens with its column
// count measured against the fallback face on a cold load.
const drawer = readSibling("../components/ThreadTerminalDrawer.tsx");
expect(drawer).toContain("document.fonts.load");
expect(drawer).toContain("document.fonts.ready");
expect(drawer).toContain("terminal.options.fontFamily = terminalFontFamily");
});
Comment thread
NoahHendrickson marked this conversation as resolved.
Resolved
});
34 changes: 32 additions & 2 deletions apps/web/src/components/ThreadTerminalDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,48 @@ export function TerminalViewport({
const localApi = readLocalApi();

const fitAddon = new FitAddon();
/* fork:begin geist-typography — see .fork/customizations.yaml#geist-typography */
// xterm reads its font from this option only — no CSS inheritance — so the
// fork's --font-mono has to be resolved by hand. The literal fallback
// covers an unmarked build where the variable is somehow unset, and names
// system faces only — no bundled family, since none is guaranteed loaded.
const terminalFontFamily =
getComputedStyle(mount).getPropertyValue("--font-mono").trim() ||
'"SF Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace';
/* fork:end geist-typography */
const terminal = new Terminal({
cursorBlink: true,
lineHeight: 1,
fontSize: 12,
scrollback: 5_000,
fontFamily:
'"SF Mono", "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace',
fontFamily: terminalFontFamily,
theme: terminalThemeFromApp(mount),
});
terminal.loadAddon(fitAddon);
terminal.open(mount);
fitTerminalSafely(fitAddon);
/* fork:begin geist-typography — see .fork/customizations.yaml#geist-typography */
// Geist Mono is a webfont; xterm sizes its cell grid at open(). If the face
// is still in flight we just measured the fallback, so re-measure once it
// lands. fonts.load() forces the fetch to start — open() mounting DOM with
// the family should have started it already, but that leans on xterm's
// char-measure element being a real DOM node, an internal worth not
// depending on. fonts.ready then awaits everything pending, including the
// other unicode-range subsets an already-painted glyph may have triggered.
// Reassigning fontFamily is what triggers the re-measure, bounced through a
// throwaway value so it registers as a change regardless of how xterm's
// options setter treats equal writes; both writes are in one task, so
// nothing paints in between.
void document.fonts.load('12px "Geist Mono Variable"');
Comment thread
NoahHendrickson marked this conversation as resolved.
Resolved
void document.fonts.ready.then(() => {
// Cleanup nulls the ref before terminal.dispose(), so this can never
// touch a disposed terminal.
if (terminalRef.current !== terminal) return;
terminal.options.fontFamily = "monospace";
terminal.options.fontFamily = terminalFontFamily;
Comment thread
NoahHendrickson marked this conversation as resolved.
Resolved
fitTerminalSafely(fitAddon);
});
/* fork:end geist-typography */

terminalRef.current = terminal;
fitAddonRef.current = fitAddon;
Expand Down
35 changes: 30 additions & 5 deletions apps/web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,36 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--animate-status-pulse: status-pulse 2s infinite;
--animate-status-ping: status-ping 2s infinite;
--animate-sidebar-working-text: sidebar-working-text 3.4s infinite;
--font-sans:
"DM Sans Variable", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
sans-serif;
--font-mono:
"SF Mono", "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;
/* fork:begin geist-typography — see .fork/customizations.yaml#geist-typography
Indirection only; the fork's actual stacks live in `theme.custom.css`. This
block is `@theme inline`, so Tailwind bakes these values *literally* into
`.font-sans`, `.font-mono` and every variant of them (`[&_input]:font-sans`
and friends) — a scoped override of `--font-sans` in the fork stylesheet
cannot reach a compiled utility, the same constraint that keeps the sidebar
palette registrations below in this file. Routing through --fork-font-*
keeps the fork's values scoped under its marker attribute, and the
fallbacks leave an unmarked, pure-upstream build on upstream's stacks. */
--font-sans: var(
--fork-font-sans,
"DM Sans Variable",
"DM Sans",
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
system-ui,
sans-serif
);
--font-mono: var(
--fork-font-mono,
"SF Mono",
"SFMono-Regular",
"JetBrains Mono",
Consolas,
"Liberation Mono",
Menlo,
monospace
);
/* fork:end geist-typography */
--color-warning-foreground: var(--warning-foreground);
--color-warning: var(--warning);
--color-success-foreground: var(--success-foreground);
Expand Down
46 changes: 46 additions & 0 deletions apps/web/src/theme.custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,59 @@
* be scoped to a selector. The fork-owned ones are prefixed `sidebar-v2-rain-*`
* so the names cannot collide with upstream's.
*
* `@font-face` is the second exception, for the same reason: a face
* *registration* is global — there is no selector to hang it off. What matters
* is that nothing *uses* it outside the marker, and the `--font-*` overrides
* below are scoped, so an unmarked build registers the families and then never
* references them (so the browser never fetches a byte).
*
* The Tailwind-facing half of the Sidebar V2 palette — the six
* `--color-sidebar-v2-*` registrations — necessarily stays in `index.css`'s
* `@theme` block, since that is the only place Tailwind reads utility names
* from. It is fenced there as `fork:sidebar-v2-status-palette`. Everything the
* cascade can carry lives here instead.
*/

/* Geist ships as two variable faces: `Geist Variable` (100..900) and
`Geist Mono Variable` (100..900). Both are pulled in here rather than from
`main.tsx` so the fork owns its own font loading and upstream's import block
stays untouched — upstream's DM Sans / JetBrains Mono imports are left in
place for the same reason, and cost nothing on the wire once the overrides
below stop referencing those families. */
@import "@fontsource-variable/geist/index.css";
@import "@fontsource-variable/geist-mono/index.css";

/* The stacks themselves. `index.css` reads these through
`--font-sans: var(--fork-font-sans, <upstream stack>)` inside its
`@theme inline` block, fenced as `fork:geist-typography` — the indirection is
what lets a scoped declaration reach Tailwind's compiled `.font-sans` /
`.font-mono` utilities, which bake their value in literally and would
otherwise ignore anything declared here. An unmarked build never sets these,
so it falls through to upstream's fallbacks.

Geist Mono is listed AHEAD of SF Mono, inverting upstream's order. Upstream
puts SF Mono first, so on macOS its bundled mono webfont never actually
renders — keeping that order would make shipping Geist Mono pointless. */
:root[data-fork="noahhendrickson-t3code"] {
--fork-font-sans:
"Geist Variable", "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
--fork-font-mono:
"Geist Mono Variable", "Geist Mono", "SF Mono", "SFMono-Regular", Consolas, "Liberation Mono",
Menlo, monospace;
}

/* Upstream repeats the literal stacks on `body` (index.css:964) and `pre, code`
(index.css:1022) instead of reading its own `@theme` tokens, so overriding the
variables alone does not reach them. `:root[data-fork=…]` (0,2,x) outranks
both bare selectors. */
:root[data-fork="noahhendrickson-t3code"] body {
font-family: var(--font-sans);
}

:root[data-fork="noahhendrickson-t3code"] :is(pre, code) {
font-family: var(--font-mono);
}

/* Sidebar V2 status palette, keyed to the fork marker so an unmarked build
falls back to upstream's variables. The design's hues are tuned for a black
panel; on the light panel the same values are near-invisible at 8px, so each
Expand Down
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading