Sync upstream Gemini-CLI v0.8.2 (#838)

This commit is contained in:
tanzhenxin
2025-10-23 09:27:04 +08:00
committed by GitHub
parent 096fabb5d6
commit eb95c131be
644 changed files with 70389 additions and 23709 deletions

View File

@@ -4,12 +4,19 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Config, IdeClient, File } from '@qwen-code/qwen-code-core';
import {
type Config,
IdeClient,
type File,
logIdeConnection,
IdeConnectionEvent,
IdeConnectionType,
} from '@qwen-code/qwen-code-core';
import {
QWEN_CODE_COMPANION_EXTENSION_NAME,
getIdeInstaller,
IDEConnectionStatus,
ideContext,
ideContextStore,
} from '@qwen-code/qwen-code-core';
import path from 'node:path';
import type {
@@ -83,7 +90,7 @@ async function getIdeStatusMessageWithFiles(ideClient: IdeClient): Promise<{
switch (connection.status) {
case IDEConnectionStatus.Connected: {
let content = `🟢 Connected to ${ideClient.getDetectedIdeDisplayName()}`;
const context = ideContext.getIdeContext();
const context = ideContextStore.get();
const openFiles = context?.workspaceState?.openFiles;
if (openFiles && openFiles.length > 0) {
content += formatFileList(openFiles);
@@ -111,13 +118,24 @@ async function getIdeStatusMessageWithFiles(ideClient: IdeClient): Promise<{
}
}
export const ideCommand = (config: Config | null): SlashCommand | null => {
if (!config) {
return null;
async function setIdeModeAndSyncConnection(
config: Config,
value: boolean,
): Promise<void> {
config.setIdeMode(value);
const ideClient = await IdeClient.getInstance();
if (value) {
await ideClient.connect();
logIdeConnection(config, new IdeConnectionEvent(IdeConnectionType.SESSION));
} else {
await ideClient.disconnect();
}
const ideClient = config.getIdeClient();
}
export const ideCommand = async (): Promise<SlashCommand> => {
const ideClient = await IdeClient.getInstance();
const currentIDE = ideClient.getCurrentIde();
if (!currentIDE || !ideClient.getDetectedIdeDisplayName()) {
if (!currentIDE) {
return {
name: 'ide',
description: 'manage IDE integration',
@@ -194,7 +212,7 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
);
// Poll for up to 5 seconds for the extension to activate.
for (let i = 0; i < 10; i++) {
await config.setIdeModeAndSyncConnection(true);
await setIdeModeAndSyncConnection(context.services.config!, true);
if (
ideClient.getConnectionStatus().status ===
IDEConnectionStatus.Connected
@@ -236,7 +254,7 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
'ide.enabled',
true,
);
await config.setIdeModeAndSyncConnection(true);
await setIdeModeAndSyncConnection(context.services.config!, true);
const { messageType, content } = getIdeStatusMessage(ideClient);
context.ui.addItem(
{
@@ -258,7 +276,7 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
'ide.enabled',
false,
);
await config.setIdeModeAndSyncConnection(false);
await setIdeModeAndSyncConnection(context.services.config!, false);
const { messageType, content } = getIdeStatusMessage(ideClient);
context.ui.addItem(
{