Skip to content

Latest commit

 

History

History
112 lines (96 loc) · 34.2 KB

AGENTS.md

File metadata and controls

112 lines (96 loc) · 34.2 KB

Working in Screenwide

Screenwide is a Tauri desktop app for macOS and Windows. The frontend uses React, TypeScript, Tailwind CSS, React Aria, and Motion. Native capture, preview, and output processing live in Rust and platform-specific code.

Git

  • Preserve unrelated changes. Do not commit, stage, or discard work unless asked.
  • Work is committed straight to main, without branches or pull requests. A commit's subject is type(scope): summary (Conventional Commits, lowercase, imperative, no trailing period). Its only body is an issue line when the work has an issue: Closes #N closes it once the commit reaches main, Refs #N links without closing. scripts/release-notes.mjs drafts each release's notes from the feat and fix subjects and their Closes lines.
  • A version is the year and month its release ships in, then which release of that month it is, from zero: 26.11.0, 26.11.1, 26.12.0; a prerelease adds a suffix (26.12.0-rc.1). package.json, src-tauri/Cargo.toml and src-tauri/tauri.conf.json carry the same one, and pnpm release:check-version checks that they match and follow the scheme. RELEASING.md covers versions and releases.
  • Issues are bugs, and work thought through to high-level acceptance criteria, labelled by type (bug, feature, polish, chore), area (area: editor, …) and, when it happens on one platform only, platform (platform: windows). Ideas, the maintainer's own included, and questions start in Discussions; an idea becomes an issue once it has acceptance criteria.
  • When asked to record what someone found, file each bug as an issue (what happened, steps, what was expected; acceptance criteria where the fix is known) and each change that is not yet decided as an Ideas discussion, each with its area label. CONTRIBUTING.md describes the same process for people.

