@cssints/devtools

A dev overlay inspector for cssints, built on what the dev server knows of every class: an element's classes grouped by the css.* call that made them, the winner per property by the sheet's own rules (layer, specificity, order, the conditions that hold now), and each winner checked against the browser's computed style.

// vite.config.ts of the app; @cssints/devtools in its devDependencies
import cssints from "cssints/vite";
import { defineConfig } from "vite";

export default defineConfig({ plugins: [cssints({ devtools: true })] });

Alt+Shift+C or the cssints button (bottom right) opens it. Hover previews an element, a click picks it; ↑ parent, ↓ first child, ← → siblings; Esc stops picking, then closes. x, or the xray button, turns on the X-ray: the picked element (xray:el), its subtree (xray:tree), or the whole page (xray:page) as boxes, with the border-box size, padding, border, corner radii, a flex/grid gap, the spaces between siblings and a 4 px grid inside the root. Every number is read from the page (getBoundingClientRect, getComputedStyle), so it follows a hover, a scroll or a query; the panel repeats them as text under X-RAY. The four buttons in the panel header (◧ ⬒ ⬓ ◨) dock it left, top, bottom or right (the default); drag the strip on its inner edge to resize it (at least 200 px, and a strip of the page stays). The side and the two sizes are kept in localStorage (cssints-devtools:dock) per origin. The panel covers the page beside it, and picking works on the rest of the page; the page is not pushed aside. The ⧉ button detaches the panel into a window of its own (window.open, a same-origin pop-up, not the Document Picture-in-Picture API: that one is Chromium only). It is the same panel: the page keeps picking (hover, click, the highlight) and the window follows the picked element live. Closing the window, ⧉ again or a dock button puts the panel back; Esc and the cssints button close both. The choice is kept with the dock, and the next open (a click or the shortcut: a pop-up needs one) opens the window again. If the browser blocks the pop-up, the docked panel says so. The panel and the cascade rule are described in docs/API.md, "Debugging: the devtools overlay"; the design in docs/research/devtools.md, "Our devtools".

Rules

Ask OpenCode

// dev only, off by default; @opencode/client in the app's devDependencies
cssints({ devtools: true, opencode: true });
cssints({ devtools: true, opencode: { agent: "build", skills: ["cssints"] } });

The panel has an OpenCode box whenever the option is on, picked element or not. It is pinned: at the bottom of the panel in a left or right dock, at its right edge (20 rem wide, to the right of the inspection) in a top or bottom dock, and in the detached window by the window's shape (wider than tall: the right edge); the inspection beside it scrolls, the box does not. The box has a title row (OpenCode, and a dot with connected or not connected), the input (Enter sends, Shift+Enter is a new line) and one status line:

The page asks the dev server whether a service is found (a probe: it looks, it creates no session) when the panel opens, when the box gets focus and after a send that found none, so starting OpenCode later shows up without a reload.

The tab with the chat

With the option on, the panel has two tabs: Inspect (the picked element, its structure and the classes that won each property) and OpenCode, which holds the conversation rather than one prompt at the panel's edge:

test/ask-browser.mjs drives it in Chrome against the fake service (the tabs, new session creating exactly one, the transcript's roles, the raw text reaching the prompt), and test/opencode.mjs covers the server side: open creates no session, new creates one, send leaves the transcript of the messages and not of the session's own state.

The command /cssints-devtools

The box does not choose a session: an OpenCode command attaches the session it runs in to a dev server. The plugin is the main entry of this package, so OpenCode loads it by the package name (checked on 2.0.27: it installs the package and finds the entry; a package subpath, @cssints/devtools/opencode, is not loaded as a plugin):

// opencode.jsonc of the repository of the app (or ~/.config/opencode/opencode.jsonc)
{ "plugins": ["@cssints/devtools"] }

Or, with the package installed in the app, a file of the repository (OpenCode loads the .ts files of .opencode/plugins/):

// .opencode/plugins/cssints-devtools.ts
export { default } from "@cssints/devtools/opencode";

Then, in an OpenCode session:

Each outcome is a message in the session (ctx.session.synthetic, which also gives the model a turn to acknowledge it). The prompts of an attached server's panel are sent to that session, which is not created again; a session that is gone makes the send fail with a message that says to run /cssints-devtools again. The rendezvous is files, not a route (the ask channel is the HMR socket, which Vite's token protects): <repository>/node_modules/.cache/cssints-devtools/<id>.json (root, pid, url) is written by the dev server while it runs, and <id>.session.json by the command. A dev server that crashed leaves a file with a dead pid, which the command ignores and removes. The plugin imports cssints/devtools-link, the module both sides share.

