Repository navigation
feat(terminal): custom background image (skin) - #8870
chldbwnstm wants to merge 7 commits into
Conversation
Add a user-pickable background image that renders behind the terminal panes, dimmed by the existing Background Opacity control. Opacity and the image are grouped in a new always-visible Background section of Terminal appearance settings, no longer buried under the advanced disclosure. Image bytes are copied into userData/terminal-backgrounds under a main-minted UUID; settings hold only a normalized reference. IPC (pick/read/delete) mirrors the custom-pet security model: UUID-gated paths, an image-extension allowlist re-validated on read/delete, zod input validation, a 64 MB cap, a guard against deleting the active file, and a startup prune for orphaned files. The blob-URL cache is id-keyed and reference-counted by the displayed image so replaces do not flash and blobs are freed when no pane shows them. The layer is plain DOM behind the PaneManager root, outside the xterm WebGL and repaint hot paths, and is visible via the existing terminalBackgroundOpacity < 1 transparency. Desktop-only (picker/layer hidden on web). Adds tests for the normalizer and shared gates, the IPC handlers (traversal and non-image refusals, delete guard, prune), and settings sanitization; i18n for en/es/ja/ko/zh. Co-Authored-By: Claude Fable 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds terminal background image support across the application. Shared validation defines supported formats, storage IDs, filenames, MIME types, and labels. Main-process IPC handles selecting, reading, deleting, and pruning stored images, with settings normalization during persistence and updates. The preload bridge exposes image operations. Renderer settings add opacity and image controls, while terminal panes load cached blob URLs and render images behind visible panes. Localization and tests cover the new functionality. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cbcc0417-3c5c-4dac-8fc0-7a0607ee028d
📒 Files selected for processing (26)
src/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/main/ipc/settings.test.tssrc/main/ipc/settings.tssrc/main/ipc/terminal-background.test.tssrc/main/ipc/terminal-background.tssrc/main/persistence.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/TerminalAppearanceSection.tsxsrc/renderer/src/components/settings/TerminalBackgroundImageSetting.tsxsrc/renderer/src/components/settings/TerminalBackgroundSection.tsxsrc/renderer/src/components/settings/TerminalWindowSection.tsxsrc/renderer/src/components/settings/terminal-search.tssrc/renderer/src/components/settings/terminal-window-setup-search.tssrc/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/terminal-background-image-blob.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/settings.tssrc/shared/terminal-background-image.test.tssrc/shared/terminal-background-image.tssrc/shared/types.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/settings/TerminalWindowSection.tsx
- Defer blob: URL revocation to the LRU pass instead of revoking eagerly when the reference count hits zero. React StrictMode runs effects mount -> unmount -> mount, and the interim unmount would revoke a URL the remount still holds in state, breaking the background. - Handle a rejected terminalBackground:read (fs error / IPC timeout) so it cannot surface as an unhandled promise rejection; drop the background. - Add docstrings to the public background-image functions. Co-Authored-By: Claude Fable 5 <[email protected]>
…und-image # Conflicts: # src/renderer/src/i18n/locales/en.json # src/renderer/src/i18n/locales/es.json # src/renderer/src/i18n/locales/ja.json # src/renderer/src/i18n/locales/ko.json # src/renderer/src/i18n/locales/zh.json
Greptile SummaryThis PR adds a custom terminal background image ("skin") feature: users can pick a local image rendered behind the terminal panes, controlled by the existing Background Opacity setting. The implementation follows the same security model as the existing custom-pet image handlers.
Confidence Score: 5/5Safe to merge — the change adds a well-bounded desktop feature with no impact on the shared renderer hot path or any server/agent code. The implementation is thorough: UUID-gated path resolution, a shared extension allowlist enforced independently on pick, read, and delete, zod validation of untrusted IPC inputs, a 64 MB cap, and normalization applied at every settings boundary. The blob-URL lifecycle (retain-on-display, lazy LRU eviction) is carefully designed to handle StrictMode remounts and concurrent panes without flash or leaks. Tests cover path-traversal refusals, extension gating, the active-file guard, orphan pruning, and normalizer edge cases. The background div is plain DOM behind the terminal container with no WebGL involvement. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/shared/terminal-background-image.ts | New shared module: type definition, UUID validator, extension allowlist, and normalizer applied at every settings boundary — single source of truth for what constitutes a valid main-minted reference |
| src/main/ipc/terminal-background.ts | New IPC handlers for pick/read/delete; UUID-gated path resolution, extension allowlist enforced on both pick and read/delete, zod-validated inputs, 64 MB cap, active-file guard on delete, and startup orphan pruner |
| src/renderer/src/components/terminal-pane/terminal-background-image-blob.ts | New blob-URL cache with id-keyed reference counting (retaining the displayed id, not the requested one) and lazy LRU eviction; handles StrictMode remounts, replace-without-flash, and concurrent panes correctly |
| src/renderer/src/components/settings/TerminalBackgroundImageSetting.tsx | Desktop-only settings row for pick/preview/replace/remove; opacity nudge only on first pick, Remove disabled during pick, uses shared blob hook for thumbnail preview |
| src/renderer/src/components/settings/TerminalBackgroundSection.tsx | New settings section co-locating Background Opacity and Background Image; reuses existing TerminalWindowSection translation keys correctly since the opacity control moved from that section |
| src/renderer/src/components/terminal-pane/TerminalPane.tsx | Adds a pointer-events-none, aria-hidden background div before the pane container; only rendered when isVisible and a blob URL is resolved — stays outside the WebGL pipeline |
| src/main/persistence.ts | Adds normalizeTerminalBackgroundImage at both the settings-load path and Store.updateSettings — consistent with existing normalizer pattern |
| src/main/ipc/terminal-background.test.ts | Comprehensive test suite covering channel registration, pick cancel/success/unsupported-type, read/delete traversal refusals, extension gating, active-file guard, and orphan prune — uses a real temp directory |
| src/shared/terminal-background-image.test.ts | Tests for normalizer, UUID validator, and backgroundImageFileMime covering traversal attempts, bad UUIDs, mismatched MIME, disallowed extensions, label edge cases |
| src/renderer/src/components/settings/terminal-window-setup-search.ts | Renames the old combined function into separate getTerminalBackgroundSearchEntries and getTerminalWindowSearchEntries; Background Image entry added to the background catalog |
Sequence Diagram
sequenceDiagram
participant User
participant SettingsUI as TerminalBackgroundImageSetting
participant BlobCache as BlobUrlCache (module)
participant Main as Main Process
participant FS as UserData/terminal-backgrounds
User->>SettingsUI: Click "Choose Image…"
SettingsUI->>Main: terminalBackground:pick (IPC)
Main->>User: Native file picker dialog
User->>Main: selects image
Main->>Main: classifyFile (extension allowlist)
Main->>FS: stat (size check ≤64MB)
Main->>FS: copyFile → uuid.ext
Main-->>SettingsUI: "TerminalBackgroundImage {id, fileName, mimeType, label}"
SettingsUI->>Main: settings:set (terminalBackgroundImage)
SettingsUI->>Main: terminalBackground:delete (previous id) [if replacing]
Note over BlobCache: TerminalPane mounts, calls useTerminalBackgroundImageUrl
BlobCache->>Main: terminalBackground:read (id, fileName)
Main->>FS: readFile → ArrayBuffer
Main-->>BlobCache: ArrayBuffer
BlobCache->>BlobCache: URL.createObjectURL(Blob)
BlobCache-->>TerminalPane: blob URL (retain until pane unmounts)
User->>SettingsUI: Click "Remove"
SettingsUI->>Main: settings:set (terminalBackgroundImage: null)
SettingsUI->>Main: terminalBackground:delete (current id, fileName)
Main->>Main: "Guard: refuse if fileName == active background"
Main->>FS: rm(filePath)
Reviews (2): Last reviewed commit: "fix(terminal): guard Remove while the ba..." | Re-trigger Greptile
The non-parented showOpenDialog fallback leaves the renderer clickable, so Remove could delete the image mid-pick and strand handlePick on a stale previous. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Merged latest Greptile's review came back 4/5 with one nit (missing The only thing blocking CI is workflow approval — as a fork PR, all four workflows (PR Checks, Linux Wayland GPU Sandbox, and both Windows E2E runs) are sitting at |
…minal-background-image # Conflicts: # src/renderer/src/i18n/locales/en.json
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Re-merged latest Verified locally: typecheck clean on both the node and web projects, and the 72 tests covering the settings slice, settings IPC, core-handler registration, and the background-image normalizer all pass. Still blocked on workflow approval — all four workflows (PR Checks, Linux Wayland GPU Sandbox, and both Windows E2E runs) are sitting at |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/ipc/terminal-background.test.ts (1)
110-134: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd test coverage for the size-limit and non-file rejection paths in
terminalBackground:pick.The suite covers cancel, successful copy, and unsupported-extension rejection, but it does not exercise two other validation branches in the handler shown in the codebase context: the
srcStat.size > MAX_BYTESrejection and thesrcStat.isFile()false case (for example, a selected directory). Add tests that seed an oversized file and a directory path, then assert the handler throws the expected error message for each case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 711a8e22-3ec8-4c83-bcd2-ba521ce734f4
📒 Files selected for processing (26)
src/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/main/ipc/settings.test.tssrc/main/ipc/settings.tssrc/main/ipc/terminal-background.test.tssrc/main/ipc/terminal-background.tssrc/main/persistence.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/TerminalAppearanceSection.tsxsrc/renderer/src/components/settings/TerminalBackgroundImageSetting.tsxsrc/renderer/src/components/settings/TerminalBackgroundSection.tsxsrc/renderer/src/components/settings/TerminalWindowSection.tsxsrc/renderer/src/components/settings/terminal-search.tssrc/renderer/src/components/settings/terminal-window-setup-search.tssrc/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/terminal-background-image-blob.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/settings.tssrc/shared/terminal-background-image.test.tssrc/shared/terminal-background-image.tssrc/shared/types.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/settings/TerminalWindowSection.tsx
🚧 Files skipped from review as they are similar to previous changes (22)
- src/main/ipc/register-core-handlers.test.ts
- src/renderer/src/components/settings/TerminalAppearanceSection.tsx
- src/renderer/src/components/terminal-pane/TerminalPane.tsx
- src/renderer/src/store/slices/settings.ts
- src/main/ipc/settings.test.ts
- src/renderer/src/components/settings/terminal-search.ts
- src/main/ipc/register-core-handlers.ts
- src/renderer/src/i18n/locales/es.json
- src/shared/types.ts
- src/preload/index.ts
- src/renderer/src/components/settings/terminal-window-setup-search.ts
- src/renderer/src/components/settings/TerminalBackgroundSection.tsx
- src/main/persistence.ts
- src/main/ipc/settings.ts
- src/shared/terminal-background-image.test.ts
- src/shared/terminal-background-image.ts
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/components/settings/TerminalBackgroundImageSetting.tsx
- src/renderer/src/components/terminal-pane/terminal-background-image-blob.ts
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/i18n/locales/en.json
- src/main/ipc/terminal-background.ts
Both guards sit between the extension check and copyFile but had no test pinning them, so a refactor could drop either silently. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Hey Neil,
Thanks for the feedback.
2026년 11월 2일 (월) 오후 1:13, Neil ***@***.***>님이 작성:
… *nwparker* left a comment (stablyai/orca#8870)
<#8870 (comment)>
Closing as superseded by #36589
<#36589>: app themes can now set a
background image with translucency, and #36796
<#36796> shows it in native chat
too. Thank you for this PR, it shaped the design.
—
Reply to this email directly, view it on GitHub
<#8870?email_source=notifications&email_token=ACXIW4P3HVBNVJIY2W4O4BL5W7NUFA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMNJWG42DGMJRGUY2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-6567431151>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACXIW4MOIKCBIDQYZLLJ5Y35W7NUFAVCNFSNUABGKJSXA33TNF2G64TZHMYTCOBTHA4DQMZUGI5US43TOVSTWNBYHEZDEMZZHEZDFILWAI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|

Summary
Adds a custom terminal background image ("skin"): users can pick a local
image that renders behind the terminal panes, dimmed by the existing
Background Opacity control. The image and opacity now live together in a new,
always-visible Background section of Terminal appearance settings.
This completes a feature the codebase was already half-way to:
terminalBackgroundOpacity < 1already enables xterm transparency and converts the composed theme background to
rgba(), but there was nothing to show behind the terminal. The Warp theme importereven parses
background_imagetoday only to report it as unsupported.What's included
terminalBackgroundImagesetting (main-minted reference; bytes stored inuserData/terminal-backgrounds/<uuid>.<ext>, never in settings JSON).custom-pet handlers' security model (UUID-gated paths,
basename+ prefixchecks, zod-validated IPC inputs, 64 MB cap).
never touches the WebGL rendering or texture-atlas hot paths, and survives
WebGL attach/detach.
Background Image (previously the image row was buried under the advanced disclosure).
Non-goals (called out for reviewers): importing
background_imagefrom Warp YAML,per-pane/per-worktree images, gradients/blur of the image, and web-build support
(the picker is desktop-only; the setting row hides on web).
Screenshots
Two terminals with a custom underwater background applied (Background Opacity ≈ 0.4).
The image renders behind the panes while terminal text stays fully legible; it works
with splits, the WebGL renderer, light/dark themes, and the floating terminal panel.
Testing
pnpm lintpnpm typecheckpnpm test(new: shared-normalizer, IPC-handler, and settings-sanitizer suites; all settings component tests pass)pnpm buildNew tests:
src/shared/terminal-background-image.test.ts— normalizer accepts a validmain-minted reference; rejects bad UUIDs, mismatched fileName prefixes,
disallowed extensions, wrong MIME, and non-object input.
src/main/ipc/terminal-background.test.ts— handlers register on the expectedchannels;
read/deleterefuse../, absolute paths, non-UUID ids, andfileNames not minted from the id, without touching the filesystem.
src/main/ipc/settings.test.ts—settings:setstrips invalidterminalBackgroundImagevalues and accepts valid ones.AI Review Report
A multi-agent code review was run over the diff before submission (finder agents per
angle + an independent verifier per finding). It surfaced the issues below; all were
fixed in this PR and re-covered by tests:
read/deletedidn't re-validate the extension. The path resolveronly checked the
${id}.prefix, so a<id>.jsonsitting in the backgrounds dircould be read/deleted. Fixed by gating
read/deleteon a sharedbackgroundImageFileMimeallowlist (UUID id + allowed image extension), re-validatedin main, not just on pick. Covered by a test that seeds
<id>.jsonand asserts it isrefused without fs access.
replacing an image reset a user's opacity of 1 to 0.85. Now it only fires when adding
the first image; replacing never touches opacity.
id-keyed and reference-counted by the id each pane is displaying, so a replace
never revokes a URL a pane is still painting (no flash), the blob is revoked when the
last pane drops it (no session-long leak), and an in-flight loser can't revoke the
winner.
pruneOrphanTerminalBackgroundsat startup (removes anyfile the current settings don't reference) plus a guard that refuses to delete the
active file — so a crash or dropped delete IPC can't accumulate disk usage.
"opacity"/"alpha" from expanding the theme preview; restored by feeding
backgroundMatchesintopreviewAdvancedMatches.(
isBackgroundImageStorageId,backgroundImageFileMime,normalizeBackgroundImageLabel)instead of a second copy of the pet primitives.
Cross-cutting checks the review confirmed:
node:path(join/basename/normalize); no hardcoded separators; noplatform-specific shell/keyboard assumptions introduced. The image layer is pure
DOM/CSS, identical across platforms and renderers.
plain DOM — outside the xterm WebGL pipeline and the reveal-repaint / texture-atlas
paths — so it adds no per-frame cost and survives renderer swaps.
Security Audit
app.getPath('userData')/terminal-backgrounds. Storage ids are UUIDs minted onlyin main (never from the renderer).
read/deletevalidate inputs with zod, thenre-resolve the path through a UUID gate +
basename+startsWith(root + sep)prefix check — the same defense the existing custom-pet handlers use. Traversal
attempts (
../, absolute paths, foreign fileNames, non-UUID ids) are covered by tests.terminalBackground:pick|read|delete).pickuses the native dialog with an image-extension filter, classifies byextension against an allowlist (png/jpg/jpeg/gif/webp),
stat-checks that thesource is a regular file, and enforces a 64 MB cap before copying. Inputs to
read/deleteare untrusted and validated before any path logic.terminalBackgroundImageis normalized at every boundary(persistence load,
Store.updateSettings,settings:setIPC, renderer storeslice) — a hand-edited settings file with a traversal path or wrong MIME is rejected.
webSecurity/contextIsolation/sandboxremain unchanged;the renderer never reads user files directly — bytes come over IPC as an
ArrayBufferand are exposed as ablob:URL (same constraint as custom pets).Notes
deletes the original file. Removing the skin deletes the stored copy.
fully opaque). Picking an image while opacity is unset or ≥ 1 nudges it to 0.85
once so the pick has a visible effect; users can raise opacity back to 1 to hide
the image without discarding it.
ELI5
You can set a custom image as the terminal background (“skin”). It sits behind panes and respects the existing background opacity control.