mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-22 09:47:47 +00:00
chore(vscode-ide-companion): rm useTerminal & some useless code about openDiff
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user