-
Notifications
You must be signed in to change notification settings - Fork 14.2k
fix(patch): cherry-pick 78a28bf to release/v0.16.0-preview.4-pr-13188 to patch version v0.16.0-preview.4 and create version 0.16.0-preview.5 #13229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
skeshive
merged 1 commit into
release/v0.16.0-preview.4-pr-13188
from
hotfix/v0.16.0-preview.4/0.16.0-preview.5/preview/cherry-pick-78a28bf/pr-13188
Nov 17, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
packages/cli/src/ui/components/GradientRegression.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import { renderWithProviders } from '../../test-utils/render.js'; | ||
| import { Footer } from './Footer.js'; | ||
| import { StatsDisplay } from './StatsDisplay.js'; | ||
| import * as SessionContext from '../contexts/SessionContext.js'; | ||
| import type { SessionStatsState } from '../contexts/SessionContext.js'; | ||
|
|
||
| // Mock the theme module | ||
| vi.mock('../semantic-colors.js', async (importOriginal) => { | ||
| const original = | ||
| await importOriginal<typeof import('../semantic-colors.js')>(); | ||
| return { | ||
| ...original, | ||
| theme: { | ||
| ...original.theme, | ||
| ui: { | ||
| ...original.theme.ui, | ||
| gradient: [], // Empty array to potentially trigger the crash | ||
| }, | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| // Mock the context to provide controlled data for testing | ||
| vi.mock('../contexts/SessionContext.js', async (importOriginal) => { | ||
| const actual = await importOriginal<typeof SessionContext>(); | ||
| return { | ||
| ...actual, | ||
| useSessionStats: vi.fn(), | ||
| }; | ||
| }); | ||
|
|
||
| const mockSessionStats: SessionStatsState = { | ||
| sessionId: 'test-session', | ||
| sessionStartTime: new Date(), | ||
| lastPromptTokenCount: 0, | ||
| promptCount: 0, | ||
| metrics: { | ||
| models: {}, | ||
| tools: { | ||
| totalCalls: 0, | ||
| totalSuccess: 0, | ||
| totalFail: 0, | ||
| totalDurationMs: 0, | ||
| totalDecisions: { accept: 0, reject: 0, modify: 0, auto_accept: 0 }, | ||
| byName: {}, | ||
| }, | ||
| files: { totalLinesAdded: 0, totalLinesRemoved: 0 }, | ||
| }, | ||
| }; | ||
|
|
||
| const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats); | ||
| useSessionStatsMock.mockReturnValue({ | ||
| stats: mockSessionStats, | ||
| getPromptCount: () => 0, | ||
| startNewPrompt: vi.fn(), | ||
| }); | ||
|
|
||
| describe('Gradient Crash Regression Tests', () => { | ||
| it('<Footer /> should not crash when theme.ui.gradient has only one color (or empty) and nightly is true', () => { | ||
| const { lastFrame } = renderWithProviders(<Footer />, { | ||
| width: 120, | ||
| uiState: { | ||
| nightly: true, // Enable nightly to trigger Gradient usage logic | ||
| sessionStats: mockSessionStats, | ||
| }, | ||
| }); | ||
| // If it crashes, this line won't be reached or lastFrame() will throw | ||
| expect(lastFrame()).toBeDefined(); | ||
| // It should fall back to rendering text without gradient | ||
| expect(lastFrame()).not.toContain('Gradient'); | ||
| }); | ||
|
|
||
| it('<StatsDisplay /> should not crash when theme.ui.gradient is empty', () => { | ||
| const { lastFrame } = renderWithProviders( | ||
| <StatsDisplay duration="1s" title="My Stats" />, | ||
| { | ||
| width: 120, | ||
| uiState: { | ||
| sessionStats: mockSessionStats, | ||
| }, | ||
| }, | ||
| ); | ||
| expect(lastFrame()).toBeDefined(); | ||
| // Ensure title is rendered | ||
| expect(lastFrame()).toContain('My Stats'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type React from 'react'; | ||
| import { Text, type TextProps } from 'ink'; | ||
| import Gradient from 'ink-gradient'; | ||
| import { theme } from '../semantic-colors.js'; | ||
|
|
||
| export const ThemedGradient: React.FC<TextProps> = ({ children, ...props }) => { | ||
| const gradient = theme.ui.gradient; | ||
|
|
||
| if (gradient && gradient.length >= 2) { | ||
| return ( | ||
| <Gradient colors={gradient}> | ||
| <Text {...props}>{children}</Text> | ||
| </Gradient> | ||
| ); | ||
| } | ||
|
|
||
| if (gradient && gradient.length === 1) { | ||
| return ( | ||
| <Text color={gradient[0]} {...props}> | ||
| {children} | ||
| </Text> | ||
| ); | ||
| } | ||
|
|
||
| return <Text {...props}>{children}</Text>; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring to use
ThemedGradienthas caused a visual regression. The original implementation usedtheme.text.primaryfor the title color when a gradient was present, andtheme.text.accentas a fallback when no gradient was available. The new implementation doesn't specify any color, so it will fall back to the default text color in both cases.To restore the original behavior, you should determine the color based on the presence of a gradient and pass it to
ThemedGradient.