Structure and naming

  • src/primitives: single-purpose primitives built on React Aria. They import nothing from composites or features. Story group: Primitives.
  • src/composites: compositions of primitives reused by more than one feature. They import nothing from features. Story group: Composites.
  • src/features: UI and behaviour owned by one feature. May import from primitives and composites. Story group: Features.
  • A layer's folder and its story group share one name, so a story is found where its source lives.
  • Every feature is a folder in src/features, and its stories sit in a sidebar folder of the same name. They are titled Features/<Feature>/<Area>/<Name>: <Feature> is the feature's folder, <Area> the first folder inside it when the story's file sits in one, and <Name> the component. No story sits directly under Features. A window with panes, such as Settings, takes each pane as an area, its states as the stories in it (Features/Settings/General/Update Available). An area that holds one component of the same name is left out (Features/Settings/Shortcuts/Hotkey Field), and a name never repeats its area (Timeline/Tracks, not Timeline/Timeline).
  • src/features/editor, src-tauri/src/editor, and the annotations, auto_zoom, compositor, cursor_effects, export, images, keyboard_effects, placement, scenes, text, timeline_edit and workspace crates in src-tauri/crates: the Editor feature. text is the text engine: type set on each platform, the style vocabulary and templates, and captions as one of its users. workspace is the editor workspace every platform shares: the scene its layers are drawn in and the editing engine (workspace::editing) that turns pointer and typing input into gestures, annotations and chrome; a platform surface only provides its Host.
  • src-tauri/crates: the Rust workspace's crates, each a layer the app crate (src-tauri/src) and the crates above it depend on, never the reverse. New Rust subsystems start as their own crate there, not as a module of the app crate, which wires the crates together: Tauri setup, commands and windows. Test a crate on its own with cargo test -p <crate>.
  • The island is one window that shows one island at a time. Each part that wants it holds an IslandClaim (src-tauri/src/app_windows/island/claims.rs): the window comes out, moves and tucks away by the claims alone, and the page shows the island of the claim on top. A new island adds its claim in the order it stands over the others, maps it to what the page draws in src/features/island/island-kinds.ts (which does not compile until every claim is mapped), and, when its state is one value, holds the island with an IslandSlot, which sends that value and lets the claim go with it. Nothing else shows or hides the island's window.
  • Shaders are WGSL, and the build compiles every one ahead of time: DXIL on Windows, Metal libraries on macOS. A shader's bind groups and vertex buffers are described once, in its crate's shader_layouts.rs (screenwide-shader-layout); build.rs precompiles it against that layout (screenwide_wgsl::precompile), which also checks the layout against what the WGSL declares, and the renderer draws with it through screenwide_gpu::Shader, which builds the pipeline from the same layout. Clippy rejects create_shader_module anywhere else, so nothing compiles WGSL at runtime except where the build compiled nothing.
  • A renderer draws on the device screenwide_gpu::shared opens for its Workload. Light (overlays, stills, references, the settings previews, recording) opens on the integrated graphics processor while it draws a screen, so a laptop's discrete one can switch off; Heavy (the editors, their playback, export) opens on the fastest. Each closes after a minute unused, and both share one device where they would land on the same processor, as on every Mac. A texture belongs to the device it was made on, so work that hands textures on stays on one workload; a picture drawn once and read back uses shared_for_readback, which takes whichever device is already open. Recording takes the light processor only where its hardware encoder accepts the recording (recording_devices).
  • src/styles: the design tokens. theme.css holds the five type roles (title, heading, body, label, caption), two heights (control-height for controls, part-height for small parts such as badges and keys), the size of a small selection mark (mark, for checkboxes and radios), icon sizes (icon-sm, icon, icon-lg; icon-xs is a utility in utilities.css, since it sets a thinner stroke with its size), semantic spacing (inline, separate, group, inset, inset-sm, traffic-lights) and four radii (sm for small marks such as swatches and checkboxes, part for small parts, control, panel); colors.css the colour roles and materials per appearance; utilities.css the utilities over them. src/index.css imports them and holds the fonts and global styles.
  • src/lib/motion.ts: shared motion timings and easing.
  • src/storybook/feature-story-stage.tsx: featureStage, the decorator that frames a feature story at its production size.
  • src/site: the public website, one short page built from primitives, composites and features (pnpm site:dev, pnpm site:build). It shows the app at work in short recordings of the real app (src/site/public/recordings, each an .mp4 with a .jpg poster), not imitations, and the real recording island as its one interactive part. The free tools and the paid Tools tier share one grid, with a card saying what each costs. Its copy is in locales/en-US/site.ftl; its stylesheet, site.css, brings the app's in and adds only what a page read from a distance needs: the hero, lede and tile sizes.
  • src-tauri/crates/licensing: who may use the paid tools, listed in its Tool: a 14-day trial of each from its first use, then a licence key per tool, proved by a record the licence server signs and the app checks offline, and checked again every few weeks. It holds no network, disk or clock code; the app sends the request, saves the state and passes the time in. Like the tools, it is under the Elastic License 2.0: the gate is theirs.
  • workers/: Cloudflare Workers, each a pnpm workspace package with its own Wrangler config, under the Elastic License 2.0 where it serves the paid tools. workers/license is the licence server: it checks a key with Payhip against every tool's product and signs the record crates/licensing verifies. Its secrets are set with wrangler secret put, never written into the repository; pnpm --filter screenwide-license-worker typecheck writes its types and checks them.
  • Editor is the editing window and its workspace, in internal names, routes, events, and stories. Export means producing or saving finished files.
  • Annotation is the only word for a drawn arrow or counter, in identifiers, comments, tests, and user-visible copy. Do not reintroduce "mark" as a synonym. Annotate stays the verb form for the live desktop overlay feature and its settings, routes, and commands. mark in this repository means the brand mark or a timeline tick marker, and nothing else.
  • Native preview is owned by the native compositor. Browser stories cannot reproduce it; do not add a substitute rendering path just for stories.

