chore(vscode-ide-companion): rm useTerminal & some useless code about openDiff

This commit is contained in:
yiliang114
2025-12-08 12:46:42 +08:00
parent 6269415e7b
commit ac0d5206ba
13 changed files with 15 additions and 240 deletions

View File

@@ -21,24 +21,12 @@ export function registerNewCommands(
disposables.push(
vscode.commands.registerCommand(openChatCommand, async () => {
const config = vscode.workspace.getConfiguration('qwenCode');
const useTerminal = config.get<boolean>('useTerminal', false);
// Use terminal mode
if (useTerminal) {
await vscode.commands.executeCommand(
runQwenCodeCommand,
vscode.TerminalLocation.Editor, // create a terminal in the editor area,
);
const providers = getWebViewProviders();
if (providers.length > 0) {
await providers[providers.length - 1].show();
} else {
// Use WebView mode
const providers = getWebViewProviders();
if (providers.length > 0) {
await providers[providers.length - 1].show();
} else {
const provider = createWebViewProvider();
await provider.show();
}
const provider = createWebViewProvider();
await provider.show();
}
}),
);

View File

@@ -165,48 +165,6 @@ export class DiffManager {
const normalizedPath = path.normalize(filePath);
const key = this.makeKey(normalizedPath, oldContent, newContent);
// TODO:
// // Suppress entirely when the extension indicates diffs should not be shown
// if (this.shouldSuppress && this.shouldSuppress()) {
// this.log(`showDiff suppressed by policy for ${filePath}`);
// return;
// }
// // Suppress during timed window
// if (this.suppressUntil && Date.now() < this.suppressUntil) {
// this.log(`showDiff suppressed by timed window for ${filePath}`);
// return;
// }
// // If permission drawer is currently open, delay to avoid double-open
// if (this.shouldDelay && this.shouldDelay()) {
// if (!this.pendingDelayTimers.has(key)) {
// const timer = setTimeout(() => {
// this.pendingDelayTimers.delete(key);
// // Fire and forget; rely on dedupe below to avoid double focus
// void this.showDiff(filePath, oldContent, newContent);
// }, 300);
// this.pendingDelayTimers.set(key, timer);
// }
// return;
// }
// // If a diff tab for the same file is already open, update its content instead of opening a new one
// for (const [, diffInfo] of this.diffDocuments.entries()) {
// if (diffInfo.originalFilePath === normalizedPath) {
// // Update left/right contents
// this.diffContentProvider.setContent(diffInfo.leftDocUri, oldContent);
// this.diffContentProvider.setContent(diffInfo.rightDocUri, newContent);
// // Update stored snapshot for future comparisons
// diffInfo.oldContent = oldContent;
// diffInfo.newContent = newContent;
// this.recentlyShown.set(key, Date.now());
// // Soft focus existing (preserve chat focus)
// await this.focusExistingDiff(normalizedPath);
// return;
// }
// }
// Check if a diff view with the same content already exists
if (this.hasExistingDiff(normalizedPath, oldContent, newContent)) {
const last = this.recentlyShown.get(key) || 0;

View File

@@ -16,7 +16,7 @@ import type {
PlanEntry,
ToolCallUpdateData,
QwenAgentCallbacks,
} from '../types/qwenTypes.js';
} from '../types/chatTypes.js';
import { QwenConnectionHandler } from '../services/qwenConnectionHandler.js';
import { QwenSessionUpdateHandler } from './qwenSessionUpdateHandler.js';
import { CliContextManager } from '../cli/cliContextManager.js';

View File

@@ -11,7 +11,7 @@
*/
import type { AcpSessionUpdate, ApprovalModeValue } from '../types/acpTypes.js';
import type { QwenAgentCallbacks } from '../types/qwenTypes.js';
import type { QwenAgentCallbacks } from '../types/chatTypes.js';
/**
* Qwen Session Update Handler class

View File

@@ -31,7 +31,6 @@ import { hasToolCallOutput } from './components/messages/toolcalls/shared/utils.
import { EmptyState } from './components/layout/EmptyState.js';
import { type CompletionItem } from '../types/completionItemTypes.js';
import { useCompletionTrigger } from './hooks/useCompletionTrigger.js';
import { InfoBanner } from './components/layout/InfoBanner.js';
import { ChatHeader } from './components/layout/ChatHeader.js';
import {
UserMessage,
@@ -43,8 +42,8 @@ import {
import { InputForm } from './components/layout/InputForm.js';
import { SessionSelector } from './components/layout/SessionSelector.js';
import { FileIcon, UserIcon } from './components/icons/index.js';
import type { EditMode } from '../types/qwenTypes.js';
import type { PlanEntry } from '../types/qwenTypes.js';
import type { EditMode } from '../types/chatTypes.js';
import type { PlanEntry } from '../types/chatTypes.js';
export const App: React.FC = () => {
const vscode = useVSCode();
@@ -77,16 +76,7 @@ export const App: React.FC = () => {
const inputFieldRef = useRef<HTMLDivElement>(
null,
) as React.RefObject<HTMLDivElement>;
// Persist the dismissal of the info banner across webview reloads
// Use VS Code webview state to avoid flicker on first render.
const [showBanner, setShowBanner] = useState<boolean>(() => {
try {
const state = (vscode.getState?.() as Record<string, unknown>) || {};
return state.infoBannerDismissed !== true; // show unless explicitly dismissed
} catch {
return true;
}
});
const [editMode, setEditMode] = useState<EditMode>('ask');
const [thinkingEnabled, setThinkingEnabled] = useState(false);
const [isComposing, setIsComposing] = useState(false);
@@ -691,24 +681,6 @@ export const App: React.FC = () => {
)}
</div>
<InfoBanner
visible={showBanner}
onDismiss={() => {
setShowBanner(false);
// merge with existing webview state so we don't clobber other keys
try {
const prev = (vscode.getState?.() as Record<string, unknown>) || {};
vscode.setState?.({ ...prev, infoBannerDismissed: true });
} catch {
/* no-op */
}
}}
onLinkClick={(e) => {
e.preventDefault();
vscode.postMessage({ type: 'openSettings', data: {} });
}}
/>
<InputForm
inputText={inputText}
inputFieldRef={inputFieldRef}

