|
1 | | -import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" |
2 | | -import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react" |
3 | | -import DynamicTextArea from "react-textarea-autosize" |
4 | | -import { useClickAway, useEvent, useWindowSize } from "react-use" |
5 | | -import styled from "styled-components" |
6 | | -import { mentionRegex, mentionRegexGlobal } from "@shared/context-mentions" |
7 | | -import { ExtensionMessage } from "@shared/ExtensionMessage" |
| 1 | +import { MAX_IMAGES_AND_FILES_PER_MESSAGE } from "@/components/chat/ChatView" |
| 2 | +import ContextMenu from "@/components/chat/ContextMenu" |
| 3 | +import SlashCommandMenu from "@/components/chat/SlashCommandMenu" |
| 4 | +import { CODE_BLOCK_BG_COLOR } from "@/components/common/CodeBlock" |
| 5 | +import Thumbnails from "@/components/common/Thumbnails" |
| 6 | +import Tooltip from "@/components/common/Tooltip" |
| 7 | +import ApiOptions, { normalizeApiConfiguration } from "@/components/settings/ApiOptions" |
8 | 8 | import { useExtensionState } from "@/context/ExtensionStateContext" |
| 9 | +import { FileServiceClient, StateServiceClient } from "@/services/grpc-client" |
9 | 10 | import { |
10 | 11 | ContextMenuOptionType, |
11 | 12 | getContextMenuOptions, |
12 | 13 | insertMention, |
13 | 14 | insertMentionDirectly, |
14 | 15 | removeMention, |
15 | | - shouldShowContextMenu, |
16 | 16 | SearchResult, |
| 17 | + shouldShowContextMenu, |
17 | 18 | } from "@/utils/context-mentions" |
| 19 | +import { useMetaKeyDetection, useShortcut } from "@/utils/hooks" |
18 | 20 | import { |
19 | | - SlashCommand, |
20 | | - slashCommandDeleteRegex, |
21 | | - shouldShowSlashCommandsMenu, |
22 | 21 | getMatchingSlashCommands, |
23 | 22 | insertSlashCommand, |
24 | 23 | removeSlashCommand, |
| 24 | + shouldShowSlashCommandsMenu, |
| 25 | + SlashCommand, |
| 26 | + slashCommandDeleteRegex, |
25 | 27 | validateSlashCommand, |
26 | 28 | } from "@/utils/slash-commands" |
27 | | -import { useMetaKeyDetection, useShortcut } from "@/utils/hooks" |
28 | 29 | import { validateApiConfiguration, validateModelId } from "@/utils/validate" |
29 | 30 | import { vscode } from "@/utils/vscode" |
30 | | -import { EmptyRequest } from "@shared/proto/common" |
31 | | -import { FileServiceClient, StateServiceClient } from "@/services/grpc-client" |
32 | | -import { CODE_BLOCK_BG_COLOR } from "@/components/common/CodeBlock" |
33 | | -import Thumbnails from "@/components/common/Thumbnails" |
34 | | -import Tooltip from "@/components/common/Tooltip" |
35 | | -import ApiOptions, { normalizeApiConfiguration } from "@/components/settings/ApiOptions" |
36 | | -import { MAX_IMAGES_AND_FILES_PER_MESSAGE } from "@/components/chat/ChatView" |
37 | | -import ContextMenu from "@/components/chat/ContextMenu" |
38 | | -import SlashCommandMenu from "@/components/chat/SlashCommandMenu" |
39 | 31 | import { ChatSettings } from "@shared/ChatSettings" |
40 | | -import ServersToggleModal from "./ServersToggleModal" |
| 32 | +import { mentionRegex, mentionRegexGlobal } from "@shared/context-mentions" |
| 33 | +import { ExtensionMessage } from "@shared/ExtensionMessage" |
| 34 | +import { EmptyRequest, StringRequest } from "@shared/proto/common" |
| 35 | +import { FileSearchRequest, RelativePathsRequest } from "@shared/proto/file" |
| 36 | +import { PlanActMode, TogglePlanActModeRequest } from "@shared/proto/state" |
| 37 | +import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" |
| 38 | +import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react" |
| 39 | +import DynamicTextArea from "react-textarea-autosize" |
| 40 | +import { useClickAway, useEvent, useWindowSize } from "react-use" |
| 41 | +import styled from "styled-components" |
41 | 42 | import ClineRulesToggleModal from "../cline-rules/ClineRulesToggleModal" |
42 | | -import { PlanActMode } from "@shared/proto/state" |
| 43 | +import ServersToggleModal from "./ServersToggleModal" |
43 | 44 |
|
44 | 45 | const getImageDimensions = (dataUrl: string): Promise<{ width: number; height: number }> => { |
45 | 46 | return new Promise((resolve, reject) => { |
@@ -320,7 +321,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( |
320 | 321 | // Fetch git commits when Git is selected or when typing a hash |
321 | 322 | useEffect(() => { |
322 | 323 | if (selectedType === ContextMenuOptionType.Git || /^[a-f0-9]+$/i.test(searchQuery)) { |
323 | | - FileServiceClient.searchCommits({ value: searchQuery || "" }) |
| 324 | + FileServiceClient.searchCommits(StringRequest.create({ value: searchQuery || "" })) |
324 | 325 | .then((response) => { |
325 | 326 | if (response.commits) { |
326 | 327 | const commits: GitCommit[] = response.commits.map( |
@@ -752,10 +753,12 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( |
752 | 753 |
|
753 | 754 | // Set a timeout to debounce the search requests |
754 | 755 | searchTimeoutRef.current = setTimeout(() => { |
755 | | - FileServiceClient.searchFiles({ |
756 | | - query: query, |
757 | | - mentionsRequestId: query, |
758 | | - }) |
| 756 | + FileServiceClient.searchFiles( |
| 757 | + FileSearchRequest.create({ |
| 758 | + query: query, |
| 759 | + mentionsRequestId: query, |
| 760 | + }), |
| 761 | + ) |
759 | 762 | .then((results) => { |
760 | 763 | setFileSearchResults(results.results || []) |
761 | 764 | setSearchLoading(false) |
@@ -998,18 +1001,20 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( |
998 | 1001 | } |
999 | 1002 | setTimeout(() => { |
1000 | 1003 | const newMode = chatSettings.mode === "plan" ? PlanActMode.ACT : PlanActMode.PLAN |
1001 | | - StateServiceClient.togglePlanActMode({ |
1002 | | - chatSettings: { |
1003 | | - mode: newMode, |
1004 | | - preferredLanguage: chatSettings.preferredLanguage, |
1005 | | - openAIReasoningEffort: chatSettings.openAIReasoningEffort, |
1006 | | - }, |
1007 | | - chatContent: { |
1008 | | - message: inputValue.trim() ? inputValue : undefined, |
1009 | | - images: selectedImages.length > 0 ? selectedImages : undefined, |
1010 | | - files: selectedFiles.length > 0 ? selectedFiles : undefined, |
1011 | | - }, |
1012 | | - }) |
| 1004 | + StateServiceClient.togglePlanActMode( |
| 1005 | + TogglePlanActModeRequest.create({ |
| 1006 | + chatSettings: { |
| 1007 | + mode: newMode, |
| 1008 | + preferredLanguage: chatSettings.preferredLanguage, |
| 1009 | + openAiReasoningEffort: chatSettings.openAIReasoningEffort, |
| 1010 | + }, |
| 1011 | + chatContent: { |
| 1012 | + message: inputValue.trim() ? inputValue : undefined, |
| 1013 | + images: selectedImages.length > 0 ? selectedImages : undefined, |
| 1014 | + files: selectedFiles.length > 0 ? selectedFiles : undefined, |
| 1015 | + }, |
| 1016 | + }), |
| 1017 | + ) |
1013 | 1018 | // Focus the textarea after mode toggle with slight delay |
1014 | 1019 | setTimeout(() => { |
1015 | 1020 | textAreaRef.current?.focus() |
@@ -1265,7 +1270,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( |
1265 | 1270 | } |
1266 | 1271 | setIntendedCursorPosition(initialCursorPos) |
1267 | 1272 |
|
1268 | | - FileServiceClient.getRelativePaths({ uris: validUris }) |
| 1273 | + FileServiceClient.getRelativePaths(RelativePathsRequest.create({ uris: validUris })) |
1269 | 1274 | .then((response) => { |
1270 | 1275 | if (response.paths.length > 0) { |
1271 | 1276 | setPendingInsertions((prev) => [...prev, ...response.paths]) |
|
0 commit comments