MCPcopy Index your code
hub / github.com/continuedev/continue / useCompactConversation

Function useCompactConversation

gui/src/util/compactConversation.ts:10–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { loadSession, saveCurrentSession } from "../redux/thunks/session";
9
10export const useCompactConversation = () => {
11 const dispatch = useAppDispatch();
12 const ideMessenger = useContext(IdeMessengerContext);
13 const currentSessionId = useAppSelector((state) => state.session.id);
14
15 return async (index: number) => {
16 if (!currentSessionId) {
17 return;
18 }
19
20 try {
21 // Set loading state
22 dispatch(setCompactionLoading({ index, loading: true }));
23
24 await ideMessenger.request("conversation/compact", {
25 index,
26 sessionId: currentSessionId,
27 });
28
29 // Reload the current session to refresh the conversation state
30 dispatch(
31 loadSession({
32 sessionId: currentSessionId,
33 saveCurrentSession: false,
34 }),
35 );
36 } catch (error) {
37 console.error("Error compacting conversation:", error);
38 } finally {
39 // Clear loading state
40 dispatch(setCompactionLoading({ index, loading: false }));
41 }
42 };
43};
44
45export const useDeleteCompaction = () => {
46 const dispatch = useAppDispatch();

Callers 2

ResponseActionsFunction · 0.90
ContextStatusFunction · 0.90

Calls 3

loadSessionFunction · 0.90
errorMethod · 0.80
requestMethod · 0.65

Tested by

no test coverage detected