Skip to content

fix: traffic light styling on light mode#6333

Merged
bijin-bruno merged 2 commits intousebruno:mainfrom
naman-bruno:bugfix/trafficlight-color
Dec 6, 2025
Merged

fix: traffic light styling on light mode#6333
bijin-bruno merged 2 commits intousebruno:mainfrom
naman-bruno:bugfix/trafficlight-color

Conversation

@naman-bruno
Copy link
Collaborator

@naman-bruno naman-bruno commented Dec 6, 2025

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features
    • Theme changes made in the application now immediately update the native/system theme so the app and OS visuals stay in sync.
    • Switching themes in the renderer reliably propagates to the native environment for consistent appearance across windows and system UI.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

Walkthrough

Renderer informs main process when the active theme changes. ThemeProvider sends a 'renderer:theme-change' IPC message after applying the stored theme; the main process listens on that channel and sets Electron's nativeTheme.themeSource accordingly.

Changes

Cohort / File(s) Summary
Renderer — ThemeProvider
packages/bruno-app/src/providers/Theme/index.js
Sends renderer:theme-change via window.ipcRenderer.send after applying storedTheme; reduced useEffect dependencies to [storedTheme] while keeping root class updates.
Main — Preferences IPC
packages/bruno-electron/src/ipc/preferences.js
Import expanded to include nativeTheme; added ipcMain.on('renderer:theme-change', ...) listener that assigns nativeTheme.themeSource = theme.

Sequence Diagram

sequenceDiagram
    participant Renderer as Renderer Process
    participant IPC as IPC Bridge
    participant Main as Main Process

    Renderer->>Renderer: ThemeProvider applies storedTheme
    Renderer->>Renderer: Update root CSS classes
    Renderer->>IPC: ipcRenderer.send("renderer:theme-change", theme)
    IPC->>Main: Deliver IPC message
    Main->>Main: ipcMain receives message
    Main->>Main: nativeTheme.themeSource = theme
    Note over Main: Native theme source updated
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review focus: correct IPC channel name and payload, useEffect dependency change, and nativeTheme assignment.
  • Files to inspect closely:
    • packages/bruno-app/src/providers/Theme/index.js — ensure ipcRenderer existence checks and no unintended re-renders.
    • packages/bruno-electron/src/ipc/preferences.js — validate import and that themeSource values match Electron expectations.

Poem

🌗 Across the bridge a whisper flies,
Theme set in renderer, main replies,
Classes change and native too,
Harmony in every hue. 🎨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title claims to fix traffic light styling in light mode, but the actual changes implement theme synchronization between renderer and main process via IPC messaging. Revise the title to reflect the actual implementation, such as 'feat: add IPC-based theme synchronization for light/dark mode' or similar, to accurately describe the theme change mechanism being added.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e93e545 and 9317225.

📒 Files selected for processing (2)
  • packages/bruno-app/src/providers/Theme/index.js (1 hunks)
  • packages/bruno-electron/src/ipc/preferences.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/providers/Theme/index.js
  • packages/bruno-electron/src/ipc/preferences.js
🧠 Learnings (1)
📚 Learning: 2025-12-05T20:31:32.975Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Applies to **/*.{jsx,tsx} : Use styled component's theme prop to manage CSS colors and not CSS variables when in the context of a styled component or any React component using the styled component

Applied to files:

  • packages/bruno-app/src/providers/Theme/index.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/ipc/preferences.js (1)
packages/bruno-app/src/providers/Theme/index.js (1)
  • theme (48-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: Unit Tests
  • GitHub Check: CLI Tests
  • GitHub Check: SSL Tests - Linux
🔇 Additional comments (2)
packages/bruno-app/src/providers/Theme/index.js (1)

40-42: IPC theme sync looks good.

The implementation correctly checks for window.ipcRenderer availability and sends the theme value to the main process. This enables proper native theme synchronization.

packages/bruno-electron/src/ipc/preferences.js (1)

1-1: Import addition looks correct.

Adding nativeTheme to the electron imports is appropriate for the theme synchronization feature.

Comment on lines +42 to +44
ipcMain.on('renderer:theme-change', (event, theme) => {
nativeTheme.themeSource = theme;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Validate the incoming theme value.

The IPC handler directly assigns the received theme value to nativeTheme.themeSource without validation. This could cause issues if an invalid value is received.

Apply this diff to add validation:

  ipcMain.on('renderer:theme-change', (event, theme) => {
-    nativeTheme.themeSource = theme;
+    const validThemes = ['system', 'light', 'dark'];
+    if (validThemes.includes(theme)) {
+      nativeTheme.themeSource = theme;
+    }
  });
📝 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.

Suggested change
ipcMain.on('renderer:theme-change', (event, theme) => {
nativeTheme.themeSource = theme;
});
ipcMain.on('renderer:theme-change', (event, theme) => {
const validThemes = ['system', 'light', 'dark'];
if (validThemes.includes(theme)) {
nativeTheme.themeSource = theme;
}
});
🤖 Prompt for AI Agents
In packages/bruno-electron/src/ipc/preferences.js around lines 42 to 44, the IPC
handler assigns the incoming theme directly to nativeTheme.themeSource; validate
the incoming value first by checking it's a string and one of the allowed values
('system', 'light', 'dark'), then only set nativeTheme.themeSource when valid;
if invalid, either ignore the change and log a warning (or send an IPC reply to
the renderer indicating invalid input) or fall back to a safe default such as
'system'.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/bruno-app/src/providers/Theme/index.js (1)

20-26: Add cleanup for the matchMedia change listener

The addEventListener('change', …) on the media query never gets cleaned up, so if ThemeProvider is ever unmounted/remounted, you’ll accumulate listeners. Consider returning a cleanup function:

-  useEffect(() => {
-    window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', (e) => {
+  useEffect(() => {
+    const mediaQuery = window.matchMedia('(prefers-color-scheme: light)');
+    const handleChange = (e) => {
       if (storedTheme !== 'system') return;
       setDisplayedTheme(e.matches ? 'light' : 'dark');
       toggleHtml();
-    });
-  }, []);
+    };
+
+    mediaQuery.addEventListener('change', handleChange);
+
+    return () => {
+      mediaQuery.removeEventListener('change', handleChange);
+    };
+  }, []);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9317225 and 6b6be16.

📒 Files selected for processing (1)
  • packages/bruno-app/src/providers/Theme/index.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/providers/Theme/index.js
🧠 Learnings (2)
📚 Learning: 2025-12-05T20:31:32.975Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Applies to **/*.{jsx,tsx} : Use styled component's theme prop to manage CSS colors and not CSS variables when in the context of a styled component or any React component using the styled component

Applied to files:

  • packages/bruno-app/src/providers/Theme/index.js
📚 Learning: 2025-12-05T20:31:32.975Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Applies to **/*.{jsx,tsx} : Styled Component CSS might also change layout but Tailwind classes shouldn't define colors

Applied to files:

  • packages/bruno-app/src/providers/Theme/index.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Windows
🔇 Additional comments (1)
packages/bruno-app/src/providers/Theme/index.js (1)

28-43: IPC theme notification + dependency array look good

Tying the effect to storedTheme and sending a guarded IPC message via window.ipcRenderer after updating the root classes is a clean way to keep the main process in sync with theme changes. No issues from a React/Electron integration standpoint here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants