Skip to content

Commit ad7446e

Browse files
author
xwj02155382
committed
chore(auth): stabilize auth ui and resolve styling overflow
1 parent f38c4a0 commit ad7446e

File tree

8 files changed

+311
-74
lines changed

8 files changed

+311
-74
lines changed

packages/cli/src/acp-integration/authMethods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function buildAuthMethods(): AuthMethod[] {
1212
return [
1313
{
1414
id: AuthType.QWEN_OAUTH,
15-
name: 'Qwen OAuth',
15+
name: t('Qwen OAuth'),
1616
description: t(
1717
'OAuth authentication for Qwen models with free daily requests',
1818
),

packages/cli/src/i18n/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ const getLocalePath = (
5555

5656
// Language detection
5757
export function detectSystemLanguage(): SupportedLanguage {
58-
const envLang = process.env['QWEN_CODE_LANG'] || process.env['LANG'];
58+
const envLang =
59+
process.env['QWEN_CODE_LANG'] ||
60+
process.env['QWEN_IDE_LANGUAGE'] ||
61+
process.env['LANG'];
5962
if (envLang) {
63+
const envLangLower = envLang.toLowerCase();
6064
for (const lang of SUPPORTED_LANGUAGES) {
61-
if (envLang.startsWith(lang.code)) return lang.code;
65+
if (envLangLower.startsWith(lang.code)) return lang.code;
6266
}
6367
}
6468

packages/vscode-ide-companion/src/services/acpConnection.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import * as vscode from 'vscode';
78
import {
89
ClientSideConnection,
910
ndJsonStream,
@@ -80,7 +81,10 @@ export class AcpConnection {
8081

8182
this.workingDir = workingDir;
8283

83-
const env = { ...process.env };
84+
const env: NodeJS.ProcessEnv = {
85+
...process.env,
86+
QWEN_IDE_LANGUAGE: vscode.env.language,
87+
};
8488

8589
const proxyArg = extraArgs.find(
8690
(arg, i) => arg === '--proxy' && i + 1 < extraArgs.length,
@@ -166,16 +170,15 @@ export class AcpConnection {
166170
const stream = ndJsonStream(stdin, stdout);
167171

168172
// Build the SDK Client implementation that bridges to our callbacks.
169-
170-
const self = this;
173+
const getSelf = () => this;
171174
this.sdkConnection = new ClientSideConnection(
172175
(_agent: Agent): Client => ({
173176
sessionUpdate(params: SessionNotification): Promise<void> {
174177
console.log(
175178
'[ACP] >>> Processing session_update:',
176179
JSON.stringify(params).substring(0, 300),
177180
);
178-
self.onSessionUpdate(params as unknown as SessionNotification);
181+
getSelf().onSessionUpdate(params as unknown as SessionNotification);
179182
return Promise.resolve();
180183
},
181184

@@ -197,7 +200,7 @@ export class AcpConnection {
197200
const metadata =
198201
rawInput?.metadata as AskUserQuestionRequest['metadata'];
199202

200-
const response = await self.onAskUserQuestion({
203+
const response = await getSelf().onAskUserQuestion({
201204
sessionId: permissionData.sessionId,
202205
questions,
203206
metadata,
@@ -230,7 +233,8 @@ export class AcpConnection {
230233
}
231234

232235
// Handle regular permission request
233-
const response = await self.onPermissionRequest(permissionData);
236+
const response =
237+
await getSelf().onPermissionRequest(permissionData);
234238
const optionId = response?.optionId;
235239
console.log('[ACP] Permission request:', optionId);
236240
let outcome: 'selected' | 'cancelled';
@@ -247,7 +251,7 @@ export class AcpConnection {
247251
if (outcome === 'cancelled') {
248252
return { outcome: { outcome: 'cancelled' } };
249253
}
250-
const selectedOptionId = self.resolvePermissionOptionId(
254+
const selectedOptionId = getSelf().resolvePermissionOptionId(
251255
permissionData,
252256
optionId,
253257
);
@@ -269,22 +273,22 @@ export class AcpConnection {
269273
params: ReadTextFileRequest,
270274
): Promise<ReadTextFileResponse> {
271275
try {
272-
const result = await self.fileHandler.handleReadTextFile({
276+
const result = await getSelf().fileHandler.handleReadTextFile({
273277
path: params.path,
274278
sessionId: params.sessionId,
275279
line: params.line ?? null,
276280
limit: params.limit ?? null,
277281
});
278282
return { content: result.content };
279283
} catch (error) {
280-
throw self.mapReadTextFileError(error, params.path);
284+
throw getSelf().mapReadTextFileError(error, params.path);
281285
}
282286
},
283287

284288
async writeTextFile(
285289
params: WriteTextFileRequest,
286290
): Promise<WriteTextFileResponse> {
287-
await self.fileHandler.handleWriteTextFile({
291+
await getSelf().fileHandler.handleWriteTextFile({
288292
path: params.path,
289293
content: params.content,
290294
sessionId: params.sessionId,
@@ -301,7 +305,7 @@ export class AcpConnection {
301305
'[ACP] >>> Processing authenticate_update:',
302306
JSON.stringify(params).substring(0, 300),
303307
);
304-
self.onAuthenticateUpdate(
308+
getSelf().onAuthenticateUpdate(
305309
params as unknown as AuthenticateUpdateNotification,
306310
);
307311
} else {
@@ -386,13 +390,16 @@ export class AcpConnection {
386390
);
387391
}
388392

389-
async authenticate(methodId?: string, _meta?: Record<string, any>): Promise<AuthenticateResponse> {
393+
async authenticate(
394+
methodId?: string,
395+
_meta?: Record<string, unknown>,
396+
): Promise<AuthenticateResponse> {
390397
const conn = this.ensureConnection();
391398
const authMethodId = methodId || 'default';
392399
console.log(
393400
'[ACP] Sending authenticate request with methodId:',
394401
authMethodId,
395-
_meta
402+
_meta,
396403
);
397404
const response = await conn.authenticate({ methodId: authMethodId, _meta });
398405
console.log('[ACP] Authenticate successful', response);

packages/vscode-ide-companion/src/webview/providers/WebViewContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class WebViewContent {
4646
const safeScriptUri = escapeHtml(scriptUri.toString());
4747

4848
return `<!DOCTYPE html>
49-
<html lang="en">
49+
<html lang="${vscode.env.language}">
5050
<head>
5151
<meta charset="UTF-8">
5252
<meta name="viewport" content="width=device-width, initial-scale=1.0">

packages/webui/src/components/layout/Onboarding.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ export const Onboarding: FC<OnboardingProps> = ({
4040
onGetStarted,
4141
authMethods = [],
4242
appName = 'Qwen Code',
43-
subtitle = 'Unlock the power of AI to understand, navigate, and transform your codebase faster than ever before.',
44-
buttonText = 'Get Started with Qwen Code',
43+
subtitle,
44+
buttonText,
4545
errorMessage,
4646
}) => {
47+
const defaultSubtitle = t(
48+
'Unlock the power of AI to understand, navigate, and transform your codebase faster than ever before.',
49+
);
50+
const defaultButtonText = t('Get Started with Qwen Code');
51+
const finalSubtitle = subtitle ?? defaultSubtitle;
52+
const finalButtonText = buttonText ?? defaultButtonText;
53+
4754
const [selectedMethodId, setSelectedMethodId] = useState<string>('');
4855
const [codingPlanKey, setCodingPlanKey] = useState<string>('');
4956
const [codingPlanRegion, setCodingPlanRegion] = useState<string>('china');
@@ -83,16 +90,20 @@ export const Onboarding: FC<OnboardingProps> = ({
8390

8491
<div className="text-center">
8592
<h1 className="text-2xl font-bold text-[var(--app-primary-foreground)] mb-2">
86-
Welcome to {appName}
93+
{appName === 'Qwen Code'
94+
? t('Welcome to Qwen Code')
95+
: `Welcome to ${appName}`}
8796
</h1>
8897
<p className="text-[var(--app-secondary-foreground)] max-w-sm">
89-
{subtitle}
98+
{finalSubtitle}
9099
</p>
91100
</div>
92101

93102
{errorMessage && (
94103
<div className="w-full p-3 bg-red-500/10 border border-red-500/30 rounded-md text-red-500 text-sm break-words">
95-
{errorMessage}
104+
{errorMessage === 'Login failed. Please try again.'
105+
? t('Login failed. Please try again.')
106+
: errorMessage}
96107
</div>
97108
)}
98109

@@ -102,7 +113,7 @@ export const Onboarding: FC<OnboardingProps> = ({
102113
onClick={() => onGetStarted('qwen-oauth')}
103114
className="w-full px-4 py-3 bg-[var(--app-primary,var(--app-button-background))] text-[var(--app-button-foreground,#ffffff)] font-medium rounded-lg shadow-sm hover:bg-[var(--app-primary-hover,var(--app-button-hover-background))] transition-colors duration-200"
104115
>
105-
{buttonText}
116+
{finalButtonText}
106117
</button>
107118
) : selectedMethodId === 'coding-plan' ? (
108119
<div className="flex flex-col gap-4 w-full text-left bg-[var(--app-input-background)] p-4 rounded-md border border-[var(--app-input-border)]">
@@ -128,9 +139,11 @@ export const Onboarding: FC<OnboardingProps> = ({
128139
onChange={(e) => setCodingPlanRegion(e.target.value)}
129140
className="px-3 py-2 bg-[var(--vscode-dropdown-background)] border border-[var(--vscode-dropdown-border)] text-[var(--vscode-dropdown-foreground)] rounded w-full outline-none focus:border-[var(--vscode-focusBorder)] cursor-pointer"
130141
>
131-
<option value="china">阿里云百炼 (aliyun.com)</option>
142+
<option value="china">
143+
{t('Alibaba Cloud (aliyun.com)')}
144+
</option>
132145
<option value="global">
133-
Alibaba Cloud (alibabacloud.com)
146+
{t('Alibaba Cloud (alibabacloud.com)')}
134147
</option>
135148
</select>
136149
</div>
@@ -165,12 +178,16 @@ export const Onboarding: FC<OnboardingProps> = ({
165178
{t('Refer to the documentation for setup instructions.')}
166179
</p>
167180
<a
168-
href="https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/"
181+
href={t(
182+
'https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/',
183+
)}
169184
target="_blank"
170185
rel="noreferrer"
171186
className="text-[var(--vscode-textLink-foreground)] hover:text-[var(--vscode-textLink-activeForeground)] underline break-all"
172187
>
173-
https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/
188+
{t(
189+
'https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/',
190+
)}
174191
</a>
175192
</div>
176193
<div className="flex gap-2 mt-4">

packages/webui/src/components/messages/AskUserQuestionDialog.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import type { FC } from 'react';
1111
import { useState, useEffect, useRef, useCallback } from 'react';
12+
import { t } from '../../utils/i18n.js';
1213

1314
export interface QuestionOption {
1415
label: string;
@@ -297,7 +298,7 @@ export const AskUserQuestionDialog: FC<AskUserQuestionDialogProps> = ({
297298
}`}
298299
onClick={() => setCurrentQuestionIndex(totalTabs - 1)}
299300
>
300-
<span>Submit</span>
301+
<span>{t('Submit')}</span>
301302
</button>
302303
</div>
303304
);
@@ -364,7 +365,7 @@ export const AskUserQuestionDialog: FC<AskUserQuestionDialogProps> = ({
364365
}}
365366
onClick={onCancel}
366367
>
367-
Cancel
368+
{t('Cancel')}
368369
</button>
369370
</div>
370371
</div>
@@ -517,7 +518,7 @@ export const AskUserQuestionDialog: FC<AskUserQuestionDialogProps> = ({
517518
}}
518519
onClick={onCancel}
519520
>
520-
Cancel
521+
{t('Cancel')}
521522
</button>
522523
</div>
523524
</div>

0 commit comments

Comments
 (0)