The session header, Jump to latest, the scrollbar's thumb and the desktop window's drag area lie over the timeline, outside its scroll element. For a wheel over them the browser goes by the layers it composites, not by the element under the pointer: it scrolled the timeline while the rows were text, and nothing once a row held a scroller of its own, such as a shell's output. An upward wheel that moved nothing still stopped the timeline from following. - handleOverWheel takes that wheel from the browser and scrolls the timeline by the wheel's distance, once. Its listener is not passive, so it is on those elements only: over the rows the browser still does not wait for the page. - The thumb of ScrollView does the same for its viewport. - A wheel with the control key zooms. It sends no intent and ends no seek. - A wheel over a marked box that holds all of its content, or one at a scroller's limit, ends a seek as a wheel over the rows does.
34 KiB
Priorities
- Prioritise, in this order: stability, simplicity, performance.
- Before changing session or timeline code, benchmark it against
origin/devwith strobe (packages/app/perf/README.md):strobe bench packages/app/perf/<area>.bench.ts --base origin/dev --head ..
Debugging
- NEVER try to restart the app, or the server process, EVER.
Local Dev
opencode dev webproxieshttps://app.opencode.ai, so local UI/CSS changes will not show there.- For local UI changes, run the backend and app dev servers separately.
- Backend (from the repository root):
bun dev serve --port 4096 - App (from
packages/app):bun dev -- --port 4444 - Open
http://localhost:4444to verify UI changes (it targets the backend athttp://localhost:4096).
Insecure Origins (HTTP LAN)
The Web UI is served over plain HTTP on non-localhost LAN and Tailscale origins (isSecureContext === false). This rule applies across app, ui, session-ui and gui-plugins window code.
- Never call
crypto.randomUUID()directly in renderer or browser code; it is[SecureContext]-only and throwsTypeError: crypto.randomUUID is not a functionon plain HTTP origins. Always useuuid()from@opencode/util/uuid. - Guard any other
[SecureContext]-only Web API (crypto.subtle,navigator.clipboard,navigator.serviceWorker) with a non-secure fallback.
SolidJS
- Always prefer
createStoreover multiplecreateSignalcalls
State Machines
This section is the single source for lifecycle state across app, ui, session-ui, gui-plugins and desktop. Anything that moves through phases (loading, submitting, connecting, retrying, dragging, revealing, quitting) is an explicit state machine. Precedents: src/composer/machine.ts, src/session/requests/auto-approve-machine.ts, packages/desktop/src/main/deep-links/machine.ts, packages/gui-plugins/src/terminal/machine.ts, packages/ui/src/hooks/list-machine.ts.
- Model the lifecycle as one discriminated union (
typeorstatustag) in its own module next to the feature (machine.ts, or<feature>-machine.tswhen the folder already has one). It is the single source of truth: no booleans, nullable "in-flight" fields,WeakSets, generation counters or closure variables beside it that also encode the phase. Data that exists only in a phase lives inside that phase's variant. - Write one pure
transition(state, event)over a closed event union that returns the next state, or{ state, effects }. No I/O, timers, signals,awaitorDate.now()inside it. An event that does not apply to the current state returns the same state object, so it is visible in the code and writes no signal. - Keep only phases the user can observe. Merge phases nothing distinguishes, and model a variation as a field, not a new variant (for example a
gesturefield instead of one variant per input device). Fewer, real variants beat a faithful copy of every step. - Derive the UI with pure selectors or a
view(state): disabled, busy, spinner, error text, which panel or tab shows. Components read selectors; they never branch on side flags or re-check the phase themselves. In the main process, every consumer (quit handlers, menus, IPC) branches only on selectors of the machine. - Run async work in a thin driver at the edge. The driver turns effects into calls, dispatches the results back as events, and owns timers and abort controllers. Tie its cleanup to the owner's lifetime (
onCleanup,ctx.onCleanup), and dispatch adisposedevent rather than keeping a disposed flag. - Reject stale results inside the machine. Carry an attempt id in the state variant and in each result event, and ignore a result whose id is not current. A machine that only moves forward can match on the phase instead; each timeout event names its phase.
- Claim work synchronously. Leave
idlein the same event that starts the work, before the firstawait(image resolution, a request, a dynamic import). A guard checked before anawaitand set after it lets a second Enter, click or retry through. - Every async path ends in a state. A failure, timeout or cancel is a transition, never a log line or a silent
return. Give a request that can hang a bounded fallback (a reveal timeout, a phase timeout) so the UI cannot stay hidden, disabled or "Loading" forever. - A result that arrives late can still have side effects. When the user went back but the server already saved the change (a key, a credential), keep the state and emit only the refresh effect. When a timeout cuts a batch short, report the real outcome of the parts that finished and time out only the rest.
- Serialize operations that touch the same data through one queue in the machine (
activepluspending), including actions that look independent (steer, remove, reorder, undo). A side path that skips the queue can resurrect what another operation removed. - On an identity change (another session, server, window or credential), move to a new target with a new attempt instead of carrying the previous target's error, controller or result forward.
- On hot paths (scroll, pointer, resize, streaming), keep the machine allocation-free: return the same object when nothing changes, reuse event objects, and keep frozen singleton states. Benchmark with strobe as the Priorities section requires. Shared or frozen singleton states are safe only in signals and plain variables. Solid store writes (
setStore(path, obj),reconcile) merge into the object already in the store, so state written into a store never shares an object between two entries or with a module constant: replace it whole (producereplacement, or a signal), or build fresh objects with a factory (createFileTreeState()), and test through the real store with two entries. - Test the pure transition. Replay the bug's event sequence as a regression that fails on the old logic, then cover stale attempts and every exit (success, failure, timeout, cancel, dispose). Build events the way production builds them (through the real decoder, without fields the wire never carries), or the test passes on routes production never takes. These tests need no DOM, timers or mocks.
- Name new driver inputs so they cannot collide with existing ones (
appState, not a secondstate), and wire Solid reads of machine state into<Match>and<Show>with keyed matches or memos so a branch never reads a value another branch already narrowed.
Suspense
A flash, a blanked area, a dialog that resizes or a reset scroll on first open almost always means a read entered Suspense. Do not ship UI that reads async data without the guard below.
-
Reading
resource()suspends while it loads. So doesresource.latestuntil the resource has resolved once: before the first value,latestbehaves like a plain read.resource.loadingandresource.statenever suspend. -
Guard every render-time read on state, and show the data you already have until then:
const loaded = () => resource.state === "ready" || resource.state === "refreshing" const items = () => (loaded() ? resource.latest : cached) ?? []Precedent:
src/new-session/workspace/controller.ts(worktreesLoaded). -
When the source can change (a drilled project, a selected session), include its key in the fetched value and use the result only when the key matches. Otherwise
latestshows the previous key's data while the next loads. -
A
<Suspense>boundary only chooses what blanks; it does not prevent the suspension. Without a local boundary, the nearest one is often a whole dialog or route. -
Suspend only on purpose, on first load, with a comment that says why.
Typography
- Use
--line-height-compact(16px) for13pxcompact UI text and--line-height-base(20px) for body text. - Do not use
leading-none,line-height: 1, or a13pxline 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-plugins 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 GUI plugin SDK |
- Never write a literal family (
Inter,"IBM Plex Mono",monospace,Menlo,system-ui) in production CSS, classes, inline styles, canvasfontstrings or widget options. A literal ignores the user's setting. - Never add an
@font-face, font file, or font package outsidepackages/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, weight440,-0.04pxletter spacing. Do not invent another size for the same content. - Prefer weight tokens (
font-medium,var(--font-weight-medium)) over literal weights. Mono at600or more renders IBM Plex Mono Bold, so reserve it for real emphasis. - Do not read font settings directly.
src/settings/model.tsxwrites them to the CSS variables above, and the plugin host passes the terminal font throughappearance.font.
Loading Indicators
This section is the single source for loading indicators across app, ui, session-ui, gui-plugins and desktop.
- The dot-matrix
Spinner(@opencode/ui/spinner, andSessionProgressIndicatorV2andActivityRing, which render it) means the AI is working: a running session, turn, subagent or tool call. Use it only for those states. - Every other loading state uses
Loader(@opencode/ui/loader): page, pane and file loads, browser reload, search, connecting, authenticating, sending, installing. Use a purpose-built indicator only when the state has one, such as the titlebar update ring. - Choose the indicator at each call site. Never restyle a shared indicator (
Loader,ActivityRing,Spinner) to look like another one; that silently changes every caller.
Floating surfaces over native pages
A native page view, such as the browser pane's, paints above every DOM element, so src/runtime/plugin/embeds.tsx hides it while floating app UI overlaps it.
- Mark the painted box of a floating surface with
data-floating-overlayfor its whole visible lifetime, including its exit animation. Mark the surface, not a full-window transparent portal wrapper. - Popper positioners,
aria-modaldialogs, open<dialog>elements and open popovers count without the marker. Tooltips never cover the page. - A positioned surface that takes pointer input and is portalled to
document.bodyafter the app root also counts without the marker. It is a fallback: mark new surfaces.
Scrolling
This section is the single source for scroll containers across app, ui, session-ui, gui-plugins and desktop.
- Pages, panels and documents scroll with a plain element:
overflow-y-auto(oroverflow-x-auto,overflow-auto) plusmin-h-0or a max height.packages/ui/src/styles/scrollbar.cssgives every native scrollbar the shared thumb. Do not addScrollViewto fix how a scrollbar looks. - Menus, popovers, dropdowns and the result lists in pickers and dialogs scroll with
MenuScroll(@opencode/ui/menu-scroll). A native scrollbar there takes 8px, more than the rows' 4-6px inset, so the end inset grows whenever the list overflows.MenuScrollhides the native scrollbar on pointer devices and draws the shared thumb over the rows; touch devices and high-contrast modes keep the native one.- Put the list's padding on the viewport (
viewportClass), not on the menu surface, so rows scroll to the edge under the thumb. - Use
viewportReffor scroll-into-view and keyboard reveal. Style a grid of rows through[data-slot="menu-scroll-content"], the element that holds them.
- Put the list's padding on the viewport (
- Mark each scroll container with
data-scrollable. Nested-scroll handling (the timeline, Home,createAutoScroll) uses it to let the inner container scroll first.MenuScrollmarks its viewport itself. - Use one element when it both sizes and scrolls. Add an outer wrapper only for something that must stay put while the content scrolls, such as
::beforeand::afteredge fades: the wrapper isrelative flex flex-col min-h-0and owns the fades, and the inner element ismin-h-0 flex-1 overflow-y-auto. - A native scrollbar takes 8px from layout while the content overflows. Where text would visibly rewrap at that moment (the composer, text fields), add
scrollbar-gutter: stableand subtractvar(--scrollbar-size, 0px)from the end padding. Do not do this in a menu or list; useMenuScroll. - A ref runs before the element's children render and before it is in the document. Restore a scroll position from
onMountor a frame later, not in the ref. ScrollView(@opencode/ui/scroll-view) is only for the session timeline and Home, which draw the thumb in an external track (thumbContainer) and, in the timeline, correct it for virtualized rows. Use it again only for one of those needs, and not for menus.- Never set
scrollbar-width: thin,scrollbar-width: autoorscrollbar-color. Chromium then ignores the shared style and draws the native Windows scrollbar. Hide a scrollbar only withno-scrollbarorscrollbar-width: none.
Timeline stability
This section is the single source for what may move or restyle the session timeline. It applies to every component and stylesheet that renders in or around the timeline, across app, ui, session-ui and gui-plugins. Each rule comes from a regression that shipped.
Scroll position
- The timeline moves when the reader scrolls it or asks to go somewhere (a jump, a search hit, a link). Nothing else scrolls it: not focus, not an update, not a row that mounts.
element.focus()scrolls its element into view. When code moves focus inside a scroll container, pass{ preventScroll: true }unless the reader must see that control next: keyboard navigation to it, or the item that takes the place of a removed one.- A virtualized row unmounts when it scrolls out of range, and a control that holds focus goes with it. Chromium then leaves focus on
<body>, and the focus rescue (packages/ui/src/context/focus-rescue.tsx) handles the row as a deleted item: it focuses a control in another row, and the browser scrolls the timeline there. After a click on one tool header, the timeline jumped 13 times in 8 wheel bursts. - A virtualized list therefore gives focus to its own viewport, without scrolling, before a row that holds focus unmounts.
VirtualRow'sonCleanupinsrc/session/timeline/virtualizer.tsxdoes this. Keep it when you change how rows mount, and do the same in a new virtualized list. - Keeper: "a focused control that scrolls out of the mounted rows leaves the timeline where it was scrolled" in
e2e/regression/session-timeline-accessibility.spec.ts. - To check by hand: click a tool header, a link and a notice in the timeline, then scroll up and down with the wheel. The timeline must follow the wheel.
Scroll writes
- A native scroll write (
scrollTo,scrollTop =) forces a layout when anything is dirty. TanStack corrects the scroll position once for each row it resizes above the view, so a batch of measured rows forced one layout for each row. scrollToFninsrc/session/timeline/virtualizer.tsxholds the corrections made while a batch of sizes is applied and writes the last one once. Keep scroll writes for size changes on that path, and callflushHeldScrollbefore code inside the batch reads the native offset.- Keeper: "corrects the scroll position once for each batch of rows an older page measures" in
e2e/regression/timeline-history.spec.ts.
Following the end
- The follow state (
src/session/timeline/machine.ts) decides whether the timeline holds the newest content at the bottom. It stops when the reader scrolls up, and it resumes when the reader scrolls to the end. - A scroll range that shrinks moves the offset without the reader: the browser clamps the offset to the new end. For a view that navigation or a selection sent somewhere (the
detachevent), that is not a return to the end. A cold link to a message detached the timeline, the rows' real sizes then shortened the range, and the clamp counted as an arrival: the session opened on its latest message and dropped the link's hash. - A reader who scrolled away and whom a clamp brings to the end follows again. At the end a wheel toward it scrolls nothing, so that reader would have no other way back.
- Apart from that clamp, a reader who left the end is back at it only by a scroll of the reader's own (
event.reader). A scroll of the timeline's own that ends at the end is not the reader's return. Its scroll event can arrive after the wheel that left the end: the timeline then followed again for a frame and cleared the route's hash. The page that PageUp and PageDown in the composer scroll is the timeline's write for the reader's key, sosetPagecounts it as the reader's. - The timeline learns that the reader scrolled from the scroll, not from the input device.
readScrollinsrc/session/timeline/virtualizer.tsxcounts each movement of the offset as the reader's, unless a scroll write of the timeline made it or the browser clamped it. Middle-click autoscroll, Ctrl+Home, PageUp on a control in a row and the scrollbar have no handler. Each one left the timeline following, and the next streamed line pulled the reader back to the end. - Put each scroll write that the timeline makes between
readScrollandsyncScroll. A write outside them counts as the reader's scroll: upward, it stops following. - A view that is not shown leaves the document and comes back at offset 0. That is not the reader scrolling to the top: the ledger starts over at the first read after the view returns (
seen.lost). - A component in a row that scrolls the timeline to hold a control in place makes that write through
holdScroll(@opencode/ui/hold-scroll), and in no other way. The virtualizer owns the scroll element (ownScroll) and runs the write betweenreadScrollandsyncScroll, so it is one of the timeline's own. Seechangeinpackages/session-ui/src/tools/tool-renderer.tsxandflipinpackages/session-ui/src/message/message-content.tsx. Folding a long prompt at the end scrolled up to hold its toggle, straight on the scroll element: the timeline took that for the reader leaving, and the reply that streamed next stayed out of view. A scroll that takes the reader somewhere, such as a link in a reply, is the reader's and leaves the end: it does not go throughholdScroll. - A wheel or scroll key toward the end that lands within
REJOIN_DISTANCEof it follows again: a reply that streams moves the end away while the scroll is on its way there. Navigation that lands there does not follow, because that would scroll its target away. The same landing gives the same result wherever the input went. The session header and the jump button lie over the timeline, and a wheel over them has no event on the scroll element, so the wheel is heard on the whole view (handleViewWheel): a wheel over the header left the view 40px short of a reply that went on streaming. PageDown in the composer lands the same way, because its page is the reader's movement. A wheel with no vertical distance, such as a sideways one, moves nothing in the timeline and is not the reader scrolling. - A wheel over a scroller inside a row, such as a shell's output, scrolls that scroller while it has room in the wheel's direction, and the timeline does not move. That is not the reader scrolling the timeline, so
handleViewWheelsends no intent for it. The timeline took every upward wheel for the reader leaving the end: a wheel up inside a shell's output stopped it from following, and the reply that streamed next stayed out of view. At the scroller's limit the browser passes the wheel on to the timeline, but not when the wheel gesture began while the scroller had room: the rest of that gesture stays with the scroller and scrolls nothing. So a wheel at the limit does not stop following by itself. The scroll that it makes does (event.reader). - The session header, the jump button, the scrollbar's thumb and the desktop window's drag area lie over the timeline, outside its scroll element. For a wheel over them the browser goes by the layers it composites, not by the element under the pointer. It scrolled the timeline while the rows were text. Once a row held a scroller of its own, such as a shell's output or a code block, it scrolled nothing: the wheel did nothing over the header, the button or the scrollbar, and an upward one still stopped the timeline from following. So the timeline takes that wheel from the browser (
preventDefault) and scrolls by the wheel's distance itself, once:handleOverWheelinsrc/session/timeline/virtualizer.tsx, and the thumb's own listener inpackages/ui/src/components/scroll-view.tsx. The scroll is the reader's, so it is made outsidereadScrollandsyncScroll. A new element that lies over the timeline gets the same listener. - Taking a wheel needs a listener that is not passive, and the browser waits for the page before it scrolls for a wheel anywhere inside the box of an element with such a listener, also where that element takes no pointer input. Put the listener on the small elements that lie over the timeline only. On the view, or on an element that covers the rows such as the scrollbar's track, it makes every wheel over the rows wait for the main thread.
- The timeline knows a scroller in a row by its
data-scrollablemark (see Scrolling). Mark every element in a row that can scroll up and down. Without the mark, a wheel, a touch drag and the scroll keys inside it count as the reader scrolling the timeline. The input and the error of a Code Mode call and the error cards had no mark. - A touch drag that has gone further sideways than up or down since the finger went down, across a code block or a table, scrolls that block sideways while the finger drifts a few pixels down. That drift is not the reader dragging the timeline, so
handleListTouchMovesends no drag for it. The timeline took it for one and stopped following: a reply that streamed next ended 1,067px out of view. A drag that does move the timeline shows as its scroll under the held finger. - The glide to the latest message is the timeline's own animation (
glideinsrc/session/timeline/virtualizer.tsx), not the browser's smooth scroll. The browser's glide heads for where the end was, and it starts again from rest at each new target. A reply that streams cut it short: the next row measurement jumped the rest of the way in one frame. While the timeline glides (isGliding), nothing else may jump the view to the end, and the reader's scroll away ends the glide. A scroll that would jump it holds the view at the glide's distance from the end instead (placeGlide), so history that loads above the view does not show. - TanStack's scroll to the end aims at the last row by its index and keeps correcting for up to 5 s. An older page that loads meanwhile gives that index to a row in the middle of the history. With the browser's smooth scroll, Jump to latest pressed while a page loaded ended thousands of pixels from the end. Do not start a smooth TanStack scroll to the end.
- The reader's input also ends TanStack's scroll to a target (
stopScroll), which TanStack writes again when a measurement moves the target. A scroll to the end keeps running only while the timeline still follows the end. - Keepers: "stays where navigation sent the view when a shrinking scroll range clamps it to the end" in
src/session/timeline/machine.test.ts; "the glide to the latest message outlasts a streamed line", "the glide to the latest message yields to the reader's wheel", "keeps a reader who left the end with … in place while the reply streams", "goes on following the reply after a group collapses from its stuck header", "goes on following the reply after a long prompt folds from its toggle", "goes on following the reply after a wheel up … a shell's output", "leaves the end with a wheel up at the top of a shell's output", "follows again when … lands within reach of the end", "a wheel over … scrolls the timeline as far as one over the rows" and "the browser scrolls for a wheel over the rows without waiting for the page" ine2e/regression/timeline-stream.spec.ts; "Jump to latest glides on while an older page loads above the view" ine2e/regression/timeline-history.spec.ts; "a sideways drag across a code block goes on following streamed output" ine2e/regression/mobile-timeline-scroll.spec.ts. - To check by hand: in a session that streams, leave the end with Ctrl+Home, the scrollbar, middle-click autoscroll, and PageUp after a click on a tool header. The timeline must stay where each one put it, and must follow again after End. Then wheel up and down inside a shell's output: the timeline must go on following. At the top of the output, after a pause, a wheel up must scroll the timeline and stop it following. Then rest the pointer on the session header, on Jump to latest and on the scrollbar's thumb in turn, and turn the wheel: the timeline must scroll as far as it does with the pointer over a row.
:has() selectors
- Chromium rechecks an element's
:has()when focus moves, an attribute changes, or an element is added or removed near it. In and around the timeline, that happens many times a second during a scroll. - When the selector ends at the
:has()element (x:has(…),x:has(…)::after), a recheck restyles that element only. - When the selector continues (
x:has(…) y,x:has(…) ~ y), a recheck restyles nearly every element insidex. Other rules decide how many: once any rule in the app ends in[data-slot=…]after a:has(), a recheck restyles every element insidexthat has adata-slotattribute, whatever its value. Such rules exist, and almost every element has adata-slot. - On an element that contains the timeline, a list, a panel or a page, end the selector at the
:has()element. To style another element, set adata-attribute on that element from code. - On a small component (a row, a tab, a card, a menu), the selector may continue after
:has(). A recheck costs the size of that component. - Never select on
styleinside:has(). Every inline style write then rechecks the:has()of the element's ancestors, and the virtualizer writes inline styles while the reader scrolls. Set adata-attribute when the element is built, and select on that. - To check: record a Chrome trace of the
devtools.timelinecategory while you scroll through history that has not been visited, click in the timeline and press a scroll key. ReadelementCounton eachUpdateLayoutTreeevent; DevTools shows it as Recalculate Style, Elements Affected. A pass that affects about as many elements as the timeline contains is this regression.
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.
- Feature work adds English source strings only. Leave non-English keys absent so the runtime English fallback applies; translations land separately after language review.
- Render count-sensitive copy only through
language.plural(baseKey, count, params). Never select or pass.zero,.one,.two,.few,.many, or.othervariants tolanguage.t(...). - When migrating existing copy to i18n, preserve the English text byte-for-byte unless the task explicitly requests a copy change.
- NEVER change existing English text or English keys to facilitate translation. English is intentional, designer-written source copy; adapt locale-specific translations and i18n mechanics around it.
- Keep locale complexity behind the shared typed i18n APIs. Feature and component code should use
language.t(...)for ordinary copy andlanguage.plural(baseKey, count, params)for count-sensitive copy. It must not inspect the locale, callIntl.PluralRules, construct or select plural-category keys such as.oneor.other, or branch on locale-specific grammar. - Do not compose translated count phrases or sentence fragments in feature components. Add a focused language-context operation that owns plural selection and composition when one UI concept needs coordinated keys.
- Prefer complete translated phrases. Do not concatenate grammatical fragments or make call sites assemble sentences. Keep placeholders to irreducible dynamic values such as names, paths, and counts.
- If a translation cannot be expressed by the current API, deepen the shared language/UI i18n module so one typed call owns locale selection, plural resolution, fallback, and interpolation. Do not leak that machinery into product code.
- Do not translate from model knowledge alone. Verify terminology and grammar with Unicode CLDR locale/plural data, Microsoft Localization Style Guides and terminology, Apple localization/style guidance and localized platform UI, Mozilla localization style guides, Mozilla Pontoon, and the Firefox localization corpus at
github.com/mozilla-l10n/firefox-l10n. - For developer-facing terminology, prefer the words already used by the target language's developer community over literal dictionary translations. Cross-check maintained localized developer products such as Firefox, KDE, and VS Code; use at least two independent corpora when they are available. If established practice keeps an English loanword or acronym, keep it rather than inventing a translation.
- Translate complete UI phrases in context. A glossary hit is evidence, not permission to translate word-by-word. Check terse labels such as session, prompt, agent, model, fork, shell, terminal, workspace, and worktree in the same grammatical role before choosing a term.
- Before a locale is ready, audit recurring concepts for one consistent translation and review every value that still equals English. Classify retained English as a product name, provider/tool name, URL, code token, keyboard legend, acronym, asset name, or established borrowing; translate unexplained leftovers.
- In translation review notes, name the corpora used and call out uncertain or region-specific terminology so native speakers can focus review where it matters.
- Also use the relevant language authority or official dictionary for the locale (for example RAE/Fundéu, FranceTerme, Duden, TDK, Kotus/Kielitoimiston sanakirja, Språkrådet/Bokmålsordboka, Rada Języka Polskiego/PWN, the Russian and Arabic language academies, the Ukrainian Orthography, Taiwan MOE dictionaries, or the Royal Society of Thailand). Treat the English dictionary as the semantic source of truth and preserve placeholders, code identifiers, product names, and keyboard labels.
Tests
A test must pay for its upkeep. Before adding one, answer three questions: which observable contract does it protect, which credible regression makes it fail, and why does no existing test already catch that regression. If any answer is missing, do not add the test.
- One contract, one owner. Test each behavior once, at the strongest boundary that observes it: the area's e2e keeper suite, or the owning module's unit test. Extend an existing table or keeper case before creating a file.
- Do not unit-test what an e2e keeper already proves, what a dependency does (for example
@pierre/trees), config that passes values through, or source text (import or string greps). Source text is fair game only when that text is the contract, such as a persisted key. - Never add production seams for tests: no test-only exports, parameters such as
now,delayorbudget, flags, globals, ordata-*attributes. Control time withsetSystemTimefrombun:testand drive the real entry point. - A test must be able to fail. Do not assert values the code under test produced, mock the behavior you assert, use soft assertions for the order the test guards, or leave
rejects/resolvesun-awaited. A regression test must fail on the code before the fix. - Do not repeat a case per theme, text direction, viewport or channel. Use one table, and only when the behavior differs.
- When you delete or move coverage, name the test that still proves the contract. When you move a contract, mutate its owner once and confirm the new test fails.
- A contract proven by a
packages/session-ui/component-teststest does not also get an app e2e copy.
Tool Calling
- ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.
Browser Automation
Use agent-browser for web automation. Run agent-browser --help for all commands.
Core workflow:
agent-browser open <url>- Navigate to pageagent-browser snapshot -i- Get interactive elements with refs (@e1, @e2)agent-browser click @e1/fill @e2 "text"- Interact using refs- Re-snapshot after page changes