Skip to content

シーリングライトのonボタンはメインの電気をつける#29

Merged
0suu merged 1 commit into
mainfrom
suu/fix-ceiling-light-on-button
Dec 29, 2025
Merged

シーリングライトのonボタンはメインの電気をつける#29
0suu merged 1 commit into
mainfrom
suu/fix-ceiling-light-on-button

Conversation

@0suu

@0suu 0suu commented Dec 29, 2025

Copy link
Copy Markdown
Owner

No description provided.

@0suu
0suu merged commit 3a00fde into main Dec 29, 2025
1 of 2 checks passed
@0suu
0suu deleted the suu/fix-ceiling-light-on-button branch December 29, 2025 15:59
@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!

このプルリクエストは、シーリングライトの制御ロジックを改善することを目的としています。特に、シーリングライトのONボタンが押された際に、単に電源を入れるだけでなく、適切な明るさレベルを設定するように動作を変更しました。これにより、ユーザーはより直感的にシーリングライトを操作できるようになります。また、シーリングライトのデバイスタイプ検出も強化され、より堅牢な識別が可能になりました。

Highlights

  • シーリングライトの検出改善: デバイスタイプを正規化し、より柔軟にシーリングライトを識別するためのnormalizedTypeCompact変数を追加しました。
  • シーリングライトのONボタン動作変更: シーリングライトの場合、ONボタンが単なるturnOnコマンドではなく、明るさを1から100の範囲で設定するsetBrightnessコマンドを送信するように変更しました。

🧠 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

このプルリクエストは、シーリングライトの「オン」ボタンの動作を、設定された明るさで点灯するように変更するものです。これにより、単に電源を入れるだけでなく、より具体的な制御が可能になります。また、シーリングライトデバイスの検出ロジックも改善されています。

変更は的確ですが、onClick ハンドラのロジックが2箇所で重複しています。これを共通の関数にリファクタリングすることで、コードの可読性とメンテナンス性が向上します。具体的な修正案をコメントに記載しましたので、ご確認ください。

Comment on lines +856 to +862
onClick={() => {
if (isCeilingLight) {
sendCommand("setBrightness", Math.round(clamp(brightness, 1, 100)));
return;
}
sendCommand("turnOn");
}}

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

この onClick ハンドラのロジックは、522-528行目でも使用されており、重複しています。コードの重複をなくし、メンテナンス性を向上させるために、このロジックを関数として抽出することをお勧めします。

例えば、DeviceControls コンポーネント内に handleTurnOn 関数を定義し、両方の Button で再利用できます。

const handleTurnOn = () => {
  if (isCeilingLight) {
    sendCommand("setBrightness", Math.round(clamp(brightness, 1, 100)));
  } else {
    sendCommand("turnOn");
  }
};

そして、この Button と522行目の ButtononClick を提案のように変更してください。

                onClick={handleTurnOn}

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