refactor(vscode-ide-companion): simplify ACP connection and cleanup configurations

- Remove .claude from .gitignore
- Update CSS file path in eslint config
- Simplify VS Code extension title
- Remove unused keybinding for openChat command
- Delete unused auth constants file
- Simplify ACP connection by removing backend parameter
- Move authMethod to acpTypes
- Restrict ACP backend to Qwen only
- Remove backend property from connection state
- Minor formatting update in webview index.tsx
This commit is contained in:
yiliang114
2025-12-08 20:40:32 +08:00
parent 96cd685b1b
commit 111234eb24
11 changed files with 19 additions and 40 deletions

2
.gitignore vendored
View File

@@ -57,5 +57,3 @@ gha-creds-*.json
# Log files
patch_output.log
.claude/

View File

@@ -120,7 +120,7 @@ export default tseslint.config(
'**/generated/**',
'./styles/tailwind.css',
'./styles/App.css',
'./styles/ClaudeCodeStyles.css'
'./styles/style.css'
],
},
],

View File

@@ -57,7 +57,7 @@
},
{
"command": "qwen-code.openChat",
"title": "Qwen Code: Open Chat",
"title": "Qwen Code: Open",
"icon": "./assets/icon.png"
},
{
@@ -107,11 +107,6 @@
"command": "qwen.diff.accept",
"key": "cmd+s",
"when": "qwen.diff.isVisible"
},
{
"command": "qwen-code.openChat",
"key": "ctrl+shift+a",
"mac": "cmd+shift+a"
}
]
},

View File

