feat: toggle transparent background - #5657
Conversation
WindowsTerminal_6hnjPAQH6h.mp4 |
3197378 to
003dafc
Compare
| if (transparent) { | ||
| resolved.background = RGBA.fromInts(0, 0, 0, 0) | ||
| // NOTE: Could alternatively apply an alpha channel to the theme's base background color | ||
| // instead of forcing full transparency, allowing for adjustable opacity levels |
There was a problem hiding this comment.
Not sure how to model this with the TUI though.
I saw https://github.com/anomalyco/opentui/blob/main/packages/core/src/renderables/Slider.ts, but it doesn't appear to exposed to Solid yet
|
Dynamically switching the text for this menu item from "Enable transparency" to "Disable transparency" to indicate its current state would be a nice touch. |
|
This is something I'd love to see! |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
|
Nice feature to have! |
Yo OpenCode, can you handle that? |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Done! ✅ I've updated the toggle transparency command to dynamically show 'Enable transparency' or 'Disable transparency' based on the current state. Pushed to the branch in commit 942bfb7. |
928ee28 to
a76d000
Compare
|
this would be really nice to have |
a76d000 to
495ae51
Compare
7db56db to
f884535
Compare
|
+1 |
Adds a new command to toggle transparent background for terminal emulators that support transparency. The toggle text dynamically updates based on the current transparency state. Closes anomalyco#11866
f884535 to
d6f11bc
Compare
|
Also really looking forward to this feature — transparent terminal with opencode would be a game changer. Hope this gets reviewed and merged soon! 🙏 |
|
+1 |
1 similar comment
|
+1 |
|
When will this feature will be merged? |
Summary
auto | on | off) for the TUI theme, persisted viatheme_transparentand resolved insideresolveTheme(theme, mode, transparency).theme.transparencycommand to the command palette. Its title reports the current policy and, inauto, the resolved effective state (e.g.Transparency: Auto (on)). Running it cyclesauto -> on -> off -> auto.theme.transparenton the resolved theme as the effective runtime state (background.a < 1), so any consumer can ask whether the active background is transparent without having to interpret the policy.theme_transparencyin the typed keybind config and map it totheme.transparency, matching the neighboring theme bindings.Closes #11866.
Why
Background transparency is useful when the terminal already provides its own transparency (e.g. Ghostty
background-opacity, kitty, alacritty), and individual themes increasingly want to express transparency intent themselves. The merged PR #8467 already makes the generatedsystemtheme transparent by default for exactly this reason.A simple boolean toggle conflicts with that direction: when the active theme is
system, the resolved background is already transparent, so a label like Enable transparency is misleading, and toggling off later cannot undo a theme-defined transparent background. The right primitive is a small policy:autorespects the theme's own background alpha, includingsystembeing transparent by default.onforces the resolved background to alpha0while preserving the original RGB.offforces any non-opaque resolved background to alpha1while preserving the original RGB, so transparent themes can be made opaque again.The command palette communicates this directly: in
autoit showsTransparency: Auto (on)orTransparency: Auto (off)depending on the active theme, and in the forced states it showsForce on/Force off.Compatibility
theme_transparent=trueis read as"on";falseor any unknown value is read as"auto"(the new default).autono longer overrides what the theme defines.Tests
resolveTheme transparency policy respects auto, on, and offinpackages/tui/test/theme.test.ts, covering:autoand become alpha-0(with original RGB preserved) underon.systemtheme is transparent underauto, and becomes opaque (with original RGB preserved) underoff.a = 0.5) are reported as transparent underautoand forced to alpha1underoff.Verified locally:
bun test packages/tui/test/theme.test.tspasses.bun typecheckinpackages/tuipasses.Screenshots
N/A – the change is a TUI-only behavior/state change. The visible difference is the command palette title for
theme.transparency, e.g.:Transparency: Auto (on)when the active theme defines a transparent background.Transparency: Auto (off)when the active theme defines an opaque background.Transparency: Force onandTransparency: Force offwhen the policy is forced.