fix(app): use the configured code and UI fonts consistently (#57242)

This commit is contained in:
Luke Parker
2026-10-20 11:45:33 +10:00
committed by GitHub
Unverified
parent 004e21a744
commit 1da2be4192
18 changed files with 74 additions and 15 deletions
+16
View File
@@ -43,6 +43,22 @@ A flash, a blanked area, a dialog that resizes or a reset scroll on first open a
- Do not use `leading-none`, `line-height: 1`, or a `13px` line height for normal text. Inter descenders clip inside truncation and overflow containers.
- Keep control and row heights explicit. Fix font metrics directly rather than using transforms, negative margins, or clip-padding compensation.
## Fonts
Users choose three fonts in Settings > Appearance. Every surface uses one of these roles. This section is the single source for font rules across `app`, `ui`, `session-ui`, `gui-extensions` and `desktop`.
| Role | Use for | Use |
|---|---|---|
| UI font | Prose, labels, titles, controls | Inherit, or `var(--font-family-sans)`, `var(--v2-font-family-sans)`, `font-sans` |
| Code font | Shell commands, code, paths shown as code, diffs, logs, tool input | `var(--font-family-mono)`, `var(--v2-font-family-code)`, `font-mono`, or a `<code>` / `<pre>` element |
| Terminal font | Terminal output only | `appearance.font("mono")` from the extension SDK |
- Never write a literal family (`Inter`, `"IBM Plex Mono"`, `monospace`, `Menlo`, `system-ui`) in production CSS, classes, inline styles, canvas `font` strings or widget options. A literal ignores the user's setting.
- Never add an `@font-face`, font file, or font package outside `packages/app/src/index.css`. That file is the only place the app ships faces: Inter (variable), IBM Plex Mono Text (weights below 600), Bold (600 and up) and Text Italic, and JetBrainsMono Nerd Font Mono Regular and Bold. If a design needs a face that is not shipped, add it there and say why in the PR.
- Show shell commands with the timeline shell metrics: code font, `13px`, weight `440`, `-0.04px` letter spacing. Do not invent another size for the same content.
- Prefer weight tokens (`font-medium`, `var(--font-weight-medium)`) over literal weights. Mono at `600` or more renders IBM Plex Mono Bold, so reserve it for real emphasis.
- Do not read font settings directly. `src/settings/model.tsx` writes them to the CSS variables above, and the extension host passes the terminal font through `appearance.font`.
## Localization
- NEVER hardcode user-visible English strings in production code. ALWAYS use an i18n key for visible copy, placeholders, accessible labels, tooltips, menus, dialogs, toasts, empty states, and displayed errors.
+2 -2
View File
@@ -263,7 +263,7 @@ export function ComposerEditor(props: ComposerEditorProps) {
// @ts-expect-error
autocomplete="off"
class="relative z-10 block min-h-[60px] w-full whitespace-pre-wrap bg-transparent px-4 pt-4 pb-2 text-[13px] font-[440] leading-5 text-v2-text-text-base focus:outline-none [&_[data-mention=file]]:text-syntax-property [&_[data-mention=agent]]:text-syntax-type [&_[data-mention=reference]]:text-syntax-keyword"
classList={{ "font-mono!": state.mode === "shell", "opacity-50": props.disabled }}
classList={{ "font-mono! tracking-[-0.04px]": state.mode === "shell", "opacity-50": props.disabled }}
style={{
"unicode-bidi": state.mode === "normal" ? "plaintext" : undefined,
"text-align": "start",
@@ -319,7 +319,7 @@ export function ComposerEditor(props: ComposerEditorProps) {
<div
dir={state.mode === "normal" ? "auto" : "ltr"}
class="pointer-events-none absolute inset-x-0 top-0 px-4 pt-4 text-[13px] font-[440] leading-5 text-v2-text-text-faint"
classList={{ "font-mono!": state.mode === "shell" }}
classList={{ "font-mono! tracking-[-0.04px]": state.mode === "shell" }}
style={{ "unicode-bidi": state.mode === "normal" ? "plaintext" : undefined, "text-align": "start" }}
>
{view.placeholder?.() ??
+26 -1
View File
@@ -10,6 +10,14 @@
font-style: normal;
}
/* The terminal draws bold cells with a bold canvas font. */
@font-face {
font-family: "JetBrainsMono Nerd Font Mono";
src: url("/assets/JetBrainsMonoNerdFontMono-Bold.woff2") format("woff2");
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: "Inter";
src: url("/assets/Inter.ttf") format("truetype");
@@ -17,14 +25,31 @@
font-style: normal;
}
/* Text covers every weight below bold, so only bold syntax tokens and markup load the Bold face. */
@font-face {
font-family: "IBM Plex Mono";
src: url("@ibm/plex/IBM-Plex-Mono/fonts/complete/woff2/IBMPlexMono-Text.woff2") format("woff2");
font-weight: 440;
font-weight: 100 599;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "IBM Plex Mono";
src: url("@ibm/plex/IBM-Plex-Mono/fonts/complete/woff2/IBMPlexMono-Bold.woff2") format("woff2");
font-weight: 600 900;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "IBM Plex Mono";
src: url("@ibm/plex/IBM-Plex-Mono/fonts/complete/woff2/IBMPlexMono-TextItalic.woff2") format("woff2");
font-weight: 100 599;
font-style: italic;
font-display: swap;
}
@media (display-mode: standalone) {
/* WebKit excludes safe-area insets from dvh in installed apps. */
#root {
@@ -130,7 +130,7 @@ export function SessionActivityChips(props: {
{(item) => (
<Menu.Item {...row(item)}>
<Icon name="console" class="shrink-0 text-v2-icon-icon-muted" />
<span dir="ltr" class="min-w-0 flex-1 truncate font-mono text-[12px] text-v2-text-text-base">
<span dir="ltr" class="min-w-0 flex-1 truncate font-mono text-[13px] tracking-[-0.04px] text-v2-text-text-base">
{item.label}
</span>
{stop(item)}
@@ -66,7 +66,7 @@ export function SessionPermissionDock(props: {
<span data-slot="permission-spacer" aria-hidden="true" />
<div data-slot="permission-patterns">
<For each={props.request.resources}>
{(pattern) => <code class="text-12-regular text-text-base break-all">{pattern}</code>}
{(pattern) => <code class="text-text-base break-all">{pattern}</code>}
</For>
</div>
</div>
+1
View File
@@ -14,6 +14,7 @@
- Follow Solid best practices, leave a comment when violating this: https://www.brenelz.com/posts/solid-js-best-practices/
- Renderer code follows the Suspense rules in `packages/app/AGENTS.md`: never read a resource in render without the `state` guard. An unguarded read makes the UI flash on first load.
- Fonts follow the Fonts section of `packages/app/AGENTS.md`: use the UI, code and terminal font roles from the design system. Never add font files, `@font-face` rules or literal font families here.
- Renderer process should only reach the main process through `window.electron` (exposed by `src/preload`) and the MessagePort RPC client in `src/renderer/api.ts`.
- Main process should define IPC handlers in `src/main/ipc-handlers/*` and compose them in `src/main/ipc.ts`.
- Avoid FS operations where possible. For any desktop persistence prefer sqlite in most cases, as performance and EPERM and many other things, especially on windows can be quite painful. Using anything other than sqlite should come with strong reasons.
+1
View File
@@ -12,6 +12,7 @@ Built-in features of the desktop and web app, each behind the SDK in `src/sdk/`.
- A contract that returns components binds each with `bindExtension` in the provider's setup, so `useExtension` inside reads the provider's context, not the consumer's. Do not wrap data methods such as `Changes.diffs`.
- SDK icon fields take an `IconName` from `@opencode/ui/icons/catalog`, the dependency-free icon catalog.
- The APIs the host always provides are context properties (`ctx.layout`, `ctx.sessions`, `ctx.storage`, `ctx.desktop`, …; in main `ctx.storage`, `ctx.windows`, `ctx.serverEndpoints`, …). `useExtension<typeof definition>()` returns the same context in components. Registries and contracts stay tokens: `ctx.add(Registry, item)`, `ctx.provide(Contract, impl)`; main provides Ipcs with `ctx.provide(Ipc, impl)`.
- Fonts follow the Fonts section of `packages/app/AGENTS.md`. Terminal-rendered output uses `ctx.appearance.font("mono")` (the terminal font); other UI uses the code and UI font CSS variables. Never bundle font files or write literal families, except for documents that carry their own fonts (Office, font previews).
- Never import `@opencode/app`, `@opencode/desktop`, or `@/` paths. Import CSS with `?inline` and contribute it through `ctx.add(Style, css)`. No module-level state: keep state inside `setup`. `bun run lint` enforces these rules.
- `bun run lint:changed` must pass before you finish: every file you add or edit has no oxlint problem at all, including the warn-level anti-slop rules (`unknown` parameters and returns, unchecked type assertions, widened types, unsafe dictionaries, missing spacing). Touching a file means leaving the whole file clean, older warnings included. Fix the code; suppress only with a `SAFETY:` comment that states a real checked invariant.
+1 -1
View File
@@ -966,7 +966,7 @@ export interface Appearance {
/**
* The CSS font family the user chose; the default mono font before the app interface mounts. Reactive.
*
* @param kind - `mono`, the terminal and code font.
* @param kind - `mono`, the terminal font.
*/
font(kind: "mono"): string
}
@@ -796,11 +796,16 @@ export const Terminal = (props: TerminalProps) => {
dir="ltr"
data-prevent-autofocus
tabIndex={-1}
style={{ "background-color": terminalColors().background, "caret-color": "transparent", opacity: 0 }}
style={{
"background-color": terminalColors().background,
"caret-color": "transparent",
"font-family": appearance.font("mono"),
opacity: 0,
}}
classList={{
...local.classList,
"select-text": true,
"size-full px-6 py-3 font-mono relative overflow-hidden": true,
"size-full px-6 py-3 relative overflow-hidden": true,
[local.class ?? ""]: !!local.class,
}}
{...others}
+1
View File
@@ -14,3 +14,4 @@
- Never copy Figma's generated `leading-none` onto text. Inter descenders clip when a solid `13px` line box meets `overflow: hidden`, `overflow: clip`, or truncation.
- Keep fixed row dimensions explicit; correct inner line metrics do not require transforms, negative margins, or paint-space compensation.
- `TextShimmer` inherits font metrics, so put typography overrides on its parent.
- Fonts follow the Fonts section of `packages/app/AGENTS.md`. Commands, code and paths shown as code use the code font with the timeline shell metrics; never write a literal family or add font files here.
@@ -1167,8 +1167,11 @@
}
code {
font-size: 14px;
line-height: var(--line-height-large);
font-family: var(--v2-font-family-code);
font-size: 13px;
font-weight: 440;
line-height: var(--line-height-base);
letter-spacing: -0.04px;
}
}
@@ -18,6 +18,7 @@
display: inline-block;
vertical-align: baseline;
min-width: 0;
font-family: var(--v2-font-family-code);
line-height: inherit;
white-space: nowrap;
}
@@ -109,6 +109,11 @@
overflow-wrap: anywhere;
}
&[data-tool="shell"] [data-slot="basic-tool-tool-subtitle"],
&[data-tool="shell"] [data-slot="tool-error-card-subtitle"] {
font-family: var(--v2-font-family-code);
}
[data-slot="tool-error-card-subtitle"] {
max-height: 240px;
overflow-y: auto;
@@ -140,7 +140,7 @@ export function ToolErrorCard(props: ToolErrorCardProps) {
)
return (
<Card {...rest} data-kind="tool-error-card" data-open={open() ? "true" : "false"} variant="error">
<Card {...rest} data-kind="tool-error-card" data-tool={split.tool} data-open={open() ? "true" : "false"} variant="error">
<Collapsible class="tool-collapsible" data-open={open() ? "true" : "false"} open={open()} onOpenChange={setOpen}>
<Collapsible.Trigger>
<div data-component="tool-trigger">
+1
View File
@@ -18,3 +18,4 @@
- Inter text at `13px` must use at least the compact `16px` line height. A `13px` solid line box can clip `g`, `j`, `p`, `q`, and `y` when the text or an ancestor truncates or hides overflow.
- Reserve `line-height: 1` and `leading-none` for non-text glyphs, icons, or deliberately reviewed display marks. Do not compensate text with transforms, negative margins, or clip-padding hacks.
- `TextShimmer` inherits font metrics. Put typography overrides on its parent when they must supersede the component defaults.
- Fonts follow the Fonts section of `packages/app/AGENTS.md`: use `var(--font-family-sans)` or `var(--font-family-mono)` and their aliases, never a literal family, and never add font files or `@font-face` rules here.
+2 -2
View File
@@ -302,7 +302,7 @@
}
[data-slot="terminal-tab-title"] {
font-family: Inter, sans-serif;
font-family: var(--font-family-sans);
font-style: normal;
font-weight: 440;
font-size: 13px;
@@ -560,7 +560,7 @@
}
[data-slot="tabs-trigger"] {
font-family: Inter, sans-serif;
font-family: var(--font-family-sans);
font-style: normal;
font-weight: 440;
font-size: 13px;
+2 -2
View File
@@ -63,7 +63,7 @@
.text-12-mono {
font-family: var(--font-family-mono);
font-feature-settings: var(--font-feature-settings-mono);
font-feature-settings: var(--font-family-mono--font-feature-settings);
font-size: var(--font-size-small);
font-style: normal;
font-weight: var(--font-weight-regular);
@@ -91,7 +91,7 @@
.text-14-mono {
font-family: var(--font-family-mono);
font-feature-settings: var(--font-feature-settings-mono);
font-feature-settings: var(--font-family-mono--font-feature-settings);
font-size: var(--font-size-base);
font-style: normal;
font-weight: var(--font-weight-regular);