Skip to content

Commit 95bd6cb

Browse files
committed
Add UI component
1 parent 603d2ef commit 95bd6cb

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

src/core/task/Task.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,15 @@ export class Task extends EventEmitter<ClineEvents> {
518518
this.lastMessageTs = sayTs
519519
}
520520

521-
await this.addToClineMessages({ ts: sayTs, type: "say", say: type, text, images, partial })
521+
await this.addToClineMessages({
522+
ts: sayTs,
523+
type: "say",
524+
say: type,
525+
text,
526+
images,
527+
partial,
528+
contextCondense,
529+
})
522530
}
523531
} else {
524532
// New now have a complete version of a previously partial message.
@@ -548,7 +556,7 @@ export class Task extends EventEmitter<ClineEvents> {
548556
this.lastMessageTs = sayTs
549557
}
550558

551-
await this.addToClineMessages({ ts: sayTs, type: "say", say: type, text, images })
559+
await this.addToClineMessages({ ts: sayTs, type: "say", say: type, text, images, contextCondense })
552560
}
553561
}
554562
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ export const ChatRowContent = ({
928928
/>
929929
)
930930
case "condense_context":
931-
return <ContextCondenseRow ts={message.ts} contextCondense={message.contextCondense} />
931+
return <ContextCondenseRow contextCondense={message.contextCondense} />
932932
default:
933933
return (
934934
<>
Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
1+
import { useState } from "react"
2+
import { useTranslation } from "react-i18next"
3+
import { VSCodeBadge } from "@vscode/webview-ui-toolkit/react"
4+
15
import { ContextCondense } from "@roo/schemas"
26

37
interface ContextCondenseRowProps {
4-
ts: number
58
contextCondense?: ContextCondense
69
}
710

811
const ContextCondenseRow = ({ contextCondense }: ContextCondenseRowProps) => {
12+
const { t } = useTranslation()
13+
const [isExpanded, setIsExpanded] = useState(false)
14+
915
if (!contextCondense) {
1016
return null
1117
}
12-
return null
18+
const { cost, prevContextTokens, newContextTokens, summary } = contextCondense
19+
20+
return (
21+
<div className="mb-2">
22+
<div
23+
className="flex items-center justify-between cursor-pointer select-none"
24+
onClick={() => setIsExpanded(!isExpanded)}>
25+
<div className="flex items-center gap-2 flex-grow">
26+
<span className="codicon codicon-compress text-blue-400" />
27+
<span className="font-bold text-vscode-foreground">
28+
{t("chat:contextCondense.title", "Context Condensed")}
29+
</span>
30+
<span className="text-vscode-descriptionForeground text-sm">
31+
{prevContextTokens.toLocaleString()}{newContextTokens.toLocaleString()} tokens
32+
</span>
33+
<VSCodeBadge style={{ opacity: cost > 0 ? 1 : 0 }}>${cost.toFixed(2)}</VSCodeBadge>
34+
</div>
35+
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span>
36+
</div>
37+
38+
{isExpanded && (
39+
<div className="mt-2 ml-6 p-3 bg-vscode-editor-background rounded text-vscode-foreground text-sm">
40+
{summary}
41+
</div>
42+
)}
43+
</div>
44+
)
1345
}
1446

1547
export default ContextCondenseRow

0 commit comments

Comments
 (0)