View File

@@ -16,7 +16,6 @@ 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 { runQwenCodeCommand } from '../commands/index.js';
export class WebViewProvider {
private panelManager: PanelManager;
@@ -1199,29 +1198,6 @@ export class WebViewProvider {
* This is called when the user clicks the "New Session" button
*/
async createNewSession(): Promise<void> {
console.log('[WebViewProvider] Creating new session in current panel');
// Check if terminal mode is enabled
const config = vscode.workspace.getConfiguration('qwenCode');
const useTerminal = config.get<boolean>('useTerminal', false);
if (useTerminal) {
// In terminal mode, execute the runQwenCode command to open a new terminal
try {
await vscode.commands.executeCommand(runQwenCodeCommand);
console.log('[WebViewProvider] Opened new terminal session');
} catch (_error) {
console.error(
'[WebViewProvider] Failed to open new terminal session:',
_error,
);
vscode.window.showErrorMessage(
`Failed to open new terminal session: ${_error}`,
);
}
return;
}
// WebView mode - create new session via agent manager
try {
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];

View File

@@ -1,109 +0,0 @@
/**
* @license
* Copyright 2025 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/
import type React from 'react';
import { TerminalIcon, CloseIcon } from '../icons/index.js';
interface InfoBannerProps {
/**
* Whether the banner is visible
*/
visible: boolean;
/**
* Callback when the banner is dismissed
*/
onDismiss: () => void;
/**
* Optional: Custom message content (if not provided, uses default)
*/
message?: React.ReactNode;
/**
* Optional: Custom link text
*/
linkText?: string;
/**
* Optional: Callback when the link is clicked
*/
onLinkClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
}
export const InfoBanner: React.FC<InfoBannerProps> = ({
visible,
onDismiss,
message,
linkText = 'Switch back in Settings.',
onLinkClick,
}) => {
if (!visible) {
return null;
}
return (
<div
className="flex items-center justify-between"
style={{
gap: '12px',
padding: '8px 16px',
maxWidth: '500px',
margin: '0 auto',
}}
>
<div className="flex items-center flex-1 min-w-0" style={{ gap: '8px' }}>
{/* Icon */}
<TerminalIcon className="flex-shrink-0 w-4 h-4" />
{/* Message */}
<label
className="m-0 leading-snug text-[11px]"
style={{ color: 'var(--app-primary-foreground)' }}
>
{message || (
<>
Prefer the Terminal experience?{' '}
{onLinkClick && (
<a
href="#"
className="no-underline hover:underline cursor-pointer outline-none"
style={{ color: 'var(--app-secondary-foreground)' }}
onClick={onLinkClick}
>
{linkText}
</a>
)}
</>
)}
</label>
</div>
{/* Close button */}
<button
className="flex items-center justify-center cursor-pointer rounded"
style={{
background: 'none',
border: 'none',
padding: '6px',
color: 'var(--app-secondary-foreground)',
borderRadius: '4px',
}}
onMouseEnter={(e) => {
e.currentTarget.style.backgroundColor =
'var(--app-ghost-button-hover-background)';
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = 'transparent';
}}
aria-label="Close banner"
onClick={onDismiss}
>
<CloseIcon className="w-[10px] h-[10px]" />
</button>
</div>
);
};

View File

@@ -19,7 +19,7 @@ import {
} from '../icons/index.js';
import { CompletionMenu } from '../layout/CompletionMenu.js';
import type { CompletionItem } from '../../../types/completionItemTypes.js';
import type { EditMode } from '../../../types/qwenTypes.js';
import type { EditMode } from '../../../types/chatTypes.js';
interface InputFormProps {
inputText: string;

View File

@@ -11,7 +11,7 @@ import type { BaseToolCallProps } from '../shared/types.js';
import type { ToolCallContainerProps } from '../shared/LayoutComponents.js';
import { groupContent, safeTitle } from '../shared/utils.js';
import { CheckboxDisplay } from './CheckboxDisplay.js';
import type { PlanEntry } from '../../../../../types/qwenTypes.js';
import type { PlanEntry } from '../../../../../types/chatTypes.js';
type EntryStatus = 'pending' | 'in_progress' | 'completed';

View File

@@ -6,7 +6,7 @@
import { useState, useCallback } from 'react';
import type { ToolCallData } from '../components/messages/toolcalls/ToolCall.js';
import type { ToolCallUpdate } from '../../types/qwenTypes.js';
import type { ToolCallUpdate } from '../../types/chatTypes.js';
/**
* Tool call management Hook

View File

@@ -11,8 +11,8 @@ import type {
PermissionOption,
ToolCall as PermissionToolCall,
} from '../components/PermissionDrawer/PermissionRequest.js';
import type { ToolCallUpdate, EditMode } from '../../types/qwenTypes.js';
import type { PlanEntry } from '../../types/qwenTypes.js';
import type { ToolCallUpdate, EditMode } from '../../types/chatTypes.js';
import type { PlanEntry } from '../../types/chatTypes.js';
interface UseWebViewMessagesProps {
// Session management