The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): app-owned composer context-menu slot + host.spellcheck
Teknium814f507f45a7
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 88228215b9b..70a245b235c 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -562,6 +562,7 @@ import { ensureLoginShellPath } from './shell-path'import { removeStaleSingletonLock } from './singleton-lock'import { createSourcePythonBackend, resolveSourceInstallationBackend, type SourceBackend } from './source-backend'import { resolveSourcePython } from './source-python'+import { registerSpellcheckDictionaryIpc } from './spellcheck-dictionary-ipc'import { resolveSshBinary } from './ssh-binary'import { createBootstrapCoordinator, sshConfigFingerprint } from './ssh-bootstrap-coordinator'import { collectSshConfigHosts, parseSshGOutput } from './ssh-config'@@ -16552,31 +16553,7 @@ ipcMain.handle('hermes:context-menu:copy-image', event => {}})-ipcMain.handle('hermes:context-menu:spellcheck', (event, action) => {- const kind = action?.kind- const word = String(action?.word || '')-- if (!word) {- return- }-- if (kind === 'replace') {- event.sender.replaceMisspelling(word)- } else if (kind === 'add') {- event.sender.session.addWordToSpellCheckerDictionary(word)- }-})--// Guest dictionary add: the webview TAG exposes replaceMisspelling but no-// session API, so the renderer names the guest by webContents id.-ipcMain.handle('hermes:context-menu:guest-add-word', (_event, payload) => {- const word = String(payload?.word || '')- const guest = electronWebContents.fromId(Number(payload?.webContentsId))-- if (word && guest && !guest.isDestroyed()) {- guest.session.addWordToSpellCheckerDictionary(word)- }-})+registerSpellcheckDictionaryIpc(ipcMain, electronWebContents)ipcMain.handle('hermes:capturePreview', async (_event, payload) => {const guest = electronWebContents.fromId(Number(payload?.webContentsId))diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.tsindex 84638b74c65..2d6f0a6443a 100644--- a/apps/desktop/electron/preload.ts+++ b/apps/desktop/electron/preload.ts@@ -360,6 +360,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {contextMenuCopyImage: () => ipcRenderer.invoke('hermes:context-menu:copy-image'),contextMenuSpellcheck: action => ipcRenderer.invoke('hermes:context-menu:spellcheck', action),contextMenuGuestAddWord: payload => ipcRenderer.invoke('hermes:context-menu:guest-add-word', payload),+ spellcheckDictionary: (op, word) => ipcRenderer.invoke('hermes:spellcheck:dictionary', { op, word }),onContextMenuSpellcheck: callback => {const listener = (_event, payload) => callback(payload)ipcRenderer.on('hermes:context-menu-spellcheck', listener)diff --git a/apps/desktop/electron/spellcheck-dictionary-ipc.test.ts b/apps/desktop/electron/spellcheck-dictionary-ipc.test.tsnew file mode 100644index 00000000000..4bcc3fdef3a--- /dev/null+++ b/apps/desktop/electron/spellcheck-dictionary-ipc.test.ts@@ -0,0 +1,88 @@+import type { IpcMainInvokeEvent } from 'electron'+import { describe, expect, it, vi } from 'vitest'++import { normalizeDictionaryWord, registerSpellcheckDictionaryIpc } from './spellcheck-dictionary-ipc'++type Handler = (event: IpcMainInvokeEvent, payload?: unknown) => unknown++function rig() {+ const handle = vi.fn<(channel: string, handler: Handler) => void>()++ const session = {+ addWordToSpellCheckerDictionary: vi.fn(() => true),+ removeWordFromSpellCheckerDictionary: vi.fn(() => true)+ }++ const event = { sender: { session } } as unknown as IpcMainInvokeEvent++ registerSpellcheckDictionaryIpc({ handle }, { fromId: () => undefined })++ const handler = handle.mock.calls.find(([channel]) => channel === 'hermes:spellcheck:dictionary')![1]+ const call = (payload: unknown) => handler(event, payload)++ return { call, session }+}++describe('normalizeDictionaryWord', () => {+ it('accepts one word of letters, marks, digits, apostrophes and hyphens', () => {+ expect(normalizeDictionaryWord('Hermes')).toBe('Hermes')+ expect(normalizeDictionaryWord(' naïve ')).toBe('naïve')+ expect(normalizeDictionaryWord("don't")).toBe("don't")+ expect(normalizeDictionaryWord('re-run')).toBe('re-run')+ expect(normalizeDictionaryWord('GPT4o')).toBe('GPT4o')+ })++ it('refuses anything that is not exactly one bounded word', () => {+ for (const raw of [+ '',+ ' ',+ 'two words',+ 'line\nbreak',+ 'tab\tbed',+ 'nul\u0000',+ '1234',+ '--',+ '<script>',+ 'a/b',+ 'x'.repeat(65),+ 42,+ null,+ undefined,+ { word: 'x' }+ ]) {+ expect(normalizeDictionaryWord(raw)).toBeNull()+ }+ })+})++describe('hermes:spellcheck:dictionary', () => {+ it("adds and removes a word on the sender's own session", async () => {+ const { call, session } = rig()++ expect(await call({ op: 'add', word: ' Hermes ' })).toBe(true)+ expect(session.addWordToSpellCheckerDictionary).toHaveBeenCalledWith('Hermes')++ expect(await call({ op: 'remove', word: 'Hermes' })).toBe(true)+ expect(session.removeWordFromSpellCheckerDictionary).toHaveBeenCalledWith('Hermes')+ })++ it('refuses an invalid word or an unknown op without touching the dictionary', async () => {+ const { call, session } = rig()++ expect(await call({ op: 'add', word: 'two words' })).toBe(false)+ expect(await call({ op: 'list', word: 'Hermes' })).toBe(false)+ expect(await call({ op: 'constructor', word: 'Hermes' })).toBe(false)+ expect(await call(undefined)).toBe(false)++ expect(session.addWordToSpellCheckerDictionary).not.toHaveBeenCalled()+ expect(session.removeWordFromSpellCheckerDictionary).not.toHaveBeenCalled()+ })++ it("reports Chromium's own verdict (false for an in-memory session)", async () => {+ const { call, session } = rig()++ session.addWordToSpellCheckerDictionary.mockReturnValue(false)++ expect(await call({ op: 'add', word: 'Hermes' })).toBe(false)+ })+})diff --git a/apps/desktop/electron/spellcheck-dictionary-ipc.ts b/apps/desktop/electron/spellcheck-dictionary-ipc.tsnew file mode 100644index 00000000000..5f64d57cdac--- /dev/null+++ b/apps/desktop/electron/spellcheck-dictionary-ipc.ts@@ -0,0 +1,72 @@+// Spell-check dictionary IPC: the custom context menu's native spell-check verbs+// and the plugin SDK's `host.spellcheck` door. Every handler acts on the+// SENDER's own session (or the named webview guest's), one word per call.++import type { IpcMain, IpcMainInvokeEvent, Session, WebContents } from 'electron'++const WORD_MAX = 64+// One word: letters, combining marks, digits, inner apostrophes and hyphens.+const WORD_RE = /^[\p{L}\p{M}\p{N}'\u2019-]+$/u+const LETTER_RE = /\p{L}/u++type DictionaryOp = (session: Session, word: string) => boolean++// A Map, not an object literal: `op` is renderer-supplied, and `'constructor'`+// or `'toString'` must not resolve to an inherited function.+const DICTIONARY_OPS = new Map<unknown, DictionaryOp>([+ ['add', (session, word) => session.addWordToSpellCheckerDictionary(word)],+ ['remove', (session, word) => session.removeWordFromSpellCheckerDictionary(word)]+])++/** The plugin door's word gate: exactly one bounded word with at least one+ * letter, NFC-normalized, or null. No whitespace, controls, markup or paths+ * ever reach Chromium's custom dictionary file through it. */+export function normalizeDictionaryWord(raw: unknown): null | string {+ if (typeof raw !== 'string') {+ return null+ }++ const word = raw.trim().normalize('NFC')++ return word.length <= WORD_MAX && WORD_RE.test(word) && LETTER_RE.test(word) ? word : null+}++export function registerSpellcheckDictionaryIpc(+ ipcMain: Pick<IpcMain, 'handle'>,+ contents: { fromId: (id: number) => undefined | WebContents }+): void {+ ipcMain.handle('hermes:context-menu:spellcheck', (event: IpcMainInvokeEvent, action) => {+ const kind = action?.kind+ const word = String(action?.word || '')++ if (!word) {+ return+ }++ if (kind === 'replace') {+ event.sender.replaceMisspelling(word)+ } else if (kind === 'add') {+ event.sender.session.addWordToSpellCheckerDictionary(word)+ }+ })++ // Guest dictionary add: the webview TAG exposes replaceMisspelling but no+ // session API, so the renderer names the guest by webContents id.+ ipcMain.handle('hermes:context-menu:guest-add-word', (_event: IpcMainInvokeEvent, payload) => {+ const word = String(payload?.word || '')+ const guest = contents.fromId(Number(payload?.webContentsId))++ if (word && guest && !guest.isDestroyed()) {+ guest.session.addWordToSpellCheckerDictionary(word)+ }+ })++ // `host.spellcheck.addWord/removeWord`. Resolves Chromium's own verdict+ // (false for an in-memory session), false for anything refused here.+ ipcMain.handle('hermes:spellcheck:dictionary', (event: IpcMainInvokeEvent, payload): boolean => {+ const op = DICTIONARY_OPS.get(payload?.op)+ const word = normalizeDictionaryWord(payload?.word)++ return Boolean(op && word && op(event.sender.session, word))+ })+}diff --git a/apps/desktop/src/app/chat/composer/contrib.ts b/apps/desktop/src/app/chat/composer/contrib.tsindex 96c0d5432ae..2437b0ab982 100644--- a/apps/desktop/src/app/chat/composer/contrib.ts+++ b/apps/desktop/src/app/chat/composer/contrib.ts@@ -13,6 +13,7 @@* data kinds (`data`): composer.middleware (ComposerMiddleware)* composer.attachments (ComposerAttachmentProvider)* composer.microActions (ComposerMicroActionProvider)+ * composer.contextMenu (ComposerContextMenuProvider)** Core keeps ownership of the transcript, input, and submit engine — these* seams AUGMENT the composer, they never replace it. Middleware runs as an@@ -38,9 +39,46 @@ export const COMPOSER_AREAS = {attachments: 'composer.attachments',microActions: 'composer.microActions',atCompletions: 'composer.atCompletions',- modelPill: 'composer.modelPill'+ modelPill: 'composer.modelPill',+ contextMenu: 'composer.contextMenu'} as const+/** What a `composer.contextMenu` provider sees when the user right-clicks the+ * composer: the word under the caret and the selection INSIDE the composer,+ * nothing else — no element, no range, no other field's text. Every field+ * is a standing compatibility promise to the plugins reading it. */+export interface ComposerContextMenuContext {+ /** Selected composer text at the click ('' when the caret is collapsed). */+ readonly selection: string+ /** The word under the caret (or at the selection's start), or null. */+ readonly word: null | string+}++/** Handed to an item's `onSelect` after the menu has closed and the composer+ * has the caret back. */+export interface ComposerContextMenuAction extends ComposerContextMenuContext {+ /** Replace the right-clicked `word` with `text` (one line). Works once, and+ * only while the composer still holds that word where it was — false+ * otherwise, never an edit somewhere else. */+ replaceWord: (text: string) => boolean+}++/** One row the app renders for a plugin in the composer's context menu. */+export interface ComposerContextMenuItem {+ /** Plain text; control characters are stripped and it is clamped. */+ label: string+ disabled?: boolean+ onSelect: (action: ComposerContextMenuAction) => void+}++/** Payload of a `composer.contextMenu` data contribution. `items` runs once+ * per right-click on the composer; return `[]` for "nothing from me". The+ * app renders each plugin's rows as its own section (plugins ordered by id,+ * at most six rows each) between its own spell-check rows and the edit verbs. */+export interface ComposerContextMenuProvider {+ items: (context: ComposerContextMenuContext) => ComposerContextMenuItem[]+}+export interface ComposerDraft {text: stringattachments?: ComposerAttachment[]diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-undo.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-undo.tsindex 72f891f6dac..5d151e72a36 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-undo.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-undo.ts@@ -3,6 +3,16 @@ import { type RefObject, useCallback, useEffect, useMemo } from 'react'import { caretOffsetInEditor, composerPlainText, placeCaretAtOffset, renderComposerContents } from '../rich-editor'import { type ComposerSnapshot, createComposerUndoHistory } from '../undo-history'+/** Each mounted composer's undo recorder, keyed by its editor element, for the+ * one edit the app makes from outside the composer tree: a context-menu+ * replacement (`app/context-menu/composer-menu.ts`). */+const recorders = new WeakMap<HTMLElement, () => void>()++/** Bank `editor`'s current state on its composer's undo stack, if one is mounted. */+export function recordComposerUndoPoint(editor: HTMLElement): void {+ recorders.get(editor)?.()+}+interface UseComposerUndoArgs {editorRef: RefObject<HTMLDivElement | null>/** Push a restored snapshot back into draftRef + composer state. */@@ -42,6 +52,24 @@ export function useComposerUndo({ editorRef, syncDraftFromEditor }: UseComposerU[editorRef, history, snapshot])+ useEffect(() => {+ const editor = editorRef.current++ if (!editor) {+ return+ }++ const record = () => recordUndoPoint()++ recorders.set(editor, record)++ return () => {+ if (recorders.get(editor) === record) {+ recorders.delete(editor)+ }+ }+ }, [editorRef, recordUndoPoint])+const applySnapshot = useCallback((next: ComposerSnapshot | null) => {const editor = editorRef.currentdiff --git a/apps/desktop/src/app/context-menu/app-context-menu.tsx b/apps/desktop/src/app/context-menu/app-context-menu.tsxindex 7da53ec8e42..e747313eb4f 100644--- a/apps/desktop/src/app/context-menu/app-context-menu.tsx+++ b/apps/desktop/src/app/context-menu/app-context-menu.tsx@@ -1,7 +1,8 @@import { useStore } from '@nanostores/react'import type { ReactNode } from 'react'-import { useEffect } from 'react'+import { useEffect, useMemo } from 'react'+import { COMPOSER_AREAS } from '@/app/chat/composer/contrib'import { terminalMenuHandleFor } from '@/app/right-sidebar/terminal/terminal-context-menu'import { openStarMapNodeMenuFor } from '@/app/starmap/context-menu-handle'import { DROPDOWN_KIT } from '@/components/ui/actions-menu'@@ -16,6 +17,7 @@ import {DropdownMenuShortcut,DropdownMenuTrigger} from '@/components/ui/dropdown-menu'+import { useContributions } from '@/contrib/react/use-contributions'import { type Translations, useI18n } from '@/i18n'import { hostPathLabel, hudForcesNativeLinks, normalizeExternalUrl, openExternalLink } from '@/lib/external-link'import { formatCombo } from '@/lib/keybinds/combo'@@ -23,6 +25,7 @@ import { isRemoteGateway } from '@/lib/media'import { reachablePreviewUrl } from '@/lib/preview-reach'import { openPreview } from '@/store/preview'+import { type ComposerMenuRow, resolveComposerMenuSections } from './composer-menu'import { ShellMenuItems } from './shell-menu-items'import {$contextMenu,@@ -120,7 +123,21 @@ function terminalSections(open: Extract<OpenContextMenu, { kind: 'terminal' }>,]}-function domSections(open: Extract<OpenContextMenu, { kind: 'dom' }>, t: Translations): ReactNode[][] {+/** One section per plugin, already ordered and capped by the resolver; each row+ * runs after the menu closed, like the built-in edit verbs. */+function composerItemSections(sections: ComposerMenuRow[][], afterClose: (run: () => void) => void): ReactNode[][] {+ return sections.map(rows =>+ rows.map(row => (+ <Item disabled={row.disabled} key={row.key} label={row.label} onSelect={() => afterClose(row.run)} />+ ))+ )+}++function domSections(+ open: Extract<OpenContextMenu, { kind: 'dom' }>,+ t: Translations,+ composerSections: ComposerMenuRow[][]+): ReactNode[][] {const copy = t.contextMenuconst { spellcheck, target } = openconst sections: ReactNode[][] = []@@ -291,6 +308,9 @@ function domSections(open: Extract<OpenContextMenu, { kind: 'dom' }>, t: Transla])}+ // Plugin rows (composer only), after the app's own spell-check rows.+ sections.push(...composerItemSections(composerSections, withEditableFocus))+// Verb availability mirrors the native menu: cut/copy act on the// SELECTION, so they need selected text — not just field content.// Inputs and textareas carry their selection on the element (Chrome@@ -543,6 +563,19 @@ function guestSections(open: Extract<OpenContextMenu, { kind: 'guest' }>, t: Traexport function AppContextMenu() {const { t } = useI18n()const open = useStore($contextMenu)+ const composerContributions = useContributions(COMPOSER_AREAS.contextMenu)+ const composerTarget = open?.kind === 'dom' ? open.target.composer : null++ // Resolved once per right-click (the target is captured at open and kept+ // across the late spell-check update), and again only if a plugin+ // registers or unloads while the menu is up.+ const composerSections = useMemo(+ () =>+ composerTarget && composerContributions.length+ ? resolveComposerMenuSections(composerContributions, composerTarget)+ : [],+ [composerContributions, composerTarget]+ )useEffect(() => {// stopPropagation beats other renderer handlers; preventDefault is never@@ -627,7 +660,9 @@ export function AppContextMenu() {? terminalSections(open, t): open.kind === 'guest'? guestSections(open, t)- : (list => (list.length ? list : [[<ShellMenuItems key="shell" kit={DROPDOWN_KIT} />]]))(domSections(open, t))+ : (list => (list.length ? list : [[<ShellMenuItems key="shell" kit={DROPDOWN_KIT} />]]))(+ domSections(open, t, composerSections)+ )return (<DropdownMenudiff --git a/apps/desktop/src/app/context-menu/composer-menu.test.tsx b/apps/desktop/src/app/context-menu/composer-menu.test.tsxnew file mode 100644index 00000000000..684574e8c6e--- /dev/null+++ b/apps/desktop/src/app/context-menu/composer-menu.test.tsx@@ -0,0 +1,265 @@+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'+import { createRef, type RefObject } from 'react'+import { MemoryRouter } from 'react-router'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'++import {+ COMPOSER_AREAS,+ type ComposerContextMenuAction,+ type ComposerContextMenuContext,+ type ComposerContextMenuItem+} from '@/app/chat/composer/contrib'+import { useComposerUndo } from '@/app/chat/composer/hooks/use-composer-undo'+import { RICH_INPUT_SLOT } from '@/app/chat/composer/rich-editor'+import { createPluginContext } from '@/contrib/plugin'++import { AppContextMenu } from './app-context-menu'+import { $contextMenu } from './store'++// The plugin side goes through the real scoped context, so provenance stamping+// and unload teardown are the production ones.+const disposers: Array<() => void> = []++function plugin(id: string, items: (context: ComposerContextMenuContext) => ComposerContextMenuItem[]) {+ const ctx = createPluginContext(id, dispose => disposers.push(dispose))++ ctx.register({ area: COMPOSER_AREAS.contextMenu, data: { items }, id: 'menu' })++ return ctx+}++function composer(text: string): HTMLElement {+ const editor = document.createElement('div')++ editor.setAttribute('contenteditable', 'true')+ editor.setAttribute('role', 'textbox')+ editor.dataset.slot = RICH_INPUT_SLOT+ editor.textContent = text+ // jsdom lacks the browser's isContentEditable.+ Object.defineProperty(editor, 'isContentEditable', { configurable: true, value: true })+ document.body.appendChild(editor)++ return editor+}++function select(editor: HTMLElement, start: number, end = start) {+ const range = document.createRange()++ range.setStart(editor.firstChild!, start)+ range.setEnd(editor.firstChild!, end)+ window.getSelection()!.removeAllRanges()+ window.getSelection()!.addRange(range)+}++/** The composer's real undo hook, mounted on `editor` the way the composer does. */+function mountUndo(editor: HTMLElement) {+ const editorRef = createRef<HTMLDivElement>() as RefObject<HTMLDivElement | null>+ const api: { current: ReturnType<typeof useComposerUndo> | null } = { current: null }++ editorRef.current = editor as HTMLDivElement++ const Harness = () => {+ api.current = useComposerUndo({ editorRef, syncDraftFromEditor: () => editor.textContent ?? '' })++ return null+ }++ render(<Harness />)++ return api+}++function menuLabels(): string[] {+ return screen.queryAllByRole('menuitem').map(item => item.textContent ?? '')+}++beforeEach(() => {+ // jsdom has no editing commands; this stands in for Chromium's insertText on+ // the live selection, which is all the app asks of it.+ document.execCommand = vi.fn((command: string, _ui?: boolean, value?: string) => {+ const range = window.getSelection()?.getRangeAt(0)++ if (command !== 'insertText' || !range) {+ return false+ }++ range.deleteContents()+ range.insertNode(document.createTextNode(value ?? ''))+ range.startContainer.parentElement?.normalize()++ return true+ }) as typeof document.execCommand+ render(+ <MemoryRouter>+ <AppContextMenu />+ </MemoryRouter>+ )+})++afterEach(() => {+ disposers.splice(0).forEach(dispose => dispose())+ $contextMenu.set(null)+ cleanup()+ document.body.innerHTML = ''+ window.getSelection()?.removeAllRanges()+})++describe('composer context-menu contribution area', () => {+ it('offers plugin items on the composer and never on any other editable', async () => {+ const items = vi.fn(() => [{ label: 'Plugin row', onSelect: vi.fn() }])++ plugin('alpha', items)++ const settingsField = document.createElement('input')++ document.body.appendChild(settingsField)+ fireEvent.contextMenu(settingsField)++ expect(await screen.findByText('Paste')).toBeTruthy()+ expect(screen.queryByText('Plugin row')).toBeNull()+ expect(items).not.toHaveBeenCalled()++ act(() => $contextMenu.set(null))++ const editor = composer('teh quick fox')++ select(editor, 1)+ fireEvent.contextMenu(editor)++ expect(await screen.findByText('Plugin row')).toBeTruthy()+ })++ it('hands a provider only the word under the caret and the composer selection', async () => {+ const seen: ComposerContextMenuContext[] = []++ plugin('alpha', context => {+ seen.push(context)++ return []+ })++ const editor = composer('teh quick fox')++ select(editor, 1)+ fireEvent.contextMenu(editor)+ await screen.findByText('Paste')++ expect(seen[0]).toEqual({ selection: '', word: 'teh' })+ expect(Object.keys(seen[0]).sort()).toEqual(['selection', 'word'])++ act(() => $contextMenu.set(null))+ select(editor, 4, 9)+ fireEvent.contextMenu(editor)+ await screen.findByText('Paste')++ expect(seen.at(-1)).toEqual({ selection: 'quick', word: 'quick' })+ })++ it('merges plugins in a deterministic order, caps each one, and isolates a throwing provider', async () => {+ plugin('zeta', () => Array.from({ length: 8 }, (_, index) => ({ label: `zeta ${index + 1}`, onSelect: vi.fn() })))+ plugin('broken', () => {+ throw new Error('plugin bug')+ })+ plugin('alpha', () => [+ { label: ' Fix\u0000 this\n ', onSelect: vi.fn() },+ { label: 42 as unknown as string, onSelect: vi.fn() },+ { label: 'No callback' } as unknown as ComposerContextMenuItem+ ])++ const editor = composer('teh quick fox')++ select(editor, 1)+ fireEvent.contextMenu(editor)+ await screen.findByText('Paste')++ const labels = menuLabels()+ const pluginLabels = labels.slice(0, labels.indexOf(labels.find(label => label.startsWith('Cut'))!))++ expect(pluginLabels).toEqual(['Fix this', 'zeta 1', 'zeta 2', 'zeta 3', 'zeta 4', 'zeta 5', 'zeta 6'])+ })++ it('runs an item after the menu closed and lets it replace only the right-clicked word, once', async () => {+ let action: ComposerContextMenuAction | null = null+ let menuOpenDuringSelect: boolean | null = null++ plugin('alpha', context => [+ {+ label: `Replace ${context.word}`,+ onSelect: received => {+ menuOpenDuringSelect = $contextMenu.get() !== null+ action = received+ }+ }+ ])++ const editor = composer('teh quick fox')++ select(editor, 1)+ fireEvent.contextMenu(editor)+ fireEvent.click(await screen.findByText('Replace teh'))++ await waitFor(() => expect(action).not.toBeNull())+ expect(menuOpenDuringSelect).toBe(false)+ expect(document.activeElement).toBe(editor)+ expect(action!.word).toBe('teh')++ expect(action!.replaceWord('the')).toBe(true)+ expect(editor.textContent).toBe('the quick fox')+ expect(action!.replaceWord('then')).toBe(false)+ expect(editor.textContent).toBe('the quick fox')+ })++ it("puts a replacement on the composer's own undo stack", async () => {+ let action: ComposerContextMenuAction | null = null++ plugin('alpha', () => [{ label: 'Fix', onSelect: received => void (action = received) }])++ const editor = composer('teh quick fox')+ const undo = mountUndo(editor)++ select(editor, 1)+ fireEvent.contextMenu(editor)+ fireEvent.click(await screen.findByText('Fix'))+ await waitFor(() => expect(action).not.toBeNull())++ expect(action!.replaceWord('the')).toBe(true)+ expect(editor.textContent).toBe('the quick fox')++ act(() => void undo.current!.undo())++ expect(editor.textContent).toBe('teh quick fox')+ })++ it('refuses a replace once the composer text under the word has changed', async () => {+ let action: ComposerContextMenuAction | null = null++ plugin('alpha', () => [{ label: 'Later', onSelect: received => void (action = received) }])++ const editor = composer('teh quick fox')++ select(editor, 1)+ fireEvent.contextMenu(editor)+ fireEvent.click(await screen.findByText('Later'))+ await waitFor(() => expect(action).not.toBeNull())++ editor.textContent = 'something else entirely'++ expect(action!.replaceWord('the')).toBe(false)+ expect(editor.textContent).toBe('something else entirely')+ })++ it("drops a plugin's items when the plugin unloads, even from an open menu", async () => {+ plugin('alpha', () => [{ label: 'Plugin row', onSelect: vi.fn() }])++ const editor = composer('teh quick fox')++ select(editor, 1)+ fireEvent.contextMenu(editor)+ expect(await screen.findByText('Plugin row')).toBeTruthy()++ act(() => disposers.splice(0).forEach(dispose => dispose()))++ await waitFor(() => expect(screen.queryByText('Plugin row')).toBeNull())+ expect(screen.getByText('Paste')).toBeTruthy()+ })+})diff --git a/apps/desktop/src/app/context-menu/composer-menu.ts b/apps/desktop/src/app/context-menu/composer-menu.tsnew file mode 100644index 00000000000..41cb3630d6e--- /dev/null+++ b/apps/desktop/src/app/context-menu/composer-menu.ts@@ -0,0 +1,258 @@+/**+ * The composer's context-menu contribution area, app side.+ *+ * Plugins contribute DATA (`composer.contextMenu` → `ComposerContextMenuProvider`);+ * the app owns everything else: it decides the click landed on a composer,+ * captures the word and selection there, hands a provider only those two+ * strings, orders and caps the rows, renders them with its own menu item, and+ * runs the chosen row after the menu closed. The live `Range` and the editor+ * element never leave this module — the only edit a plugin can make through it+ * is replacing the exact word the user right-clicked, once.+ */++import type {+ ComposerContextMenuAction,+ ComposerContextMenuContext,+ ComposerContextMenuItem,+ ComposerContextMenuProvider+} from '@/app/chat/composer/contrib'+import { recordComposerUndoPoint } from '@/app/chat/composer/hooks/use-composer-undo'+import { RICH_INPUT_SLOT } from '@/app/chat/composer/rich-editor'+import type { Contribution } from '@/contrib/types'++/** Rows one plugin may put in the menu — the app's own spell-check section is+ * five suggestions plus "Add to dictionary". */+export const COMPOSER_CONTEXT_MENU_ITEM_CAP = 6++const LABEL_MAX = 80+const REPLACEMENT_MAX = 200+const SELECTION_MAX = 2000+const WORD_MAX = 64++// C0/C1 controls and the bidi overrides/isolates a label could use to dress up+// as a different row.+const UNSAFE_LABEL_CHARS = /[\p{Cc}\u202a-\u202e\u2066-\u2069]/gu+const CONTROL_CHARS = /\p{Cc}/u+const WORD_CHAR = /[\p{L}\p{M}\p{N}'\u2019-]/u+const WORD_EDGE = /['\u2019-]/++/** The app-held half of a composer right-click. `context` is all a provider+ * ever sees; `editor` and `wordRange` stay here. */+export interface ComposerMenuTarget {+ context: ComposerContextMenuContext+ editor: HTMLElement+ wordRange: Range | null+}++/** One rendered row: the app's label and a runner that builds the action. */+export interface ComposerMenuRow {+ disabled: boolean+ key: string+ label: string+ run: () => void+}++/** The word around a collapsed caret, or at a selection's start. A caret sits+ * on a boundary between characters, so step to the nearest word character+ * first; otherwise the word found depends on which side of a gap the caret+ * happened to land. */+function wordRangeAt(selected: Range): Range | null {+ const node = selected.startContainer++ if (node.nodeType !== Node.TEXT_NODE) {+ return null+ }++ const text = node.nodeValue ?? ''+ const isWord = (index: number) => WORD_CHAR.test(text[index] ?? '')+ let start = Math.min(selected.startOffset, text.length)++ if (!isWord(start)) {+ start = isWord(start - 1) ? start - 1 : start+ }++ if (!isWord(start)) {+ return null+ }++ let end = start++ while (start > 0 && isWord(start - 1)) {+ start--+ }++ while (end < text.length && isWord(end)) {+ end+++ }++ // Quotes and dashes join a word's inside ("don't", "re-run"), never its edges.+ while (start < end && WORD_EDGE.test(text[start])) {+ start+++ }++ while (end > start && WORD_EDGE.test(text[end - 1])) {+ end--+ }++ if (end === start || end - start > WORD_MAX) {+ return null+ }++ const range = document.createRange()++ range.setStart(node, start)+ range.setEnd(node, end)++ return range+}++/** Capture the right-click when (and only when) it landed in a composer —+ * the main input or the message-edit composer, both marked by the rich+ * input slot. Any other editable (settings fields, API keys, dialogs)+ * resolves to null and contributes nothing. */+export function captureComposerMenuTarget(editable: HTMLElement | null): ComposerMenuTarget | null {+ if (!editable || editable.dataset.slot !== RICH_INPUT_SLOT) {+ return null+ }++ const selection = window.getSelection()+ const selected = selection?.rangeCount ? selection.getRangeAt(0) : null++ const inside = Boolean(+ selected && editable.contains(selected.startContainer) && editable.contains(selected.endContainer)+ )++ const wordRange = inside && selected ? wordRangeAt(selected) : null++ return {+ context: Object.freeze({+ selection: inside && selected ? selected.toString().slice(0, SELECTION_MAX) : '',+ word: wordRange ? wordRange.toString() : null+ }),+ editor: editable,+ wordRange+ }+}++function safeLabel(raw: unknown): null | string {+ if (typeof raw !== 'string') {+ return null+ }++ const label = raw.replace(UNSAFE_LABEL_CHARS, ' ').replace(/\s+/g, ' ').trim()++ return label ? (label.length > LABEL_MAX ? `${label.slice(0, LABEL_MAX - 1)}…` : label) : null+}++/** The action an item's `onSelect` receives: the same context plus a replace+ * of the right-clicked word, refused once the composer no longer holds that+ * word in that place — which a first replace itself ends, so it works once. */+function composerMenuAction(target: ComposerMenuTarget): ComposerContextMenuAction {+ const { context, editor, wordRange } = target++ const replaceWord = (text: string): boolean => {+ const stale =+ !wordRange ||+ !editor.isConnected ||+ !editor.contains(wordRange.startContainer) ||+ wordRange.toString() !== context.word++ if (stale || typeof text !== 'string' || !text || text.length > REPLACEMENT_MAX || CONTROL_CHARS.test(text)) {+ return false+ }++ editor.focus()++ const selection = window.getSelection()++ selection?.removeAllRanges()+ selection?.addRange(wordRange)++ // The composer owns ⌘Z, and Chromium's editing command below never reaches+ // its stack on its own: bank the pre-edit state so the swap is undoable.+ recordComposerUndoPoint(editor)++ // Chromium's own editing command, so the composer's input handling sees a+ // normal edit (draft sync, caret after the new word).+ return document.execCommand('insertText', false, text)+ }++ return Object.freeze({ ...context, replaceWord })+}++const byCodePoint = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0)++function rowFor(item: unknown, key: string, target: ComposerMenuTarget, source: string): ComposerMenuRow | null {+ const candidate = item as Partial<ComposerContextMenuItem> | null+ const label = safeLabel(candidate?.label)+ const onSelect = candidate?.onSelect++ if (!label || typeof onSelect !== 'function') {+ return null+ }++ return {+ disabled: Boolean(candidate?.disabled),+ key,+ label,+ run: () => {+ try {+ onSelect(composerMenuAction(target))+ } catch (error) {+ console.warn(`[composer.contextMenu] ${source} item failed`, error)+ }+ }+ }+}++/**+ * Resolve the area's contributions into menu sections: one per plugin, plugins+ * in code-point order of their source id (then contribution id) — never load+ * order or a plugin-chosen `order` — and at most+ * `COMPOSER_CONTEXT_MENU_ITEM_CAP` rows per plugin across all its+ * contributions. A provider that throws or returns garbage contributes nothing+ * and leaves every other row standing.+ */+export function resolveComposerMenuSections(+ contributions: readonly Contribution[],+ target: ComposerMenuTarget+): ComposerMenuRow[][] {+ const bySource = new Map<string, ComposerMenuRow[]>()++ const ordered = [...contributions].sort(+ (a, b) => byCodePoint(a.source ?? 'core', b.source ?? 'core') || byCodePoint(a.id, b.id)+ )++ for (const contribution of ordered) {+ const source = contribution.source ?? 'core'+ const rows = bySource.get(source) ?? []+ const provider = contribution.data as Partial<ComposerContextMenuProvider> | undefined++ bySource.set(source, rows)++ if (rows.length >= COMPOSER_CONTEXT_MENU_ITEM_CAP || typeof provider?.items !== 'function') {+ continue+ }++ let items: unknown++ try {+ items = provider.items(target.context)+ } catch (error) {+ console.warn(`[composer.contextMenu] ${source} provider failed`, error)++ continue+ }++ for (const [index, item] of (Array.isArray(items) ? items : []).entries()) {+ const row =+ rows.length < COMPOSER_CONTEXT_MENU_ITEM_CAP && rowFor(item, `${contribution.id}:${index}`, target, source)++ if (row) {+ rows.push(row)+ }+ }+ }++ return [...bySource.values()].filter(rows => rows.length > 0)+}diff --git a/apps/desktop/src/app/context-menu/target.ts b/apps/desktop/src/app/context-menu/target.tsindex f71fb60d3fc..3eb02202a14 100644--- a/apps/desktop/src/app/context-menu/target.ts+++ b/apps/desktop/src/app/context-menu/target.ts@@ -7,7 +7,12 @@* image section still appears because the target carries both.*/+import { captureComposerMenuTarget, type ComposerMenuTarget } from './composer-menu'+export interface ContextMenuDomTarget {+ /** Set only when the click landed in a composer: what the composer+ * context-menu area may see and act on (see `composer-menu.ts`). */+ composer: ComposerMenuTarget | null/** The enclosing dialog content node, when the click landed inside one. */dialogPortalContainer: HTMLElement | null/** The clicked editable, when the click landed in one. */@@ -44,10 +49,12 @@ export function resolveDomTarget(element: Element | null): ContextMenuDomTargetconst dialogContent = element?.closest('[data-slot="dialog-content"]')const image = element?.closest('img')const linkUrl = anchor?.getAttribute('href')?.trim() ?? ''+ const editable = editableFrom(element)return {+ composer: captureComposerMenuTarget(editable),dialogPortalContainer: dialogContent instanceof HTMLElement ? dialogContent : null,- editable: editableFrom(element),+ editable,// A placeholder anchor is not a link the menu can act on.linkUrl: linkUrl === '#' ? '' : linkUrl,imageUrl: image instanceof HTMLImageElement ? image.currentSrc || image.src : '',diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.tsindex b266da09084..10e4ed6c2de 100644--- a/apps/desktop/src/global.d.ts+++ b/apps/desktop/src/global.d.ts@@ -349,6 +349,9 @@ declare global {/** Add a word to the spell-check dictionary of a webview guest's* session (the tag exposes no session API). */contextMenuGuestAddWord?: (payload: { webContentsId: number; word: string }) => Promise<void>+ /** Add/remove ONE validated word in this window's spell-check+ * dictionary (`host.spellcheck`); resolves main's verdict. */+ spellcheckDictionary?: (op: 'add' | 'remove', word: string) => Promise<boolean>/** Spell-check facts for the gesture that opened the current menu;* fires shortly after the DOM contextmenu event. */onContextMenuSpellcheck?: (diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 1aa33b2313e..1a126f4d201 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -119,6 +119,7 @@ import {} from './profile-request'import { sessionsHost } from './sessions'import { desktopSettings } from './settings'+import { spellcheckHost } from './spellcheck'import { $viewport, type ViewportRect } from './viewport'/** Pane, status bar and titlebar slots; see `./areas` for the mount rules. */@@ -1543,6 +1544,9 @@ export const host = {composer: composerHost,+ /** Chromium's custom spell-check dictionary, one validated word per call. */+ spellcheck: spellcheckHost,+/** Language packs: `host.i18n.registerAppLocale(id, { endonym, rtl?,* translations })` adds a whole UI language at runtime (see `sdk/i18n.ts`);* `host.i18n.languageOptions()` lists what the switcher shows. */@@ -1580,6 +1584,10 @@ export {type ComposerAtCompletionItem,type ComposerAtCompletionSource,type ComposerAttachmentProvider,+ type ComposerContextMenuAction,+ type ComposerContextMenuContext,+ type ComposerContextMenuItem,+ type ComposerContextMenuProvider,type ComposerMiddleware,type ComposerModelPillContext,type ComposerModelPillProviderdiff --git a/apps/desktop/src/sdk/spellcheck.test.ts b/apps/desktop/src/sdk/spellcheck.test.tsnew file mode 100644index 00000000000..432bb14dd24--- /dev/null+++ b/apps/desktop/src/sdk/spellcheck.test.ts@@ -0,0 +1,43 @@+import { afterEach, describe, expect, it, vi } from 'vitest'++import { host } from '@/sdk'++const desktopWindow = window as unknown as { hermesDesktop?: Partial<Window['hermesDesktop']> }++afterEach(() => {+ delete desktopWindow.hermesDesktop+})++describe('host.spellcheck dictionary verbs', () => {+ it("routes one word through the app's dictionary IPC and reports main's verdict", async () => {+ const spellcheckDictionary = vi.fn(async () => true)++ desktopWindow.hermesDesktop = { spellcheckDictionary }++ expect(await host.spellcheck.addWord('Hermes')).toBe(true)+ expect(await host.spellcheck.removeWord('Hermes')).toBe(true)++ expect(spellcheckDictionary.mock.calls).toEqual([+ ['add', 'Hermes'],+ ['remove', 'Hermes']+ ])++ spellcheckDictionary.mockResolvedValueOnce(false)++ expect(await host.spellcheck.addWord('two words')).toBe(false)+ })++ it('resolves false instead of throwing without a desktop shell or with a non-string', async () => {+ expect(await host.spellcheck.addWord('Hermes')).toBe(false)++ const spellcheckDictionary = vi.fn(async () => {+ throw new Error('older shell')+ })++ desktopWindow.hermesDesktop = { spellcheckDictionary }++ expect(await host.spellcheck.removeWord('Hermes')).toBe(false)+ expect(await host.spellcheck.addWord(42 as unknown as string)).toBe(false)+ expect(spellcheckDictionary).toHaveBeenCalledTimes(1)+ })+})diff --git a/apps/desktop/src/sdk/spellcheck.ts b/apps/desktop/src/sdk/spellcheck.tsnew file mode 100644index 00000000000..c78cd5a0659--- /dev/null+++ b/apps/desktop/src/sdk/spellcheck.ts@@ -0,0 +1,28 @@+// `host.spellcheck`: Chromium's custom spell-check dictionary, one word at a+// time. The word gate and the session call live in main+// (`electron/spellcheck-dictionary-ipc.ts`); this side only forwards and turns+// every missing-capability case into `false`.++async function dictionary(op: 'add' | 'remove', word: string): Promise<boolean> {+ const bridge = typeof window === 'undefined' ? undefined : window.hermesDesktop++ if (typeof word !== 'string' || !bridge?.spellcheckDictionary) {+ return false+ }++ try {+ return (await bridge.spellcheckDictionary(op, word)) === true+ } catch {+ // A renderer bundle can outlive an older shell with no handler.+ return false+ }+}++export const spellcheckHost = {+ /** Teach the app's spell checker one word (letters, marks, digits, inner+ * `'`/`-`; ≤ 64 chars) so Chromium stops underlining it everywhere.+ * Resolves false when main refuses the word or the shell can't. */+ addWord: (word: string): Promise<boolean> => dictionary('add', word),+ /** Forget one word added earlier (same gate). */+ removeWord: (word: string): Promise<boolean> => dictionary('remove', word)+}diff --git a/website/docs/developer-guide/desktop-plugin-sdk.md b/website/docs/developer-guide/desktop-plugin-sdk.mdindex 28c84ca79e6..b9bd9aa3680 100644--- a/website/docs/developer-guide/desktop-plugin-sdk.md+++ b/website/docs/developer-guide/desktop-plugin-sdk.md@@ -475,7 +475,7 @@ whole migration.### Composer extensions`COMPOSER_AREAS` (`top`, `bottom`, `underside`, `leading`, `actions`,-`attachments`, `middleware`) let a plugin add controls around the message+`attachments`, `middleware`, `contextMenu`) let a plugin add controls around the messagecomposer, provide an attachment source, or transform a draft before it is sent(`ComposerMiddleware` with a `handler(draft) => draft | null`). `top` is abanner strip above the input and `bottom` a row below the input grid, both@@ -484,6 +484,89 @@ composer with no chrome of its own — the seat for a suggestion pill or a statuhint that should sit outside the input frame (the next-prompt plugin renders its"next prompt" pill there).+### Composer context menu — rows on a right-click in the input {#composer-context-menu}++`COMPOSER_AREAS.contextMenu` adds rows to the menu the app opens when the user+right-clicks **the composer** (the main input or the message-edit composer).+A contribution is data: an `items(context)` function the app calls once per+right-click. The app renders the rows with its own menu items, so they focus,+style and keyboard-navigate like the built-in ones; a plugin never touches the+menu's DOM.++```javascript+import { COMPOSER_AREAS, host } from '@hermes/plugin-sdk'++ctx.register({+ id: 'spelling',+ area: COMPOSER_AREAS.contextMenu,+ data: {+ // context = { word: string | null, selection: string } — nothing else.+ items: ({ word }) => {+ if (!word || isKnown(word)) return []++ return [+ ...suggest(word).slice(0, 5).map(suggestion => ({+ label: suggestion,+ // Runs after the menu closed, with the caret back in the composer.+ onSelect: action => action.replaceWord(suggestion)+ })),+ { label: ctx.i18n.t('addToDictionary'), onSelect: () => void host.spellcheck.addWord(word) }+ ]+ }+ }+})+```++```ts+interface ComposerContextMenuContext {+ word: string | null // the word under the caret (or at the selection's start)+ selection: string // the selected composer text, '' when the caret is collapsed+}++interface ComposerContextMenuItem {+ label: string // plain text: controls/bidi overrides stripped, clamped to 80 chars+ disabled?: boolean+ onSelect: (action: ComposerContextMenuAction) => void+}++interface ComposerContextMenuAction extends ComposerContextMenuContext {+ replaceWord(text: string): boolean // one line, <= 200 chars+}+```++**What the app owns.** It decides the click landed on a composer; any other+field (Settings inputs, API keys, dialogs, the transcript) never consults a+provider. A provider sees two strings — the word and the composer selection+(capped at 2,000 chars) — never the element, a `Range` or other text.+`replaceWord` is the only edit it offers: it replaces exactly the word the user+right-clicked through Chromium's own editing command, works once, and returns+`false` (changing nothing) when the composer no longer holds that word in that+place. For anything else, use [`host.composer`](#composer-draft-api--read-and-write-the-live-input).++**Arbitration.** Each plugin gets its own section, placed after the app's own+spell-check rows and before Cut / Copy / Paste. Plugins are ordered by plugin id+(code-point order, then contribution id); load order and `order` play no part.+A plugin shows at most **six rows** across all its contributions; extra rows are+dropped. A provider that throws, returns a non-array, or a row without a string+label or an `onSelect` function contributes nothing and leaves every other row+standing; a throwing `onSelect` is logged, not raised. Rows registered through+`ctx.register` disappear when the plugin unloads or is disabled — including+from a menu that is open at the time.++#### Spell-check dictionary — `host.spellcheck`++```ts+host.spellcheck.addWord(word: string): Promise<boolean>+host.spellcheck.removeWord(word: string): Promise<boolean>+```++Adds or removes one word in the app's Chromium spell-check dictionary, so the+red underline clears (or returns) everywhere in the app. The main process takes+only one bounded word: letters, combining marks, digits and inner `'` / `-`,+at least one letter, at most 64 characters. Anything else resolves `false`+without touching the dictionary; so does an older desktop shell. There is no+way to list or read the dictionary.+### Composer draft API — read and write the live inputFor everything the composer areas can't do — put text INTO the input, replace@@ -2122,10 +2205,10 @@ pipeline as a trust boundary.| Category | Exports ||----------|---------|-| Host | `host` (`.state.*`, `.settings`, `.notify`, `.notifyError`, `.navigate`, `.onEvent`, `.logs`, `.status`, `.restartGateway`, `.request`, `.composer`, `.sessions`, `.skills`, `.toolsets`, `.profiles`, `.pluginDecisions`) |+| Host | `host` (`.state.*`, `.settings`, `.notify`, `.notifyError`, `.navigate`, `.onEvent`, `.logs`, `.status`, `.restartGateway`, `.request`, `.composer`, `.spellcheck`, `.sessions`, `.skills`, `.toolsets`, `.profiles`, `.pluginDecisions`) || Plugin contract | `HermesPlugin`, `PluginContext`, `PluginContribution`, `PluginStorage`, `PluginOs`, `PluginPet`, `PetSayOptions`, `PetMessageTone`, `PluginAppActionId`, `PluginAppActionInfo`, `PluginRunActionResult`, `PLUGIN_APP_ACTIONS`, `PluginRestOptions`, `PluginNativeNotificationInput`, `PluginNotificationAction`, `HermesOpenTarget`, `Contribution` || Area constants | `PANES_AREA`, `ROUTES_AREA`, `SIDEBAR_NAV_AREA`, `STATUSBAR_AREAS`, `TITLEBAR_AREAS`, `WORKSPACE_PAGE_HEADER_AREA`, `PALETTE_AREA`, `KEYBINDS_AREA`, `THEMES_AREA`, `COMPOSER_AREAS`, `MODEL_MENU_ROW_AREA`, `KANBAN_CARD_AREAS`, `SESSION_ROW_AREAS`, `SIDEBAR_NAV_PREFS_AREA`, `APPEARANCE_AREAS`, `SETTINGS_PLUGINS_AREA` |-| Area payloads | `PluginSettingsPage`, `PluginSettingsSubpage` (+ `pluginSettingsHref`), `RouteContribution`, `SidebarNavContribution`, `StatusbarItem`, `TitlebarTool`, `PaletteContribution`, `KeybindContribution`, `ComposerMiddleware`, `ComposerAttachmentProvider`, `SessionRowSlotContribution`, `KanbanCardBadgeContribution` (+ `KanbanCard`, `KanbanCardBoard`, `KanbanCardBadge`, `KanbanCardBadgeTone`, `KANBAN_CARD_BADGE_HUES`, `KANBAN_CARD_BADGE_LIMITS`), `SidebarNavPrefsContribution` |+| Area payloads | `PluginSettingsPage`, `PluginSettingsSubpage` (+ `pluginSettingsHref`), `RouteContribution`, `SidebarNavContribution`, `StatusbarItem`, `TitlebarTool`, `PaletteContribution`, `KeybindContribution`, `ComposerMiddleware`, `ComposerAttachmentProvider`, `ComposerContextMenuProvider` (+ `ComposerContextMenuItem`, `ComposerContextMenuContext`, `ComposerContextMenuAction`), `SessionRowSlotContribution`, `KanbanCardBadgeContribution` (+ `KanbanCard`, `KanbanCardBoard`, `KanbanCardBadge`, `KanbanCardBadgeTone`, `KANBAN_CARD_BADGE_HUES`, `KANBAN_CARD_BADGE_LIMITS`), `SidebarNavPrefsContribution` || React / state | `useValue`, `atom`, `computed`, `useQuery`, `useMutation`, `useQueryClient`, `queryClient`, `Contribute`, `WorkspacePageHeaderControl` || Theming | `useTheme`, `requestTheme`, `setAccentOverride`, `$accentOverride`, `retintTheme`, `themeHue`, `DesktopTheme`, `DesktopThemeColors`, plus OKLCH math (`hexToOklch`, `oklchToHex`, `oklchToSrgb255`, `mixOklab`, `maxChroma`, `hueDelta`, `normalizeHex`) and sRGB measures (`contrastRatio` — `number | null`, null for unparseable input — `readableOn`) || UI kit | `Button`, `Input`, `Textarea`, `Select*`, `Switch`, `Checkbox`, `SegmentedControl`, `Tabs*`, `Dialog*`, `ConfirmDialog`, `DropdownMenu*`, `ContextMenu*`, `Popover*`, `Tip`/`Tooltip*`, `Badge`, `Kbd`/`KbdGroup`, `SearchField`, `ScrollArea`, `Separator`, `Skeleton`, `GlyphSpinner`, `Loader`, `EmptyState`, `ErrorState`, `CopyButton`, `StatusDot`, `LogView`, `Codicon`, `DecodeText`, `SandboxedFrame` |