Without an attached session, Enter starts a session on the running OpenCode V2 service (Service.discover of @opencode/client; the page never talks to it) in the nearest folder up from the Vite root that has a .git. The prompt is built by src/core/prompt.ts:

Every list and value is cut, the server cuts the whole at 16,000 characters from the end (the App: line, the instruction and the header come first and stay). With no service running the box says how to connect and keeps your text. The page and the server talk over the HMR channel (cssints:devtools:ask, asked, link, linked), not a route. A build has none of it. The idea, and the calls to the V2 client, follow brendonovich/vite-plugin-opencode (MIT, Brendan Allan), which marks the markup with Babel and so needs no table; here the table is the context.

Vitals in the console

The panel inspects one element; @cssints/devtools/vitals inspects the page and prints to the console, because a page that draws to a canvas has no elements to pick (the native browser target is one). No dev server and no overlay chunk: a plain ES module, about 30 kB (9.5 kB gzip), that any page imports in dev.

// the app's entry, dev only
import { observe, vitals } from "@cssints/devtools/vitals";
observe(); // long tasks and long animation frames are not buffered: observe before the work

vitals(); // later, from the console — or window.vitals(), set by the module
cssints vitals
265 ms · 214 nodes · 1 sheet · 380 classes
vitals   FCP 412 ms · LCP 1.20 s (h1.hero) · CLS 0.002
         INP 96 ms (button.primary) · 8+40+48 · TTFB 38 ms
frames   p50 16.7 ms · p95 33.4 ms · max 51.2 ms · 3 dropped  ▁▂▃▅▇▆▃▂▁▂▃▅
main     7 long tasks · 412 ms · max 120 ms · style+layout 41 ms · 0 errors · heap 42.1 MB
sheet    64.4 kB · +29 B on src/registry/button/button.tsx · 3 loads · 81 B a class  ▁▁█
load     2 sheets · 1 render-blocking · 66 ms to last · slow.css 65 ms (327 B)
history  12 loads · LCP 1.20 s (−180 ms) (−312 B)  ▁▂▃▅▆▇▆▅
CSS      41.2 kB · 380 rules · 1 902 decls · 0 blocked · specificity 0,3,2 (._1t8gqy5:hover)
layer    _.k       ████████████████████ 22.4 kB
tokens   14 colours · 2 fonts · 1 !important · custom props 12 declared / 9 used / 3 orphaned · keyframes 2 / 1 unused
coverage 41 / 380 classes unused (11%)  cs-Landing-hero …

report() returns the numbers without printing, print(report) prints, stop() ends the frame loop.

Layout

Browsers

Chrome, Firefox and WebKit, checked by test:browsers on apps/demo's dev server.

Limits

Credits

The prompt box that starts an OpenCode session follows brendonovich/vite-plugin-opencode (MIT, Brendan Allan): the idea and the calls to the V2 client. No code is copied. The overlay is built with Solid (MIT).

Tests

bun run test            # test/core.mjs (the cascade on happy-dom: hover vs media, @container, @supports, @scope,
                        # an unlayered rule, frame's kernel, within(), grouping), test/build.mjs (nothing in a build
                        # without the option; with "build": the table, the lazy chunk, the loader's size; apps/docs/test/browser.mjs opens it in Chrome),
                        # test/opencode.mjs (the dev server and a fake OpenCode service: the prompt as sent, the agent, the directory, the status, no service; the link probe, with and without the service and the client; an attached session, a detached one, two dev servers, a session that is gone, stale files),
                        # test/opencode-plugin.mjs (the command on a fake plugin context: none, one, several, a pick, off, a stale pid),
                        # test/vitals.mjs (the charts, and the sheet reader on happy-dom: classes, coverage, custom properties, keyframes, specificity)
bun run test:browsers   # builds dist/overlay.js, then the demo in Chrome, Firefox and WebKit (test/browsers.mjs; each dock: the panel on its side, a pick beside it, a drag of the grip, the button after Esc, the dock and sizes after a reload; detach: the pop-up with the panel, a pick in the page followed live, the choice after a reload, closing re-docks, a blocked pop-up), then the console report in Chrome (test/vitals-browser.mjs: layers, @property, keyframes in use, a long task and its animation frame, the paint entries, the printed group), then the OpenCode box in Chrome (test/ask-browser.mjs: with nothing picked, pinned in each dock and in the window, the connect text, a service started later found on focus, the attached session and its title; screenshots in test/out/)