Palette

Palette is a maintained fork of tjcages/komo. It is published as @hazem3500/palette. Install it with npm install @hazem3500/palette.
Comments for your website. Point at an element, mark an area, and leave feedback your team can reply to, resolve, or copy into a coding agent.
Framework independent. Shared persistence. Google identities and guest reviewers.
Documentation
Review actions update immediately while saving in the background. Failed writes roll back with a notice; unsaved comment text is retained.
Install
npm install @hazem3500/palette
Requires Node.js 22 or newer. The unscoped komo package on npm is unrelated; use @hazem3500/palette.
Palette has no hosted default. Comments go to a Palette server that you run, and every install sets endpoint to it. Start a server first:
- Node and PostgreSQL, including Cloud Run: run
npx @hazem3500/palette init --node and follow the Node self-hosting guide.
- Cloudflare Worker and D1: run
npx @hazem3500/palette init --self-host; see Self-host.
Both print the endpoint and project key for your site. If your team already runs a Palette server with hosted setup turned on (PALETTE_HOSTED=true), connect to it with npx @hazem3500/palette init --endpoint https://palette.example.com; see Hosted setup.
Usage
Mount after the page has loaded:
import { initPalette } from '@hazem3500/palette';
initPalette({
endpoint: 'https://palette.example.com',
project: 'YOUR_PROJECT_KEY',
});
Optional configuration stays at the call site:
initPalette({
endpoint: 'https://palette.example.com',
project: 'YOUR_PROJECT_KEY',
enabled: import.meta.env.DEV || import.meta.env.PUBLIC_PREVIEW === 'true',
pageRoot: document.querySelector('#app'),
});
React
With React 18.2 or 19, call the hook once near your app root:
'use client'; // Required for Next.js App Router client components.
import { usePalette } from '@hazem3500/palette/react';
export function Palette() {
usePalette({
endpoint: 'https://palette.example.com',
project: 'YOUR_PROJECT_KEY',
});
return null;
}
Render <Palette /> in your app or layout. The hook handles mounting, cleanup, and React Strict Mode. Inline configuration objects are supported; unchanged values do not restart Palette. Changing configuration remounts it, and enabled: false removes it. Memoize callback options with useCallback and pass stable DOM elements for pageRoot or drawerContainer. Mount only one hook per page; do not combine it with a separate initPalette() call. Server rendering does not mount the tool.
The endpoint is the comments API, your Palette server, not your website or preview URL. It is required: without it, Palette logs an error and does not mount. Google sign-in returns to ENDPOINT/auth/google/callback, regardless of the website embedding Palette. Your current page comes from the browser. Setup detects repository metadata from Git; include its printed repo value to enrich agent prompts.
Comments are shared across deployments by default. Use pnpm exec palette init --branch-scope to separate them by branch. For automatic branch detection, import from the optional generated palette.config.js helper and run palette sync before builds. It detects the current branch from deployment environment variables or Git; set PALETTE_BRANCH if neither is available. It fails rather than silently grouping unknown branches.
Migrating from komo
Palette was called komo. Existing installs keep working without changes.
- API names.
initPalette, definePalette, usePalette, usePaletteInspectable, usePaletteDesignTokens and the Palette* types are the main names. initKomo, defineKomo, useKomo, useKomoInspectable, useKomoDesignTokens and the Komo* types still work and are marked deprecated.
- CLI. The command is
palette. komo still works as an alias.
- Package. The package is now
@hazem3500/palette. Replace @hazem3500/komo in your dependencies and imports (including subpaths such as /react and /vite); @hazem3500/komo is deprecated and gets no new releases.
- Stored and wire names. The Palette names are the main ones, and the komo names are still read, so sessions, settings, tokens, deployments, comments and host integrations keep working:
- Browser storage. Keys start with
palette:. When Palette mounts, each of its keys from before the rename (branch-comments:*, komo:*) is copied to its palette: name if that is unset, and the old key stays, so an older copy of the app on the same origin keeps working. The new key wins when both exist. Clearing a value (signing out, closing the sidebar) clears both. Other keys on the origin are left alone.
- Environment variables. Set
PALETTE_* (PALETTE_TOKEN, PALETTE_ALLOW_GUESTS, PALETTE_TRUSTED_PROXY_HOPS and the rest). Each KOMO_* name still works when its PALETTE_* name is unset or empty, on the server, the Node image and the CLI.
- Access tokens. New tokens start with
palette_pat_. Tokens starting with komo_pat_ keep authenticating everywhere until they expire or are revoked. The token list shows each one as …_pat_<id>…<last4>.
- Project files. New projects use
.palette/ and palette.config.js. A project set up before the rename keeps .komo/ and komo.config.js, so its imports and ignored files stay valid. The CLI also reads credentials saved under ~/.config/komo; new ones go to ~/.config/palette, and palette logout revokes and removes the sessions saved in both. palette init rewrites the AGENTS.md workflow block's komo:workflow markers to palette:workflow.
- Page attributes and CSS. Use
data-palette-no-snapshot, data-palette-inspectable, data-palette-design-tokens and --palette-selection. Their data-komo-* and --komo-selection forms are still read. usePaletteInspectable returns both data-palette-inspectable and data-komo-inspectable. Frame's viewport link uses ?palette-shell=; ?komo-shell= still opens it. The viewport iframe keeps the name komo-viewport and carries both data-palette-viewport and data-komo-viewport, so an older framed copy still knows it is framed.
- Webhooks. Each request carries
X-Palette-Event, X-Palette-Delivery and X-Palette-Signature, and the same values as X-Komo-*.
- Comments. Design edits are marked
palette: "design-edit" (fence palette-design-edit), and snapshot notes say palette:. Comments written before the rename, with komo markers, still parse.
- Unchanged. Database tables, project keys (
komo_…), the reserved _komo management project and exported feedback (komo-export) keep their names.
Features
-
Point and area comments anchored to page elements.
-
On-demand design mode for temporary typography, color, spacing, border, and layout previews; copy the resulting CSS or attach a comment to the selected element.
-
Replies, reactions, author-only editing, resolution, and undo.
-
Group tags: add them while writing a comment or on an open thread, with suggestions from tags already in the project.
-
Safe HTTP(S) links and simple Markdown links in comment messages.
-
Searchable sidebar, draggable dock, and Google or guest profiles.
-
Dismiss the toolbar for the current tab with ×; restore it with Shift+K, controller.restore(), or controller.open() (which also opens the sidebar). Set showToolbar: false to start hidden.
-
More → Hide comments (H) clears pins, comment cards and the open sidebar or Frame from the page while review stays on. Unsent comments and replies, the open thread and the list's filters and scroll come back with Show comments. Comments return only when the reviewer asks: Show comments, or starting a comment, opening the list or a thread. The choice lasts for the current tab (session storage).
-
More → Pin size switches pins between Full, Compact (a small initial), Dot (the author's accent at full strength, with a brief breathing halo, until you open its latest comment in this browser; quieter after that) and Auto (dots while browsing, full while commenting or with the sidebar open). Small pins keep a 24px target and expand in place on hover, focus, a nearby pointer or selection. The choice is remembered per project and wins over pins.size.
-
Crowded pins consolidate. Comments on the same target (its persistent owner, including a custom anchorTarget) draw as one tight avatar stack at the oldest comment's anchor; more than three collapse to the first author and a count. Hover, keyboard focus or a tap fans the stack out in creation order, and each pin opens its own thread. Pins on different targets whose 24px targets overlap at the current zoom or Frame scale merge into a count bubble; it opens a keyboard-navigable list of those comments. Grouping never changes anchors or saves anything, the open comment's pin is always drawn at its own anchor, and a pin moved with Move pin stays out of stacks and bubbles. Set pins.cluster: false to draw every pin on its own.
-
Keyboard shortcuts: C to comment, V to browse, D to toggle Design mode, L to view all comments, H to hide or show comments, Shift+K to restore. Remap or disable them with shortcuts; see Choosing shortcuts. In Design mode, ? or Keyboard shortcuts in the empty inspector lists every canvas key and gesture.
-
Copy open feedback with selectors, source paths, page URLs, replies, and geometry into an agent.
-
Your own Worker/D1 or Node/PostgreSQL service.
Comment pins stay anchored during ordinary pointer drags. Authors and verified reviewers can choose Comment actions → Move pin to reposition one explicitly: drag it, or use arrow keys (Shift for larger steps), then Enter or Save position. Escape or Cancel move restores its previous position without saving. Completed moves use the existing thread anchor endpoint and remain attached after reload; the page element itself never moves. Dragging a floating comment card is independent of pin placement.
Design mode edits the rendered page only. Preview styles and inline text edits are temporary and reset when the page refreshes; styles are restored when the Palette widget is destroyed. Use Copy CSS to apply a rule in your site stylesheet; Palette does not write source files. Double-click text, or use Edit text, to edit it inline. Edits accept plain text only and change text in place: nested markup, links, and buttons keep their structure. Text marked data-private or data-sensitive, form fields, and text inside graphics, media, or frames stay read-only. An explicitly registered React textProp routes edits through the app's state callback. The inspector can select an iframe as one element but cannot edit its isolated contents. Elements inside open or closed shadow roots are not traversed; select the component host instead.
The design inspector loads as a separate optional browser chunk when Design mode is first opened, so the default widget load does not pay its bundle cost. The package size check measures this chunk separately from the core bundle.
The inspector takes direct UX/UI inspiration from DialKit: a compact dark floating panel, collapsible Color/Typography/Layout/Border groups, horizontal live sliders with editable numeric values, and color swatches paired with CSS color inputs. Group collapse state survives selection and Undo/Reset. Each slider gesture is one undoable edit; numeric fields remain available for precise keyboard entry. No DialKit runtime dependency is added.
Design mode also takes interaction cues from established design tools: select a visible element, keep its controls contextual, and make each change easy to reverse. Figma places editable layer properties and file-local styles or variables beside the selected layer; its Dev Mode provides inspection and measurements. pen.dev pairs an IDE design-mode toggle with a canvas, layer list, contextual property panel, and undo/redo. OpenPencil synchronizes layer-tree and canvas selection and offers contextual typography/layout controls, variables, and undoable operations.
Opt-in React prop inspection
React teams can register selected component roots for typed prop previews through the ./react entry. A build-time TypeScript Compiler API pass generates the prop manifest from an explicitly marked function component and props type; the inspector edits only strings, numbers, booleans, and literal unions. Functions, refs, ReactNode, objects, generics and unsupported types are omitted from editable controls. This metadata is a safe allowlist, not runtime discovery of every React component; defaultProps and every React component form are not inferred. A literal-union prop previews each option as you hover it or move to it with the arrow keys, through the component's own onChange; click or Enter commits one Undo step, and moving off the list, Escape or clicking elsewhere puts the opening value back. While Palette drives a preview (an option, a token under the pointer, Before/After), the element's own CSS transitions are held, so each step renders at once and the panel reads final values; the element's attributes and style are left exactly as they were.
The app provides an onChange callback that updates its own state. Palette previews those values through React's normal render cycle, offers undo/reset, and can prefill an explicit comment with the proposed before/after values and source path. Posting still requires the user to submit the comment. Palette's core never accesses React Fiber internals and never writes source files; the one exception is the separate, opt-in React fiber adapter, which reads React internals only for apps that install it. Preview prop changes reset on refresh. A component may opt one leaf render into direct text editing by setting textProp to the name of an allowed string prop; Palette does not infer which child text belongs to a prop. See examples/react-props for the generated fixture and limitations.
Opt-in design tokens
usePaletteDesignTokens can register a bounded list of named CSS custom properties from a host-owned source. Each entry supplies its token path, DTCG scalar type, CSS variable, eligible element properties, and an explicit selector for the estimated theme-preview scope. Palette does not scan arbitrary computed styles or infer a complete semantic system. The first adapter uses the Design Tokens Format Module 2025.10 naming/type vocabulary; it is not a general DTCG file importer, and composite typography tokens are not editable.
Compatible registered tokens appear inside each existing style control, next to the color, spacing, typography, or radius value they affect. The chooser filters by that control's CSS property; it never guesses a token by name, matches computed values, or snaps arbitrary values to a scale. A control reads Connected only when the element's winning declaration (inline, or a same-origin stylesheet rule ranked by !important, specificity, and order) references the registered var(--token). Typing a value, or choosing Custom value, records a custom override that keeps the original token as provenance; choosing another token rebinds the preview, and choosing the original token again removes the override. The comment proposal lists each change once, with its token before and after. Undo and Reset restore the original declaration and token provenance. Cross-origin stylesheets are skipped (their properties read as not connected), and cascade layers are ranked as if unlayered. For registered React components, a build-generated string prop can opt into one allowlisted styleProperty mapping (for example brandColor → color); the token reference then goes through the component's supplied React state callback and stays in the proposed prop diff. Unsupported prop types remain read-only.