Skip to content

Commit 14c85de

Browse files
committed
@mention-buggy
1 parent e7f1cbe commit 14c85de

File tree

4 files changed

+104
-54
lines changed

4 files changed

+104
-54
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -881,64 +881,49 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
881881
// Trigger manual summarization of the conversation context
882882
const currentCline = provider.getCurrentCline()
883883
if (currentCline) {
884-
try {
885-
// First send a message to the webview to show a progress indicator
886-
provider.postMessageToWebview({
887-
type: "summarizationStatus",
888-
status: "started",
889-
text: t("common:info.summarizing_context"),
890-
})
891-
892-
// Notify user that summarization is in progress
893-
vscode.window.showInformationMessage(t("common:info.summarizing_context"))
894-
895-
// Add a "summarizing" message to the chat
896-
await currentCline.say("summarizing", t("common:info.summarizing_context"), undefined, true)
897-
898-
// Trigger the summarization process
899-
await currentCline.summarizeConversationContext(true) // true indicates manual trigger
900-
901-
// Update the "summarizing" message to show completion
902-
const lastMessage = currentCline.clineMessages.at(-1)
903-
if (lastMessage && lastMessage.say === "summarizing" && lastMessage.partial) {
904-
lastMessage.text = t("common:info.summarization_complete")
905-
lastMessage.partial = false
906-
await currentCline.saveClineMessages()
907-
await provider.postStateToWebview()
908-
}
909-
910-
// Send a message to the webview to hide the progress indicator
911-
provider.postMessageToWebview({
912-
type: "summarizationStatus",
913-
status: "completed",
914-
text: t("common:info.summarization_complete"),
915-
})
884+
// First send a message to the webview to show a progress indicator
885+
void provider.postMessageToWebview({
886+
type: "summarizationStatus",
887+
status: "started",
888+
text: t("common:info.summarizing_context"),
889+
})
916890

917-
// Notify user that summarization is complete
918-
vscode.window.showInformationMessage(t("common:info.summarization_complete"))
919-
} catch (error) {
920-
provider.log(
921-
`Error during manual summarization: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
922-
)
891+
// Use a non-blocking approach with proper error handling
892+
;(async function summarizeContext() {
893+
try {
894+
// Add a system notification message that doesn't require user interaction
895+
await currentCline.say("text", "[System: Summarizing conversation context...]")
896+
897+
// Trigger the summarization process
898+
await currentCline.summarizeConversationContext(true) // true indicates manual trigger
899+
900+
// Add a completion message
901+
await currentCline.say("text", "[System: Conversation context summarization complete]")
902+
903+
// Send a message to the webview to hide the progress indicator
904+
void provider.postMessageToWebview({
905+
type: "summarizationStatus",
906+
status: "completed",
907+
text: t("common:info.summarization_complete"),
908+
})
909+
} catch (error) {
910+
provider.log(
911+
`Error during manual summarization: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
912+
)
923913

924-
// Update the UI to show the error
925-
provider.postMessageToWebview({
926-
type: "summarizationStatus",
927-
status: "failed",
928-
text: t("common:errors.summarization_failed"),
929-
})
914+
// Update the UI to show the error
915+
void provider.postMessageToWebview({
916+
type: "summarizationStatus",
917+
status: "failed",
918+
text: t("common:errors.summarization_failed"),
919+
})
930920

931-
// Update any partial message
932-
const lastMessage = currentCline.clineMessages.at(-1)
933-
if (lastMessage && lastMessage.say === "summarizing" && lastMessage.partial) {
934-
lastMessage.text = t("common:errors.summarization_failed")
935-
lastMessage.partial = false
936-
await currentCline.saveClineMessages()
937-
await provider.postStateToWebview()
921+
// Add an error message
922+
await currentCline.say("error", t("common:errors.summarization_failed"))
938923
}
939-
940-
vscode.window.showErrorMessage(t("common:errors.summarization_failed"))
941-
}
924+
})().catch((error) => {
925+
provider.log(`Unhandled error in summarization: ${String(error)}`)
926+
})
942927
}
943928
break
944929
// --- End Context Summarization ---

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import ChatTextArea from "./ChatTextArea"
3838
import TaskHeader from "./TaskHeader"
3939
import AutoApproveMenu from "./AutoApproveMenu"
4040
import SystemPromptWarning from "./SystemPromptWarning"
41+
import SummarizationIndicator from "./SummarizationIndicator"
4142
import { useTaskSearch } from "../history/useTaskSearch"
4243

