Skip to content

Commit c15680c

Browse files
committed
manual-fixed
1 parent 14c85de commit c15680c

File tree

3 files changed

+48
-53
lines changed

3 files changed

+48
-53
lines changed

src/core/Cline.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,7 +2682,7 @@ export class Cline extends EventEmitter<ClineEvents> {
26822682
* @param isManualTrigger Whether this summarization was manually triggered by the user.
26832683
* @returns A promise that resolves when summarization is complete.
26842684
*/
2685-
public async summarizeConversationContext(isManualTrigger: boolean = false): Promise<void> {
2685+
public async summarizeConversationContext(_isManualTrigger: boolean = false): Promise<void> {
26862686
// Skip if summarization is disabled
26872687
if (!this.enableContextSummarization) {
26882688
this.providerRef.deref()?.log("[Summarization] Context summarization is disabled.")
@@ -2739,13 +2739,6 @@ export class Cline extends EventEmitter<ClineEvents> {
27392739
// Create new history with summary
27402740
const newHistory = [...initialMessages, summaryMessage, ...recentMessages]
27412741

2742-
// Add a system message to notify the user in the UI
2743-
if (isManualTrigger) {
2744-
await this.say("text", "[Conversation history has been summarized to preserve context]")
2745-
} else {
2746-
await this.say("text", "[Older conversation turns summarized to preserve context]")
2747-
}
2748-
27492742
// Update the conversation history
27502743
await this.overwriteApiConversationHistory(newHistory)
27512744

src/core/webview/webviewMessageHandler.ts

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -889,41 +889,28 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
889889
})
890890

891891
// 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-
)
913-
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-
})
892+
try {
893+
// Trigger the summarization process directly without adding system messages
894+
await currentCline.summarizeConversationContext(true) // true indicates manual trigger
895+
896+
// Send a message to the webview to hide the progress indicator
897+
void provider.postMessageToWebview({
898+
type: "summarizationStatus",
899+
status: "completed",
900+
text: t("common:info.summarization_complete"),
901+
})
902+
} catch (error) {
903+
provider.log(
904+
`Error during manual summarization: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
905+
)
920906

921-
// Add an error message
922-
await currentCline.say("error", t("common:errors.summarization_failed"))
923-
}
924-
})().catch((error) => {
925-
provider.log(`Unhandled error in summarization: ${String(error)}`)
926-
})
907+
// Update the UI to show the error
908+
void provider.postMessageToWebview({
909+
type: "summarizationStatus",
910+
status: "failed",
911+
text: t("common:errors.summarization_failed"),
912+
})
913+
}
927914
}
928915
break
929916
// --- End Context Summarization ---

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,22 +253,37 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
253253
break
254254
}
255255
case "summarizationStatus": {
256-
setState((prevState) => ({
257-
...prevState,
258-
summarizationStatus: {
259-
status: message.status as "started" | "completed" | "failed",
260-
text: message.text || "",
261-
},
262-
}))
256+
// For "started" status, update the state immediately
257+
if (message.status === "started") {
258+
setState((prevState) => ({
259+
...prevState,
260+
summarizationStatus: {
261+
status: message.status as "started" | "completed" | "failed",
262+
text: message.text || "",
263+
},
264+
}))
265+
}
266+
// For "completed" or "failed" status, update and then clear after delay
267+
else if (message.status === "completed" || message.status === "failed") {
268+
// First update the status
269+
setState((prevState) => ({
270+
...prevState,
271+
summarizationStatus: {
272+
status: message.status as "completed" | "failed",
273+
text: message.text || "",
274+
},
275+
}))
263276

264-
// Auto-clear the status after completion or failure
265-
if (message.status === "completed" || message.status === "failed") {
266-
setTimeout(() => {
277+
// Then clear it after a delay
278+
const timer = setTimeout(() => {
267279
setState((prevState) => ({
268280
...prevState,
269281
summarizationStatus: undefined,
270282
}))
271-
}, 5000) // Clear after 5 seconds
283+
}, 3000) // Reduced to 3 seconds for better UX
284+
285+
// Clean up the timer if component unmounts
286+
return () => clearTimeout(timer)
272287
}
273288
break
274289
}

0 commit comments

Comments
 (0)