Skip to content

Suu/add night light button#23

Merged
0suu merged 2 commits into
mainfrom
suu/AddNightLightButton
Dec 28, 2025
Merged

Suu/add night light button#23
0suu merged 2 commits into
mainfrom
suu/AddNightLightButton

Conversation

@0suu

@0suu 0suu commented Dec 28, 2025

Copy link
Copy Markdown
Owner

No description provided.

@0suu 0suu merged commit fdab1d3 into main Dec 28, 2025
1 of 2 checks passed
@0suu 0suu deleted the suu/AddNightLightButton branch December 28, 2025 10:03
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @0suu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new 'Night Light' functionality, primarily targeting ceiling light devices. It allows users to associate a specific scene with a dedicated 'Night Light' button within the device controls. The chosen scene can then be executed with a single click, and these assignments are saved locally for convenience. This enhancement improves usability for ceiling lights by providing quick access to a common lighting configuration.

Highlights

  • Night Light Button Feature: Introduced a new 'Night Light' button specifically for ceiling light devices, enabling users to quickly activate a pre-assigned scene.
  • Scene Assignment and Persistence: Users can now assign a specific scene to the 'Night Light' button for each ceiling light device. These assignments are automatically persisted locally using electronStore.
  • Dedicated UI for Night Light Settings: A new settings section has been added within the device controls for ceiling lights, allowing users to easily select, save, and reload scenes for the night light button.
  • Internationalization Support: New translation keys have been added for both English and Japanese to support the new 'Night Light' feature's user interface text.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a 'Night Light' feature for ceiling light devices, which allows executing a pre-assigned scene. The changes are well-implemented across the UI component (DeviceControls.tsx), Redux state (sceneSlice.ts), and app initialization (App.tsx), including persistence and internationalization. The new UI provides good feedback to the user. I've added a couple of review comments with suggestions to improve the robustness of data loading from storage and to follow React-Redux best practices for selecting state, which will enhance performance and prevent potential issues with stale data.

Comment on lines +84 to +92
const assignedNightLightSceneId = useSelector((state: RootState) =>
selectNightLightSceneForDevice(state, device.deviceId)
);
const nightLightExecuting = useSelector((state: RootState) =>
assignedNightLightSceneId ? selectSceneIsExecuting(state, assignedNightLightSceneId) : false
);
const nightLightExecutionError = useSelector((state: RootState) =>
assignedNightLightSceneId ? selectSceneExecutionError(state, assignedNightLightSceneId) : null
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

These consecutive useSelector hooks, where some depend on the output of others from the previous render, can lead to stale data and unnecessary re-renders. It's a best practice to derive all related state within a single useSelector hook. This ensures data consistency for a single render and can be more performant, especially when providing a custom equality check to prevent re-renders if the derived data hasn't functionally changed.

Suggested change
const assignedNightLightSceneId = useSelector((state: RootState) =>
selectNightLightSceneForDevice(state, device.deviceId)
);
const nightLightExecuting = useSelector((state: RootState) =>
assignedNightLightSceneId ? selectSceneIsExecuting(state, assignedNightLightSceneId) : false
);
const nightLightExecutionError = useSelector((state: RootState) =>
assignedNightLightSceneId ? selectSceneExecutionError(state, assignedNightLightSceneId) : null
);
const { assignedNightLightSceneId, nightLightExecuting, nightLightExecutionError } = useSelector((state: RootState) => {
const sceneId = selectNightLightSceneForDevice(state, device.deviceId);
return {
assignedNightLightSceneId: sceneId,
nightLightExecuting: sceneId ? selectSceneIsExecuting(state, sceneId) : false,
nightLightExecutionError: sceneId ? selectSceneExecutionError(state, sceneId) : null
};
}, (left, right) =>
left.assignedNightLightSceneId === right.assignedNightLightSceneId &&
left.nightLightExecuting === right.nightLightExecuting &&
left.nightLightExecutionError === right.nightLightExecutionError
);

async () => {
try {
const stored = await window.electronStore.get(NIGHT_LIGHT_SCENE_STORAGE_KEY);
if (stored && typeof stored === "object") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The check typeof stored === "object" is also true for arrays. If an array is somehow stored in NIGHT_LIGHT_SCENE_STORAGE_KEY (e.g., due to a bug or a previous data format), Object.entries will iterate over its indices, which is not the intended behavior for a key-value map. To make this data loading more robust, you should add a check to ensure the stored value is not an array.

Suggested change
if (stored && typeof stored === "object") {
if (stored && typeof stored === "object" && !Array.isArray(stored)) {

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant