Skip to content

feat(themes): background images for app themes - #36589

Merged
nwparker merged 1 commit into
mainfrom
nwparker/theme-window-background-image
Nov 1, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/theme-window-background-image

Conversation

@nwparker

@nwparker nwparker commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61
Prod 25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​484 $\color{#cf222e}{\Huge{\mathbf{−}}}$​80 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​404

Restacked onto main (it was stacked on #36580, which is held for perf work). The only things it used from #36580 are now carried here, without the window material:

See "Restack" below.

Ported from #36580

These are keyed only on data-theme-background; #36580 re-adds the window material when it rebases.

Left in #36580: the window material itself, the Reduce Visual Effects setting and hook, and the modal-blur and floating-surface changes.

Summary

App theme files can now declare one background image:

{
  "base": "dark",
  "tokens": { "--background": "#14161c", "--foreground": "#e8e6f0" },
  "background": { "path": "images/dusk.webp", "opacity": 0.6, "size": "cover", "position": "center" }
}

Root cause: plugin themes could only set color tokens. The value check refuses url(), and nothing in the paint path could place an image under translucent surfaces. This PR adds both halves. The first is a validated and safely served image. The second, taken from #36580, is that terminals paint their translucent background exactly once over whatever is behind them.

Design

  • Schema (plugin-theme-background.ts):
    • path must be inside the plugin (pluginRelativePathSchema).
    • opacity is 0–1, default 1.
    • size is cover, contain or tile.
    • position is center, top, bottom, left or right.
    • validate:plugin is strict and refuses unknown keys.
    • At runtime a malformed or newer background is dropped and the theme still applies. Older Orca already strips the unknown key, so the theme loads without the image.
  • Image rules: a new theme-background kind in PLUGIN_IMAGE_RULES: PNG/JPEG/WebP only (no SVG), static, at least 640×360, at most 2 MB.
  • Delivery reuses the existing safe plugin image mechanism (the one behind plugin icons, covers and screenshots), not raw file URLs:
    • The theme registry hands the renderer an orca-plugin-image://installed/<key>/<contentHash|dev>/theme-<index> URL.
    • The protocol handler resolves theme-<index> back to the theme file and checks the bytes on every serve. It goes through the same contained read and header and rule check, now shared as readCheckedPluginImage; the protocol's own inline copy was removed. A bad image simply 404s and the theme still applies.
    • Registration deliberately does not read the image. Doing so would read up to 2 MB per theme for themes nobody selected.
    • validate:plugin reports a missing image file.
    • The renderer never sees a path, and the existing CSP already allows only this scheme for plugin images.
    • Dev plugins are served no-store so authors see image edits. Legacy 32-character install hashes are accepted, and a malformed registration background drops only the image.
  • Paint: one static layer, never blurred.
    • lib/theme-background.ts sets four custom properties plus data-theme-background.
    • main.css paints the image as the body's background, with a --background veil sized by opacity. No extra element, no backdrop-filter, no animation.
    • Only translucent terminals reveal it, at the user's Background Opacity.
    • Non-terminal tab bodies, split gutters and the sidebar seam keep an opaque base, with rules keyed on data-theme-background.
    • Unfocused splits skip their 0.95 opacity dim while a backdrop is active, so the image never bleeds through chrome.
  • Only when it can show: the image layer is set only while Background Opacity is below 1 and the OS Reduce Transparency setting is off. The Reduce Visual Effects setting joins this gate when feat(window): working background opacity and blur on macOS, Windows and Linux #36580 lands. With opaque terminals there is no decode and no transparent terminal rendering, and split dimming stays.
  • Single paint without a window material: terminals switch to the paint-once layering whenever a theme image is active. A tiny useThemeBackgroundStore flag re-runs the terminal appearance when the image arrives (plugin themes load after first paint).
  • Zero cost when unused: no attribute, no custom properties, no extra paint, and the terminal path is unchanged.

Closes #7714
Refs #19301 (background imagery; app-wide transparency is not in scope)

Builds on #8870 by @chldbwnstm, #15836 by @cunicopia-dev, #17596 by @chris-albert, #27485 by @mark22013333 and #15525 by @Sylen00 (and the #15524 discussion). Unlike those, the image comes from a theme plugin with validated bytes rather than an arbitrary user file path, and it is one static layer rather than a per-pane or blurred texture.

Visual proof

The dev theme plugin Dusk (image opacity 0.6 dark / 0.45 light). Background Opacity is 0.75, the window material is off (opaque window), and the split shows a terminal next to a markdown editor. The image shows only under the terminal; the editor, sidebars and chrome stay opaque. Before this PR the same theme file renders with no image (the field is ignored).

Dark
dark

Light
light

Layers painting the terminal background, from DOM inspection: the split root at rgba(40,44,52,0.75). The xterm layers are rgba(…, 0), and the body is --background plus the image.

Review

One Opus review and Codex (gpt-6.1-sol, xhigh). Fixed:

  • The image was activated even with opaque terminals (decode, transparent xterm, lost split dimming). It is now gated on opacity < 1 and reduce-effects, and the gating is reactive (verified: the attribute and the xterm alpha toggle with the opacity setting).
  • The registration-time full read, a possible main-process memory spike, now happens only at serve.
  • validate:plugin now checks that the image file exists.
  • The sidebar seam image slit is fixed.
  • A future style value no longer drops the image: per-field tolerance.
  • Dev images are no longer cached forever: no-store.
  • Legacy 32-character install hashes made the whole theme vanish. They are now accepted, and the registration background is tolerant.
  • theme-007 slot aliases are refused.
  • Backdrop helpers moved to lib/window-backdrop.ts, and a type alias was dropped.

Not changed: indexOf(contribution) relies on the registry passing the manifest's own contribution objects (it does); image bytes are not checked by validate:plugin (its reader is text-only).

Merge-risk assessment

Low (was Low–medium). Phase 2 rendered it on a real Linux desktop (GNOME/Mutter X11, comment): the image appears under translucent terminals only, the chrome stays opaque, and the protocol serves the theme-<index> slot. Combined with the earlier macOS CDP run and the unit tests for strict/tolerant parsing and the protocol, the remaining risk was in the restack itself, and it has been re-verified (see Restack).

  • Additive schema and image kind. Older Orca and the web client ignore the field; the web client cannot load orca-plugin-image, so it simply shows no image.
  • Main-process work is one contained read plus a header check per theme registration and per image request. The cache is immutable per content hash; dev plugins use dev, as other plugin images already do.
  • The renderer change is scoped to data-theme-background and the backdrop rules (which feat(window): working background opacity and blur on macOS, Windows and Linux #36580 will extend to data-window-material).
  • Shared hot files are touched additively:
    • plugin-theme-artifact.ts: one optional field each in the strict, tolerant and registration schemas, plus the parse output.
    • main.css: one rule, and the backdrop selectors now also match data-theme-background.

Negative user-facing tradeoffs

  • The image is invisible until the user lowers terminal Background Opacity below 1. By design only translucent surfaces show it; a theme cannot force translucency. The OS Reduce Transparency setting also hides it (and Reduce Visual Effects, once feat(window): working background opacity and blur on macOS, Windows and Linux #36580 lands).
  • The image is not shown in the paired web client.
  • While a theme image is active, unfocused split groups are not dimmed, the same tradeoff feat(window): working background opacity and blur on macOS, Windows and Linux #36580 makes for the window material.
  • No image on startup until plugin themes load. The cached startup paint carries tokens only, so the image appears a moment later on launch.
  • A broken image is not reported in the app. The terminal stays translucent over the plain theme background; authors find out through validate:plugin (missing file) or by noticing the image doesn't appear.

Validation

  • pnpm tc passes.
  • oxlint and oxfmt pass on the changed files.
  • pnpm generate:plugin-schemas was run; the hand-written docs/reference/plugin-themes.md has a new "Background image" section.
  • pnpm test covers:
    • plugin-theme-artifact.test.ts, extended: strict acceptance and rejection, and runtime drop without failing the theme;
    • plugin-image-protocol.test.ts, extended: the theme-<index> slot is served and an undersized image or missing slot returns 404;
    • all of src/main/plugins/contributions/, src/shared/plugins/images/ and components/tab-group/;
    • document-theme.test.ts, use-document-appearance.test.tsx and terminal-appearance.test.ts.
  • Exercised in the running app (ORCA_BACKGROUND_LAUNCH=1, CDP port 9317, throwaway profile, folder workspace). A local dev theme plugin was consented through window.api.plugins, and its dark and light slots were selected:
    • The registration carried orca-plugin-image://installed/wswindow.dusk/dev/theme-0.
    • Toggling Background Opacity 0.75 → 1 → 0.75 removed and restored data-theme-background and the alpha-0 xterm background live.
    • The body computed the veil plus url(…).
    • The terminal stack showed a single paint, and the editor group stayed opaque.
  • Phase 2: fresh clone run visibly on openclaw (GNOME X11) with a dev theme plugin; real X11 screenshot captured.

Restack (onto main, without #36580)

#36580 depended on nothing from this PR, but this PR used five small pieces of #36580. They now live here, cut down to the theme image:

lib/window-backdrop.ts stays as the single place that answers "does something paint under terminals"; today the answer is the theme image only. When #36580 rebases, it adds activeWindowMaterial() !== 'off' there and [data-window-material] to the three CSS selectors. Its expected conflicts are main.css, TabGroupPanel.tsx, terminal-appearance.ts and use-document-appearance.ts. The patches and hooks are identical, so they apply cleanly. All conflicts are mechanical.

Re-verified on the restacked head in the real app: e2e build, ORCA_BACKGROUND_LAUNCH=1, hidden.

  • With an image at Background Opacity 0.7: the image shows under the terminal; the split root is rgba(40, 44, 52, 0.7) and the xterm viewport is rgba(0, 0, 0, 0) (one paint); chrome stays opaque.
  • With no image, or with an image theme at Background Opacity 1: there is no data-theme-background and no --orca-theme-background-* property.

Perf

Measured in the hidden app with CDP Performance.getMetrics and a devtools.timeline trace, alternating image and no-image runs on the same build (e2e build, macOS, hidden window):

  • Zero cost when unused: with no image, or with an image theme while Background Opacity is 1, the document has no attribute and no custom property, and terminals keep opaque rendering. The CSS rules are all gated on :root[data-theme-background].
  • Terminal streaming (seq 1 40000, 6 s window): main-thread TaskDuration was 0.15 s / 0.06 s with the image and 0.05 s / 0.05 s without. DOM paint was 1.4–1.7 ms with the image and 0.3 ms without. Both are negligible; xterm draws on its own canvas.
  • Main process: registration builds a URL and reads nothing. Each image request does one contained read of at most 2 MB plus a header check. That happens once per window load per URL, cached immutable per content hash; dev plugins use no-store.
  • No backdrop-filter, no animation: the image is one static body layer.

Review of the restack (Opus + Codex gpt-6.1-sol, xhigh)

Fixed:

  • Codex P1: the WebGL clear/blend patch was missing from the first restack. It is ported above.
  • Codex P2: the renderer used the theme registration as received. A newer host sending, for example, size: "stretch" or a non-plugin URL could reach applyThemeBackground and CSS. use-document-appearance.ts now re-parses through tolerantPluginThemeBackgroundRegistration, so anything this build can't paint becomes "no image".
  • Opus: the unused data-reduce-effects hook was dropped, and the duplicated media-query logic was folded into useMediaQuery.

Known, not changed:

  • With a dev plugin, editing only the image bytes doesn't refresh until the theme file or Orca reloads, because the dev URL stays the same. This affects authoring only.
  • The iOS Hangul preedit overlay takes its background from the xterm theme, which is transparent over an image. That is cosmetic and limited to that IME path.

Re-measured on the final head: zero cost with no image (no attribute, no properties). With the image, terminal streaming main-thread time was 0.11 s / 0.04 s; without it, 0.06 s / 0.04 s.

@nwparker
nwparker force-pushed the nwparker/theme-window-material branch from 29c953c to 4edcb65 Compare October 31, 2026 04:52
@nwparker
nwparker force-pushed the nwparker/theme-window-background-image branch from 66aa369 to 1cfc503 Compare October 31, 2026 04:53
@nwparker
nwparker force-pushed the nwparker/theme-window-material branch from 4edcb65 to 040af97 Compare October 31, 2026 05:04
@nwparker
nwparker force-pushed the nwparker/theme-window-background-image branch 2 times, most recently from f7f115b to 9a730d4 Compare October 31, 2026 05:17
@nwparker

nwparker commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Phase 2: background image on a real Linux desktop

On openclaw (Ubuntu, GNOME/Mutter X11, visible window), I built a fresh clone of this branch and loaded a dev theme plugin with background: { path: 'images/dusk.webp', opacity: 0.6 }. Background Opacity was 0.75 and the window material was off.

  • The registration carried orca-plugin-image://installed/wswindow.dusk/dev/theme-0. The protocol served it, and the image painted under the translucent terminal only. The sidebars, file panel and status bar stayed opaque. Real X11 screenshot below.
  • With the window material on (Translucent) together with a theme image, the image is the backdrop: it covers the desktop, which is expected because the image is opaque.
  • The same flow ran on macOS (CDP) before. No Windows-specific code path is involved, since it is renderer CSS plus the shared image protocol.

(screenshot removed: contained real product data)

@nwparker
nwparker force-pushed the nwparker/theme-window-background-image branch from 9a730d4 to 9fdf1db Compare October 31, 2026 23:52
@nwparker
nwparker requested a review from Jinwoo-H as a code owner October 31, 2026 23:52
@nwparker
nwparker changed the base branch from nwparker/theme-window-material to main October 31, 2026 23:52
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 97a0ea52-eb5f-45c9-b380-f9ff79e51a1b
Commits

Reviewing files that changed from the base of the PR and between 6fb044b and 9fdf1db.

Files selected for processing: 24
  • docs/reference/plugin-themes.md
  • src/main/plugins/contributions/plugin-theme-background-image.ts
  • src/main/plugins/contributions/plugin-theme-registries.ts
  • src/main/plugins/plugin-image-protocol.test.ts
  • src/main/plugins/plugin-image-protocol.ts
  • src/main/plugins/plugin-image-read.ts
  • src/renderer/src/app-shell/use-document-appearance.ts
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/tab-group/TabGroupPanel.tsx
  • src/renderer/src/components/tab-group/TabGroupSplitLayout.tsx
  • src/renderer/src/components/terminal-pane/terminal-appearance.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/hooks/use-media-query.ts
  • src/renderer/src/hooks/use-reduce-visual-effects.ts
  • src/renderer/src/lib/pane-manager/pane-manager-types.ts
  • src/renderer/src/lib/theme-background.ts
  • src/renderer/src/lib/window-backdrop.ts
  • src/renderer/src/store/theme-background.ts
  • src/shared/plugins/artifacts/plugin-theme-artifact.test.ts
  • src/shared/plugins/artifacts/plugin-theme-artifact.ts
  • src/shared/plugins/artifacts/plugin-theme-background.ts
  • src/shared/plugins/authoring/plugin-strict-artifact-checks.ts
  • src/shared/plugins/images/plugin-image-fields.ts
  • src/shared/plugins/images/plugin-image-url.ts
Files with no reviewable changes: 1
  • src/renderer/src/lib/pane-manager/pane-manager-types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Walkthrough

App themes can specify a bundled background image with optional opacity, size, and position settings. Orca validates image files and serves valid images through installed-image URLs. The renderer applies the selected background when terminal opacity is below 1 and visual effects are not reduced. Renderer styling and terminal appearance updates control which surfaces remain opaque and when terminals use transparency.

Merge Risk: Minimal · previous review 9fdf1

Invalid background images are omitted while the theme still applies, as documented. No identified issue needs resolution before merge beyond normal checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning [#7714] requires a user-selectable local image, opacity control, display modes including Cover, Contain, Stretch, and Center, and area selection for the editor, sidebar, terminal, or full window. The … Implement the [#7714] user-facing settings and behavior for local image selection, opacity, all required display modes including Stretch, and selectable target areas. Add automated tests for those settings and rendering paths, or change the…
Docstring Coverage Warning Docstring coverage is 56.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: adding background images for app themes.
Out of Scope Changes check Passed The changed schema, image validation, contained protocol delivery, theme registration, terminal transparency, CSS backdrop rules, and related tests all support the PR's background-image feature. No un…
Description check Passed The description is detailed and covers the change, rationale, linked issue, visual proof, testing, compatibility, performance, tradeoffs, and review history. It does not reproduce several template hea…
Full details: Out of Scope Changes check

Explanation

The changed schema, image validation, contained protocol delivery, theme registration, terminal transparency, CSS backdrop rules, and related tests all support the PR's background-image feature. No unrelated change is demonstrated.

Full details: Description check

Explanation

The description is detailed and covers the change, rationale, linked issue, visual proof, testing, compatibility, performance, tradeoffs, and review history. It does not reproduce several template headings and checkboxes, including ELI5, AI Disclosure, Agent skill upstream boundary, Notes, and Checklist, but the required information is mostly present elsewhere.

Full details: Linked Issues check

Explanation

[#7714] requires a user-selectable local image, opacity control, display modes including Cover, Contain, Stretch, and Center, and area selection for the editor, sidebar, terminal, or full window. The PR implements a bundled plugin-theme image instead. pluginThemeBackgroundSchema supports cover, contain, and tile; useDocumentAppearance activates it only below terminal Background Opacity 1; and the CSS paints it beneath translucent terminals. The PR does not implement local-image selection, user area selection, or the required Stretch mode. The added validation and protocol tests cover the plugin-image path, not these missing issue requirements.

Resolution

Implement the [#7714] user-facing settings and behavior for local image selection, opacity, all required display modes including Stretch, and selectable target areas. Add automated tests for those settings and rendering paths, or change the linked issue relationship if this PR intentionally delivers a different, narrower feature.

Full details: Docstring Coverage

Explanation

Docstring coverage is 56.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 21 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@nwparker
nwparker force-pushed the nwparker/theme-window-background-image branch from 9fdf1db to 1df4268 Compare November 1, 2026 00:24
An app theme may declare one validated raster image (png/jpeg/webp, <=2 MB, >=640x360, inside the plugin) served through orca-plugin-image, painted as one static body layer under translucent terminals. Older Orca ignores the field; a bad image drops only the image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Feature Request: Support custom background images in the IDE

1 participant