fix(patch): cherry-pick 858918f to release/v0.29.0-pr-19460 to patch version v0.29.0 and create version 0.29.1#19480
Conversation
Summary of ChangesHello @gemini-cli-robot, 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 facilitates an automated patch release, advancing the project version from Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request appears to be an automated cherry-pick intended to patch version v0.29.0. The main change is the addition of the color-convert dependency. However, the corresponding code changes to utilize this new dependency seem to be missing, leaving an existing bug in the theme selection logic unfixed. My review identifies this as a critical issue, as the patch is incomplete. The provided comment highlights this problem and suggests a concrete fix.
| "chalk": "^4.1.2", | ||
| "cli-spinners": "^2.9.2", | ||
| "clipboardy": "^5.0.0", | ||
| "color-convert": "^2.0.1", |
There was a problem hiding this comment.
The color-convert dependency is added here, but it's not used anywhere in the codebase. This suggests an incomplete fix, which is critical for a patch release.
There's a bug in the getLuminance function in packages/cli/src/ui/themes/color-utils.ts where it incorrectly handles non-hex color values (like 'white' or 'black'). This can cause incorrect automatic theme selection. This new dependency was likely intended to fix this.
The current buggy getLuminance function:
export function getLuminance(backgroundColor: string): number {
let hex = backgroundColor.replace(/^#/, '');
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
}To correctly fix this, getLuminance should be updated to use color-convert to handle different color formats. Here's a suggested implementation:
import convert from 'color-convert';
import { debugLogger } from '@google/gemini-cli-core';
export function getLuminance(backgroundColor: string): number {
try {
const rgb = backgroundColor.startsWith('#')
? convert.hex.rgb(backgroundColor.slice(1))
: convert.keyword.rgb(backgroundColor.toLowerCase() as any);
const [r, g, b] = rgb;
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
} catch (e) {
debugLogger.warn(`Could not parse color "${backgroundColor}" to calculate luminance.`);
return 0; // Default to dark for safety
}
}Please ensure the full fix is included in this patch release.
import convert from 'color-convert';
import { debugLogger } from '@google/gemini-cli-core';
export function getLuminance(backgroundColor: string): number {
try {
const rgb = backgroundColor.startsWith('#')
? convert.hex.rgb(backgroundColor.slice(1))
: convert.keyword.rgb(backgroundColor.toLowerCase() as any);
const [r, g, b] = rgb;
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
} catch (e) {
debugLogger.warn(`Could not parse color "${backgroundColor}" to calculate luminance.`);
return 0; // Default to dark for safety
}
}|
Size Change: -2 B (0%) Total Size: 23.9 MB ℹ️ View Unchanged
|
…version v0.29.0 and create version 0.29.1 (google-gemini#19480) Co-authored-by: christine betts <chrstn@uw.edu>
This PR automatically cherry-picks commit 858918f to patch version v0.29.0 in the stable release to create version 0.29.1.