Repository navigation
Conversation
- Add opacity slider (20-100%) for window transparency - Add vibrancy options for macOS (sidebar, under-window, etc.) - Add background material options for Windows 11 (mica, acrylic, etc.) - Settings persist across app restarts - Platform-specific UI shows only relevant options
📝 WalkthroughWalkthroughAdds persisted window appearance controls (opacity, macOS vibrancy, Windows background material) across schema, TRPC endpoints, Electron main process, and renderer settings UI with platform guards and defaults. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as Renderer (UI)
participant TRPCClient as TRPC Client
participant TRPCServer as TRPC Server
participant DB as Database
participant Electron as Electron Window
User->>UI: adjust opacity / vibrancy / material
UI->>UI: optimistic update
UI->>TRPCClient: call setOpacity / setVibrancy / setBackgroundMaterial
TRPCClient->>TRPCServer: send mutation
TRPCServer->>TRPCServer: validate input & platform
TRPCServer->>Electron: apply appearance change
Electron->>Electron: BrowserWindow applies appearance
TRPCServer->>DB: upsert settings row (id=1)
DB-->>TRPCServer: persist confirmation
TRPCServer-->>TRPCClient: return result
TRPCClient-->>UI: confirm or trigger rollback
UI-->>User: reflect final state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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
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
🤖 Fix all issues with AI agents
In `@apps/desktop/src/main/windows/main.ts`:
- Around line 33-49: The catch in getWindowAppearanceSettings currently swallows
DB read errors; modify it to catch the error as a variable and call the module
logger (e.g., processLogger or the existing logger used in this file) to log a
prefixed message like "getWindowAppearanceSettings: failed to read appearance
settings" plus the error details when localDb.select().from(settings).get()
throws, then return the same default object; ensure you reference
getWindowAppearanceSettings and the localDb.select().from(settings).get() call
when adding the log.
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/appearance/components/AppearanceSettings/AppearanceSettings.tsx`:
- Around line 102-169: The mutation onError handlers (for setWindowOpacity,
setWindowVibrancy, and setWindowBackgroundMaterial) currently revert cache state
but swallow the error; update each onError to log the error with a clear prefix
(e.g., "AppearanceSettings:setWindowOpacity onError:",
"AppearanceSettings:setWindowVibrancy onError:",
"AppearanceSettings:setWindowBackgroundMaterial onError:") before performing the
existing revert logic—use console.error (or the app logging utility if
available) to include the error object and any relevant vars/context so failures
are diagnosable while keeping the current cache rollback and invalidate
behavior.
🧹 Nitpick comments (4)
apps/desktop/src/main/windows/main.ts (1)
57-60: Avoid hardcoded opacity constants.Extract the
100literal to a named constant to keep the opacity range centralized.As per coding guidelines, extract magic numbers to named constants.♻️ Suggested refactor
+const WINDOW_OPACITY_MAX = 100; + function applyWindowAppearance(window: BrowserWindow) { const { opacity, vibrancy, backgroundMaterial } = getWindowAppearanceSettings(); // Apply opacity - if (opacity !== 100) { - window.setOpacity(opacity / 100); + if (opacity !== WINDOW_OPACITY_MAX) { + window.setOpacity(opacity / WINDOW_OPACITY_MAX); }apps/desktop/src/renderer/routes/_authenticated/settings/appearance/components/AppearanceSettings/AppearanceSettings.tsx (1)
259-351: Extract opacity range literals into constants.The min/max/step/default values are repeated magic numbers. Prefer a shared default and a named range constant.
As per coding guidelines, extract magic numbers to named constants.♻️ Suggested refactor
import { WINDOW_BACKGROUND_MATERIALS, WINDOW_VIBRANCY_OPTIONS, type WindowBackgroundMaterial, type WindowVibrancy, } from "@superset/local-db"; import { electronTrpc } from "renderer/lib/electron-trpc"; +import { DEFAULT_WINDOW_OPACITY } from "shared/constants"; @@ const MATERIAL_LABELS: Record<WindowBackgroundMaterial, string> = { none: "None", auto: "Auto", mica: "Mica", acrylic: "Acrylic", tabbed: "Tabbed", }; + +const WINDOW_OPACITY_RANGE = { MIN: 20, MAX: 100, STEP: 5 } as const; @@ <Slider - value={[windowOpacity ?? 100]} - min={20} - max={100} - step={5} + value={[windowOpacity ?? DEFAULT_WINDOW_OPACITY]} + min={WINDOW_OPACITY_RANGE.MIN} + max={WINDOW_OPACITY_RANGE.MAX} + step={WINDOW_OPACITY_RANGE.STEP} onValueChange={handleOpacityChange} className="flex-1" /> <span className="text-sm text-muted-foreground w-12 text-right"> - {windowOpacity ?? 100}% + {windowOpacity ?? DEFAULT_WINDOW_OPACITY}% </span>apps/desktop/src/lib/trpc/routers/settings/index.ts (1)
276-294: LGTM!The opacity getter/setter procedures follow the established patterns in this file. The validation range (20-100) is correctly applied, and the upsert pattern is consistent.
Consider extracting the magic numbers
20and100to named constants (e.g.,MIN_WINDOW_OPACITY,MAX_WINDOW_OPACITY) inshared/constantsto ensure consistency with the same validation inwindow.ts. As per coding guidelines, magic numbers should be extracted to named constants.apps/desktop/src/lib/trpc/routers/window.ts (1)
103-114: LGTM!The
setVibrancyprocedure correctly handles macOS-specific vibrancy with appropriate platform detection. The mapping of"none"tonullcorrectly disables vibrancy via Electron's API.Minor: The return type varies between
{ success: false }(line 107) and{ success: false, reason: string }(line 109). For consistency and easier error handling by consumers, consider adding areasonfield to the null-window case as well:♻️ Suggested refinement
setVibrancy: publicProcedure .input(z.object({ vibrancy: z.enum(WINDOW_VIBRANCY_OPTIONS) })) .mutation(({ input }) => { const window = getWindow(); - if (!window) return { success: false }; + if (!window) return { success: false, reason: "window not available" }; if (process.platform !== "darwin") { return { success: false, reason: "vibrancy is only supported on macOS" }; }
Address CodeRabbit review feedback by logging errors instead of silently swallowing them in the main process settings loader and renderer mutation handlers.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/appearance/components/AppearanceSettings/AppearanceSettings.tsx`:
- Around line 123-124: The three mutations
(electronTrpc.window.setOpacity.useMutation(),
electronTrpc.window.setVibrancy.useMutation(),
electronTrpc.window.setBackgroundMaterial.useMutation()) currently swallow
errors; add onError handlers to each useMutation that call your logger (e.g.,
processLogger or the existing logger used in this file) with a clear prefixed
context like "AppearanceSettings: setOpacity failed", "AppearanceSettings:
setVibrancy failed", and "AppearanceSettings: setBackgroundMaterial failed" and
include the error object/details so failures are visible for debugging.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/settings/appearance/components/AppearanceSettings/AppearanceSettings.tsx (1)
279-281: Extract window opacity slider constants
min/max/step/defaultare magic numbers. Please lift them into named constants at module top for clarity and reuse.♻️ Suggested refactor
+const WINDOW_OPACITY_MIN = 0; +const WINDOW_OPACITY_MAX = 100; +const WINDOW_OPACITY_STEP = 5; +const WINDOW_OPACITY_DEFAULT = 100;- value={[windowOpacity ?? 100]} - min={0} - max={100} - step={5} + value={[windowOpacity ?? WINDOW_OPACITY_DEFAULT]} + min={WINDOW_OPACITY_MIN} + max={WINDOW_OPACITY_MAX} + step={WINDOW_OPACITY_STEP}- {windowOpacity ?? 100}% + {windowOpacity ?? WINDOW_OPACITY_DEFAULT}%As per coding guidelines, extract magic numbers to named constants.
| const applyWindowOpacity = electronTrpc.window.setOpacity.useMutation(); | ||
|
|
There was a problem hiding this comment.
Log failures when applying window effects
The apply mutations (setOpacity, setVibrancy, setBackgroundMaterial) have no onError logging, so failures are silent and hard to diagnose. Please log with a prefixed context.
🛠️ Suggested logging (apply to all three mutations)
- const applyWindowOpacity = electronTrpc.window.setOpacity.useMutation();
+ const applyWindowOpacity = electronTrpc.window.setOpacity.useMutation({
+ onError: (err) => {
+ console.error("[appearance/apply-opacity] Failed to apply:", err);
+ },
+ });
- const applyWindowVibrancy = electronTrpc.window.setVibrancy.useMutation();
+ const applyWindowVibrancy = electronTrpc.window.setVibrancy.useMutation({
+ onError: (err) => {
+ console.error("[appearance/apply-vibrancy] Failed to apply:", err);
+ },
+ });
- const applyWindowBackgroundMaterial =
- electronTrpc.window.setBackgroundMaterial.useMutation();
+ const applyWindowBackgroundMaterial =
+ electronTrpc.window.setBackgroundMaterial.useMutation({
+ onError: (err) => {
+ console.error("[appearance/apply-material] Failed to apply:", err);
+ },
+ });Based on learnings, avoid swallowing errors silently.
Also applies to: 147-147, 173-174
🤖 Prompt for AI Agents
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/appearance/components/AppearanceSettings/AppearanceSettings.tsx`
around lines 123 - 124, The three mutations
(electronTrpc.window.setOpacity.useMutation(),
electronTrpc.window.setVibrancy.useMutation(),
electronTrpc.window.setBackgroundMaterial.useMutation()) currently swallow
errors; add onError handlers to each useMutation that call your logger (e.g.,
processLogger or the existing logger used in this file) with a clear prefixed
context like "AppearanceSettings: setOpacity failed", "AppearanceSettings:
setVibrancy failed", and "AppearanceSettings: setBackgroundMaterial failed" and
include the error object/details so failures are visible for debugging.
|
Closing: stale appearance feature PR from Jan 24 with no recent activity. Can be reopened if revisited. |
|
Hey — just a heads up, this was closed as part of an automated stale PR cleanup. If you think this was done in error, feel free to reopen it! |
|
Hey — this was closed by an automated cleanup of PRs with major merge conflicts that are 3+ weeks old. If you think this was done incorrectly, please feel free to reopen it. Sorry for any inconvenience! |
…#931) Review surfaced the third macOS leak from microsoft/node-pty#907: SetupExitCallback opens a kqueue per spawned pty to wait on NOTE_EXIT and never closes it, leaking one fd per session against the daemon's RLIMIT_NOFILE (distinct from the ptmx-cap leak). Extend the patch with upstream's one-line fix (microsoft/node-pty#931, close(kq)). Verified: 10 spawn/exit cycles leave kqueue fd count flat (was +1 per session). New regression test mirrors upstream's, macOS-gated.
…#931) Review surfaced the third macOS leak from microsoft/node-pty#907: SetupExitCallback opens a kqueue per spawned pty to wait on NOTE_EXIT and never closes it, leaking one fd per session against the daemon's RLIMIT_NOFILE (distinct from the ptmx-cap leak). Extend the patch with upstream's one-line fix (microsoft/node-pty#931, close(kq)). Verified: 10 spawn/exit cycles leave kqueue fd count flat (was +1 per session). New regression test mirrors upstream's, macOS-gated.
…#931) Review surfaced the third macOS leak from microsoft/node-pty#907: SetupExitCallback opens a kqueue per spawned pty to wait on NOTE_EXIT and never closes it, leaking one fd per session against the daemon's RLIMIT_NOFILE (distinct from the ptmx-cap leak). Extend the patch with upstream's one-line fix (microsoft/node-pty#931, close(kq)). Verified: 10 spawn/exit cycles leave kqueue fd count flat (was +1 per session). New regression test mirrors upstream's, macOS-gated.
This was one of my favorite feature of Warp's that I used to be able to configure. Would love to bring it to superset!
Summary
Note: Window opacity only affects the window frame, not the text/content inside.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.