Merge pull request #11506 from mvanhorn/fix/11480-tui-live-spent-cost

fix(cli): show live session spend in TUI sidebar during active turn
This commit is contained in:
Catriel Müller
2026-07-03 16:57:00 -03:00
committed by GitHub
2 changed files with 14 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---
Show live session spend in the TUI sidebar while an assistant turn is still running.
@@ -14,7 +14,15 @@ function View(props: { api: TuiPluginApi; session_id: string }) {
const theme = () => props.api.theme.current
const msg = createMemo(() => props.api.state.session.messages(props.session_id))
const session = createMemo(() => props.api.state.session.get(props.session_id))
const cost = createMemo(() => session()?.cost ?? 0)
// kilocode_change start
const cost = createMemo(() => {
const total = msg().reduce((sum, item) => {
if (item.role !== "assistant") return sum
return sum + (item.cost ?? 0)
}, 0)
return Math.max(session()?.cost ?? 0, total)
})
// kilocode_change end
const state = createMemo(() => {
const last = msg().findLast((item): item is AssistantMessage => item.role === "assistant" && item.tokens.output > 0)