Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

User-facing changes only, grouped by date under Added / Improved / Fixed.

## 0.7.0 — 2026-11-27

### Added

- Browser extension: Pick and comment. Click elements on any page, add a comment to each, and copy them all as compact text an AI agent understands without an extra prompt. A note can ask for a change or just point an element out. Start it with Alt+Shift+C, from the extension popup, or by right-clicking the page → CapKit.
- Browser extension: Font tool. Hover any text to see its font, size, weight, line height and colour; click to copy it as CSS. Alt+Shift+F or right-click → CapKit → Font.
- Browser extension: Colour tool. Hover to see an element's text, background and border colours; click to lock it and copy any of them as HEX. Press E to pick any pixel on screen. Alt+Shift+K or right-click → CapKit → Colour.
- Screen record: hover a recording to copy the video file (paste it into a folder, chat or email) or show it in its folder.

### Improved

- Screen record: clicking a recording opens it in your default video player. If none is set, Windows asks which app to use. The in-app player and its full-screen button, which could break the dashboard window, are gone.
- Browser extension: the popup and on-page panels now match the CapKit dashboard: Geist font, compact buttons, and light and dark themes. The extension uses the CapKit app logo.

### Fixed

- Browser extension: after the extension updates, its tools start on pages that were already open, instead of asking you to reload the page.

## 0.6.2 — 2026-11-26

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions apps/browser-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"test": "vitest run"
},
"dependencies": {
"@fontsource-variable/jetbrains-mono": "5.2.8",
"@fontsource-variable/plus-jakarta-sans": "5.2.8",
"@fontsource-variable/geist": "5.3.0",
"@fontsource-variable/geist-mono": "5.3.0",
"@jridgewell/trace-mapping": "^0.3.31",
"@snaphub/devtools-protocol": "workspace:*",
"react": "^19.2.7",
Expand Down
Binary file modified apps/browser-extension/public/icons/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/browser-extension/public/icons/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/browser-extension/public/icons/32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/browser-extension/public/icons/48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 21 additions & 5 deletions apps/browser-extension/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,35 @@
"manifest_version": 3,
"name": "CapKit Inspector",
"version": "0.3.0",
"description": "Inspect spacing, styles and source locations on any page, and give CapKit exact element data.",
"description": "Inspect spacing, styles and source locations, comment on elements for AI agents, read fonts and pick colours on any page.",
"minimum_chrome_version": "116",
"icons": { "16": "icons/16.png", "48": "icons/48.png", "128": "icons/128.png" },
"action": { "default_popup": "popup/index.html", "default_title": "CapKit Inspector" },
"icons": { "16": "icons/16.png", "32": "icons/32.png", "48": "icons/48.png", "128": "icons/128.png" },
"action": {
"default_popup": "popup/index.html",
"default_title": "CapKit Inspector",
"default_icon": { "16": "icons/16.png", "32": "icons/32.png" }
},
"background": { "service_worker": "background.js" },
"permissions": ["activeTab", "alarms", "scripting", "storage", "clipboardWrite"],
"permissions": ["activeTab", "alarms", "scripting", "storage", "clipboardWrite", "contextMenus"],
"host_permissions": ["http://localhost/*", "http://127.0.0.1/*"],
"optional_host_permissions": ["<all_urls>"],
"commands": {
"toggle-inspector": {
"suggested_key": { "default": "Alt+Shift+I" },
"description": "Inspect the page"
},
"toggle-picker": {
"suggested_key": { "default": "Alt+Shift+C" },
"description": "Pick elements and comment"
},
"toggle-font": {
"suggested_key": { "default": "Alt+Shift+F" },
"description": "Read fonts"
},
"toggle-color": {
"suggested_key": { "default": "Alt+Shift+K" },
"description": "Pick colours"
}
},
"web_accessible_resources": [{ "resources": ["fonts/*"], "matches": ["<all_urls>"], "use_dynamic_url": true }]
"web_accessible_resources": [{ "resources": ["fonts/*"], "matches": ["<all_urls>"], "use_dynamic_url": false }]
}
2 changes: 1 addition & 1 deletion apps/browser-extension/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ await build({
});

