Skip to content

feat(tui): port Kilo sidebar panels with slot order - #15427

Merged
marius-kilocode merged 4 commits into
v2from
kilo-sidebar-plugins
Oct 23, 2026
Merged

marius-kilocode merged 4 commits into
v2from
kilo-sidebar-plugins

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #15337

What Problem This Solves

The v2 session sidebar showed only the upstream panels (Context, MCP, Todo, footer). The v1 Kilo sidebar panels were missing: the PR of the current branch, the Kilo balance and Kilo Pass, the version line, and the usage panel with tokens, cost and usage per routed model (left open by #15404, which ported /usage). The v2 TUI slot API also had no numeric order, so a plugin could not place a panel between the upstream panels as v1 did.

Why This Change Was Made

  • Slot order seam. Slot claims get an optional order. Each anchor is sorted stably by it; a claim without an order counts as 100, 200, ... in enable order. Without any order the result is the enable order, so upstream behavior and tests do not change. With today's upstream claims (Context, MCP, Todo, footer) this gives the v1 positions: pr 50, Context, usage 150, MCP, (indexing 225, processes 250), Todo, (memory 1000); Kilo footer 99 before the upstream footer.
  • Usage panel (kilocode.sidebar.usage, order 150), as v1 sidebar-usage.tsx, sidebar-usage-row.tsx and model-usage.ts:
    • Token Usage of the whole session family (root and subagents): input, output, reasoning, cache read and write, cache rate, generation speed, cost.
    • Models: one row per provider and model, keyed by the routed model of each step (native.kilo.routedModelID), grouped by provider, sorted by cost, then provider and model. A step counts when it has token usage, as a v1 step-finish part. Rows expand to the token breakdown.
    • Terminal Bench 2.0 of the current Kilo model, from the kilocode.gateway models RPC.
    • v1 read a server usage query; v2 has no such endpoint, and the TUI message store keeps only one page per session. The panel reads every message page of the family through the existing message.list API and reads them again when the cost or token totals of a family session change (a finished step), as v1 read its query after each step. Title or time updates do not trigger a read.
  • Balance (kilocode.sidebar.footer, order 99), as v1 sidebar-footer.tsx: personal or team credits (error color at $2 or less), Kilo Pass usage, bonus and renewal for the personal scope. Refresh on sign-in, on the Gateway organization event (team switch), 10 s after a billed Kilo step, and every 5 minutes on a team; 30 s request timeout. Signed out, the panel sends no request. A second claim at order 101 adds the v1 • Kilo <version> line below the location path.
  • PR panel (kilocode.sidebar.pr, order 50), as v1 sidebar-pr.tsx: PR #<n> - <title> through the gh CLI, with the v1 lookup order (tracking ref, branch, head SHA, fork parent by branch and by SHA, only PRs whose head is HEAD), 1 s per command, 20 s overall, gh probe cached 5 minutes. Nothing shows without gh or a PR.
  • modelLabel is extracted from routedModelLabel in routed-model.tsx so the usage rows and the routed badges use the same v1 label rules.

User Impact

In a wide terminal (or with the sidebar open) the session sidebar shows, in v1 order: PR, Context, Token Usage, Models, Terminal Bench, MCP, Todo, then Balance, the location path and the Kilo version. Signed out, the balance is hidden, as on v1.

Not ported, because the backing feature is not on v2 yet:

v1 panel (order) Missing backing feature
Code Indexing (225) Code indexing
Background processes (250) Background process tool and its process list
Memory (1000) Memory

The seam already supports their orders; the panels can follow with their features.

Evidence

v1 reference on main: packages/opencode/src/kilocode/plugins/{sidebar-usage,sidebar-usage-row,model-usage,sidebar-footer,sidebar-pr}.tsx, packages/opencode/src/kilocode/session/model-usage.ts, packages/opencode/test/kilocode/sidebar-footer.test.ts.

Automated (isolated OPENCODE_TEST_HOME/XDG paths). First run with Bun 1.4.2; after merging v2 with the v2.1.3 sync (#15425), rerun with the pinned Bun 1.4.4: packages/tui bun test 1618 pass, 2 fail (same baseline test), root bun run check, shared-patch and annotation checks, progress map --check, plus a TUI smoke test (signed out prompt, usage panel and version line).

  • packages/tui: bun test 1613 pass, 2 fail. The 2 failures (dialog-shell-output.test.tsx, "shell output opens, follows, scrolls...") fail the same way on origin/v2 without this change.
  • New tests: slot-order.test.ts (enable order without order; the v1 sidebar order pr, context, usage, mcp, indexing, processes, todo, memory; footer 99 before upstream footer), model-usage.test.ts (routed model keying, running steps excluded, cost sort and ties, provider grouping), sidebar-usage.view.test.tsx (real app, root and subagent over two message pages: panel order Context, Token Usage, Models, Terminal Bench, MCP; family totals, cache rate, speed, routed model rows, row expansion; Balance above the path, version below), sidebar-footer.test.ts (v1 assertions: format, scope, credit label, Kilo Pass line, renewal date, billed step), sidebar-pr.test.ts (lookup order, SHA match, fork parent, no gh).
  • packages/plugin: bun test 9 pass. bun typecheck in plugin and tui; root bun run check; bun script/check-shared-patches.ts --worktree; bun script/check-opencode-annotations.ts --worktree; bun script/upstream/placement.ts --imports (no new core-internal imports); progress map twice (identical) plus --check.

Self-test, real TUI (vscode-self-test harness, --mode none, bun dev --standalone via script/dev-isolated.ts, fresh KILO_V2_PROFILE, env -i child environment):

  1. Signed out, kilo/kilo-auto/free: a prompt that ran one general subagent, then a switch to Laguna S 2.1 (free) and a second prompt. The sidebar showed Context, Token Usage (family totals, cache rate, speed), Models (2), then Models (3) live after the second prompt with the routed models of root and subagent; no Balance; no errors in the log. Pass.
  2. Same session with the local Gateway fixture (@kilocode/gateway-core/testing, KILO_API_URL, KILO_API_KEY=fixture-token), current model Kilo Auto Frontier: Terminal Bench 2.0 72.0% / $0.45, Balance $42.50 with Kilo Pass $12 / $50, bonus +$5.00, renews Nov 1, above the location path; model row expansion. Pass.
  3. Signed out, in this worktree (branch with this PR open), gh with the real config dir (GH_CONFIG_DIR, because bun dev isolates HOME): the sidebar shows PR #15427 - feat(tui): port Kilo sidebar panels with slot order above Context, and • Kilo local below the location path. Pass.
  4. v1 (main, temporary HOME, same prompts and models, same fixture, BROWSER=true): same panels, order and content.

Proof

Signed out, same prompts and models. v1 (main):

v1 sidebar signed out: Context, Token Usage, Models (3), then the v1-only Code Indexing, LSP and Memory panels

v2 (this PR):

v2 sidebar signed out: Context, Token Usage, Models (3)

Local Gateway fixture, Kilo Auto Frontier selected, one model row expanded. v1:

v1 sidebar with the fixture: Token Usage, Models with an expanded row, Terminal Bench 2.0, Balance with Kilo Pass, path, Kilo version

v2:

v2 sidebar with the fixture: Token Usage, Models with an expanded row, Terminal Bench 2.0, Balance with Kilo Pass, path

Differences on purpose or from missing features: v1 shows Code Indexing, LSP and Memory (not on v2); v1 shows the session ID under the title (upstream v2 sidebar does not); v1 shows the generation speed only for steps with computed metrics, v2 uses the step times as /usage does (#15404). The v2 fixture screenshot above was taken before the version line was added. On the final head, same fixture (Laguna selected, so no Terminal Bench), the footer shows Balance, the location path and • Kilo local as on v1:

v2 sidebar on the final head: Balance with Kilo Pass, location path, Kilo version line

v2 PR panel (order 50, above Context) and version line, in this worktree with this PR open (sidebar only). v1 shows the same PR #<n> - <title> line at the top of its sidebar:

v2 sidebar: PR line above Context, usage panel, location path and Kilo version line

Placement

Change Rung Why not lower Proof
Optional slot claim order 3 No plugin hook or host option reaches the slot resolver; the claim type, its normalization and the resolver are the only places that know claim positions packages/plugin/src/tui/context.ts (1 line), packages/tui/src/plugin/api.tsx (1 line), packages/tui/src/plugin/structure.ts (1 line plus a 10-line block); shared-patches.json entries
Sidebar PR, balance, usage panels 1 (TUI plugin API) n/a packages/tui/src/kilocode/plugins/*
Registration of the three plugins 4 (registration) The TUI built-in list is in the TUI process, which the host does not reach (same as KiloTeams, KiloUsage) packages/tui/src/plugin/builtins.ts, 6 marked lines

Shared upstream files: packages/plugin/src/tui/context.ts (existing entry, text extended), packages/tui/src/plugin/api.tsx and packages/tui/src/plugin/structure.ts (new, rung 3), packages/tui/src/plugin/builtins.ts (existing entry, text extended). Limits: files 46 to 48, markedLines 334 to 353. No new core-internal imports. No mirrored files. Startup budget: no entries, the new plugins are TUI plugins and the budget measures server plugins.

Progress map

plugin: 1/34 to 7/34. module 1/26 to 6/26, test 0/6 to 1/6.

Done, and why:

  • by file name (6): sidebar-usage.tsx, sidebar-usage-row.tsx, model-usage.ts, sidebar-pr.tsx, sidebar-footer.tsx -> packages/tui/src/kilocode/plugins/; sidebar-footer.test.ts -> packages/tui/test/kilocode/sidebar-footer.test.ts.

Still open:

  • sidebar-indexing.tsx, sidebar-background-processes.tsx, memory-status.tsx, memory-palette.tsx: the backing features are not on v2.
  • patch:plugin:e579fb4997a9 (v1 withKiloTuiPlugins in plugin/tui/internal.ts): it registers every v1 Kilo TUI plugin, most of them other units.
  • usage-cost session/model-usage.ts and its test: the v1 server endpoint for per-model usage, also used by the VS Code extension (G2). The TUI aggregates on the client.
  • Other plugin cells (session switcher, remote, sandbox, attention, and more) belong to other units.

Limits

  • v1 privacy mode (masked balance) is not carried: v2 has no privacy mode yet (U-E9-12). The footer cell closes by name; the masking follows with that unit.
  • The upstream getting-started text still says "OpenCode includes free models"; product strings change through the rename script during syncs.
  • Under bun dev, gh runs with the isolated profile HOME, so the PR panel needs GH_CONFIG_DIR (or GH_TOKEN) in the self-test; installed builds use the real HOME.
  • The usage panel reads all message pages of the family after each finished step. For very long sessions this is several local requests per step.
  • The balance panel shows when the Kilo integration has a connection (an environment key or a stored /connect credential, both listed by integration.list). The self-test covered the environment key only; no real login flow was started.

# Conflicts:
#	migration-tracking/progress/README.md
#	migration-tracking/progress/history.svg
#	migration-tracking/progress/progress.json
#	migration-tracking/progress/progress.svg
#	script/upstream/shared-patches.json
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

➖ v2 migration progress: 1.5% → 1.5% (+6 done, 0 total, 0 dropped; 149/9828 cells)

Placement: 19 new marked lines in shared files (19 seam), 0 new kilo_port annotations, 0 new core-internal imports.

Ratchets: 25 core-internal imports (base 25); shared patches by rung 28 seam, 20 patch (base 26 seam, 20 patch).

Feature Before After Change
plugin 1/34 7/34 +5 modules done; +1 test done
6 cells closed
  • module:packages/opencode/src/kilocode/plugins/model-usage.ts
  • module:packages/opencode/src/kilocode/plugins/sidebar-footer.tsx
  • module:packages/opencode/src/kilocode/plugins/sidebar-pr.tsx
  • module:packages/opencode/src/kilocode/plugins/sidebar-usage-row.tsx
  • module:packages/opencode/src/kilocode/plugins/sidebar-usage.tsx
  • module:packages/opencode/test/kilocode/sidebar-footer.test.ts

v2 migration progress map at this commit

Full map · how cells close

@github-actions github-actions Bot added the area:cli CLI, TUI and core engine label Oct 23, 2026
Comment thread packages/tui/src/kilocode/plugins/sidebar-usage.tsx Outdated
@kilo-code-bot

kilo-code-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The incremental change re-keys the usage resource on the family's session cost and tokens, which session.usage.updated writes into session.info on every finished step (packages/core/src/session/projector.ts:822), so the panel now refreshes at step granularity as described. The previous finding is resolved.

Files Reviewed (1 file)
  • packages/tui/src/kilocode/plugins/sidebar-usage.tsx
Previous Review Summary (commit 11b7da2)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 11b7da2)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
packages/tui/src/kilocode/plugins/sidebar-usage.tsx 35 The resource key uses time.updated, which the client store only refreshes when session info is re-synced (turn end, title rename, route/tab mount), not on session.step.ended; the panel therefore stays stale during a long multi-step turn instead of re-reading per step as the comment and PR body state.

SUGGESTION

File Line Issue
PR body - The stated shared-patch limits and progress counts do not match the committed files: the diff raises files 44 to 47 and markedLines 329 to 348, and the progress map moves plugin to 6/34 and module to 5/26, while the body says 46 to 48, 334 to 353, 7/34 and 6/26. Worth updating so the body matches the merge.
Files Reviewed (20 files)
  • script/upstream/shared-patches.json
  • packages/plugin/src/tui/context.ts
  • packages/tui/src/plugin/api.tsx
  • packages/tui/src/plugin/structure.ts
  • packages/tui/src/plugin/builtins.ts
  • packages/tui/src/kilocode/routed-model.tsx
  • packages/tui/src/kilocode/plugins/model-usage.ts
  • packages/tui/src/kilocode/plugins/sidebar-usage.tsx
  • packages/tui/src/kilocode/plugins/sidebar-usage-row.tsx
  • packages/tui/src/kilocode/plugins/sidebar-pr.tsx
  • packages/tui/src/kilocode/plugins/sidebar-footer.tsx
  • packages/tui/test/kilocode/model-usage.test.ts
  • packages/tui/test/kilocode/sidebar-footer.test.ts
  • packages/tui/test/kilocode/sidebar-pr.test.ts
  • packages/tui/test/kilocode/sidebar-usage.view.test.tsx
  • packages/tui/test/kilocode/slot-order.test.ts
  • migration-tracking/progress/README.md
  • migration-tracking/progress/progress.json
  • migration-tracking/progress/history.svg
  • migration-tracking/progress/progress.svg

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 39K · Output: 4.2K · Cached: 413.4K

Review guidance: REVIEW.md from base branch v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli CLI, TUI and core engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants