Elffuss BraidHub

kikocis/continue public

merge: main
Changeset54d55003e0dd3338ea5d0ce04a956a8a34c1a7d60abf7d7f6a324ea99e6cda98
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-11 12:20 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-09-11 12:20 -07:00
Parentsc302a3f43ba7, 4ad58566a4b3

Browse the files at this changeset

14 files changed

modified .github/workflows/continue-detailed-review.yaml +1 −1
@@ -18,7 +18,7 @@
1818 timeout-minutes: 10
1919 steps:
2020 - name: Run Detailed PR Review
21- uses: continuedev/continue/actions/detailed-review@b3f4b82600f603ca28c65a319b80ec36c4644ed7
21+ uses: continuedev/continue/actions/detailed-review@5dc7a050db441934c26eb910b8433291f627db7f
2222 with:
2323 continue-api-key: ${{ secrets.CONTINUE_API_KEY }}
2424 continue-org: continuedev
modified .github/workflows/continue-general-review.yaml +1 −1
@@ -18,7 +18,7 @@
1818 timeout-minutes: 10
1919 steps:
2020 - name: Run Continue PR Review Action
21- uses: continuedev/continue/actions/general-review@b3f4b82600f603ca28c65a319b80ec36c4644ed7
21+ uses: continuedev/continue/actions/general-review@5dc7a050db441934c26eb910b8433291f627db7f
2222 with:
2323 continue-api-key: ${{ secrets.CONTINUE_API_KEY }}
2424 continue-org: "continuedev"
modified core/config/types.ts +1 −0
@@ -1061,6 +1061,7 @@
10611061 filepath?: string;
10621062 fileContent?: string;
10631063 originalFileContent?: string;
1064+ autoFormattingDiff?: string;
10641065 }
10651066
10661067 export interface RangeInFileWithContents {
modified core/index.d.ts +1 −0
@@ -1387,6 +1387,7 @@
13871387 fileContent?: string;
13881388 originalFileContent?: string;
13891389 toolCallId?: string;
1390+ autoFormattingDiff?: string;
13901391 }
13911392
13921393 export interface StreamDiffLinesPayload {
added extensions/cli/src/stream/messageQueue.test.ts +62 −0
@@ -0,0 +1,62 @@
1+import { beforeEach, describe, expect, it, vi } from "vitest";
2+
3+vi.mock("../util/logger.js", () => ({
4+ logger: {
5+ debug: vi.fn(),
6+ info: vi.fn(),
7+ warn: vi.fn(),
8+ error: vi.fn(),
9+ setLevel: vi.fn(),
10+ configureHeadlessMode: vi.fn(),
11+ getLogPath: vi.fn(),
12+ getSessionId: vi.fn(),
13+ },
14+}));
15+
16+import { messageQueue } from "./messageQueue.js";
17+
18+describe("messageQueue", () => {
19+ beforeEach(() => {
20+ // Drain any leftover items from previous tests
21+ while (messageQueue.getAllQueuedMessages()) {}
22+ });
23+
24+ it("enqueues and emits messageQueued", async () => {
25+ const event = new Promise<any>((resolve) =>
26+ messageQueue.once("messageQueued", resolve),
27+ );
28+
29+ const ok = await messageQueue.enqueueMessage("hello world");
30+ expect(ok).toBe(true);
31+ expect(messageQueue.getQueueLength()).toBe(1);
32+
33+ const queued = await event;
34+ expect(queued.message).toBe("hello world");
35+ });
36+
37+ it("combines messages, merges image maps, writes history, and clears queue", async () => {
38+ const bufA = Buffer.from("A");
39+ const bufB = Buffer.from("B");
40+
41+ const img1 = new Map<string, Buffer>([["a", bufA]]);
42+ const img2 = new Map<string, Buffer>([["b", bufB]]);
43+
44+ const history = { addEntry: vi.fn() } as any;
45+
46+ await messageQueue.enqueueMessage("one", img1);
47+ await messageQueue.enqueueMessage("two", img2, history);
48+
49+ const combined = messageQueue.getAllQueuedMessages();
50+ expect(combined).toBeTruthy();
51+ expect(combined!.message).toBe("one\ntwo");
52+ expect(combined!.imageMap).toBeDefined();
53+ expect(combined!.imageMap!.get("a")).toEqual(bufA);
54+ expect(combined!.imageMap!.get("b")).toEqual(bufB);
55+
56+ // queue should be cleared
57+ expect(messageQueue.getQueueLength()).toBe(0);
58+
59+ // input history should receive the combined message
60+ expect(history.addEntry).toHaveBeenCalledWith("one\ntwo");
61+ });
62+});
added extensions/cli/src/stream/messageQueue.ts +94 −0
@@ -0,0 +1,94 @@
1+import { EventEmitter } from "events";
2+
3+import { InputHistory } from "../util/inputHistory.js";
4+import { logger } from "../util/logger.js";
5+
6+export interface QueuedMessage {
7+ message: string;
8+ imageMap?: Map<string, Buffer>;
9+ timestamp: number;
10+}
11+
12+export interface MessageProcessor {
13+ (message: string, imageMap?: Map<string, Buffer>): Promise<void>;
14+}
15+
16+/**
17+ * A queue to store messages that need to be processed later
18+ */
19+class MessageQueue extends EventEmitter {
20+ private queue: QueuedMessage[] = [];
21+ private inputHistory: InputHistory | undefined;
22+
23+ constructor() {
24+ super();
25+ }
26+
27+ async enqueueMessage(
28+ message: string,
29+ imageMap?: Map<string, Buffer>,
30+ inputHistory?: InputHistory,
31+ ): Promise<boolean> {
32+ this.inputHistory = inputHistory;
33+
34+ const queuedMessage: QueuedMessage = {
35+ message,
36+ imageMap,
37+ timestamp: Date.now(),
38+ };
39+
40+ this.queue.push(queuedMessage);
41+ logger.debug("MessageQueue: Message queued", {
42+ queueLength: this.queue.length,
43+ });
44+
45+ // Emit event for UI to show the queued message
46+ this.emit("messageQueued", queuedMessage);
47+
48+ return true;
49+ }
50+
51+ public getAllQueuedMessages() {
52+ if (this.queue.length === 0) return undefined;
53+
54+ // Combine all queued messages into one
55+ const combinedMessage = this.queue.map((msg) => msg.message).join("\n");
56+ const combinedImageMap = new Map<string, Buffer>();
57+
58+ // Merge all image maps
59+ for (const queuedMsg of this.queue) {
60+ if (queuedMsg.imageMap) {
61+ for (const [key, value] of queuedMsg.imageMap) {
62+ combinedImageMap.set(key, value);
63+ }
64+ }
65+ }
66+
67+ const result = {
68+ message: combinedMessage,
69+ imageMap: combinedImageMap.size > 0 ? combinedImageMap : undefined,
70+ timestamp: Date.now(),
71+ };
72+
73+ // Add to input history and clear the queue
74+ this.inputHistory?.addEntry(combinedMessage);
75+ this.queue = [];
76+
77+ logger.debug("MessageQueue: All messages dequeued and combined", {
78+ combinedLength: combinedMessage.length,
79+ queueLength: this.queue.length,
80+ });
81+
82+ return result;
83+ }
84+
85+ public getLatestMessage() {
86+ return this.getAllQueuedMessages();
87+ }
88+
89+ getQueueLength(): number {
90+ return this.queue.length;
91+ }
92+}
93+
94+export const messageQueue = new MessageQueue();
modified extensions/cli/src/ui/TUIChat.tsx +2 −0
@@ -188,6 +188,7 @@
188188 inputMode,
189189 activePermissionRequest,
190190 wasInterrupted,
191+ queuedMessages,
191192 handleUserMessage,
192193 handleInterrupt,
193194 handleFileAttached,
@@ -282,6 +283,7 @@
282283 model={services.model?.model || undefined}
283284 mcpService={services.mcp?.mcpService || undefined}
284285 chatHistory={chatHistory}
286+ queuedMessages={queuedMessages}
285287 renderMessage={renderMessage}
286288 refreshTrigger={staticRefreshTrigger}
287289 />
modified extensions/cli/src/ui/UserInput.tsx +12 −15
@@ -9,6 +9,7 @@
99 import type { FileIndexServiceState } from "../services/FileIndexService.js";
1010 import { SERVICE_NAMES, serviceContainer } from "../services/index.js";
1111 import { modeService } from "../services/ModeService.js";
12+import { messageQueue } from "../stream/messageQueue.js";
1213 import { InputHistory } from "../util/inputHistory.js";
1314
1415 import { FileSearchUI } from "./FileSearchUI.js";
@@ -515,7 +516,7 @@
515516 }
516517
517518 // Normal Enter behavior - submit if there's content
518- if ((textBuffer.text.trim() || wasInterrupted) && !isWaitingForResponse) {
519+ if (textBuffer.text.trim() || wasInterrupted) {
519520 // Get images before expanding paste blocks
520521 const imageMap = textBuffer.getAllImages();
521522
@@ -523,14 +524,19 @@
523524 textBuffer.expandAllPasteBlocks();
524525 const submittedText = textBuffer.text.trim();
525526
526- // Only add to history if there's actual text (not when resuming)
527- if (submittedText) {
527+ if (isWaitingForResponse) {
528+ // Process message later when LLM has responded
529+ void messageQueue.enqueueMessage(
530+ submittedText,
531+ imageMap,
532+ inputHistory,
533+ );
534+ } else {
535+ // Submit with images
528536 inputHistory.addEntry(submittedText);
537+ onSubmit(submittedText, imageMap);
529538 }
530539
531- // Submit with images
532- onSubmit(submittedText, imageMap);
533-
534540 textBuffer.clear();
535541 setInputText("");
536542 setCursorPosition(0);
@@ -647,15 +653,6 @@
647653 return;
648654 }
649655
650- // Allow typing during streaming, but block submission
651- if (!inputMode) {
652- // Block only Enter key submission during streaming
653- if (key.return && !key.shift) {
654- return;
655- }
656- // Allow all other input (typing, navigation, etc.)
657- }
658-
659656 // Handle slash command navigation
660657 if (showSlashCommands) {
661658 if (handleSlashCommandNavigation(key)) {
modified extensions/cli/src/ui/components/StaticChatContent.tsx +13 −1
@@ -1,9 +1,10 @@
11 import type { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml";
2-import { Box, Static, useStdout } from "ink";
2+import { Box, Static, Text, useStdout } from "ink";
33 import React, { useCallback, useEffect, useRef, useState } from "react";
44
55 import type { ChatHistoryItem } from "../../../../../core/index.js";
66 import type { MCPService } from "../../services/MCPService.js";
7+import type { QueuedMessage } from "../../stream/messageQueue.js";
78 import { useTerminalSize } from "../hooks/useTerminalSize.js";
89 import { IntroMessage } from "../IntroMessage.js";
910
@@ -13,6 +14,7 @@
1314 model?: ModelConfig;
1415 mcpService?: MCPService;
1516 chatHistory: ChatHistoryItem[];
17+ queuedMessages?: QueuedMessage[];
1618 renderMessage: (item: ChatHistoryItem, index: number) => React.ReactElement;
1719 refreshTrigger?: number; // Add a prop to trigger refresh from parent
1820 }
@@ -23,6 +25,7 @@
2325 model,
2426 mcpService,
2527 chatHistory,
28+ queuedMessages = [],
2629 renderMessage,
2730 refreshTrigger,
2831 }) => {
@@ -140,6 +143,15 @@
140143 <React.Fragment key={`pending-${index}`}>{item}</React.Fragment>
141144 ))}
142145 </Box>
146+
147+ {/* Queued messages - show at bottom with queue indicators */}
148+ {queuedMessages.length > 0 && (
149+ <Box paddingLeft={2} paddingBottom={1}>
150+ <Text color="gray" italic>
151+ {queuedMessages.map((msg) => msg.message).join("\n")}
152+ </Text>
153+ </Box>
154+ )}
143155 </Box>
144156 );
145157 };
modified extensions/cli/src/ui/hooks/useChat.ts +126 −44
@@ -1,3 +1,4 @@
1+/* eslint-disable max-lines */
12 import type { ChatHistoryItem, Session } from "core/index.js";
23 import { useApp } from "ink";
34 import { useEffect, useRef, useState } from "react";
@@ -11,6 +12,7 @@
1112 updateSessionHistory,
1213 } from "../../session.js";
1314 import { handleSlashCommands } from "../../slashCommands.js";
15+import { messageQueue, QueuedMessage } from "../../stream/messageQueue.js";
1416 import { telemetryService } from "../../telemetry/telemetryService.js";
1517 import { formatError } from "../../util/formatError.js";
1618 import { logger } from "../../util/logger.js";
@@ -166,6 +168,22 @@
166168 // Track interrupted state for resume functionality
167169 const [wasInterrupted, setWasInterrupted] = useState(false);
168170
171+ // Track queued messages for immediate display
172+ const [queuedMessages, setQueuedMessages] = useState<QueuedMessage[]>([]);
173+
174+ // Set up message queue listeners
175+ useEffect(() => {
176+ const onMessageQueued = (queuedMessage: QueuedMessage) => {
177+ setQueuedMessages((prev) => [...prev, queuedMessage]);
178+ };
179+
180+ messageQueue.on("messageQueued", onMessageQueued);
181+
182+ return () => {
183+ messageQueue.off("messageQueued", onMessageQueued);
184+ };
185+ }, []);
186+
169187 // Clean up abort controller on unmount
170188 useEffect(() => {
171189 return () => {
@@ -306,6 +324,30 @@
306324 setIsWaitingForResponse(false);
307325 setResponseStartTime(null);
308326 setInputMode(true);
327+
328+ // Check if there are queued messages and process them after a microtask delay
329+ // This ensures the GUI state has been updated before processing the next message
330+ const queuedMessageData = messageQueue.getLatestMessage();
331+ if (queuedMessageData) {
332+ const { message: latestQueuedMessage, imageMap } = queuedMessageData;
333+ logger.debug("processing queued message", { latestQueuedMessage });
334+
335+ // Clear all queued messages from display since we're processing them all together
336+ setQueuedMessages([]);
337+
338+ // Add the queued message to chat history so it shows in the GUI
339+ const formattedQueuedMessage = await formatMessageWithFiles(
340+ latestQueuedMessage,
341+ [], // No attached files for queued messages
342+ imageMap,
343+ );
344+ setChatHistory((prev) => [...prev, formattedQueuedMessage]);
345+
346+ await new Promise((resolve) => setTimeout(resolve, 100)); // add timeout for react to render the tui
347+
348+ // Process the queued message using the internal processing logic without re-adding to history
349+ await processQueuedMessage(latestQueuedMessage, imageMap);
350+ }
309351 }
310352 };
311353
@@ -398,20 +440,11 @@
398440 .join("");
399441 };
400442
401- const handleUserMessage = async (
443+ const processMessage = async (
402444 message: string,
403445 imageMap?: Map<string, Buffer>,
446+ isQueuedMessage: boolean = false,
404447 ) => {
405- // Check if this is a resume request (empty message after interruption)
406- if (await handleResumeRequest(message)) {
407- return;
408- }
409-
410- // Clear interrupted state if user types a new message
411- if (wasInterrupted && message !== "") {
412- setWasInterrupted(false);
413- }
414-
415448 // Handle special commands
416449 const handled = await handleSpecialCommands({
417450 message,
@@ -440,27 +473,9 @@
440473 // Track telemetry
441474 trackUserMessage(message, model);
442475
443- // Format message with attached files and images
444- logger.debug("Processing message with images", {
445- hasImages: !!(imageMap && imageMap.size > 0),
446- imageCount: imageMap?.size || 0,
447- });
448- const newUserMessage = await formatMessageWithFiles(
449- message,
450- attachedFiles,
451- imageMap,
452- );
453- logger.debug("Message formatted successfully");
454-
455- if (attachedFiles.length > 0) {
456- setAttachedFiles([]);
457- }
458-
459476 // In remote mode, send message to server instead of processing locally
460477 if (isRemoteMode && remoteUrl) {
461- const messageContentString = convertMessageContentToString(
462- newUserMessage.message.content,
463- );
478+ const messageContentString = convertMessageContentToString(message);
464479
465480 await handleRemoteMessage({
466481 remoteUrl,
@@ -469,23 +484,87 @@
469484 return;
470485 }
471486
472- // Check if auto-compacting is needed BEFORE adding user message
473- const { currentChatHistory, currentCompactionIndex } =
474- await handleAutoCompaction({
475- chatHistory,
476- model,
477- llmApi,
478- compactionIndex,
479- setChatHistory: setChatHistory,
480- setCompactionIndex,
487+ // For non-queued messages, format and add to chat history
488+ if (isQueuedMessage) {
489+ // For queued messages, chat history is already updated
490+ // Check if auto-compacting is needed with current history
491+ const { currentChatHistory, currentCompactionIndex } =
492+ await handleAutoCompaction({
493+ chatHistory,
494+ model,
495+ llmApi,
496+ compactionIndex,
497+ setChatHistory: setChatHistory,
498+ setCompactionIndex,
499+ });
500+
501+ // Execute the streaming response with the current history (which already includes the queued message)
502+ await executeStreamingResponse(
503+ currentChatHistory,
504+ currentCompactionIndex,
505+ );
506+ } else {
507+ // Format message with attached files and images
508+ logger.debug("Processing message with images", {
509+ hasImages: !!(imageMap && imageMap.size > 0),
510+ imageCount: imageMap?.size || 0,
481511 });
512+ const newUserMessage = await formatMessageWithFiles(
513+ message,
514+ attachedFiles,
515+ imageMap,
516+ );
517+ logger.debug("Message formatted successfully");
482518
483- // Add the formatted user message to history
484- const newHistory = [...currentChatHistory, newUserMessage];
485- setChatHistory(newHistory);
519+ if (attachedFiles.length > 0) {
520+ setAttachedFiles([]);
521+ }
522+
523+ // Check if auto-compacting is needed BEFORE adding user message
524+ const { currentChatHistory, currentCompactionIndex } =
525+ await handleAutoCompaction({
526+ chatHistory,
527+ model,
528+ llmApi,
529+ compactionIndex,
530+ setChatHistory: setChatHistory,
531+ setCompactionIndex,
532+ });
533+
534+ // Add the formatted user message to history
535+ const newHistory = [...currentChatHistory, newUserMessage];
536+ setChatHistory(newHistory);
537+
538+ // Execute the streaming response
539+ await executeStreamingResponse(newHistory, currentCompactionIndex);
540+ }
541+ };
542+
543+ const processQueuedMessage = async (
544+ message: string,
545+ imageMap?: Map<string, Buffer>,
546+ ) => {
547+ // For queued messages, we can reuse the core message processing logic
548+ // by calling the internal processing function directly
549+ await processMessage(message, imageMap, true);
550+ };
551+
552+ const handleUserMessage = async (
553+ message: string,
554+ imageMap?: Map<string, Buffer>,
555+ ) => {
556+ // Check if this is a resume request (empty message after interruption)
557+ if (await handleResumeRequest(message)) {
558+ return;
559+ }
560+
561+ // Clear interrupted state if user types a new message
562+ if (wasInterrupted && message !== "") {
563+ setWasInterrupted(false);
564+ }
486565
487- // Execute the streaming response
488- await executeStreamingResponse(newHistory, currentCompactionIndex);
566+ // Use the common message processing logic
567+ await processMessage(message, imageMap, false);
489568 };
490569
491570 const handleInterrupt = () => {
@@ -537,6 +616,8 @@
537616 additionalRules,
538617 );
539618 setChatHistory(newHistory);
619+ // Clear any queued messages when resetting chat
620+ setQueuedMessages([]);
540621 };
541622
542623 const handleToolPermissionResponse = async (
@@ -614,6 +695,7 @@
614695 attachedFiles,
615696 activePermissionRequest,
616697 wasInterrupted,
698+ queuedMessages,
617699 handleUserMessage,
618700 handleInterrupt,
619701 handleFileAttached,
modified extensions/vscode/src/diff/processDiff.ts +38 −5
@@ -1,8 +1,11 @@
11 import { Core } from "core/core";
22 import { DataLogger } from "core/data/log";
3+import { myersDiff } from "core/diff/myers";
4+
35 import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider";
46 import { editOutcomeTracker } from "../extension/EditOutcomeTracker";
57 import { VsCodeIde } from "../VsCodeIde";
8+
69 import { VerticalDiffManager } from "./vertical/manager";
710
811 export async function processDiff(
@@ -42,7 +45,8 @@
4245 }
4346
4447 if (streamId) {
45- const fileContent = await ide.readFile(newOrCurrentUri);
48+ // Capture file content before save to detect autoformatting
49+ const preSaveContent = await ide.readFile(newOrCurrentUri);
4650
4751 // Record the edit outcome before updating the apply state
4852 await editOutcomeTracker.recordEditOutcome(
@@ -51,16 +55,45 @@
5155 DataLogger.getInstance(),
5256 );
5357
58+ // Save the file
59+ await ide.saveFile(newOrCurrentUri);
60+
61+ // Capture file content after save to detect autoformatting
62+ const postSaveContent = await ide.readFile(newOrCurrentUri);
63+
64+ // Detect autoformatting by comparing normalized content
65+ let autoFormattingDiff: string | undefined;
66+ const normalizedPreSave = preSaveContent.trim();
67+ const normalizedPostSave = postSaveContent.trim();
68+
69+ if (normalizedPreSave !== normalizedPostSave) {
70+ // Auto-formatting was applied by the editor
71+ const diffLines = myersDiff(preSaveContent, postSaveContent);
72+ autoFormattingDiff = diffLines
73+ .map((line) => {
74+ switch (line.type) {
75+ case "old":
76+ return `-${line.line}`;
77+ case "new":
78+ return `+${line.line}`;
79+ case "same":
80+ return ` ${line.line}`;
81+ }
82+ })
83+ .join("\n");
84+ }
85+
5486 await sidebar.webviewProtocol.request("updateApplyState", {
55- fileContent,
87+ fileContent: postSaveContent, // Use post-save content
5688 filepath: newOrCurrentUri,
5789 streamId,
5890 status: "closed",
5991 numDiffs: 0,
6092 toolCallId,
93+ autoFormattingDiff, // Include autoformatting diff
6194 });
95+ } else {
96+ // Save the file even if no streamId
97+ await ide.saveFile(newOrCurrentUri);
6298 }
63-
64- // Save the file
65- await ide.saveFile(newOrCurrentUri);
6699 }
modified gui/src/components/mainInput/ContextStatus.tsx +22 −0
@@ -1,3 +1,4 @@
1+import { useMemo, useRef } from "react";
12 import { useAppDispatch, useAppSelector } from "../../redux/hooks";
23 import { saveCurrentSession } from "../../redux/thunks/session";
34 import { useCompactConversation } from "../../util/compactConversation";
@@ -8,15 +9,36 @@
89 const contextPercentage = useAppSelector(
910 (state) => state.session.contextPercentage,
1011 );
12+ const selectedChatModel = useAppSelector(
13+ (state) => state.config.config.selectedModelByRole.chat?.model,
14+ );
15+ const previousHistoryLength = useRef<number | null>(null);
16+ const previousSelectedChatModel = useRef<string | null>(null);
1117 const history = useAppSelector((state) => state.session.history);
1218 const percent = Math.round((contextPercentage ?? 0) * 100);
1319 const isPruned = useAppSelector((state) => state.session.isPruned);
1420
21+ const isDifferentModelAndSameHistory = useMemo(() => {
22+ if (!selectedChatModel) return false;
23+ // only reset if history changes
24+ if (previousHistoryLength.current !== history.length) {
25+ previousHistoryLength.current = history.length;
26+ previousSelectedChatModel.current = selectedChatModel;
27+ return false;
28+ }
29+ return previousSelectedChatModel.current !== selectedChatModel;
30+ }, [history.length, selectedChatModel]);
31+
1532 const compactConversation = useCompactConversation();
1633 if (!isPruned && percent < 60) {
1734 return null;
1835 }
1936
37+ // if user changed to a different model, we shouldn't show the context status until the user sends a new message
38+ if (isDifferentModelAndSameHistory) {
39+ return null;
40+ }
41+
2042 const barColorClass = isPruned ? "bg-error" : "bg-description";
2143
2244 return (
modified gui/src/redux/thunks/handleApplyStateUpdate.ts +45 −1
@@ -83,12 +83,57 @@
8383 }
8484
8585 if (accepted) {
86+ // Add autoformatting diff to tool output if present
87+ if (applyState.autoFormattingDiff) {
88+ dispatch(
89+ updateToolCallOutput({
90+ toolCallId: applyState.toolCallId,
91+ contextItems: [
92+ {
93+ icon: "info",
94+ name: "Auto-formatting Applied",
95+ description: "Editor auto-formatting changes",
96+ content: `Along with your edits, the editor applied the following auto-formatting:\n\n${applyState.autoFormattingDiff}\n\n(Note: Pay close attention to changes such as single quotes being converted to double quotes, semicolons being removed or added, long lines being broken into multiple lines, adjusting indentation style, adding/removing trailing commas, etc. This will help you ensure future SEARCH/REPLACE operations to this file are accurate.)`,
97+ hidden: false,
98+ },
99+ ],
100+ }),
101+ );
102+ }
103+
86104 if (toolCallState.status !== "errored") {
87105 dispatch(
88106 acceptToolCall({
89107 toolCallId: applyState.toolCallId,
90108 }),
91109 );
110+ dispatch(
111+ updateToolCallOutput({
112+ toolCallId: applyState.toolCallId,
113+ contextItems: [
114+ {
115+ name: "Edit Success",
116+ content: `Successfully edited ${applyState.filepath}`,
117+ description: "",
118+ hidden: true,
119+ },
120+ ],
121+ }),
122+ );
123+ } else {
124+ dispatch(
125+ updateToolCallOutput({
126+ toolCallId: applyState.toolCallId,
127+ contextItems: [
128+ {
129+ name: "Edit Failed",
130+ content: `Failed to edit ${applyState.filepath}. To continue working with the file, read it again to see the most up-to-date contents`,
131+ description: "",
132+ hidden: true,
133+ },
134+ ],
135+ }),
136+ );
92137 }
93138
94139 void dispatch(
@@ -98,7 +143,6 @@
98143 );
99144 }
100145 }
101- // TODO return output from edit tools so the model knows the result
102146 }
103147 }
104148 }
modified gui/src/util/clientTools/editImpl.ts +3 −9
@@ -17,13 +17,13 @@
1717 filepath = filepath.slice(2);
1818 }
1919
20- const openFiles = await extras.ideMessenger.ide.getOpenFiles();
2120 let firstUriMatch = await resolveRelativePathInDir(
2221 filepath,
2322 extras.ideMessenger.ide,
2423 );
2524
2625 if (!firstUriMatch) {
26+ const openFiles = await extras.ideMessenger.ide.getOpenFiles();
2727 for (const uri of openFiles) {
2828 if (uri.endsWith(filepath)) {
2929 firstUriMatch = uri;
@@ -46,13 +46,7 @@
4646 );
4747
4848 return {
49- respondImmediately: true,
50- output: [
51- {
52- name: "File edited successfully",
53- content: `Successfully initiated edit for ${firstUriMatch}`,
54- description: "File edit operation started",
55- },
56- ],
49+ respondImmediately: false,
50+ output: undefined, // no immediate output - output for edit tools should be added based on apply state coming in
5751 };
5852 };