diff --git a/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ApplyBlockHoverButtons.tsx b/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ApplyBlockHoverButtons.tsx index c1451e88da66..577426eb6763 100644 --- a/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ApplyBlockHoverButtons.tsx +++ b/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ApplyBlockHoverButtons.tsx @@ -10,7 +10,8 @@ import { isFeatureNameDisabled } from '../../../../common/cortexideSettingsTypes import { URI } from '../../../../../../../base/common/uri.js' import { FileSymlink, LucideIcon, RotateCw, Terminal } from 'lucide-react' import { Check, X, Square, Copy, Play, } from 'lucide-react' -import { getBasename, ListableToolItem, voidOpenFileFn, ToolChildrenWrapper } from '../sidebar-tsx/SidebarChat.js' +import { getBasename, voidOpenFileFn } from '../sidebar-tsx/shared/pathUtils.js' +import { ListableToolItem, ToolChildrenWrapper } from '../sidebar-tsx/tools/ToolPrimitives.js' import { PlacesType, VariantType } from 'react-tooltip' enum CopyButtonText { diff --git a/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ChatMarkdownRender.tsx b/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ChatMarkdownRender.tsx index d5f6bbc77502..cb8d58dc95d0 100644 --- a/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ChatMarkdownRender.tsx +++ b/src/vs/workbench/contrib/cortexide/browser/react/src/markdown/ChatMarkdownRender.tsx @@ -22,7 +22,7 @@ import { isAbsolute } from '../../../../../../../base/common/path.js' import { separateOutFirstLine } from '../../../../common/helpers/util.js' import { BlockCode } from '../util/inputs.js' import { CodespanLocationLink } from '../../../../common/chatThreadServiceTypes.js' -import { getBasename, getRelative, voidOpenFileFn } from '../sidebar-tsx/SidebarChat.js' +import { getBasename, getRelative, voidOpenFileFn } from '../sidebar-tsx/shared/pathUtils.js' export type ChatMessageLocation = { diff --git a/src/vs/workbench/contrib/cortexide/browser/react/src/settings/ModelDropdown.tsx b/src/vs/workbench/contrib/cortexide/browser/react/src/settings/ModelDropdown.tsx index 72bc36c8e472..b0d0630c360d 100644 --- a/src/vs/workbench/contrib/cortexide/browser/react/src/settings/ModelDropdown.tsx +++ b/src/vs/workbench/contrib/cortexide/browser/react/src/settings/ModelDropdown.tsx @@ -8,7 +8,7 @@ import { FeatureName, featureNames, isFeatureNameDisabled, ModelSelection, model import { useSettingsState, useRefreshModelState, useAccessor } from '../util/services.js' import { _VoidSelectBox, VoidCustomDropdownBox } from '../util/inputs.js' import { SelectBox } from '../../../../../../../base/browser/ui/selectBox/selectBox.js' -import { IconWarning } from '../sidebar-tsx/SidebarChat.js' +import { IconWarning } from '../sidebar-tsx/shared/icons.js' import { CORTEXIDE_OPEN_SETTINGS_ACTION_ID, CORTEXIDE_TOGGLE_SETTINGS_ACTION_ID } from '../../../cortexideSettingsPane.js' import { modelFilterOfFeatureName, ModelOption } from '../../../../../../../workbench/contrib/cortexide/common/cortexideSettingsService.js' import { WarningBox } from './WarningBox.js' diff --git a/src/vs/workbench/contrib/cortexide/browser/react/src/settings/Settings.tsx b/src/vs/workbench/contrib/cortexide/browser/react/src/settings/Settings.tsx index fe226c00dc22..abc00921bef4 100644 --- a/src/vs/workbench/contrib/cortexide/browser/react/src/settings/Settings.tsx +++ b/src/vs/workbench/contrib/cortexide/browser/react/src/settings/Settings.tsx @@ -14,7 +14,7 @@ import { ModelDropdown } from './ModelDropdown.js' import { ChatMarkdownRender } from '../markdown/ChatMarkdownRender.js' import { WarningBox } from './WarningBox.js' import { os } from '../../../../common/helpers/systemInfo.js' -import { IconLoading } from '../sidebar-tsx/SidebarChat.js' +import { IconLoading } from '../sidebar-tsx/shared/icons.js' import { ToolApprovalType, toolApprovalTypes } from '../../../../common/toolsServiceTypes.js' import Severity from '../../../../../../../base/common/severity.js' import { getModelCapabilities, modelOverrideKeys, ModelOverrides } from '../../../../common/modelCapabilities.js'; diff --git a/src/vs/workbench/contrib/cortexide/browser/react/src/settings/WarningBox.tsx b/src/vs/workbench/contrib/cortexide/browser/react/src/settings/WarningBox.tsx index 97e0e4c35e19..48fd6cb8f5de 100644 --- a/src/vs/workbench/contrib/cortexide/browser/react/src/settings/WarningBox.tsx +++ b/src/vs/workbench/contrib/cortexide/browser/react/src/settings/WarningBox.tsx @@ -1,4 +1,4 @@ -import { IconWarning } from '../sidebar-tsx/SidebarChat.js'; +import { IconWarning } from '../sidebar-tsx/shared/icons.js'; export const WarningBox = ({ text, onClick, className }: { text: string; onClick?: () => void; className?: string }) => { diff --git a/src/vs/workbench/contrib/cortexide/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/cortexide/browser/react/src/sidebar-tsx/SidebarChat.tsx index dbc0fea44075..578728748760 100644 --- a/src/vs/workbench/contrib/cortexide/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/cortexide/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -7,7 +7,6 @@ import React, { ButtonHTMLAttributes, FormEvent, FormHTMLAttributes, Fragment, K import { useAccessor, useChatThreadsState, useChatThreadsStreamState, useSettingsState, useActiveURI, useCommandBarState, useFullChatThreadsStreamState } from '../util/services.js'; -import { ScrollType } from '../../../../../../../editor/common/editorCommon.js'; import { ChatMarkdownRender, ChatMessageLocation, getApplyBoxId } from '../markdown/ChatMarkdownRender.js'; import { URI } from '../../../../../../../base/common/uri.js'; @@ -46,170 +45,14 @@ import { ImageAttachmentList } from '../util/ImageAttachmentList.js'; import { ChatImageAttachment, ChatPDFAttachment } from '../../../../common/chatThreadServiceTypes.js'; import { ImageMessageRenderer } from '../util/ImageMessageRenderer.js'; import { PDFMessageRenderer } from '../util/PDFMessageRenderer.js'; +import { IconX, IconArrowUp, IconSquare, IconWarning, IconLoading, TypingCursor } from './shared/icons.js'; +import { getBasename, getFolderName, getRelative, voidOpenFileFn } from './shared/pathUtils.js'; +import { ToolChildrenWrapper, CodeChildren, ListableToolItem } from './tools/ToolPrimitives.js'; - - -export const IconX = ({ size, className = '', ...props }: { size: number, className?: string } & React.SVGProps) => { - return ( - - - - ); -}; - -const IconArrowUp = ({ size, className = '' }: { size: number, className?: string }) => { - return ( - - - - ); -}; - - -const IconSquare = ({ size, className = '' }: { size: number, className?: string }) => { - return ( - - - - ); -}; - - -export const IconWarning = ({ size, className = '' }: { size: number, className?: string }) => { - return ( - - - - ); -}; - - -type LoadingState = 'thinking' | 'typing' | 'processing' | 'default'; - -// Format token count with k/m suffixes for better readability -const formatTokenCount = (count: number): string => { - if (count >= 1000000) { - return `${(count / 1000000).toFixed(1)}M`; - } else if (count >= 1000) { - return `${(count / 1000).toFixed(1)}k`; - } - return count.toString(); -} - -export const IconLoading = ({ - className = '', - showTokenCount, - state = 'default', - inline = false -}: { - className?: string, - showTokenCount?: number, - state?: LoadingState, - inline?: boolean -}) => { - // Use CSS animations instead of JavaScript for better performance - const [prevTokenCount, setPrevTokenCount] = useState(undefined); - const [shouldPulse, setShouldPulse] = useState(false); - - useEffect(() => { - if (showTokenCount !== undefined && showTokenCount !== prevTokenCount) { - setShouldPulse(true); - setPrevTokenCount(showTokenCount); - const timer = setTimeout(() => setShouldPulse(false), 300); - return () => clearTimeout(timer); - } - }, [showTokenCount, prevTokenCount]); - - const tokenText = showTokenCount !== undefined - ? ` (${formatTokenCount(showTokenCount)} tokens)` - : ''; - - // Different animation speeds for different states - const animationSpeed = state === 'thinking' ? '1.6s' : state === 'processing' ? '1.2s' : '1.4s'; - - const dots = ( - - - - - - ); - - return ( -
- {dots} - {tokenText && ( - - {tokenText} - - )} -
- ); -} - -// Typing cursor component for inline use at end of streaming content -export const TypingCursor = ({ className = '' }: { className?: string }) => { - return ( -