await mkdir(resolve(dist, "fonts"), { recursive: true });
for (const pkg of ["plus-jakarta-sans", "jetbrains-mono"]) {
for (const pkg of ["geist", "geist-mono"]) {
const dir = resolve(dirname(require.resolve(`@fontsource-variable/${pkg}/package.json`)), "files");
for (const file of await readdir(dir)) {
if (file.endsWith("-latin-wght-normal.woff2")) await cp(resolve(dir, file), resolve(dist, "fonts", file));
Expand Down
31 changes: 23 additions & 8 deletions apps/browser-extension/src/background.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PROTOCOL_VERSION, type AppMessage, type ExtensionMessage } from "@snaphub/devtools-protocol/protocol";
import { ACCENT_KEY } from "./accent";
import { Link, WAKE_ALARM_MINUTES, wakeAlarmFor, type SocketLike, type TokenStore } from "./link";
import { backgroundRequestSchema, type LinkStatus, type PageRequest } from "./messages";
import { installMenus, toolForCommand, toolForMenu } from "./menus";
import { backgroundRequestSchema, type LinkStatus, type PageRequest, type Tool } from "./messages";
import { activeTabs, askTab, injectMainWorld, matchTab, originPattern, siteAccessFor, type TabRef } from "./tabs";

const TOKEN_KEY = "capkitToken";
Expand Down Expand Up @@ -112,14 +113,19 @@ async function currentTab(): Promise<TabRef | null> {
return tab?.id === undefined ? null : { id: tab.id, url: tab.url ?? "", title: tab.title ?? "" };
}

/** Opening the popup or pressing the shortcut grants activeTab, so the inspector needs no site access. */
async function inspectActiveTab(): Promise<boolean> {
const tab = await currentTab();
/** The popup, a shortcut or a menu click grants activeTab, so the page tools need no site access. */
async function runTool(tab: TabRef | null, tool: Tool, action: "toggle" | "start"): Promise<boolean> {
if (tab === null || originPattern(tab.url) === null) return false;
const result = await askTab(tab, { kind: "toggle" }, { requireSiteAccess: false });
const result = await askTab(tab, { kind: "tool", tool, action }, { requireSiteAccess: false });
return result.response !== null;
}

async function refreshMenus(): Promise<void> {
const commands = await chrome.commands.getAll();
const shortcuts = new Map(commands.flatMap((command) => (command.name === undefined || command.shortcut === undefined ? [] : [[command.name, command.shortcut] as const])));
await installMenus(chrome.contextMenus, shortcuts);
}

async function dispatch(raw: unknown, sender: chrome.runtime.MessageSender): Promise<unknown> {
const parsed = backgroundRequestSchema.safeParse(raw);
if (!parsed.success) return { ok: false };
Expand All @@ -145,8 +151,8 @@ async function dispatch(raw: unknown, sender: chrome.runtime.MessageSender): Pro
case "forget":
await link.forget();
return link.status;
case "inspectActiveTab":
return { ok: await inspectActiveTab() };
case "startTool":
return { ok: await runTool(await currentTab(), request.tool, "start") };
case "siteAccess":
return siteAccessFor(await currentTab());
}
Expand All @@ -161,7 +167,14 @@ chrome.runtime.onMessage.addListener((message: unknown, sender, sendResponse) =>
});

chrome.commands.onCommand.addListener((command) => {
if (command === "toggle-inspector") void inspectActiveTab();
const tool = toolForCommand(command);
if (tool !== null) void currentTab().then((tab) => runTool(tab, tool, "toggle"));
});

chrome.contextMenus.onClicked.addListener((info, tab) => {
const tool = toolForMenu(info.menuItemId);
if (tool === null || tab?.id === undefined) return;
void runTool({ id: tab.id, url: tab.url ?? info.pageUrl ?? "", title: tab.title ?? "" }, tool, "start");
});

// A fresh worker already connects at the bottom of this file; the alarm only nudges a live one.
Expand All @@ -170,8 +183,10 @@ chrome.alarms.onAlarm.addListener((alarm) => {
});
chrome.runtime.onStartup.addListener(() => {
void link.connect();
void refreshMenus();
});
chrome.runtime.onInstalled.addListener(() => {
void link.connect();
void refreshMenus();
});
void link.connect();
13 changes: 13 additions & 0 deletions apps/browser-extension/src/content/contrast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ export function gradeContrast(ratio: number, largeText: boolean): ContrastGrade
if (ratio >= (largeText ? 3 : 4.5)) return "AA";
return "Fail";
}

/** The opaque colour behind an element: its own and its ancestors' backgrounds composited over white. */
export function effectiveBackground(element: Element): Rgba {
const layers: Rgba[] = [];
for (let node: Element | null = element; node !== null; node = node.parentElement) {
const color = parseColor(getComputedStyle(node).backgroundColor);
if (color !== null && color.a > 0) {
layers.push(color);
if (color.a >= 1) break;
}
}
return layers.reduceRight<Rgba>((below, layer) => over(layer, below), { r: 255, g: 255, b: 255, a: 1 });
}
2 changes: 1 addition & 1 deletion apps/browser-extension/src/content/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function handlePageRequest(env: Env, request: PageRequest): Promise<PageR
const matches = findSensitiveInArea(env.document, toCssRect(request.area, scale), scale);
return Promise.resolve({ kind: "findSensitive", status: "ok", matches });
}
case "toggle":
case "tool":
case "ping":
return Promise.resolve({ kind: "ok" });
}
Expand Down
27 changes: 12 additions & 15 deletions apps/browser-extension/src/content/inspector/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { buildElementMarkdown } from "@snaphub/devtools-protocol/markdown";
import { toViewportRect } from "../../geometry";
import { describeElement, rectOf, shortLabel } from "../dom";
import { ensureHost, resolveComponentData } from "../mainClient";
import { resolveComponentData } from "../mainClient";
import { hostShadow, installFonts } from "../shadow";
import { THEME_CSS } from "../theme";
import { measureBetween } from "../measure";
import { h } from "./dom";
import { Overlay } from "./overlay";
Expand All @@ -17,14 +19,6 @@ const FONT_FACES = ["Plus Jakarta Sans", "JetBrains Mono"];