UI conventions

  • Reuse primitives and composites. Inspect their APIs before adding custom controls, sizes, padding, typography, or interaction behaviour.
  • Join class names with cn from src/lib/styling.ts, never clsx directly: cn runs clsx and then resolves conflicting Tailwind classes, so a caller's className overrides the component's own. ESLint rejects clsx imports anywhere else.
  • Use the tokens for type, colour, heights, icon sizes, spacing and radii. Spacing tokens are named by what they separate: gap-inline between things read as one (an icon and its label), gap-separate between neighbours that stand on their own (a message and its action, buttons side by side, rows), gap-group between titled groups of rows (a settings pane's sections), p-inset between a box's edge and its content, and p-inset-sm for the tight inset: inside a small part (a badge, a key), round a list in its panel and inside its items. A role with no token yet gets one when it appears, rather than a raw step from Tailwind's scale. A raw colour must not replace a token. Text and fills are translucent so the native window material shows through; keep them so. A value one feature needs, such as a column's width, stays in that feature rather than becoming a token. Use stories under Features as reference for current usage.
  • One look on every platform. What the OS dictates (traffic lights versus caption buttons, ⌘ versus Ctrl) keys off data-platform where it is used; the windows: variants left in components go as each is redone.
  • Colour is monochrome, and each role is chosen by meaning. primary fills the primary action, the one control a window exists for, anything checked or on (a switch, a checked box, a held toggle, the selected clip), the chosen segment of a segmented control, progress, and the playhead, with on-primary on it: a warm black, a warm near-white in dark. State that should be read at a glance takes primary. focus is that ink at a third of its strength, ringing the focused control. selected is a quieter choice made in place, where the item itself carries the meaning: a grey surface with the text unchanged, such as a chosen style tile or a selected range. emphasis is orange, the one colour beside the monochrome palette, kept for the selection on the picture: a mark, never text. Text Recognition's marks (the area read, the lines found, the selection and its QR codes) take the blue the Ruler draws its guides in, info. Neutrals and the status colours are the app's own, drawn in OKLCH beside the orange.
  • The material follows what is drawn. A control you press, and the state of a control, is raised: control-raised for a neutral one (a button, a Select, a PathField or HotkeyField), primary-raised over bg-primary for the primary action and anything on, checked or chosen (a toggle that is on, a checked box, a switch that is on, the chosen segment, the selected SidebarNav row). A mark or measure drawn on content or a track is flat primary, without the bevel: the playhead, selected timeline clips and lanes, spring and cut handles, slider and progress fills, the minimap's marks, the storage strip, the Glide destination tile. Grey selected stays the quieter choice made in place (tiles, the export look cards), and the field material (control-sunken) stays for what you type into and for tracks. Islands draw their ghost controls with no fill of their own: the island's fill (IslandFill) grows in under the pointer, and a ghost control that is on or chosen there takes that fill, deepened, rather than the raised material. The island's primary action, a choice that stands as a card (the recording modes) and a toggle laid over a picture, where the fill would not read (the camera's Flip), stay raised primary.
  • Name a component's colour prop color. Use status names (error, success) only when the colour means that status. Colours that only tell things apart, such as rotation axes, take hue names (red, green, blue) drawn with the status colours, so the app keeps one palette.
  • Use WindowHeader for window titles. It is one look on every platform: macOS leaves room for the traffic lights, Windows ends in the caption buttons. A window's commands go in its actions area; version text belongs there too and uses the mono font. Tools do not go in the title bar, except the Editor's modes, a recording's Tracks and the Library, centred between the project's name and the actions (center), each its glyph alone with its name in a tooltip; the Editor's tools for drawing on the picture stay in its left column.
  • Window layout owns the inset and header/content gap. Use flex/grid gaps for sibling separation rather than adding spacing inside the header.
  • Use ScrollArea for scrolling regions. Where there is more to scroll it fades the content at that edge, a mask rather than a painted band, so it reads on any background including a native panel's material; edgeEffect="none" turns that off. A settings pane groups its rows in boxes (SettingsGroup: the fill a notice sits in, panel radius), each named by a heading above it, with no dividers between rows. Every shortcut lives in the Shortcuts pane, grouped by feature.
  • Copy takes its type and colour from Text's role (title, heading, body, label, caption), not from classes written by hand, so a role reads the same everywhere. caption is a note about something: a row's description, a group's note, a footnote. Text inside a control (a switch's or checkbox's label, a select's value, a list item, a pill, a badge, a keycap, a field's value) is styled by the control, which changes it with its states, as a button styles its label.
  • Use ControlRow for title/control rows, in Settings and editor tool panels alike. Descriptions are optional: omit them when the label is sufficient, otherwise use plain language and at most ten words in Settings. Avoid repeating the label.
  • Editor tool panels and islands order their rows in fixed groups, skipping any a tool lacks: (1) mode: the tool's on/off switch, a choice that changes which rows appear (Show shortcuts, Redaction and its Style, Fit), or an image's picture rows (Image, Frame, Playback); (2) size: Dimensions, Size or Width, Zoom, Block size or Strength; (3) shape: Radius, Inset; (4) placement: Position, then Angle or Rotation; (5) options: Head, Alignment, Hand-drawn, Shadow, Follow face, other switches; (6) animation: Animate, Animation, Click animation; (7) colour: the colour grid, Background, Appearance; (8) footnotes; (9) one-shot actions (Reverse, Recenter, Reset, Restore, Trim) at the end of their own row, each as wide as its label. An image's Flip is the exception: it sits beside Replace in the Image row, since a button acts on the row it sits in. Recording-only and conditional rows sit late so their absence never reorders the rows above.
  • The Camera island reads: Inset (a camera-only recording), Radius and Rotation (a camera-only recording), then one line of Enhance, Shadow and Follow face, then Remove background on a line of its own with the rows it brings (Background, Objects) under it. Its row ends with whether the camera is drawn into the video (CameraInVideoToggle), the Export island's choice too, while the recording keeps both its screen and its camera; saved as its own file, the camera is not in the picture, so the island holds only that toggle and a note saying so.
  • Islands are built from src/primitives/island: a row (IslandRow, or the editor island's own), an optional line under it in the row's black (below), and a section hanging beneath; what each holds comes, goes and changes over with IslandParts. Shared primitives and composites draw themselves in the island skin; do not restyle them per island. Say what is in hand, or what is going on, at the row's start with IslandRowTitle; name a control in a section with ControlRow; a quiet icon button takes text-fg-secondary enabled:hover:text-fg; a cut, delete or discard asks twice with ConfirmActionButton (variant="ghost" on the row). Islands show no tooltips: a control whose glyph stands for its words carries them as its accessible name alone.
  • Island spacing, measured from the black's edge, keeps two lines: what is filled at the section's edge, and what is read on a text column inside it. The row's and a line's controls sit 8 px in; a section's controls (circles, pills, switches, fields, lists, tiles, buttons, meters, a progress bar) sit flush with the section's 10 px inset. Everything read, words and glyphs that stand on no fill of their own, sits on one text column 16 px in, which is px-inset-sm inside a section and px-inset in a line: a row title's glyph, a ControlRow's name, an IslandWorkLine's words, hints, notes, a transcript, and a labelled toggle's glyph and words, its pill padded px-inset-sm so its edge stays on the 10 px line while it draws no fill. A section that is only a list of named switches, such as Tracks, has no other fill holding the 10 px line, so its switches come in to the text column too (pe-inset-sm) and the list sits evenly between the island's sides. Neighbouring controls stand gap-separate apart, rows in a section gap-inline. A hint is a caption in text-fg-secondary, with keys as Keyboard keycaps. An Alert on an island speaks as a hint does, a caption in text-fg-secondary with a small icon: alone it is centred under the parts it is about, its lines starting at the icon rather than each centred, and with an action it starts on the text column, the action at the line's end. A choice between looks (sides, sizes, corners) is drawn as glyphs on a line (AnnotationLine), named only for assistive technology. An option on or off in an editor island's section is an OptionToggle showing its glyph and then its name. Each island lays its options out for what it holds rather than by one rule: on the line beside its choices, on a line of their own, or two to a line (AnnotationOptions, its columns flush with the section's start and end). Rows named at their start (Radius, Inset, Rotation) come first and the lines of named toggles after them, before the footnotes and actions, so the toggles do not split the named rows. A choice left alone between named options is named at its row's start (AnnotationChoiceRow), as the Camera and Image islands' Radius and the camera's Background are, rather than floating centred between them. Toggles among the glyphs at the end of a row, in a picker's rows, and on the compact islands keep their glyph alone (isLabelHidden). A typed figure keeps its ControlRow name, since a bare number does not say what it measures. A figure shows its unit. Each island is as wide as its own content needs; islands do not share a width. Parts that wrap or fill (tiles, wrapping text) take the width the island's controls set (w-0 min-w-full) rather than setting it, and a part with no width of its own (a waveform, a transcript, scrolling tiles) takes one its island sets, kept in that island's folder. A field whose figures are typed keeps room for them, so typing does not resize the island. Every island story offers an isShown control.
  • An island's shape follows what it is. The editor island is an inspector and is one block: everything under its row spans the row (sectionSpansRow), a note such as a hint, an alert or a transcript's status sits at the block's foot, and only a column of choices too many to hold inline opens beside it (IslandAside, as text's template and font pickers do). A hint for one row's gesture, such as how to pick the camera's objects, sits under that row instead, while the gesture is under way. A pinned annotation's tracking status (AnnotationPinNote) answers the pin toggle in the island's row, so it comes first in the section, its answers at its end; it stays on one line and keeps the room of its widest form while the annotation is pinned, so the island does not change width as the playhead moves. The compact islands (recording, annotate, ruler, text recognition) hang each part under the part of the row it belongs to, at its own width. Parts that come and go anywhere in an island (the row, a line, a section, a line in a section) use IslandParts; a row or line that changes into another while the island stays out swaps with IslandSwap.
  • Parts several islands need are shared in src/features/editor/island: a tool's missing model is IslandModelLine (its name, the model's size and Download, then the bar), a tool at work IslandWorkLine, a crop's shape CropAspectChoice, following the face FollowFaceToggle, a scene's own settings SceneOnlyNote. A failure is an error Alert, not a grey note. An on/off option is an OptionToggle whose glyph draws both states, or an IconToggleButton with one glyph, which the island fills while on; never a single glyph handed to OptionToggle, which would show no state. An IconToggleButton given a label shows it after its glyph, as a pill. A reset names what it puts back where more than one thing could be meant (Reset crop).
  • Use switches for settings that take effect immediately. Use checkboxes for selection or checklist semantics, such as release-note task lists.
  • Use Keyboard and Shortcut for shortcut display, HotkeyField (src/features/settings/shortcuts/hotkey-field) for capture, and PathField for file/folder controls. A shortcut is set by pressing its key and picking: the field offers the free combinations as chips, best first, with the modifiers as toggles beside the key; another Screenwide shortcut's combination is marked and never taken, and a reserved one (the system's or most apps', both platforms' lists in reserved-shortcuts.ts) only once chosen and then confirmed, by Return or a second click. A whole chord held is taken at once when free. Ruler and OCR keep bare keys, and Glide's hold keys their own capture.
  • Use Lucide icons at a size token: size-icon-xs for an icon laid over a small part such as a swatch (it brings a thinner stroke with it), size-icon-sm beside caption text, size-icon beside body text and control labels, size-icon-lg for an icon standing alone that needs more presence. A primitive sizes the icons it contains; do not reach into nested primitives with ancestor selectors to resize them. Play and pause are always drawn filled (fill-current), wherever they appear.
  • Text buttons carry no icon, primary or neutral: dialogs, sheets, Settings, forms, footers, and tool panel actions are text only, as on macOS and Windows. A window toolbar (the Editor titlebar) is the exception: there every text command takes a leading icon, and an action always uses the same icon. Icon-only buttons are unaffected. Exempt are icons that belong to a control or its content rather than decorating a label: PathField, HotkeyField, Select, NumberField steppers, and source thumbnails.
  • No ellipsis ("…" or "...") in labels, buttons, menu items, or status and loading text. Truncating content that does not fit, such as a shortened file path, may still use one.
  • Preserve keyboard navigation, accessible names, focus behaviour, and disabled states. Reuse the existing Escape-cancellation handling where applicable.
  • Every primitive tells assistive technology what it is and what value it holds: build it on React Aria's hook or component for that role (useMeter, useSlider, useSwitch). A control with no visible label takes a required aria-label, and its value text is a translated message. Parts that only decorate (ticks, glyphs, a readout beside an announced value) are aria-hidden.
  • Nothing floats in the page. Menus, pop-up lists, colour grids, popovers and tooltips open in native panel windows (src/features/popup-panel for panels, TooltipTrigger from the Tooltip primitive for tooltips), never as in-page overlays such as React Aria's Popover or Tooltip. Every panel and tooltip is drawn in the island's look, wherever it opens, so they read the same across the app: the window has no material and no native shadow, whose rim reads as a border, and the panel host (popup-panel-window.tsx) or the Tooltip primitive paints the island's black with a faint inset ring, in the dark appearance. What draws inside a panel paints no surface of its own: the content has no background, border or shadow, and states such as a hovered item use the translucent fills over the black. A primitive meant for a panel is written that way too, and its stories render it bare; check it in pnpm dev:storybook-native, which shows it in the real panel window. A story's own menus open there too, in the app's menu window; browser Storybook has no native windows, so they do nothing there.
  • Settings uses SidebarNav, expanded, its rows showing their labels. Its panes are General, Recording, Tools, Moments, Models, Shortcuts and Licences; what changes a recording (the island's camera and sound, file size, countdown, frame rate, auto zoom, anti-flicker) lives in Recording, not General. Licences (src/features/settings/licences, under the Elastic License with the gate) lists each paid tool's state, the bundle and the keys held; a paid tool turned away opens Settings on it. A pane's picture is pinned above its rows (src/features/settings/stage), follows the hovered or focused row, and has no caption: the row names itself. A picture shows its whole subject, scaled down into the stage where it does not fit (StageScreen). Pictures are the real thing: the islands themselves on the user's wallpaper, the camera only when access is already granted, and native settings previews (src/features/settings/preview over the settings_preview crate) that draw Ruler, OCR and Annotate and play recording scenes through the export's compositor and the auto_zoom planner; never a CSS imitation.

Translation

  • User-visible text lives in locales/en-US/*.ftl (Fluent). The webviews read it with t from src/i18n/i18n.ts and Rust with screenwide_i18n::t!. Do not write copy into components or native code. Rust error details, logs and text written into exported files stay English; titles and messages a person reads are translated. TRANSLATING.md is the contributor guide.
  • A message id starts with its file's name (project-browser-…) and holds one string: no attributes. Pass ids to t and t! as literals so pnpm i18n:check can find them. The Annotation wording rule applies to ids as well as text.
  • Write whole sentences in the message, with placeholders and variants for counts ($count) and platforms ($platform, from platformArg()). Never join fragments or choose plurals in code.
  • Call t while rendering, not at module scope. Format dates, numbers and lists with React Aria's useDateFormatter, useNumberFormatter and useListFormatter, or with appLocale().formatLocale outside components; never Intl.*(undefined).
  • After adding a language, or adding, renaming or removing an en-US message, or changing its placeholders, run pnpm i18n:generate. It writes src/i18n/messages.ts and the macOS bundle strings in src-tauri/macos-localizations. Tests compare text in en-US with Fluent's direction isolates (U+2068, U+2069) removed.
  • screenwide/no-literal-copy flags literal copy anywhere in src; stories, tests, fixtures and dev previews are exempt in eslint.config.js.
  • Try a language with SCREENWIDE_LOCALE=<tag> for the app, or Storybook's Language toolbar. en-XA is the pseudo-locale: accented, longer English that shows text skipping translation and layouts that break. en-XB is its right-to-left twin, and Storybook's Direction toolbar mirrors any language.
  • Layouts mirror in right-to-left languages. Name sides by start and end: ms-/me-, ps-/pe-, start-/end-, text-start, rounded-s, border-e, and insetInlineStart-style keys in style. screenwide/logical-direction flags left and right. Where something must sit on a physical side, say so with an rtl: or ltr: variant; a sideways translate-x needs its rtl: twin by hand. Directional icons (arrows, chevrons) flip with rtl:-scale-x-100. The timeline, the picture and screen geometry stay left to right: their roots carry dir="ltr", and their files are exempt from the rule in eslint.config.js.
  • Names that come from the system or the user (devices, windows, projects, files, moments) take dir="auto", so an English name in a right-to-left window keeps its own order and is cut short at its own end.

Models

  • A model is usable when the licence on its weights permits it. Go by the licence the authors attach to the weights; do not trace the licences of the datasets they were trained on.
  • Weights with no licence of their own take the licence of the repository that publishes them. Weights published with no licence anywhere are not usable.

Stories and verification

  • Every feature is redesigned on the current primitives, and its stories live under Features.
  • Frame every feature story with the featureStage decorator, so the canvas scrolls instead of squeezing it. A window in src-tauri/tauri.conf.json takes featureStage({ window: "<label>" }), never copied numbers: a resizable window then fills the canvas down to its minimum size. A window sized at runtime, a Rust-built window or a part of one takes featureStage({ width, height }); omit height when the content sets it. Pass a function to pick the size from args. Other decorators go before it in the array, so the stage wraps them. A window's root fills its parent, as WindowShell does by default, never the viewport (h-screen, w-screen, dvh): in a story the viewport is the canvas, not the window.
  • Keep each story focused on one useful state. Avoid explanatory filler and artificial backgrounds unrelated to the feature. Use safe preview callbacks instead of triggering native saves, updates, or other live actions.
  • Give every event prop (onPress, onChange, …) an fn() from storybook/test in meta.args, so the Actions panel logs each event, and leave it out of Controls, where it only offers to replace the function. A story that renders its own grid passes the arg on to every instance, and a render that handles an event itself, such as one keeping Controls in step, still calls the arg.
  • Storybook Docs shows a component's JSDoc. A primitive whose name says what it does gets no component JSDoc; notes for whoever edits it go in // comments. Prop JSDoc gives the unit or meaning in a few words ("Angle in degrees."), or is omitted when the name says it. Stories take no JSDoc: the story's name says what it shows.
  • Stories import Meta and StoryObj as types from @storybook/react-vite and declare meta with satisfies Meta<typeof Component>.
  • A story not framed by featureStage uses layout: "centered", set once in meta; no story switches to padded.
  • Give a color or variant prop an inline-radio control with its default in table.defaultValue, and one story that shows every value side by side, with Controls disabled. Lay it out with StoryGrid and a StoryGridRow per value, from src/storybook/story-grid.tsx; when a second prop changes how the first looks, pass its values as columns. Set the shown value after spreading args (<Button {...args} color={color} />), or the story's args override it. Pass elements to a story's components as JSX children, never inside object props: Storybook's source printer recurses through such objects until the stack overflows.
  • Do not add a story that only changes a value Controls already sets, such as a number or text. Interaction states such as disabled keep their own story, as does an optional part that changes the layout when present, such as a description under a label. A control with a few distinct states (unchecked, checked, indeterminate) shows them side by side in a States story, and its Disabled story repeats that grid disabled.
  • Verify in proportion to the change. Use existing meaningful tests; do not add tests that merely repeat implementation details.
  • For UI changes, inspect the relevant story. Native visual behaviour still needs native verification; lint and type checks do not prove appearance.
  • Report unrelated pre-existing failures separately from failures introduced by the change. Do not quietly fix unrelated code to make checks pass.
  • Respect the source-size checks and SPDX headers. Split responsibilities instead of raising a file's ceiling in scripts/source-size-debt.json. The paid tools (today Ruler, References, Glide and live Annotate) and their licence gate are under the Elastic License 2.0 and everything else under the GPL; ELASTIC_PATHS in scripts/check-spdx.mjs lists their paths, and a file's header names the licence its path takes. A new file that belongs to a paid tool goes under one of those paths, or the path is added to the list. Annotations in the editor are free and stay GPL; only the live Annotate overlay is paid.

Choose commands relevant to the change, run from the repository root; this is not a checklist. Reserve pnpm check for broad changes or required full verification:

  • pnpm exec eslint <changed files>
  • pnpm exec prettier --check <changed files>
  • pnpm exec tsc --noEmit
  • pnpm exec vitest run <relevant tests>
  • pnpm storybook / pnpm dev:storybook-native
  • pnpm build-storybook
  • cargo check --manifest-path src-tauri/Cargo.toml --all-targets
  • pnpm architecture:check / pnpm license:check
  • pnpm classes:check after renaming or removing a token in src/styles
  • pnpm check for the full repository verification pipeline.