diff --git a/packages/cli/src/ui/components/messages/ToolMessage.tsx b/packages/cli/src/ui/components/messages/ToolMessage.tsx index a81326cc..591a3b8d 100644 --- a/packages/cli/src/ui/components/messages/ToolMessage.tsx +++ b/packages/cli/src/ui/components/messages/ToolMessage.tsx @@ -321,7 +321,8 @@ const ToolInfo: React.FC = ({ > {name} - {' '} + + {description} diff --git a/packages/core/src/code_assist/oauth2.test.ts b/packages/core/src/code_assist/oauth2.test.ts index ef448899..3ae05287 100644 --- a/packages/core/src/code_assist/oauth2.test.ts +++ b/packages/core/src/code_assist/oauth2.test.ts @@ -548,6 +548,17 @@ describe('oauth2', () => { expect(updatedAccountData.old).toContain('test@example.com'); }); + it('should handle Qwen module clearing gracefully', async () => { + // This test verifies that clearCachedCredentialFile doesn't throw + // when Qwen modules are available and can be cleared + + // Since dynamic imports in tests are complex, we'll just verify + // that the function completes without error and doesn't throw + await expect(clearCachedCredentialFile()).resolves.not.toThrow(); + + // The actual Qwen clearing logic is tested separately in the Qwen module tests + }); + it('should clear the in-memory OAuth client cache', async () => { const mockSetCredentials = vi.fn(); const mockGetAccessToken = vi diff --git a/packages/core/src/code_assist/oauth2.ts b/packages/core/src/code_assist/oauth2.ts index 221a2b9f..953266c5 100644 --- a/packages/core/src/code_assist/oauth2.ts +++ b/packages/core/src/code_assist/oauth2.ts @@ -402,6 +402,25 @@ export async function clearCachedCredentialFile() { await clearCachedGoogleAccount(); // Clear the in-memory OAuth client cache to force re-authentication clearOauthClientCache(); + + /** + * Also clear Qwen SharedTokenManager cache and credentials file to prevent stale credentials + * when switching between auth types + * TODO: We do not depend on code_assist, we'll have to build an independent auth-cleaning procedure. + */ + try { + const { SharedTokenManager } = await import( + '../qwen/sharedTokenManager.js' + ); + const { clearQwenCredentials } = await import('../qwen/qwenOAuth2.js'); + + const sharedManager = SharedTokenManager.getInstance(); + sharedManager.clearCache(); + + await clearQwenCredentials(); + } catch (qwenError) { + console.debug('Could not clear Qwen credentials:', qwenError); + } } catch (e) { console.error('Failed to clear cached credentials:', e); }