Skip to content

Commit 67b1ac5

Browse files
committed
Improve manual summarization UX with visual feedback
1 parent 08adf5f commit 67b1ac5

File tree

7 files changed

+53
-1
lines changed

7 files changed

+53
-1
lines changed

src/core/Cline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export class Cline extends EventEmitter<ClineEvents> {
370370
this.emit("message", { action: "updated", message: partialMessage })
371371
}
372372

373-
private async saveClineMessages() {
373+
public async saveClineMessages() {
374374
try {
375375
await saveTaskMessages({
376376
messages: this.clineMessages,

src/core/webview/webviewMessageHandler.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,18 +882,61 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
882882
const currentCline = provider.getCurrentCline()
883883
if (currentCline) {
884884
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+
885892
// Notify user that summarization is in progress
886893
vscode.window.showInformationMessage(t("common:info.summarizing_context"))
887894

895+
// Add a "summarizing" message to the chat
896+
await currentCline.say("summarizing", t("common:info.summarizing_context"), undefined, true)
897+
888898
// Trigger the summarization process
889899
await currentCline.summarizeConversationContext(true) // true indicates manual trigger
890900

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+
})
916+
891917
// Notify user that summarization is complete
892918
vscode.window.showInformationMessage(t("common:info.summarization_complete"))
893919
} catch (error) {
894920
provider.log(
895921
`Error during manual summarization: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
896922
)
923+
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+
})
930+
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()
938+
}
939+
897940
vscode.window.showErrorMessage(t("common:errors.summarization_failed"))
898941
}
899942
}

src/exports/roo-code.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ type ClineMessage = {
342342
| "checkpoint_saved"
343343
| "rooignore_error"
344344
| "diff_error"
345+
| "summarizing"
345346
)
346347
| undefined
347348
text?: string | undefined
@@ -423,6 +424,7 @@ type RooCodeEvents = {
423424
| "checkpoint_saved"
424425
| "rooignore_error"
425426
| "diff_error"
427+
| "summarizing"
426428
)
427429
| undefined
428430
text?: string | undefined

src/exports/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ type ClineMessage = {
347347
| "checkpoint_saved"
348348
| "rooignore_error"
349349
| "diff_error"
350+
| "summarizing"
350351
)
351352
| undefined
352353
text?: string | undefined
@@ -432,6 +433,7 @@ type RooCodeEvents = {
432433
| "checkpoint_saved"
433434
| "rooignore_error"
434435
| "diff_error"
436+
| "summarizing"
435437
)
436438
| undefined
437439
text?: string | undefined

src/schemas/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ export const clineSays = [
789789
"checkpoint_saved",
790790
"rooignore_error",
791791
"diff_error",
792+
"summarizing",
792793
] as const
793794

794795
export const clineSaySchema = z.enum(clineSays)

src/shared/ExtensionMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export interface ExtensionMessage {
6767
| "toggleApiConfigPin"
6868
| "acceptInput"
6969
| "setHistoryPreviewCollapsed"
70+
| "summarizationStatus"
7071
text?: string
7172
action?:
7273
| "chatButtonClicked"
@@ -103,6 +104,7 @@ export interface ExtensionMessage {
103104
promptText?: string
104105
results?: { path: string; type: "file" | "folder"; label?: string }[]
105106
error?: string
107+
status?: "started" | "completed" | "failed"
106108
}
107109

108110
export type ExtensionState = Pick<

src/shared/WebviewMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export interface WebviewMessage {
133133
| "contextSummarizationInitialStaticTurns"
134134
| "contextSummarizationRecentTurns"
135135
| "manualSummarize"
136+
| "summarizationStatus"
136137
text?: string
137138
disabled?: boolean
138139
askResponse?: ClineAskResponse
@@ -161,6 +162,7 @@ export interface WebviewMessage {
161162
hasSystemPromptOverride?: boolean
162163
terminalOperation?: "continue" | "abort"
163164
historyPreviewCollapsed?: boolean
165+
status?: "started" | "completed" | "failed"
164166
}
165167

166168
export const checkoutDiffPayloadSchema = z.object({

0 commit comments

Comments
 (0)