Skip to content

Commit 621fc0e

Browse files
committed
Revert "Merge pull request RooCodeInc#1518 from RooVetGit/revert_tool_progress_for_now"
This reverts commit dba9116, reversing changes made to 85dd1a1.
1 parent edb53bf commit 621fc0e

File tree

7 files changed

+73
-1
lines changed

7 files changed

+73
-1
lines changed

src/core/Cline.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
ClineSay,
4949
ClineSayBrowserAction,
5050
ClineSayTool,
51+
ToolProgressStatus,
5152
} from "../shared/ExtensionMessage"
5253
import { getApiMetrics } from "../shared/getApiMetrics"
5354
import { HistoryItem } from "../shared/HistoryItem"
@@ -408,6 +409,7 @@ export class Cline {
408409
type: ClineAsk,
409410
text?: string,
410411
partial?: boolean,
412+
progressStatus?: ToolProgressStatus,
411413
): Promise<{ response: ClineAskResponse; text?: string; images?: string[] }> {
412414
// If this Cline instance was aborted by the provider, then the only thing keeping us alive is a promise still running in the background, in which case we don't want to send its result to the webview as it is attached to a new instance of Cline now. So we can safely ignore the result of any active promises, and this class will be deallocated. (Although we set Cline = undefined in provider, that simply removes the reference to this instance, but the instance is still alive until this promise resolves or rejects.)
413415
if (this.abort) {
@@ -423,6 +425,7 @@ export class Cline {
423425
// existing partial message, so update it
424426
lastMessage.text = text
425427
lastMessage.partial = partial
428+
lastMessage.progressStatus = progressStatus
426429
// todo be more efficient about saving and posting only new data or one whole message at a time so ignore partial for saves, and only post parts of partial message instead of whole array in new listener
427430
// await this.saveClineMessages()
428431
// await this.providerRef.deref()?.postStateToWebview()
@@ -460,6 +463,8 @@ export class Cline {
460463
// lastMessage.ts = askTs
461464
lastMessage.text = text
462465
lastMessage.partial = false
466+
lastMessage.progressStatus = progressStatus
467+
463468
await this.saveClineMessages()
464469
// await this.providerRef.deref()?.postStateToWebview()
465470
await this.providerRef
@@ -511,6 +516,7 @@ export class Cline {
511516
images?: string[],
512517
partial?: boolean,
513518
checkpoint?: Record<string, unknown>,
519+
progressStatus?: ToolProgressStatus,
514520
): Promise<undefined> {
515521
if (this.abort) {
516522
throw new Error(`Task: ${this.taskNumber} Roo Code instance aborted (#2)`)
@@ -526,6 +532,7 @@ export class Cline {
526532
lastMessage.text = text
527533
lastMessage.images = images
528534
lastMessage.partial = partial
535+
lastMessage.progressStatus = progressStatus
529536
await this.providerRef
530537
.deref()
531538
?.postMessageToWebview({ type: "partialMessage", partialMessage: lastMessage })
@@ -545,6 +552,7 @@ export class Cline {
545552
lastMessage.text = text
546553
lastMessage.images = images
547554
lastMessage.partial = false
555+
lastMessage.progressStatus = progressStatus
548556

549557
// instead of streaming partialMessage events, we do a save and post like normal to persist to disk
550558
await this.saveClineMessages()
@@ -1703,8 +1711,16 @@ export class Cline {
17031711
try {
17041712
if (block.partial) {
17051713
// update gui message
1714+
let toolProgressStatus
1715+
if (this.diffStrategy && this.diffStrategy.getProgressStatus) {
1716+
toolProgressStatus = this.diffStrategy.getProgressStatus(block)
1717+
}
1718+
17061719
const partialMessage = JSON.stringify(sharedMessageProps)
1707-
await this.ask("tool", partialMessage, block.partial).catch(() => {})
1720+
1721+
await this.ask("tool", partialMessage, block.partial, toolProgressStatus).catch(
1722+
() => {},
1723+
)
17081724
break
17091725
} else {
17101726
if (!relPath) {
@@ -1799,6 +1815,14 @@ export class Cline {
17991815
diff: diffContent,
18001816
} satisfies ClineSayTool)
18011817

1818+
let toolProgressStatus
1819+
if (this.diffStrategy && this.diffStrategy.getProgressStatus) {
1820+
toolProgressStatus = this.diffStrategy.getProgressStatus(block, diffResult)
1821+
}
1822+
await this.ask("tool", completeMessage, block.partial, toolProgressStatus).catch(
1823+
() => {},
1824+
)
1825+
18021826
const didApprove = await askApproval("tool", completeMessage)
18031827
if (!didApprove) {
18041828
await this.diffViewProvider.revertChanges() // This likely handles closing the diff view

src/core/diff/strategies/multi-search-replace.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { DiffStrategy, DiffResult } from "../types"
22
import { addLineNumbers, everyLineHasLineNumbers, stripLineNumbers } from "../../../integrations/misc/extract-text"
33
import { distance } from "fastest-levenshtein"
4+
import { ToolProgressStatus } from "../../../shared/ExtensionMessage"
5+
import { ToolUse } from "../../assistant-message"
46

57
const BUFFER_LINES = 40 // Number of extra context lines to show before and after matches
68

@@ -362,4 +364,27 @@ Only use a single line of '=======' between search and replacement content, beca
362364
failParts: diffResults,
363365
}
364366
}
367+
368+
getProgressStatus(toolUse: ToolUse, result?: DiffResult): ToolProgressStatus {
369+
const diffContent = toolUse.params.diff
370+
if (diffContent) {
371+
const icon = "diff-multiple"
372+
const searchBlockCount = (diffContent.match(/SEARCH/g) || []).length
373+
if (toolUse.partial) {
374+
if (diffContent.length < 1000 || (diffContent.length / 50) % 10 === 0) {
375+
return { icon, text: `${searchBlockCount}` }
376+
}
377+
} else if (result) {
378+
if (result.failParts?.length) {
379+
return {
380+
icon,
381+
text: `${searchBlockCount - result.failParts.length}/${searchBlockCount}`,
382+
}
383+
} else {
384+
return { icon, text: `${searchBlockCount}` }
385+
}
386+
}
387+
}
388+
return {}
389+
}
365390
}

src/core/diff/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* Interface for implementing different diff strategies
33
*/
44

5+
import { ToolProgressStatus } from "../../shared/ExtensionMessage"
6+
import { ToolUse } from "../assistant-message"
7+
58
export type DiffResult =
69
| { success: true; content: string; failParts?: DiffResult[] }
710
| ({
@@ -34,4 +37,6 @@ export interface DiffStrategy {
3437
* @returns A DiffResult object containing either the successful result or error details
3538
*/
3639
applyDiff(originalContent: string, diffContent: string, startLine?: number, endLine?: number): Promise<DiffResult>
40+
41+
getProgressStatus?(toolUse: ToolUse, result?: any): ToolProgressStatus
3742
}

src/exports/roo-code.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface ClineMessage {
9292
reasoning?: string
9393
conversationHistoryIndex?: number
9494
checkpoint?: Record<string, unknown>
95+
progressStatus?: ToolProgressStatus
9596
}
9697

9798
export interface ClineProvider {

src/shared/ExtensionMessage.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,8 @@ export interface HumanRelayCancelMessage {
231231
}
232232

233233
export type ClineApiReqCancelReason = "streaming_failed" | "user_cancelled"
234+
235+
export type ToolProgressStatus = {
236+
icon?: string
237+
text?: string
238+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export const ChatRowContent = ({
258258
<span style={{ fontWeight: "bold" }}>Roo wants to edit this file:</span>
259259
</div>
260260
<CodeAccordian
261+
progressStatus={message.progressStatus}
261262
isLoading={message.partial}
262263
diff={tool.diff!}
263264
path={tool.path!}

webview-ui/src/components/common/CodeAccordian.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { memo, useMemo } from "react"
22
import { getLanguageFromPath } from "../../utils/getLanguageFromPath"
33
import CodeBlock, { CODE_BLOCK_BG_COLOR } from "./CodeBlock"
4+
import { ToolProgressStatus } from "../../../../src/shared/ExtensionMessage"
45

56
interface CodeAccordianProps {
67
code?: string
@@ -12,6 +13,7 @@ interface CodeAccordianProps {
1213
isExpanded: boolean
1314
onToggleExpand: () => void
1415
isLoading?: boolean
16+
progressStatus?: ToolProgressStatus
1517
}
1618

1719
/*
@@ -32,6 +34,7 @@ const CodeAccordian = ({
3234
isExpanded,
3335
onToggleExpand,
3436
isLoading,
37+
progressStatus,
3538
}: CodeAccordianProps) => {
3639
const inferredLanguage = useMemo(
3740
() => code && (language ?? (path ? getLanguageFromPath(path) : undefined)),
@@ -95,6 +98,14 @@ const CodeAccordian = ({
9598
</>
9699
)}
97100
<div style={{ flexGrow: 1 }}></div>
101+
{progressStatus && progressStatus.text && (
102+
<>
103+
{progressStatus.icon && <span className={`codicon codicon-${progressStatus.icon} mr-1`} />}
104+
<span className="mr-1 ml-auto text-vscode-descriptionForeground">
105+
{progressStatus.text}
106+
</span>
107+
</>
108+
)}
98109
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span>
99110
</div>
100111
)}

0 commit comments

Comments
 (0)