Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: 🟡 Moderate · up to Theme colors can be rendered incorrectly, and a stale profile or unauthorized snapshot may supply terminal colors. Resolve the settings and IPC ownership risks before merging; the remaining wording issue is cosmetic. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (5)
src/renderer/src/i18n/locales/en.json (1)
10675-10687: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove internal roadmap terminology from user-facing description.
The description for
AgentTerminalThemesstates: "Paired-server background workers are not themed in phase 1." The phrase "phase 1" is internal release terminology. Users read this text in Settings without context for what "phase 1" means or when a later phase arrives. State the current limitation without referencing an internal phase number.✏️ Proposed wording fix
- "description": "Shells and unset agents use the global Dark/Light themes. App chrome does not follow the agent. Paired-server background workers are not themed in phase 1.", + "description": "Shells and unset agents use the global Dark/Light themes. App chrome does not follow the agent. Paired-server background workers do not use agent themes yet.",src/renderer/src/components/settings/agent-terminal-theme-options.ts (1)
6-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a localized catalog for the inherit label.
getAgentTerminalThemeOptionscallstranslateon each invocation. The caller inAgentTerminalThemesSection.tsxmemoizes the result with[settings]only. After a UI language change, the "Inherit global" label stays in the previous language untilsettingschanges.Wrap the option list with
createLocalizedCatalog(the same pattern used inagent-terminal-theme-search.ts), or remove theuseMemoat the call site.src/renderer/src/components/settings/AgentTerminalThemesSection.tsx (1)
105-117: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse i18next pluralization for the override count.
The code selects between
override_count_oneandoverride_count_otherwith a JavaScript comparison. That bypasses CLDR plural rules, so locales with more than two plural forms cannot resolve the correct form.Pass
countto the translation call and let i18next select the form.♻️ Proposed refactor
- const overrideSummary = - overrideCount === 0 - ? null - : overrideCount === 1 - ? translate( - 'auto.components.settings.AgentTerminalThemes.override_count_one', - '1 override' - ) - : translate( - 'auto.components.settings.AgentTerminalThemes.override_count_other', - '{{value0}} overrides', - { value0: overrideCount } - ) + const overrideSummary = + overrideCount === 0 + ? null + : translate( + 'auto.components.settings.AgentTerminalThemes.override_count', + '{{count}} overrides', + { count: overrideCount } + )Add the matching
_oneand_othercatalog entries for the new key, then run the localization catalog scripts.Based on learnings: "do not rely on synthetic
plugin<hex>IDs … provide the pack's declared locale so i18next can apply the correct CLDR plural rules, especially for languages such as Russian that require more than_oneand_otherforms."Source: Learnings
src/renderer/src/components/settings/TerminalThemeSections.tsx (1)
221-226: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShow the Dark-slot hint only while Match dark mode is on.
The paragraph renders whenever the target is light. When the user turns Match dark mode off, agent overrides use the Light slot, so the hint no longer applies to the current state.
♻️ Proposed change
- <p className="text-xs text-muted-foreground"> - {translate( - 'auto.components.settings.TerminalThemeSections.agent_themes_follow_dark', - 'Agent terminal themes follow the Dark slot while Match dark mode is on.' - )} - </p> + {matchDarkMode ? ( + <p className="text-xs text-muted-foreground"> + {translate( + 'auto.components.settings.TerminalThemeSections.agent_themes_follow_dark', + 'Agent terminal themes follow the Dark slot while Match dark mode is on.' + )} + </p> + ) : null}Note: the added test in
TerminalThemeSections.lifecycle.test.tsrenders withterminalUseSeparateLightTheme: false, so it still passes with this change.src/renderer/src/components/terminal-pane/terminal-appearance.ts (1)
71-91: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider memoizing the composed themes and the published snapshot.
applyTerminalAppearanceruns on every settings change and on every pane creation. Each call rebuilds the global appearance, callspublishTerminalViewAttributesSnapshot, and then composes one theme per pane.buildTerminalViewAttributesSnapshotbuilds a 256-entry palette for the global scope and for each overridden agent, andpublishComposedTerminalViewAttributesSnapshotserializes that whole push withJSON.stringifyfor its dedupe check. A tab that restores several panes repeats that work once per pane.Two low-cost improvements:
- Cache the composed pane theme per resolved agent inside one invocation, because panes that share an agent produce an identical theme.
- Gate the snapshot publish on a
(settings, systemPrefersDark)identity check so repeated calls with unchanged inputs skip the compose and the serialization.♻️ Per-agent theme cache inside one invocation
const terminalFontWeights = resolveTerminalFontWeights(settings.terminalFontWeight) const ligaturesEnabled = resolveTerminalLigaturesEnabled( settings.terminalLigatures, settings.terminalFontFamily ) + // Why: panes that share an agent compose an identical theme; build each palette once per call. + const themeByAgent = new Map<TuiAgent | null, ReturnType<typeof composeActiveTerminalTheme>>() + const composeForPaneAgent = ( + agent: TuiAgent | null + ): { theme: ReturnType<typeof composeActiveTerminalTheme>; mode: 'dark' | 'light' } => { + const paneAppearance = resolveEffectiveTerminalAppearance(settings, systemPrefersDark, agent) + if (!themeByAgent.has(agent)) { + themeByAgent.set( + agent, + composeActiveTerminalTheme( + paneAppearance.theme ?? getBuiltinTheme(paneAppearance.themeName), + settings + ) + ) + } + return { theme: themeByAgent.get(agent) ?? null, mode: paneAppearance.mode } + } for (const pane of manager.getPanes()) { const agent = resolvePaneThemeAgent(pane) - const paneAppearance = resolveEffectiveTerminalAppearance(settings, systemPrefersDark, agent) - const paneTheme = composeActiveTerminalTheme( - paneAppearance.theme ?? getBuiltinTheme(paneAppearance.themeName), - settings - ) + const { theme: paneTheme, mode: paneMode } = composeForPaneAgent(agent)Then read
paneModewherepaneAppearance.modeis used for the contrast ratio.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9497a75d-4ea2-477e-863d-31ce01941486
📥 Commits
Reviewing files that changed from the base of the PR and between 93334dc and 3014e393517fa60b22b66fa30acdea75513e523b.
📒 Files selected for processing (66)
src/main/ipc/pty.tssrc/main/ipc/settings.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/terminal-view-attribute-store.test.tssrc/main/runtime/terminal-view-attribute-store.tssrc/main/runtime/terminal-view-attributes-seed.test.tssrc/main/runtime/terminal-view-attributes-seed.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/dashboard-popout/AgentTerminalDialog.test.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalPreview.theme.test.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsxsrc/renderer/src/components/dashboard-popout/agent-terminal-preview-theme.tssrc/renderer/src/components/settings/AgentTerminalThemeRow.tsxsrc/renderer/src/components/settings/AgentTerminalThemesSection.test.tsxsrc/renderer/src/components/settings/AgentTerminalThemesSection.tsxsrc/renderer/src/components/settings/AppearanceAdvancedDisclosure.tsxsrc/renderer/src/components/settings/TerminalAppearanceSection.tsxsrc/renderer/src/components/settings/TerminalThemePicker.tsxsrc/renderer/src/components/settings/TerminalThemeSections.lifecycle.test.tssrc/renderer/src/components/settings/TerminalThemeSections.tsxsrc/renderer/src/components/settings/agent-terminal-theme-options.tssrc/renderer/src/components/settings/agent-terminal-theme-rows.test.tssrc/renderer/src/components/settings/agent-terminal-theme-rows.tssrc/renderer/src/components/settings/agent-terminal-theme-search.tssrc/renderer/src/components/settings/terminal-search.test.tssrc/renderer/src/components/settings/terminal-search.tssrc/renderer/src/components/settings/terminal-theme-search.tssrc/renderer/src/components/terminal-pane/pane-theme-identity.test.tssrc/renderer/src/components/terminal-pane/pane-theme-identity.tssrc/renderer/src/components/terminal-pane/terminal-appearance.test.tssrc/renderer/src/components/terminal-pane/terminal-appearance.tssrc/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.test.tssrc/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.tssrc/renderer/src/components/terminal-pane/terminal-view-attributes-snapshot.test.tssrc/renderer/src/components/terminal-pane/terminal-view-attributes-snapshot.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/terminal-theme.test.tssrc/renderer/src/lib/terminal-theme.tssrc/renderer/src/lib/terminal-themes-data.tssrc/renderer/src/lib/terminal-themes/index.tssrc/renderer/src/store/slices/settings.tssrc/shared/agent-terminal-themes.test.tssrc/shared/agent-terminal-themes.tssrc/shared/compose-active-terminal-theme.test.tssrc/shared/compose-active-terminal-theme.tssrc/shared/constants.tssrc/shared/terminal-themes/classic.tssrc/shared/terminal-themes/defaults.tssrc/shared/terminal-themes/index.tssrc/shared/terminal-themes/popular-dark-core.tssrc/shared/terminal-themes/popular-dark-extended.tssrc/shared/terminal-themes/popular-dark.tssrc/shared/terminal-themes/popular-light.tssrc/shared/terminal-themes/shared.tssrc/shared/terminal-themes/types.tssrc/shared/terminal-view-attributes-composition.test.tssrc/shared/terminal-view-attributes-composition.tssrc/shared/terminal-view-attributes.test.tssrc/shared/terminal-view-attributes.tssrc/shared/types.ts
| ipcMain.removeAllListeners('pty:terminalViewAttributes') | ||
| ipcMain.on('pty:terminalViewAttributes', (_event, args: unknown) => { | ||
| // Why validate-or-drop: a malformed palette gives a wrong color reply that breaks TUI theme detection worse than the silent-until-first-push default. | ||
| const attributes = validateTerminalViewAttributes(args) | ||
| if (attributes) { | ||
| setTerminalViewAttributes(attributes) | ||
| const push = validateTerminalViewAttributesPush(args) | ||
| if (push) { | ||
| commitTerminalViewAttributesSnapshot(push) | ||
| markRendererCommittedSnapshot() | ||
| } | ||
| }) |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Restrict this handler to the main window's webContents.
The handler ignores _event, so any webContents in the app can commit terminal view attributes. Two consequences follow:
commitTerminalViewAttributesSnapshotsets the colors that main uses to answer OSC 4/10/11 for hidden PTYs and to seed cold-start palettes, so a foreign sender can inject arbitrary colors into every PTY reply.markRendererCommittedSnapshotrecords that the renderer owns the snapshot. The seed layer reads that flag, so one spoofed push suppresses the settings-derived seed for the rest of the session.
Sibling state-mutating handlers in this file already gate on the sender, for example pty:write (line 7175), pty:writeAccepted (line 7186), and pty:rendererDispatcherReady (line 7372). Apply the same guard here.
🔒️ Proposed fix
ipcMain.removeAllListeners('pty:terminalViewAttributes')
- ipcMain.on('pty:terminalViewAttributes', (_event, args: unknown) => {
+ ipcMain.on('pty:terminalViewAttributes', (event, args: unknown) => {
+ // Why: these attributes drive OSC color replies and suppress the main-process seed; only the owning window may commit them.
+ if (!isPtyWriteEventFromMainWindow(event, mainWindow.webContents)) {
+ return
+ }
const push = validateTerminalViewAttributesPush(args)
if (push) {
commitTerminalViewAttributesSnapshot(push)
markRendererCommittedSnapshot()
}
})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ipcMain.removeAllListeners('pty:terminalViewAttributes') | |
| ipcMain.on('pty:terminalViewAttributes', (_event, args: unknown) => { | |
| // Why validate-or-drop: a malformed palette gives a wrong color reply that breaks TUI theme detection worse than the silent-until-first-push default. | |
| const attributes = validateTerminalViewAttributes(args) | |
| if (attributes) { | |
| setTerminalViewAttributes(attributes) | |
| const push = validateTerminalViewAttributesPush(args) | |
| if (push) { | |
| commitTerminalViewAttributesSnapshot(push) | |
| markRendererCommittedSnapshot() | |
| } | |
| }) | |
| ipcMain.removeAllListeners('pty:terminalViewAttributes') | |
| ipcMain.on('pty:terminalViewAttributes', (event, args: unknown) => { | |
| // Only the owning window may commit terminal view attributes. | |
| if (!isPtyWriteEventFromMainWindow(event, mainWindow.webContents)) { | |
| return | |
| } | |
| const push = validateTerminalViewAttributesPush(args) | |
| if (push) { | |
| commitTerminalViewAttributesSnapshot(push) | |
| markRendererCommittedSnapshot() | |
| } | |
| }) |
| const theme = getNativeTheme() | ||
| if (nativeThemeSeedingInstalled || typeof theme?.on !== 'function') { | ||
| return | ||
| } | ||
| nativeThemeSeedingInstalled = true | ||
| theme.on('updated', () => { | ||
| if (hasRendererCommittedSnapshot()) { | ||
| return | ||
| } | ||
| seedTerminalViewAttributesFromSettings(getSettings(), readSystemPrefersDarkForSeed()) | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Refresh the native-theme settings accessor.
Line 154 returns after the first installation. The registered listener retains that first getSettings closure. If another Store becomes active, a later native-theme update can seed attributes from the earlier profile.
Store the latest accessor on every call. Keep one listener that reads the current accessor.
Proposed fix
let nativeThemeSeedingInstalled = false
+let nativeThemeSettingsAccessor: (() => SeedSettings) | null = null
export function installTerminalViewAttributeNativeThemeSeeding(
getSettings: () => SeedSettings
): void {
+ nativeThemeSettingsAccessor = getSettings
const theme = getNativeTheme()
if (nativeThemeSeedingInstalled || typeof theme?.on !== 'function') {
return
@@
- seedTerminalViewAttributesFromSettings(getSettings(), readSystemPrefersDarkForSeed())
+ const settings = nativeThemeSettingsAccessor
+ if (settings) {
+ seedTerminalViewAttributesFromSettings(settings(), readSystemPrefersDarkForSeed())
+ }
})
}
export function _resetNativeThemeViewAttributeSeedingForTest(): void {
nativeThemeSeedingInstalled = false
+ nativeThemeSettingsAccessor = null
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const theme = getNativeTheme() | |
| if (nativeThemeSeedingInstalled || typeof theme?.on !== 'function') { | |
| return | |
| } | |
| nativeThemeSeedingInstalled = true | |
| theme.on('updated', () => { | |
| if (hasRendererCommittedSnapshot()) { | |
| return | |
| } | |
| seedTerminalViewAttributesFromSettings(getSettings(), readSystemPrefersDarkForSeed()) | |
| }) | |
| const theme = getNativeTheme() | |
| if (nativeThemeSeedingInstalled || typeof theme?.on !== 'function') { | |
| return | |
| } | |
| nativeThemeSeedingInstalled = true | |
| theme.on('updated', () => { | |
| if (hasRendererCommittedSnapshot()) { | |
| return | |
| } | |
| const settings = nativeThemeSettingsAccessor | |
| if (settings) { | |
| seedTerminalViewAttributesFromSettings(settings(), readSystemPrefersDarkForSeed()) | |
| } | |
| }) |
| /** Publishes a snapshot with empty byAgent so existing callers keep compiling. */ | ||
| export function publishTerminalViewAttributes( | ||
| theme: ITheme | null, | ||
| mode: TerminalColorSchemeMode, | ||
| settings: Pick<GlobalSettings, 'terminalCursorStyle' | 'terminalCursorBlink'>, | ||
| send: (attributes: TerminalViewAttributes) => boolean = sendViaPreload | ||
| send: (attributes: TerminalViewAttributes) => boolean = sendLegacyAttributesViaPreload | ||
| ): boolean { | ||
| const attributes = composeTerminalViewAttributes(theme, mode, settings) | ||
| const serialized = JSON.stringify(attributes) | ||
| if (serialized === lastPublishedSnapshot) { | ||
| return false | ||
| } | ||
| if (!send(attributes)) { | ||
| // Not recorded: a later call with a working bridge must still publish. | ||
| return false | ||
| } | ||
| lastPublishedSnapshot = serialized | ||
| return true | ||
| return publishComposedTerminalViewAttributesSnapshot( | ||
| { kind: 'snapshot', global: attributes, byAgent: {} }, | ||
| (push) => send(push.global) | ||
| ) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
The legacy wrapper can erase every per-agent override in the main-process store.
publishTerminalViewAttributes publishes { kind: 'snapshot', global, byAgent: {} } through publishComposedTerminalViewAttributesSnapshot, which shares lastPublishedSnapshot with the full-snapshot publisher. commitTerminalViewAttributesSnapshot in src/main/runtime/terminal-view-attribute-store.ts replaces the stored map with byAgent: { ...snapshot.byAgent }. A legacy publish that lands after a full snapshot therefore drops every agent override and fans the global attributes out to each agent scope. src/main/runtime/terminal-view-attribute-store.test.ts lines 90-94 pin that replacement behavior. If a full snapshot follows, the overrides come back, so agent-scoped PTYs receive an OSC color flap.
Confirm whether any production caller still uses this wrapper. If one remains, either route it through buildTerminalViewAttributesSnapshot so it carries the agent map, or give the legacy path its own dedupe state and a store commit that leaves byAgent untouched.
#!/bin/bash
# Description: Find non-test callers of the legacy global-only publisher.
set -euo pipefail
rg -nP --type=ts --type=tsx '\bpublishTerminalViewAttributes\s*\(' -g '!**/*.test.ts' -g '!**/*.test.tsx' src| if (settings.terminalBackgroundOpacity !== undefined && theme.background) { | ||
| theme = { | ||
| ...theme, | ||
| background: hexToRgba(theme.background, settings.terminalBackgroundOpacity) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Guard non-hex backgrounds before opacity conversion.
If theme.background is rgb(...), rgba(...), or a named color, hexToRgba creates invalid CSS with NaN channels. Preserve non-hex backgrounds, or parse their CSS form before applying opacity.
Proposed fix
- if (settings.terminalBackgroundOpacity !== undefined && theme.background) {
+ if (
+ settings.terminalBackgroundOpacity !== undefined &&
+ theme.background &&
+ isHexColor(theme.background)
+ ) {3014e39 to
ff273b0
Compare
|
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. |
|
Hi just checking in |
Each agent can override the terminal theme (for example a cream theme for
Claude and Dracula for Codex). Every agent defaults to inheriting the
global theme, behind a collapsed disclosure in Appearance.
Ported onto main's owner-answered color replies:
☼ The PTY owner (main process, daemon, relay) keeps answering OSC 10/11
from one host-wide color, now with an optional per-agent map. The
startup intent carries launchAgent, so an agent pane answers with its
agent's colors. Older owners ignore both optional fields and answer
globally.
☼ The renderer pushes one atomic {global, byAgent} view-attribute
snapshot. Main fans it out per effective scope, so an identical re-push
or an unchanged inherit leaves live OSC color overlays alone.
☼ Per-agent seeds from saved settings answer OSC 10/11 before the first
renderer push. The hidden-pane OSC 4/12 responder still waits for that
push, as it does for the global palette.
☼ Settings normalization covers agentTerminalThemes on load, on update
and over the settings IPC.
☼ Reuses main's shared theme catalog and theme selection; the agent
argument is optional everywhere.
ff273b0 to
d841ff7
Compare
ELI5
Orca can theme every terminal, but all agents share that one theme, so five side-by-side agent panes look identical. This adds per-agent theme overrides: give Claude a cream theme and Codex Dracula, and each pane (plus its OSC color replies) follows its agent. Everything defaults to "Inherit global", collapsed behind a disclosure, so nothing changes unless you opt in.


What
Fixes #14174. Settings map (
agentTerminalThemes, missing key = inherit), agent-aware resolver, per-pane apply keyed by immutable pane-lifetime launch identity (splits and shells stay global), atomic{global, byAgent}view-attribute snapshot with cold-start seeding so hiddenworker-startPTYs answer OSC 10/11/12 with the right palette (local/direct-SSH; paired-server background workers documented out of scope), dashboard preview support, collapsed-by-default Appearance UI with detected-agent rows, i18n and settings search. Catalog re-homed tosrc/sharedwith a renderer re-export.Why
Multi-agent workflows can be unreadable at a glance when every TUI shares one palette; #13908/#6091-class startup color races made this worse. Related-but-different: #7257 (launch overrides).
Testing
~270 new/updated tests across sanitizer, resolver, per-pane apply, snapshot store/IPC, runtime spawn colors (Codex PTY receives Codex palette; scoped fan-out), UI (real-render assertions, no component mocks).
pnpm typecheckandpnpm buildpass. Full Windows vitest under Node 24 (the CI engine): 50,032 passed, 337 failed across 83 files with ZERO overlap with this PR's changed files - the failures are pre-existing env-dependent suites (ai-vault, cloud artifacts, git/fsync) that reproduce identically on Node 24 and Node 25 independent of this diff. Every diff in this PR also passed an independent review pass before merge into the branch (real-render test assertions; component mocks removed where found). Dev-build E2E verified: screenshots attached (settings state, multi-pane split with distinct palettes, match-dark-mode behavior).Behavior note
Agents that hard-paint their own TUI colors (Grok CLI) keep their native look; the override governs the base palette, host-palette TUIs, shells, and OSC replies.
AI disclosure
AI-assisted implementation, human-reviewed and E2E-verified.
X: x.com/edenaion