@@ -1,7 +0,0 @@
/**
* @license
* Copyright 2025 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/
export const authMethod = 'qwen-oauth';

View File

@@ -6,7 +6,6 @@
import { JSONRPC_VERSION } from '../types/acpTypes.js';
import type {
AcpBackend,
AcpMessage,
AcpPermissionRequest,
AcpResponse,
@@ -31,7 +30,6 @@ export class AcpConnection {
private child: ChildProcess | null = null;
private pendingRequests = new Map<number, PendingRequest<unknown>>();
private nextRequestId = { value: 0 };
private backend: AcpBackend | null = null;
// Remember the working dir provided at connect() so later ACP calls
// that require cwd (e.g. session/list) can include it.
private workingDir: string = process.cwd();
@@ -53,15 +51,13 @@ export class AcpConnection {
}
/**
* Connect to ACP backend
* Connect to Qwen ACP
*
* @param backend - Backend type
* @param cliPath - CLI path
* @param workingDir - Working directory
* @param extraArgs - Extra command line arguments
*/
async connect(
backend: AcpBackend,
cliPath: string,
workingDir: string = process.cwd(),
extraArgs: string[] = [],
@@ -70,7 +66,6 @@ export class AcpConnection {
this.disconnect();
}
this.backend = backend;
this.workingDir = workingDir;
const isWindows = process.platform === 'win32';
@@ -136,15 +131,13 @@ export class AcpConnection {
};
this.child = spawn(spawnCommand, spawnArgs, options);
await this.setupChildProcessHandlers(backend);
await this.setupChildProcessHandlers();
}
/**
* Set up child process handlers
*
* @param backend - Backend name
*/
private async setupChildProcessHandlers(backend: string): Promise<void> {
private async setupChildProcessHandlers(): Promise<void> {
let spawnError: Error | null = null;
this.child!.stderr?.on('data', (data) => {
@@ -153,9 +146,9 @@ export class AcpConnection {
message.toLowerCase().includes('error') &&
!message.includes('Loaded cached')
) {
console.error(`[ACP ${backend}]:`, message);
console.error(`[ACP qwen]:`, message);
} else {
console.log(`[ACP ${backend}]:`, message);
console.log(`[ACP qwen]:`, message);
}
});
@@ -165,7 +158,7 @@ export class AcpConnection {
this.child!.on('exit', (code, signal) => {
console.error(
`[ACP ${backend}] Process exited with code: ${code}, signal: ${signal}`,
`[ACP qwen] Process exited with code: ${code}, signal: ${signal}`,
);
});
@@ -177,7 +170,7 @@ export class AcpConnection {
}
if (!this.child || this.child.killed) {
throw new Error(`${backend} ACP process failed to start`);
throw new Error(`Qwen ACP process failed to start`);
}
// Handle messages from ACP server
@@ -409,7 +402,6 @@ export class AcpConnection {
this.pendingRequests.clear();
this.sessionManager.reset();
this.backend = null;
}
/**

View File

@@ -20,7 +20,7 @@ import type {
import { QwenConnectionHandler } from '../services/qwenConnectionHandler.js';
import { QwenSessionUpdateHandler } from './qwenSessionUpdateHandler.js';
import { CliContextManager } from '../cli/cliContextManager.js';
import { authMethod } from '../constants/auth.js';
import { authMethod } from '../types/acpTypes.js';
export type { ChatMessage, PlanEntry, ToolCallUpdateData };
@@ -1220,7 +1220,7 @@ export class QwenAgentManager {
);
}
// Try to create a new ACP session. If the backend asks for auth despite our
// Try to create a new ACP session. If Qwen asks for auth despite our
// cached flag (e.g. fresh process or expired tokens), re-authenticate and retry.
try {
await this.connection.newSession(workingDir);

View File

@@ -16,7 +16,7 @@ import type { QwenSessionReader } from '../services/qwenSessionReader.js';
import type { AuthStateManager } from '../services/authStateManager.js';
import { CliVersionManager } from '../cli/cliVersionManager.js';
import { CliContextManager } from '../cli/cliContextManager.js';
import { authMethod } from '../constants/auth.js';
import { authMethod } from '../types/acpTypes.js';
/**
* Qwen Connection Handler class
@@ -71,7 +71,7 @@ export class QwenConnectionHandler {
// Build extra CLI arguments (only essential parameters)
const extraArgs: string[] = [];
await connection.connect('qwen', effectiveCliPath, workingDir, extraArgs);
await connection.connect(effectiveCliPath, workingDir, extraArgs);
// Check if we have valid cached authentication
if (authStateManager) {
@@ -214,14 +214,14 @@ export class QwenConnectionHandler {
errorMessage,
);
// If the backend reports that authentication is required, try to
// If Qwen reports that authentication is required, try to
// authenticate on-the-fly once and retry without waiting.
const requiresAuth =
errorMessage.includes('Authentication required') ||
errorMessage.includes('(code: -32000)');
if (requiresAuth) {
console.log(
'[QwenAgentManager] Backend requires authentication. Authenticating and retrying session/new...',
'[QwenAgentManager] Qwen requires authentication. Authenticating and retrying session/new...',
);
try {
await connection.authenticate(authMethod);

View File

@@ -5,8 +5,9 @@
*/
export const JSONRPC_VERSION = '2.0' as const;
export const authMethod = 'qwen-oauth';
export type AcpBackend = 'qwen' | 'claude' | 'gemini' | 'codex';
export type AcpBackend = 'qwen';
export interface AcpRequest {
jsonrpc: typeof JSONRPC_VERSION;

View File

@@ -28,5 +28,4 @@ export interface AcpConnectionState {
nextRequestId: number;
sessionId: string | null;
isInitialized: boolean;
backend: string | null;
}

View File

@@ -15,7 +15,7 @@ import { MessageHandler } from '../webview/MessageHandler.js';
import { WebViewContent } from '../webview/WebViewContent.js';
import { CliInstaller } from '../cli/cliInstaller.js';
import { getFileName } from './utils/webviewUtils.js';
import { authMethod } from '../constants/auth.js';
import { authMethod } from '../types/acpTypes.js';
export class WebViewProvider {
private panelManager: PanelManager;

View File

@@ -6,6 +6,7 @@
import ReactDOM from 'react-dom/client';
import { App } from './App.js';
// eslint-disable-next-line import/no-internal-modules
import './styles/tailwind.css';
// eslint-disable-next-line import/no-internal-modules