fix: update surface config on theme switch to restore ANSI palette#2685
fix: update surface config on theme switch to restore ANSI palette#2685shelldonGuo wants to merge 1 commit intomanaflow-ai:mainfrom
Conversation
When switching between light and dark themes, existing terminal surfaces retained the ANSI color palette (colors 0-15) from the previous theme. `ghostty_surface_set_color_scheme` only updates the scheme flag but does not re-apply the full palette to the surface buffer. Fix by calling `ghostty_surface_update_config` with the current app config before `ghostty_surface_set_color_scheme` in `applySurfaceColorScheme`. This pushes the complete palette for the new theme to each existing surface, matching the behavior ghostty's standalone app introduced in PR #9360. Also fix a Swift build error in ContentView.swift: protocol 'Panel' used as an existential type must be written as 'any Panel'.
|
Someone is attempting to deploy a commit to the Manaflow Team on Vercel. A member of the Team first needs to authorize it. |
|
This review could not be run because your cubic account has exceeded the monthly review limit. If you need help restoring access, please contact contact@cubic.dev. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates Swift existential typing in ContentView and enhances Ghostty terminal color scheme switching by ensuring the full ANSI palette is reapplied via config update before switching color schemes. Changes
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR fixes stale ANSI color palettes on existing terminal surfaces when switching between light/dark themes by calling Confidence Score: 5/5Safe to merge — targeted fix on a non-hot code path with no blocking issues. The fix is narrowly scoped to theme-change event paths (viewDidChangeEffectiveAppearance, attachSurface, viewDidMoveToWindow), well-commented, and mirrors the upstream Ghostty fix. The nil-guard on GhosttyApp.shared.config is a correct defensive pattern. Both changed files have straightforward, correct changes. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant GhosttyApp
participant SurfaceView as WindowTerminalHostView
participant Ghostty as libghostty
User->>GhosttyApp: Switch theme (light ↔ dark)
GhosttyApp->>SurfaceView: viewDidChangeEffectiveAppearance()
SurfaceView->>SurfaceView: applySurfaceColorScheme()
Note over SurfaceView: guard config != nil and scheme changed
SurfaceView->>Ghostty: ghostty_surface_update_config(surface, config)
Note over Ghostty: Pushes full config incl. ANSI palette (colors 0–15)
SurfaceView->>Ghostty: ghostty_surface_set_color_scheme(surface, scheme)
Note over Ghostty: Updates scheme flag on surface
SurfaceView->>SurfaceView: appliedColorScheme = scheme
Reviews (1): Last reviewed commit: "fix: update surface config on theme swit..." | Re-trigger Greptile |
Problem
When switching between light and dark themes in cmux, existing terminal windows retain the ANSI color palette (colors 0–15) from the previous theme. This causes white text on a light background when switching from dark → light.
Root cause:
applySurfaceColorSchemecallsghostty_surface_set_color_scheme, which only updates the scheme flag on the surface but does not re-apply the full ANSI palette. The palette (OSC 4, colors 0–15) stays from the previous theme.New windows are unaffected because ghostty initializes their palette from the current config at surface creation time.
This is the cmux-side equivalent of the fix ghostty made in their standalone app (ghostty-org/ghostty#9360, shipped in ghostty 1.3.0): explicitly pushing the updated config to existing surfaces when the color scheme changes.
Fix
In
applySurfaceColorScheme(GhosttyTerminalView.swift), callghostty_surface_update_config(surface, config)beforeghostty_surface_set_color_scheme. This pushes the complete config — including the correct ANSI palette for the new theme — to each existing surface.Also fixes a Swift build error in
ContentView.swift: protocolPanelused as an existential type must be written asany Panel.Testing
Summary by cubic
Fixes theme switching so existing terminal surfaces update their ANSI palette, preventing white-on-light text after dark → light (and vice versa). Also resolves a Swift build error in
ContentView.swift.GhosttyTerminalView.swift, callghostty_surface_update_config(surface, config)beforeghostty_surface_set_color_scheme(surface, scheme)to re-apply the ANSI palette on existing surfaces.ContentView.swift, changePanelexistential toany Panelto fix the build.Written for commit 1ba3da7. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Refactor