Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/collapsible-context-sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Let the Context section in the TUI session sidebar collapse and expand on header click, matching the existing collapsible pattern used by Token Usage, Models, and Terminal Bench 2.0. When collapsed, the header shows a one-line summary of percent used and total cost.
30 changes: 23 additions & 7 deletions packages/tui/src/feature-plugins/sidebar/context.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AssistantMessage } from "@kilocode/sdk/v2"
import type { TuiPlugin, TuiPluginApi } from "@kilocode/plugin/tui"
import type { BuiltinTuiPlugin } from "../builtins"
import { createMemo } from "solid-js"
import { createMemo, createSignal, Show } from "solid-js" // kilocode_change

const id = "internal:sidebar-context"

Expand All @@ -11,6 +11,9 @@ const money = new Intl.NumberFormat("en-US", {
})

function View(props: { api: TuiPluginApi; session_id: string }) {
// kilocode_change start
const [open, setOpen] = createSignal(true)
// kilocode_change end
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))
Expand Down Expand Up @@ -44,12 +47,25 @@ function View(props: { api: TuiPluginApi; session_id: string }) {

return (
<box>
<text fg={theme().text}>
<b>Context</b>
</text>
<text fg={theme().textMuted}>{state().tokens.toLocaleString()} tokens</text>
<text fg={theme().textMuted}>{state().percent ?? 0}% used</text>
<text fg={theme().textMuted}>{money.format(cost())} spent</text>
{/* kilocode_change start */}
<box flexDirection="row" gap={1} onMouseDown={() => setOpen((x) => !x)}>
Comment thread
IamCoder18 marked this conversation as resolved.
<text fg={theme().text}>{open() ? "▼" : "▶"}</text>
<text fg={theme().text}>
<b>Context</b>
<Show when={!open()}>
<span style={{ fg: theme().textMuted }}>
{" "}
({state().percent ?? 0}% · {money.format(cost())})
</span>
</Show>
</text>
</box>
<Show when={open()}>
<text fg={theme().textMuted}>{state().tokens.toLocaleString()} tokens</text>
<text fg={theme().textMuted}>{state().percent ?? 0}% used</text>
<text fg={theme().textMuted}>{money.format(cost())} spent</text>
</Show>
{/* kilocode_change end */}
</box>
)
}
Expand Down
Loading