-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(cli): remove residual blank lines after MCP init completes #3509
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8d30860
fix(cli): remove residual blank lines after MCP init completes (#3095)
BZ-D ba6cdfa
fix(cli): suppress MCP init message when custom status line is active
BZ-D 7990e8d
fix(cli): show MCP init progress even under a custom status line
BZ-D 29838ad
fix(cli): keep MCP init progress visible in screen-reader mode
BZ-D c4064a6
refactor(cli): drop duplicated screen-reader init path and show progr…
BZ-D 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
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,111 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, it, expect, afterEach } from 'vitest'; | ||
| import { renderHook, act } from '@testing-library/react'; | ||
| import { MCPServerStatus, type McpClient } from '@qwen-code/qwen-code-core'; | ||
| import { appEvents } from '../../utils/events.js'; | ||
| import { useConfigInitMessage } from './useConfigInitMessage.js'; | ||
|
|
||
| function makeClient(status: MCPServerStatus): McpClient { | ||
| return { getStatus: () => status } as unknown as McpClient; | ||
| } | ||
|
|
||
| describe('useConfigInitMessage', () => { | ||
| afterEach(() => { | ||
| appEvents.removeAllListeners('mcp-client-update'); | ||
| }); | ||
|
|
||
| it('returns null once config is initialized', () => { | ||
| const { result } = renderHook(() => useConfigInitMessage(true)); | ||
| expect(result.current).toBeNull(); | ||
| }); | ||
|
|
||
| it('defaults to "Initializing..." while config is still initializing', () => { | ||
| const { result } = renderHook(() => useConfigInitMessage(false)); | ||
| expect(result.current).toBe('Initializing...'); | ||
| }); | ||
|
|
||
| it('reports connection progress as MCP clients connect', () => { | ||
| const { result } = renderHook(() => useConfigInitMessage(false)); | ||
|
|
||
| const clients = new Map<string, McpClient>([ | ||
| ['a', makeClient(MCPServerStatus.CONNECTED)], | ||
| ['b', makeClient(MCPServerStatus.DISCONNECTED)], | ||
| ['c', makeClient(MCPServerStatus.DISCONNECTED)], | ||
| ]); | ||
|
|
||
| act(() => { | ||
| appEvents.emit('mcp-client-update', clients); | ||
| }); | ||
| expect(result.current).toBe('Connecting to MCP servers... (1/3)'); | ||
|
|
||
| clients.set('b', makeClient(MCPServerStatus.CONNECTED)); | ||
| act(() => { | ||
| appEvents.emit('mcp-client-update', clients); | ||
| }); | ||
| expect(result.current).toBe('Connecting to MCP servers... (2/3)'); | ||
| }); | ||
|
|
||
| it('falls back to "Initializing..." when the clients map is empty', () => { | ||
| const { result } = renderHook(() => useConfigInitMessage(false)); | ||
|
|
||
| act(() => { | ||
| appEvents.emit( | ||
| 'mcp-client-update', | ||
| new Map<string, McpClient>([ | ||
| ['a', makeClient(MCPServerStatus.CONNECTED)], | ||
| ]), | ||
| ); | ||
| }); | ||
| expect(result.current).toBe('Connecting to MCP servers... (1/1)'); | ||
|
|
||
| act(() => { | ||
| appEvents.emit('mcp-client-update', new Map<string, McpClient>()); | ||
| }); | ||
| expect(result.current).toBe('Initializing...'); | ||
| }); | ||
|
|
||
| it('flips to null as soon as config finishes initializing', () => { | ||
| const { result, rerender } = renderHook( | ||
| ({ initialized }: { initialized: boolean }) => | ||
| useConfigInitMessage(initialized), | ||
| { initialProps: { initialized: false } }, | ||
| ); | ||
|
|
||
| act(() => { | ||
| appEvents.emit( | ||
| 'mcp-client-update', | ||
| new Map<string, McpClient>([ | ||
| ['a', makeClient(MCPServerStatus.CONNECTED)], | ||
| ]), | ||
| ); | ||
| }); | ||
| expect(result.current).toBe('Connecting to MCP servers... (1/1)'); | ||
|
|
||
| rerender({ initialized: true }); | ||
| expect(result.current).toBeNull(); | ||
| }); | ||
|
|
||
| it('unsubscribes from mcp-client-update on unmount', () => { | ||
| const { unmount } = renderHook(() => useConfigInitMessage(false)); | ||
| expect(appEvents.listenerCount('mcp-client-update')).toBe(1); | ||
| unmount(); | ||
| expect(appEvents.listenerCount('mcp-client-update')).toBe(0); | ||
| }); | ||
|
|
||
| it('unsubscribes when config transitions to initialized', () => { | ||
| const { rerender } = renderHook( | ||
| ({ initialized }: { initialized: boolean }) => | ||
| useConfigInitMessage(initialized), | ||
| { initialProps: { initialized: false } }, | ||
| ); | ||
| expect(appEvents.listenerCount('mcp-client-update')).toBe(1); | ||
|
|
||
| rerender({ initialized: true }); | ||
| expect(appEvents.listenerCount('mcp-client-update')).toBe(0); | ||
| }); | ||
| }); |
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.
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.
Moving the init status into
Footerregresses screen-reader mode.Composeronly renders<Footer />when!isScreenReaderEnabled, while the oldConfigInitDisplaywas rendered regardless, so users running with a screen reader now lose all MCP init progress feedback during startup. We should keep an accessible path for this message outside the footer gate, or special-case screen-reader mode here.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.
Good catch — the old
ConfigInitDisplaywas rendered inComposeroutside the!isScreenReaderEnabled && <Footer />gate, and moving it into the footer silently dropped the init feedback for screen-reader users.Fixed in 29838ad:
Composernow rendersconfigInitMessageas a plain<Text>node whenisScreenReaderEnabledis true, reusing the sameuseConfigInitMessagehook. This keeps the Footer-based rendering (and its constant live-area height) for everyone else — screen-reader users never experienced the residual-blank-line issue that motivated the move in the first place, so an independent text node is harmless for them.