-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(core): address post-merge monitor tool and UI routing issues #3792
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
9 commits
Select commit
Hold shift + click to select a range
9d25aaf
fix(core): address post-merge monitor tool and UI routing issues
doudouOUC 773ddae
Merge main into pr-3792 to resolve conflicts
doudouOUC 607bd80
fix(core,cli,vscode): address PR #3792 review feedback
doudouOUC 57d089c
fix(core,vscode): address follow-up review comments
doudouOUC b92c5cf
fix(core,cli): adopt review feedback — ReadonlySet + hasRunningEntries
doudouOUC 52f0203
fix(core,webui,vscode): address remaining PR #3792 review comments
doudouOUC 683b2b1
test(webui): add unit test for getToolCallComponent routing
doudouOUC c8acd99
fix(cli): add missing hasRunningEntries to useResumeCommand test mocks
doudouOUC 1da06cc
test(cli): add unit tests for backgroundWorkUtils shared utility
doudouOUC 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,116 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Qwen Code | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import type { Config } from '@qwen-code/qwen-code-core'; | ||
| import { | ||
| hasBlockingBackgroundWork, | ||
| resetBackgroundStateForSessionSwitch, | ||
| } from './backgroundWorkUtils.js'; | ||
|
|
||
| function createMockConfig(overrides?: { | ||
| hasUnfinalizedTasks?: boolean; | ||
| runningMonitors?: unknown[]; | ||
| hasRunningEntries?: boolean; | ||
| }): Config { | ||
| return { | ||
| getBackgroundTaskRegistry: () => ({ | ||
| hasUnfinalizedTasks: () => overrides?.hasUnfinalizedTasks ?? false, | ||
| reset: vi.fn(), | ||
| }), | ||
| getMonitorRegistry: () => ({ | ||
| getRunning: () => overrides?.runningMonitors ?? [], | ||
| reset: vi.fn(), | ||
| }), | ||
| getBackgroundShellRegistry: () => ({ | ||
| hasRunningEntries: () => overrides?.hasRunningEntries ?? false, | ||
| reset: vi.fn(), | ||
| }), | ||
| } as unknown as Config; | ||
| } | ||
|
|
||
| describe('hasBlockingBackgroundWork', () => { | ||
| it('returns false when nothing is running', () => { | ||
| expect(hasBlockingBackgroundWork(createMockConfig())).toBe(false); | ||
| }); | ||
|
|
||
| it('returns true when background tasks are unfinalized', () => { | ||
| expect( | ||
| hasBlockingBackgroundWork( | ||
| createMockConfig({ hasUnfinalizedTasks: true }), | ||
| ), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it('returns true when monitors are running', () => { | ||
| expect( | ||
| hasBlockingBackgroundWork( | ||
| createMockConfig({ runningMonitors: [{ id: 'm1' }] }), | ||
| ), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it('returns true when shell entries are running', () => { | ||
| expect( | ||
| hasBlockingBackgroundWork(createMockConfig({ hasRunningEntries: true })), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it('short-circuits: does not check monitors or shells when tasks are unfinalized', () => { | ||
| const config = { | ||
| getBackgroundTaskRegistry: () => ({ | ||
| hasUnfinalizedTasks: () => true, | ||
| reset: vi.fn(), | ||
| }), | ||
| getMonitorRegistry: () => { | ||
| throw new Error('should not be called'); | ||
| }, | ||
| getBackgroundShellRegistry: () => { | ||
| throw new Error('should not be called'); | ||
| }, | ||
| } as unknown as Config; | ||
|
|
||
| expect(hasBlockingBackgroundWork(config)).toBe(true); | ||
| }); | ||
|
|
||
| it('short-circuits: does not check shells when monitors are running', () => { | ||
| const config = { | ||
| getBackgroundTaskRegistry: () => ({ | ||
| hasUnfinalizedTasks: () => false, | ||
| reset: vi.fn(), | ||
| }), | ||
| getMonitorRegistry: () => ({ | ||
| getRunning: () => [{ id: 'm1' }], | ||
| reset: vi.fn(), | ||
| }), | ||
| getBackgroundShellRegistry: () => { | ||
| throw new Error('should not be called'); | ||
| }, | ||
| } as unknown as Config; | ||
|
|
||
| expect(hasBlockingBackgroundWork(config)).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('resetBackgroundStateForSessionSwitch', () => { | ||
| it('calls reset on all three registries', () => { | ||
| const resetTasks = vi.fn(); | ||
| const resetMonitors = vi.fn(); | ||
| const resetShells = vi.fn(); | ||
|
|
||
| const config = { | ||
| getBackgroundTaskRegistry: () => ({ reset: resetTasks }), | ||
| getMonitorRegistry: () => ({ reset: resetMonitors }), | ||
| getBackgroundShellRegistry: () => ({ reset: resetShells }), | ||
| } as unknown as Config; | ||
|
|
||
| resetBackgroundStateForSessionSwitch(config); | ||
|
|
||
| expect(resetTasks).toHaveBeenCalledOnce(); | ||
| expect(resetMonitors).toHaveBeenCalledOnce(); | ||
| expect(resetShells).toHaveBeenCalledOnce(); | ||
| }); | ||
| }); |
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,21 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Qwen Code | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type { Config } from '@qwen-code/qwen-code-core'; | ||
|
|
||
| export function hasBlockingBackgroundWork(config: Config): boolean { | ||
| return ( | ||
| config.getBackgroundTaskRegistry().hasUnfinalizedTasks() || | ||
| config.getMonitorRegistry().getRunning().length > 0 || | ||
| config.getBackgroundShellRegistry().hasRunningEntries() | ||
| ); | ||
| } | ||
|
doudouOUC marked this conversation as resolved.
|
||
|
|
||
| export function resetBackgroundStateForSessionSwitch(config: Config): void { | ||
| config.getBackgroundTaskRegistry().reset(); | ||
| config.getMonitorRegistry().reset(); | ||
| config.getBackgroundShellRegistry().reset(); | ||
| } | ||
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.
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.
[Suggestion] 提取到共享模块的
hasBlockingBackgroundWork缺少 JSDoc。建议添加说明其检查顺序和阻塞语义:— deepseek-v4-pro via Qwen Code /review