diff --git a/packages/app/AGENTS.md b/packages/app/AGENTS.md index 3dd0d6b6da0..60df3ba72b5 100644 --- a/packages/app/AGENTS.md +++ b/packages/app/AGENTS.md @@ -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 `` / `
` 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.
diff --git a/packages/app/public/assets/JetBrainsMonoNerdFontMono-Bold.woff2 b/packages/app/public/assets/JetBrainsMonoNerdFontMono-Bold.woff2
new file mode 100644
index 00000000000..4d671d1db45
Binary files /dev/null and b/packages/app/public/assets/JetBrainsMonoNerdFontMono-Bold.woff2 differ
diff --git a/packages/app/src/composer/editor/editor.tsx b/packages/app/src/composer/editor/editor.tsx
index 979a308d6a1..6b1295faafb 100644
--- a/packages/app/src/composer/editor/editor.tsx
+++ b/packages/app/src/composer/editor/editor.tsx
@@ -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) {
             
{view.placeholder?.() ?? diff --git a/packages/app/src/index.css b/packages/app/src/index.css index d835f3c66b1..88025cc0fd4 100644 --- a/packages/app/src/index.css +++ b/packages/app/src/index.css @@ -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 { diff --git a/packages/app/src/session/composer/activity-chips.tsx b/packages/app/src/session/composer/activity-chips.tsx index c0fa1987a53..24f605bb321 100644 --- a/packages/app/src/session/composer/activity-chips.tsx +++ b/packages/app/src/session/composer/activity-chips.tsx @@ -130,7 +130,7 @@ export function SessionActivityChips(props: { {(item) => ( - + {item.label} {stop(item)} diff --git a/packages/app/src/session/requests/session-permission-dock.tsx b/packages/app/src/session/requests/session-permission-dock.tsx index f1b0445a98e..aaa274db8a4 100644 --- a/packages/app/src/session/requests/session-permission-dock.tsx +++ b/packages/app/src/session/requests/session-permission-dock.tsx @@ -66,7 +66,7 @@ export function SessionPermissionDock(props: {
diff --git a/packages/desktop/AGENTS.md b/packages/desktop/AGENTS.md index 6daf0117980..7752fdf2d0b 100644 --- a/packages/desktop/AGENTS.md +++ b/packages/desktop/AGENTS.md @@ -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. diff --git a/packages/gui-extensions/AGENTS.md b/packages/gui-extensions/AGENTS.md index 0b4c212f001..cc406b5b1a8 100644 --- a/packages/gui-extensions/AGENTS.md +++ b/packages/gui-extensions/AGENTS.md @@ -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()` 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. diff --git a/packages/gui-extensions/src/sdk/host-apis.ts b/packages/gui-extensions/src/sdk/host-apis.ts index a635fc44dd4..50550693c5a 100644 --- a/packages/gui-extensions/src/sdk/host-apis.ts +++ b/packages/gui-extensions/src/sdk/host-apis.ts @@ -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 } diff --git a/packages/gui-extensions/src/terminal/terminal.tsx b/packages/gui-extensions/src/terminal/terminal.tsx index d01b8ccd124..3fddfb0defd 100644 --- a/packages/gui-extensions/src/terminal/terminal.tsx +++ b/packages/gui-extensions/src/terminal/terminal.tsx @@ -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} diff --git a/packages/session-ui/AGENTS.md b/packages/session-ui/AGENTS.md index 98a8baece80..7e6410a58ce 100644 --- a/packages/session-ui/AGENTS.md +++ b/packages/session-ui/AGENTS.md @@ -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. diff --git a/packages/session-ui/src/components/message-part.css b/packages/session-ui/src/components/message-part.css index c80c4af962b..788a7a87d4f 100644 --- a/packages/session-ui/src/components/message-part.css +++ b/packages/session-ui/src/components/message-part.css @@ -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; } } diff --git a/packages/session-ui/src/components/shell-submessage.css b/packages/session-ui/src/components/shell-submessage.css index f72ba3fc755..59f0ae0cb42 100644 --- a/packages/session-ui/src/components/shell-submessage.css +++ b/packages/session-ui/src/components/shell-submessage.css @@ -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; } diff --git a/packages/session-ui/src/components/tool-error-card.css b/packages/session-ui/src/components/tool-error-card.css index c5539020c1c..34c9192a633 100644 --- a/packages/session-ui/src/components/tool-error-card.css +++ b/packages/session-ui/src/components/tool-error-card.css @@ -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; diff --git a/packages/session-ui/src/components/tool-error-card.tsx b/packages/session-ui/src/components/tool-error-card.tsx index 45b78bc724c..7e122a75d13 100644 --- a/packages/session-ui/src/components/tool-error-card.tsx +++ b/packages/session-ui/src/components/tool-error-card.tsx @@ -140,7 +140,7 @@ export function ToolErrorCard(props: ToolErrorCardProps) { ) return ( - +
diff --git a/packages/ui/AGENTS.md b/packages/ui/AGENTS.md index 80c5071b95e..6511258d72f 100644 --- a/packages/ui/AGENTS.md +++ b/packages/ui/AGENTS.md @@ -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. diff --git a/packages/ui/src/navigation/tabs/tabs.css b/packages/ui/src/navigation/tabs/tabs.css index 7c8ef483e0a..a0b75eedebb 100644 --- a/packages/ui/src/navigation/tabs/tabs.css +++ b/packages/ui/src/navigation/tabs/tabs.css @@ -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; diff --git a/packages/ui/src/styles/utilities.css b/packages/ui/src/styles/utilities.css index 3a05a9515fa..10cfe50278b 100644 --- a/packages/ui/src/styles/utilities.css +++ b/packages/ui/src/styles/utilities.css @@ -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);