let savedPosition: PanelPosition | null = null;

function fontCss(): string {
const url = (file: string): string => chrome.runtime.getURL(`fonts/${file}`);
return [
`@font-face{font-family:"CapKit Sans";src:url("${url("plus-jakarta-sans-latin-wght-normal.woff2")}") format("woff2");font-weight:200 800}`,
`@font-face{font-family:"CapKit Mono";src:url("${url("jetbrains-mono-latin-wght-normal.woff2")}") format("woff2");font-weight:100 800}`,
].join("");
}

function label(element: Element, name: string | null): string {
const rect = element.getBoundingClientRect();
return `${name ?? shortLabel(element)} · ${element.tagName.toLowerCase()} · ${String(Math.round(rect.width))}×${String(Math.round(rect.height))}`;
Expand All @@ -33,7 +27,7 @@ function label(element: Element, name: string | null): string {
/** Page-side inspector: hover outline, lock, side panel, measure, keyboard shortcuts. */
export class InspectorController {
private active = false;
private shadow: ShadowRoot | null = null;
private frame: HTMLElement | null = null;
private root: HTMLElement | null = null;
private overlay: Overlay | null = null;
private panel: Panel | null = null;
Expand All @@ -59,15 +53,17 @@ export class InspectorController {
start(): void {
if (this.active) return;
this.active = true;
const { host } = ensureHost(this.doc);
this.shadow ??= host.attachShadow({ mode: "closed" });
const style = h(this.doc, "style", {}, fontCss(), INSPECTOR_CSS);
installFonts(this.doc);
const style = h(this.doc, "style", {}, THEME_CSS, INSPECTOR_CSS);
this.root = h(this.doc, "div", { class: "root" });
const root = this.root;
void readAccent().then((accent) => {
root.style.setProperty("--accent", accent);
});
this.shadow.replaceChildren(style, this.root);
// Own frame in the shared shadow root, so stopping never removes the picker's UI.
this.frame?.remove();
this.frame = h(this.doc, "div", { style: "display:contents" }, style, root);
hostShadow(this.doc).append(this.frame);
this.overlay = new Overlay(this.doc, this.root);
this.panel = new Panel(this.doc, this.root, savedPosition ?? defaultPosition(), {
close: (): void => {
Expand Down Expand Up @@ -106,8 +102,9 @@ export class InspectorController {
const panel = this.panel;
panel?.node.classList.remove("open");
panel?.node.classList.add("closing");
const frame = this.frame;
setTimeout(() => {
if (!this.active) this.shadow?.replaceChildren();
frame?.remove();
}, EXIT_MS);
this.hovered = null;
this.locked = null;
Expand Down
23 changes: 6 additions & 17 deletions apps/browser-extension/src/content/inspector/panel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ElementDetails } from "@snaphub/devtools-protocol/protocol";
import { toHexColor } from "@snaphub/devtools-protocol/markdown";
import { contrastRatio, gradeContrast, over, parseColor, type Rgba } from "../contrast";
import { contrastRatio, effectiveBackground, gradeContrast, over, parseColor } from "../contrast";
import { readBoxModel } from "./overlay";
import { closeIcon } from "../theme";
import { h } from "./dom";

const PANEL_WIDTH = 320;
Expand All @@ -20,18 +21,6 @@ function clampPosition(position: PanelPosition): PanelPosition {
};
}

function effectiveBackground(element: Element): Rgba {
const layers: Rgba[] = [];
for (let node: Element | null = element; node !== null; node = node.parentElement) {
const color = parseColor(getComputedStyle(node).backgroundColor);
if (color !== null && color.a > 0) {
layers.push(color);
if (color.a >= 1) break;
}
}
return layers.reduceRight<Rgba>((below, layer) => over(layer, below), { r: 255, g: 255, b: 255, a: 1 });
}

export type ContrastInfo = { ratio: number; grade: "AAA" | "AA" | "Fail" };

export function contrastOf(element: Element): ContrastInfo | null {
Expand Down Expand Up @@ -105,12 +94,12 @@ export class Panel {
) {
this.position = clampPosition(position);
this.body = h(doc, "div");
const close = h(doc, "button", { type: "button", "aria-label": "Close inspector" }, "Esc");
const close = h(doc, "button", { type: "button", class: "ghost icon", "aria-label": "Close inspector", title: "Close (Esc)" }, closeIcon(doc));
close.addEventListener("click", actions.close);
const copy = h(doc, "button", { type: "button", "aria-label": "Copy element as Markdown" }, "Copy");
const copy = h(doc, "button", { type: "button", class: "primary", "aria-label": "Copy element as Markdown" }, "Copy");
copy.addEventListener("click", actions.copy);
const header = h(doc, "header", {}, h(doc, "h2", {}, "CapKit Inspector"), copy, close);
this.node = h(doc, "div", { class: "panel", role: "dialog", "aria-label": "CapKit Inspector", tabindex: "-1" }, header, this.body);
const header = h(doc, "header", {}, h(doc, "h2", {}, "Inspect"), copy, close);
this.node = h(doc, "div", { class: "panel card", role: "dialog", "aria-label": "CapKit Inspector", tabindex: "-1" }, header, this.body);
this.apply();
this.enableDrag(header);
root.append(this.node);
Expand Down
Loading
Loading