4344
export interface ChatViewProps {
@@ -1249,6 +1250,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
12491250
<CheckpointWarningMessage />
12501251
</div>
12511252
)}
1253+
1254+
{/* Summarization status indicator */}
1255+
<div className="px-3">
1256+
<SummarizationIndicator />
1257+
</div>
12521258
</>
12531259
) : (
12541260
<div className="flex-1 min-h-0 overflow-y-auto flex flex-col gap-4">
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react"
2+
import { cn } from "@/lib/utils"
3+
import { useExtensionState } from "@/context/ExtensionStateContext"
4+
5+
/**
6+
* A component that displays the current status of context summarization
7+
*/
8+
export const SummarizationIndicator: React.FC = () => {
9+
const { summarizationStatus } = useExtensionState()
10+
11+
if (!summarizationStatus) {
12+
return null
13+
}
14+
15+
return (
16+
<div
17+
className={cn(
18+
"flex items-center p-3 my-2 rounded-md transition-all duration-300",
19+
summarizationStatus.status === "started"
20+
? "bg-vscode-inputValidation-infoBackground border border-vscode-inputValidation-infoBorder"
21+
: summarizationStatus.status === "completed"
22+
? "bg-vscode-inputValidation-successBackground border border-vscode-inputValidation-successBorder"
23+
: "bg-vscode-inputValidation-errorBackground border border-vscode-inputValidation-errorBorder",
24+
)}>
25+
{summarizationStatus.status === "started" && (
26+
<span className="codicon codicon-loading codicon-modifier-spin mr-2" />
27+
)}
28+
{summarizationStatus.status === "completed" && <span className="codicon codicon-check mr-2" />}
29+
{summarizationStatus.status === "failed" && <span className="codicon codicon-error mr-2" />}
30+
<span className="text-vscode-foreground">{summarizationStatus.text}</span>
31+
</div>
32+
)
33+
}
34+
35+
export default SummarizationIndicator

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export interface ExtensionStateContextType extends ExtensionState {
2020
mcpServers: McpServer[]
2121
hasSystemPromptOverride?: boolean
2222
currentCheckpoint?: string
23+
summarizationStatus?: {
24+
status: "started" | "completed" | "failed"
25+
text: string
26+
}
2327
filePaths: string[]
2428
openedTabs: Array<{ label: string; isActive: boolean; path?: string }>
2529
setApiConfiguration: (config: ApiConfiguration) => void
@@ -248,6 +252,26 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
248252
setCurrentCheckpoint(message.text)
249253
break
250254
}
255+
case "summarizationStatus": {
256+
setState((prevState) => ({
257+
...prevState,
258+
summarizationStatus: {
259+
status: message.status as "started" | "completed" | "failed",
260+
text: message.text || "",
261+
},
262+
}))
263+
264+
// Auto-clear the status after completion or failure
265+
if (message.status === "completed" || message.status === "failed") {
266+
setTimeout(() => {
267+
setState((prevState) => ({
268+
...prevState,
269+
summarizationStatus: undefined,
270+
}))
271+
}, 5000) // Clear after 5 seconds
272+
}
273+
break
274+
}
251275
case "listApiConfig": {
252276
setListApiConfigMeta(message.listApiConfig ?? [])
253277
break

0 commit comments

Comments
 (0)