From f5505257ab180ec08cd77cc0e3a19f6775ceb811 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 18 Jul 2025 09:00:51 -0700 Subject: [PATCH 1/8] feat: compaction --- .../StepContainer/ResponseActions.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gui/src/components/StepContainer/ResponseActions.tsx b/gui/src/components/StepContainer/ResponseActions.tsx index 96cb1bab1..4fda49ac8 100644 --- a/gui/src/components/StepContainer/ResponseActions.tsx +++ b/gui/src/components/StepContainer/ResponseActions.tsx @@ -80,6 +80,15 @@ export default function ResponseActions({ return (
+ + + + {isLast && ruleGenerationSupported && ( )} - - - - Date: Fri, 18 Jul 2025 09:24:48 -0700 Subject: [PATCH 2/8] improv: compaction ui --- .../StepContainer/ResponseActions.tsx | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/gui/src/components/StepContainer/ResponseActions.tsx b/gui/src/components/StepContainer/ResponseActions.tsx index 4fda49ac8..673e05d9a 100644 --- a/gui/src/components/StepContainer/ResponseActions.tsx +++ b/gui/src/components/StepContainer/ResponseActions.tsx @@ -40,10 +40,22 @@ export default function ResponseActions({ const ideMessenger = useContext(IdeMessengerContext); const currentSessionId = useAppSelector((state) => state.session.id); const selectedModel = useAppSelector(selectSelectedChatModel); + const contextPercentage = useAppSelector( + (state) => state.session.contextPercentage, + ); + const isPruned = useAppSelector((state) => state.session.isPruned); const ruleGenerationSupported = useMemo(() => { return selectedModel && modelSupportsTools(selectedModel); }, [selectedModel]); + const percent = Math.round((contextPercentage ?? 0) * 100); + const buttonColorClass = + isLast && (isPruned || percent > 80) + ? "text-warning" + : "text-description-muted"; + + const showLabel = isLast && (isPruned || percent >= 60); + const onGenerateRule = () => { dispatch(setShowDialog(true)); dispatch(setDialogMessage()); @@ -82,11 +94,26 @@ export default function ResponseActions({
- +
+ + {showLabel && ( + + Compact conversation + + )} +
{isLast && ruleGenerationSupported && ( From 5b854675ea7c762ec1e29673f1700f87ca22516f Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 18 Jul 2025 09:42:59 -0700 Subject: [PATCH 3/8] feat: compaction --- .../StepContainer/ResponseActions.tsx | 40 +++--------------- .../components/mainInput/ContextStatus.tsx | 42 ++++++++++++------- gui/src/util/compactConversation.ts | 40 ++++++++++++++++++ 3 files changed, 72 insertions(+), 50 deletions(-) create mode 100644 gui/src/util/compactConversation.ts diff --git a/gui/src/components/StepContainer/ResponseActions.tsx b/gui/src/components/StepContainer/ResponseActions.tsx index 673e05d9a..b507a2307 100644 --- a/gui/src/components/StepContainer/ResponseActions.tsx +++ b/gui/src/components/StepContainer/ResponseActions.tsx @@ -7,13 +7,11 @@ import { import { ChatHistoryItem } from "core"; import { modelSupportsTools } from "core/llm/autodetect"; import { renderChatMessage } from "core/util/messageContent"; -import { useContext, useMemo } from "react"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useMemo } from "react"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectSelectedChatModel } from "../../redux/slices/configSlice"; -import { setCompactionLoading } from "../../redux/slices/sessionSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; -import { loadSession } from "../../redux/thunks/session"; +import { useCompactConversation } from "../../util/compactConversation"; import { FeedbackButtons } from "../FeedbackButtons"; import { GenerateRuleDialog } from "../GenerateRuleDialog"; import { CopyIconButton } from "../gui/CopyIconButton"; @@ -37,8 +35,6 @@ export default function ResponseActions({ isLast, }: ResponseActionsProps) { const dispatch = useAppDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - const currentSessionId = useAppSelector((state) => state.session.id); const selectedModel = useAppSelector(selectSelectedChatModel); const contextPercentage = useAppSelector( (state) => state.session.contextPercentage, @@ -56,39 +52,13 @@ export default function ResponseActions({ const showLabel = isLast && (isPruned || percent >= 60); + const compactConversation = useCompactConversation(); + const onGenerateRule = () => { dispatch(setShowDialog(true)); dispatch(setDialogMessage()); }; - const onCompactConversation = async () => { - if (!currentSessionId) { - return; - } - - try { - // Set loading state - dispatch(setCompactionLoading({ index, loading: true })); - - await ideMessenger.request("conversation/compact", { - index, - sessionId: currentSessionId, - }); - - // Reload the current session to refresh the conversation state - dispatch( - loadSession({ - sessionId: currentSessionId, - saveCurrentSession: false, - }), - ); - } catch (error) { - console.error("Error compacting conversation:", error); - } finally { - // Clear loading state - dispatch(setCompactionLoading({ index, loading: false })); - } - }; return (
@@ -100,7 +70,7 @@ export default function ResponseActions({ : "Compact conversation" } tabIndex={-1} - onClick={onCompactConversation} + onClick={() => compactConversation(index)} >
{ const dispatch = useAppDispatch(); @@ -10,6 +11,8 @@ const ContextStatus = () => { const history = useAppSelector((state) => state.session.history); const percent = Math.round((contextPercentage ?? 0) * 100); const isPruned = useAppSelector((state) => state.session.isPruned); + + const compactConversation = useCompactConversation(); if (!isPruned && percent < 60) { return null; } @@ -42,21 +45,30 @@ const ContextStatus = () => { )} {history.length > 0 && ( -
- Start a{" "} - { - dispatch( - saveCurrentSession({ - openNewSession: true, - generateTitle: false, - }), - ); - }} - > - New Session - +
+
+ compactConversation(history.length - 1)} + > + Compact conversation + + {"\n"} + or {"\n"} + { + dispatch( + saveCurrentSession({ + openNewSession: true, + generateTitle: false, + }), + ); + }} + > + Start a new session + +
)}
diff --git a/gui/src/util/compactConversation.ts b/gui/src/util/compactConversation.ts new file mode 100644 index 000000000..1908e8d62 --- /dev/null +++ b/gui/src/util/compactConversation.ts @@ -0,0 +1,40 @@ +import { useContext } from "react"; +import { IdeMessengerContext } from "../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../redux/hooks"; +import { setCompactionLoading } from "../redux/slices/sessionSlice"; +import { loadSession } from "../redux/thunks/session"; + +export const useCompactConversation = () => { + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + const currentSessionId = useAppSelector((state) => state.session.id); + + return async (index: number) => { + if (!currentSessionId) { + return; + } + + try { + // Set loading state + dispatch(setCompactionLoading({ index, loading: true })); + + await ideMessenger.request("conversation/compact", { + index, + sessionId: currentSessionId, + }); + + // Reload the current session to refresh the conversation state + dispatch( + loadSession({ + sessionId: currentSessionId, + saveCurrentSession: false, + }), + ); + } catch (error) { + console.error("Error compacting conversation:", error); + } finally { + // Clear loading state + dispatch(setCompactionLoading({ index, loading: false })); + } + }; +}; \ No newline at end of file From e19400bf5a717873cdb10acc5289b1cedfe0a44e Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 18 Jul 2025 09:52:46 -0700 Subject: [PATCH 4/8] feat: delete compaction --- core/core.ts | 16 ++++++- core/protocol/core.ts | 7 ++++ core/protocol/passThrough.ts | 1 + core/util/conversationCompaction.ts | 41 ++++++++++++++++++ .../constants/MessageTypes.kt | 1 + .../StepContainer/ConversationSummary.tsx | 15 ++++++- gui/src/redux/slices/sessionSlice.ts | 11 +++++ gui/src/util/compactConversation.ts | 42 ++++++++++++++++++- 8 files changed, 131 insertions(+), 3 deletions(-) diff --git a/core/core.ts b/core/core.ts index a3fe4cab5..92c40b67d 100644 --- a/core/core.ts +++ b/core/core.ts @@ -24,7 +24,7 @@ import { createNewPromptFileV2 } from "./promptFiles/createNewPromptFile"; import { callTool } from "./tools/callTool"; import { ChatDescriber } from "./util/chatDescriber"; import { clipboardCache } from "./util/clipboardCache"; -import { compactConversation } from "./util/conversationCompaction"; +import { compactConversation, deleteCompaction } from "./util/conversationCompaction"; import { GlobalContext } from "./util/GlobalContext"; import historyManager from "./util/history"; import { editConfigFile, migrateV1DevDataFiles } from "./util/paths"; @@ -572,6 +572,20 @@ export class Core { } }); + on("conversation/deleteCompaction", async (msg) => { + try { + await deleteCompaction({ + sessionId: msg.data.sessionId, + index: msg.data.index, + historyManager, + }); + return undefined; + } catch (error) { + console.error("Error deleting compaction:", error); + return undefined; + } + }); + // Autocomplete on("autocomplete/complete", async (msg) => { const outcome = diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 251922696..f208b0fb4 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -193,6 +193,13 @@ export type ToCoreFromIdeOrWebviewProtocol = { }, string | undefined, ]; + "conversation/deleteCompaction": [ + { + index: number; + sessionId: string; + }, + void, + ]; "stats/getTokensPerDay": [ undefined, { day: string; promptTokens: number; generatedTokens: number }[], diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 6e25e5f54..5dbb7b341 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -48,6 +48,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "streamDiffLines", "chatDescriber/describe", "conversation/compact", + "conversation/deleteCompaction", "stats/getTokensPerDay", "stats/getTokensPerModel", // Codebase diff --git a/core/util/conversationCompaction.ts b/core/util/conversationCompaction.ts index 541d7d520..4c5a28c04 100644 --- a/core/util/conversationCompaction.ts +++ b/core/util/conversationCompaction.ts @@ -9,6 +9,12 @@ export interface CompactionParams { currentModel: ILLM; } +export interface DeleteCompactionParams { + sessionId: string; + index: number; + historyManager: HistoryManager; +} + /** * Compacts conversation history up to a specified index by generating a summary. * This helper function extracts the compaction logic from the main core handler. @@ -87,3 +93,38 @@ export async function compactConversation({ historyManager.save(updatedSession); } + +/** + * Deletes a conversation summary from a specific message in the history. + * This function removes the conversationSummary property from the specified message. + * + * @param params - Object containing sessionId, index, and historyManager + * @returns Promise - Updates the session with the conversation summary removed + */ +export async function deleteCompaction({ + sessionId, + index, + historyManager, +}: DeleteCompactionParams): Promise { + // Get the current session + const session = historyManager.load(sessionId); + + // Create a copy of the history + const updatedHistory = [...session.history]; + + // Remove the conversation summary from the specified message + if (updatedHistory[index]?.conversationSummary) { + updatedHistory[index] = { + ...updatedHistory[index], + conversationSummary: undefined, + }; + } + + // Update the session with the modified history + const updatedSession = { + ...session, + history: updatedHistory, + }; + + historyManager.save(updatedSession); +} diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 02fedb3b3..5630bea57 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -114,6 +114,7 @@ class MessageTypes { "streamDiffLines", "chatDescriber/describe", "conversation/compact", + "conversation/deleteCompaction", "stats/getTokensPerDay", "stats/getTokensPerModel", // Codebase diff --git a/gui/src/components/StepContainer/ConversationSummary.tsx b/gui/src/components/StepContainer/ConversationSummary.tsx index 78c3043f9..32c4aef02 100644 --- a/gui/src/components/StepContainer/ConversationSummary.tsx +++ b/gui/src/components/StepContainer/ConversationSummary.tsx @@ -1,9 +1,12 @@ import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/solid"; +import { TrashIcon } from "@heroicons/react/24/outline"; import { ChatHistoryItem } from "core"; import { useState } from "react"; import { AnimatedEllipsis } from "../"; import { useAppSelector } from "../../redux/hooks"; import StyledMarkdownPreview from "../StyledMarkdownPreview"; +import { useDeleteCompaction } from "../../util/compactConversation"; +import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; interface ConversationSummaryProps { item: ChatHistoryItem; @@ -15,6 +18,7 @@ export default function ConversationSummary(props: ConversationSummaryProps) { const isLoading = useAppSelector( (state) => state.session.compactionLoading[props.index] || false, ); + const deleteCompaction = useDeleteCompaction(); if (!props.item.conversationSummary && !isLoading) { return null; @@ -47,7 +51,16 @@ export default function ConversationSummary(props: ConversationSummaryProps) { ) : ( )} - Conversation Summary + Conversation Summary + { + e.stopPropagation(); + deleteCompaction(props.index); + }} + > + +
{open && ( <> diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 76c7b9410..a93221935 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -437,6 +437,16 @@ export const sessionSlice = createSlice({ state.isPruned = false; state.contextPercentage = undefined; }, + deleteCompaction: (state, action: PayloadAction) => { + // Removes the conversation summary from the specified message + const historyItem = state.history[action.payload]; + if (historyItem?.conversationSummary) { + state.history[action.payload] = { + ...historyItem, + conversationSummary: undefined, + }; + } + }, updateHistoryItemAtIndex: ( state, { @@ -992,6 +1002,7 @@ export const { clearDanglingMessages, setMainEditorContentTrigger, deleteMessage, + deleteCompaction, setIsGatheringContext, resetNextCodeBlockToApplyIndex, updateApplyState, diff --git a/gui/src/util/compactConversation.ts b/gui/src/util/compactConversation.ts index 1908e8d62..5e58a0ff3 100644 --- a/gui/src/util/compactConversation.ts +++ b/gui/src/util/compactConversation.ts @@ -1,7 +1,7 @@ import { useContext } from "react"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../redux/hooks"; -import { setCompactionLoading } from "../redux/slices/sessionSlice"; +import { setCompactionLoading, deleteCompaction } from "../redux/slices/sessionSlice"; import { loadSession } from "../redux/thunks/session"; export const useCompactConversation = () => { @@ -37,4 +37,44 @@ export const useCompactConversation = () => { dispatch(setCompactionLoading({ index, loading: false })); } }; +}; + +export const useDeleteCompaction = () => { + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + const currentSessionId = useAppSelector((state) => state.session.id); + + return async (index: number) => { + if (!currentSessionId) { + return; + } + + try { + // Update local state immediately + dispatch(deleteCompaction(index)); + + // Communicate with core to persist the change + await ideMessenger.request("conversation/deleteCompaction", { + index, + sessionId: currentSessionId, + }); + + // Reload the current session to refresh the conversation state + dispatch( + loadSession({ + sessionId: currentSessionId, + saveCurrentSession: false, + }), + ); + } catch (error) { + console.error("Error deleting compaction:", error); + // Optionally reload session to revert optimistic update + dispatch( + loadSession({ + sessionId: currentSessionId, + saveCurrentSession: false, + }), + ); + } + }; }; \ No newline at end of file From c9c7aa40aa8ad3c4dad48b4f5229a044fe8ebe4c Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 18 Jul 2025 10:15:58 -0700 Subject: [PATCH 5/8] improv: ui --- gui/src/components/mainInput/ContextStatus.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/ContextStatus.tsx b/gui/src/components/mainInput/ContextStatus.tsx index 148b23c36..a52327dc7 100644 --- a/gui/src/components/mainInput/ContextStatus.tsx +++ b/gui/src/components/mainInput/ContextStatus.tsx @@ -35,7 +35,7 @@ const ContextStatus = () => { }} clickable > -
+
{`${percent}% of context filled`} From 251f4d3d061c60b418ebe2db6a80b774ed62a944 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 18 Jul 2025 10:42:00 -0700 Subject: [PATCH 6/8] fix: prettier --- core/core.ts | 5 ++++- core/util/conversationCompaction.ts | 8 ++++---- gui/src/components/StepContainer/ConversationSummary.tsx | 2 +- gui/src/components/StepContainer/ResponseActions.tsx | 1 - gui/src/util/compactConversation.ts | 7 +++++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/core/core.ts b/core/core.ts index 92c40b67d..86a20c493 100644 --- a/core/core.ts +++ b/core/core.ts @@ -24,7 +24,10 @@ import { createNewPromptFileV2 } from "./promptFiles/createNewPromptFile"; import { callTool } from "./tools/callTool"; import { ChatDescriber } from "./util/chatDescriber"; import { clipboardCache } from "./util/clipboardCache"; -import { compactConversation, deleteCompaction } from "./util/conversationCompaction"; +import { + compactConversation, + deleteCompaction, +} from "./util/conversationCompaction"; import { GlobalContext } from "./util/GlobalContext"; import historyManager from "./util/history"; import { editConfigFile, migrateV1DevDataFiles } from "./util/paths"; diff --git a/core/util/conversationCompaction.ts b/core/util/conversationCompaction.ts index 4c5a28c04..e428b0a66 100644 --- a/core/util/conversationCompaction.ts +++ b/core/util/conversationCompaction.ts @@ -108,10 +108,10 @@ export async function deleteCompaction({ }: DeleteCompactionParams): Promise { // Get the current session const session = historyManager.load(sessionId); - + // Create a copy of the history const updatedHistory = [...session.history]; - + // Remove the conversation summary from the specified message if (updatedHistory[index]?.conversationSummary) { updatedHistory[index] = { @@ -119,12 +119,12 @@ export async function deleteCompaction({ conversationSummary: undefined, }; } - + // Update the session with the modified history const updatedSession = { ...session, history: updatedHistory, }; - + historyManager.save(updatedSession); } diff --git a/gui/src/components/StepContainer/ConversationSummary.tsx b/gui/src/components/StepContainer/ConversationSummary.tsx index 32c4aef02..6980ba5f7 100644 --- a/gui/src/components/StepContainer/ConversationSummary.tsx +++ b/gui/src/components/StepContainer/ConversationSummary.tsx @@ -59,7 +59,7 @@ export default function ConversationSummary(props: ConversationSummaryProps) { deleteCompaction(props.index); }} > - +
{open && ( diff --git a/gui/src/components/StepContainer/ResponseActions.tsx b/gui/src/components/StepContainer/ResponseActions.tsx index b507a2307..068432792 100644 --- a/gui/src/components/StepContainer/ResponseActions.tsx +++ b/gui/src/components/StepContainer/ResponseActions.tsx @@ -59,7 +59,6 @@ export default function ResponseActions({ dispatch(setDialogMessage()); }; - return (
{ @@ -77,4 +80,4 @@ export const useDeleteCompaction = () => { ); } }; -}; \ No newline at end of file +}; From 398584ba630631fd32e3f4553a05082391bb9e67 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 18 Jul 2025 11:22:19 -0700 Subject: [PATCH 7/8] improv: simplify compaction --- core/core.ts | 19 +------- core/protocol/core.ts | 7 --- core/protocol/passThrough.ts | 1 - core/util/conversationCompaction.ts | 41 ------------------ .../constants/MessageTypes.kt | 1 - gui/src/util/compactConversation.ts | 43 ++++--------------- 6 files changed, 9 insertions(+), 103 deletions(-) diff --git a/core/core.ts b/core/core.ts index 86a20c493..a3fe4cab5 100644 --- a/core/core.ts +++ b/core/core.ts @@ -24,10 +24,7 @@ import { createNewPromptFileV2 } from "./promptFiles/createNewPromptFile"; import { callTool } from "./tools/callTool"; import { ChatDescriber } from "./util/chatDescriber"; import { clipboardCache } from "./util/clipboardCache"; -import { - compactConversation, - deleteCompaction, -} from "./util/conversationCompaction"; +import { compactConversation } from "./util/conversationCompaction"; import { GlobalContext } from "./util/GlobalContext"; import historyManager from "./util/history"; import { editConfigFile, migrateV1DevDataFiles } from "./util/paths"; @@ -575,20 +572,6 @@ export class Core { } }); - on("conversation/deleteCompaction", async (msg) => { - try { - await deleteCompaction({ - sessionId: msg.data.sessionId, - index: msg.data.index, - historyManager, - }); - return undefined; - } catch (error) { - console.error("Error deleting compaction:", error); - return undefined; - } - }); - // Autocomplete on("autocomplete/complete", async (msg) => { const outcome = diff --git a/core/protocol/core.ts b/core/protocol/core.ts index f208b0fb4..251922696 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -193,13 +193,6 @@ export type ToCoreFromIdeOrWebviewProtocol = { }, string | undefined, ]; - "conversation/deleteCompaction": [ - { - index: number; - sessionId: string; - }, - void, - ]; "stats/getTokensPerDay": [ undefined, { day: string; promptTokens: number; generatedTokens: number }[], diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 5dbb7b341..6e25e5f54 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -48,7 +48,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "streamDiffLines", "chatDescriber/describe", "conversation/compact", - "conversation/deleteCompaction", "stats/getTokensPerDay", "stats/getTokensPerModel", // Codebase diff --git a/core/util/conversationCompaction.ts b/core/util/conversationCompaction.ts index e428b0a66..541d7d520 100644 --- a/core/util/conversationCompaction.ts +++ b/core/util/conversationCompaction.ts @@ -9,12 +9,6 @@ export interface CompactionParams { currentModel: ILLM; } -export interface DeleteCompactionParams { - sessionId: string; - index: number; - historyManager: HistoryManager; -} - /** * Compacts conversation history up to a specified index by generating a summary. * This helper function extracts the compaction logic from the main core handler. @@ -93,38 +87,3 @@ export async function compactConversation({ historyManager.save(updatedSession); } - -/** - * Deletes a conversation summary from a specific message in the history. - * This function removes the conversationSummary property from the specified message. - * - * @param params - Object containing sessionId, index, and historyManager - * @returns Promise - Updates the session with the conversation summary removed - */ -export async function deleteCompaction({ - sessionId, - index, - historyManager, -}: DeleteCompactionParams): Promise { - // Get the current session - const session = historyManager.load(sessionId); - - // Create a copy of the history - const updatedHistory = [...session.history]; - - // Remove the conversation summary from the specified message - if (updatedHistory[index]?.conversationSummary) { - updatedHistory[index] = { - ...updatedHistory[index], - conversationSummary: undefined, - }; - } - - // Update the session with the modified history - const updatedSession = { - ...session, - history: updatedHistory, - }; - - historyManager.save(updatedSession); -} diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 5630bea57..02fedb3b3 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -114,7 +114,6 @@ class MessageTypes { "streamDiffLines", "chatDescriber/describe", "conversation/compact", - "conversation/deleteCompaction", "stats/getTokensPerDay", "stats/getTokensPerModel", // Codebase diff --git a/gui/src/util/compactConversation.ts b/gui/src/util/compactConversation.ts index a0ede7d4b..67ac3813d 100644 --- a/gui/src/util/compactConversation.ts +++ b/gui/src/util/compactConversation.ts @@ -5,7 +5,7 @@ import { setCompactionLoading, deleteCompaction, } from "../redux/slices/sessionSlice"; -import { loadSession } from "../redux/thunks/session"; +import { loadSession, saveCurrentSession } from "../redux/thunks/session"; export const useCompactConversation = () => { const dispatch = useAppDispatch(); @@ -44,40 +44,13 @@ export const useCompactConversation = () => { export const useDeleteCompaction = () => { const dispatch = useAppDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - const currentSessionId = useAppSelector((state) => state.session.id); - return async (index: number) => { - if (!currentSessionId) { - return; - } - - try { - // Update local state immediately - dispatch(deleteCompaction(index)); - - // Communicate with core to persist the change - await ideMessenger.request("conversation/deleteCompaction", { - index, - sessionId: currentSessionId, - }); - - // Reload the current session to refresh the conversation state - dispatch( - loadSession({ - sessionId: currentSessionId, - saveCurrentSession: false, - }), - ); - } catch (error) { - console.error("Error deleting compaction:", error); - // Optionally reload session to revert optimistic update - dispatch( - loadSession({ - sessionId: currentSessionId, - saveCurrentSession: false, - }), - ); - } + return (index: number) => { + // Update local state and save to persistence + dispatch(deleteCompaction(index)); + dispatch(saveCurrentSession({ + openNewSession: false, + generateTitle: false, + })); }; }; From 84fccc7c719357ed532f1effd54dae9b3ff540a8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 18 Jul 2025 11:33:29 -0700 Subject: [PATCH 8/8] fix: prettier --- gui/src/util/compactConversation.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gui/src/util/compactConversation.ts b/gui/src/util/compactConversation.ts index 67ac3813d..cbe57a619 100644 --- a/gui/src/util/compactConversation.ts +++ b/gui/src/util/compactConversation.ts @@ -48,9 +48,11 @@ export const useDeleteCompaction = () => { return (index: number) => { // Update local state and save to persistence dispatch(deleteCompaction(index)); - dispatch(saveCurrentSession({ - openNewSession: false, - generateTitle: false, - })); + dispatch( + saveCurrentSession({ + openNewSession: false, + generateTitle: false, + }), + ); }; };