Files
Neil 9ef5e48f09 Plugins: add editor.readTypography and editor.typography.changed (#40736)
* feat(plugins): add editor.readTypography and editor.typography.changed

Plugins that render code next to Orca's editor had to open the private
profile database and reimplement Orca's font rules to match it. Host API 1.6
adds editor.readTypography (no capability; worker, panel and editor frames):
the font family and CSS stack, size with editor zoom, weight, line height in
px, ligatures, word wrap and minimap that the file editor resolves now.
editor.typography.changed carries the same values after a settings write or
an editor zoom changes them; it is the first event that needs no capability.

The pure resolution (editor typography, editor zoom, monospace font stack)
moves to src/shared so main and the renderer use one implementation.

* fix(plugins): keep editor typography resolution from throwing in main

A hand-edited profile with a non-string font family made the shared resolver
throw, which the main-process watcher would surface at startup and on every
settings write. Font values are now type-checked, the watcher catches and
logs, and it reads live settings so a write without listeners cannot leave the
event payload stale. Over-long font families are cut to the schema bound
instead of failing every read. Regenerates the testing runtime.
2026-11-10 03:38:47 -08:00

2.7 KiB

Events

Worker events

List each in contributes.events ({ "on": "<event>" }), with main, the trusted-worker profile and the capability shown; then orca.events.on(event, handler) in activate(orca) returns { dispose() }. Payloads:

  • workspace.created (capability workspace:read; since 1.4.245): A worktree workspace was created. { workspaceId: string; kind: "worktree" | "folder"; path: string; branch: string }
  • workspace.removed (capability workspace:read; since 1.4.245): A worktree workspace was removed. { workspaceId: string; kind: "worktree" | "folder"; path: string }
  • agent.status.changed (capability agent:read; since 1.4.160): An agent in a terminal pane changed status; workspaceId is null when Orca cannot tie the pane to a workspace, and terminalId names its terminal when Orca lists it. { workspaceId: string | null; paneKey: string; terminalId?: string; title?: string; state: "working" | "blocked" | "waiting" | "done"; receivedAt: number; mainAgent?: { state: "working" | "blocked" | "waiting" | "done"; outcome?: "success" | "failure" | "cancellation" | "superseded" | "interruption" | "unconfirmed"; stateStartedAt: number } }
  • workspace.changed (capability workspace:read; since 1.4.246): The focused workspace changed, or its terminals were opened, closed or renamed; context is what workspace.readContext now answers. Each new subscriber first gets the current context. { context: { branch: string; displayName: string; terminals: { id: string; title?: string }[] } | null }
  • editor.typography.changed (no capability; since 1.4.256): What Orca's file editor uses changed (a setting or the editor zoom); the payload is what editor.readTypography now answers. Needs no capability. { fontFamily: string; cssFontFamily: string; fontSize: number; fontWeight: string; lineHeight: number; fontLigatures: boolean; wordWrap: "on" | "off"; minimap: boolean }

Frame events (orca.on(event, handler) in HTML panels and custom editors)

  • theme: FrameTheme: The --orca-* variables and the light/dark class on <html> already changed.
  • 'editor.document': EditorDocument: Custom editors: a new document; orca.document.onDidChange is the usual way to listen.
  • 'editor.flush': undefined: Custom editors: post pending edits before a save; Orca waits for a returned promise.

Components panel events (on(event, handler) from orca)

  • theme: { colorScheme: 'light' | 'dark' }
  • Every worker event above, with the same payload and capability; a panel needs no contributes.events entry, it subscribes while it is open. HTML panels get them on orca.on too.