-
Notifications
You must be signed in to change notification settings - Fork 13.1k
feat(cli): support selective topic expansion and click-to-expand #24793
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
+202
−14
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d4a0894
feat(cli): make topic summaries expandable via Ctrl+O
Abhijit-2592 55eef95
feat(cli): support selective topic expansion and click-to-expand
Abhijit-2592 75cf073
feat(cli): support selective topic expansion and click-to-expand
Abhijit-2592 f425a9a
refactor(cli): address review feedback for topic expansion
Abhijit-2592 240b09e
refactor(cli): address review feedback for topic expansion and test c…
Abhijit-2592 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
Some comments aren't visible on the classic Files Changed page.
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
114 changes: 114 additions & 0 deletions
114
packages/cli/src/ui/components/messages/TopicMessage.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,114 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import { TopicMessage } from './TopicMessage.js'; | ||
| import { renderWithProviders } from '../../../test-utils/render.js'; | ||
| import { | ||
| TOPIC_PARAM_TITLE, | ||
| TOPIC_PARAM_SUMMARY, | ||
| TOPIC_PARAM_STRATEGIC_INTENT, | ||
| CoreToolCallStatus, | ||
| UPDATE_TOPIC_TOOL_NAME, | ||
| } from '@google/gemini-cli-core'; | ||
|
|
||
| describe('<TopicMessage />', () => { | ||
| const baseArgs = { | ||
| [TOPIC_PARAM_TITLE]: 'Test Topic', | ||
| [TOPIC_PARAM_STRATEGIC_INTENT]: 'This is the strategic intent.', | ||
| [TOPIC_PARAM_SUMMARY]: | ||
| 'This is the detailed summary that should be expandable.', | ||
| }; | ||
|
|
||
| const renderTopic = async ( | ||
| args: Record<string, unknown>, | ||
| height?: number, | ||
| toolActions?: { | ||
| isExpanded?: (callId: string) => boolean; | ||
| toggleExpansion?: (callId: string) => void; | ||
| }, | ||
| ) => | ||
| renderWithProviders( | ||
| <TopicMessage | ||
| args={args} | ||
| terminalWidth={80} | ||
| availableTerminalHeight={height} | ||
| callId="test-topic" | ||
| name={UPDATE_TOPIC_TOOL_NAME} | ||
| description="Updating topic" | ||
| status={CoreToolCallStatus.Success} | ||
| confirmationDetails={undefined} | ||
| resultDisplay={undefined} | ||
| />, | ||
| { toolActions, mouseEventsEnabled: true }, | ||
| ); | ||
|
|
||
| it('renders title and intent by default (collapsed)', async () => { | ||
| const { lastFrame } = await renderTopic(baseArgs, 40); | ||
| const frame = lastFrame(); | ||
| expect(frame).toContain('Test Topic:'); | ||
| expect(frame).toContain('This is the strategic intent.'); | ||
| expect(frame).not.toContain('This is the detailed summary'); | ||
| expect(frame).not.toContain('(ctrl+o to expand)'); | ||
| }); | ||
|
|
||
| it('renders summary when globally expanded (Ctrl+O)', async () => { | ||
| const { lastFrame } = await renderTopic(baseArgs, undefined); | ||
| const frame = lastFrame(); | ||
| expect(frame).toContain('Test Topic:'); | ||
| expect(frame).toContain('This is the strategic intent.'); | ||
| expect(frame).toContain('This is the detailed summary'); | ||
| expect(frame).not.toContain('(ctrl+o to collapse)'); | ||
| }); | ||
|
|
||
| it('renders summary when selectively expanded via context', async () => { | ||
| const isExpanded = vi.fn((id) => id === 'test-topic'); | ||
| const { lastFrame } = await renderTopic(baseArgs, 40, { isExpanded }); | ||
| const frame = lastFrame(); | ||
| expect(frame).toContain('Test Topic:'); | ||
| expect(frame).toContain('This is the detailed summary'); | ||
| expect(frame).not.toContain('(ctrl+o to collapse)'); | ||
| }); | ||
|
|
||
| it('calls toggleExpansion when clicked', async () => { | ||
| const toggleExpansion = vi.fn(); | ||
| const { simulateClick } = await renderTopic(baseArgs, 40, { | ||
| toggleExpansion, | ||
| }); | ||
|
|
||
| // In renderWithProviders, the component is wrapped in a Box with terminalWidth. | ||
| // The TopicMessage has marginLeft={2}. | ||
| // So col 5 should definitely hit the text content. | ||
| // row 1 is the first line of the TopicMessage. | ||
| await simulateClick(5, 1); | ||
|
|
||
| expect(toggleExpansion).toHaveBeenCalledWith('test-topic'); | ||
| }); | ||
|
|
||
| it('falls back to summary if strategic_intent is missing', async () => { | ||
| const args = { | ||
| [TOPIC_PARAM_TITLE]: 'Test Topic', | ||
| [TOPIC_PARAM_SUMMARY]: 'Only summary is present.', | ||
| }; | ||
| const { lastFrame } = await renderTopic(args, 40); | ||
| const frame = lastFrame(); | ||
| expect(frame).toContain('Test Topic:'); | ||
| expect(frame).toContain('Only summary is present.'); | ||
| expect(frame).not.toContain('(ctrl+o to expand)'); | ||
| }); | ||
|
|
||
| it('renders only strategic_intent if summary is missing', async () => { | ||
| const args = { | ||
| [TOPIC_PARAM_TITLE]: 'Test Topic', | ||
| [TOPIC_PARAM_STRATEGIC_INTENT]: 'Only intent is present.', | ||
| }; | ||
| const { lastFrame } = await renderTopic(args, 40); | ||
| const frame = lastFrame(); | ||
| expect(frame).toContain('Test Topic:'); | ||
| expect(frame).toContain('Only intent is present.'); | ||
| expect(frame).not.toContain('(ctrl+o to expand)'); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.