Skip to content

feat(sidebar): option B layout on the shared CortexKit frame (#839) - #869

Draft
iceteaSA wants to merge 5 commits into
cortexkit:masterfrom
iceteaSA:feat/sidebar-option-b
Draft

iceteaSA wants to merge 5 commits into
cortexkit:masterfrom
iceteaSA:feat/sidebar-option-b

Conversation

@iceteaSA

@iceteaSA iceteaSA commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Approved issue: #839

This is a draft. The collapsed view waits for cortexkit/common-auth#12. See "Not in this draft".

Summary

  • The sidebar uses the shared SidebarFrame from @cortexkit/common-auth/quota-sidebar and shows option B from Sidebar: adopt the shared CortexKit sidebar layout (design proposal, PR offered) #839: Context, History, Prompt cache, Knowledge, Dreamer, and a Health section that shows only when something is wrong.
  • The snapshot gets the values that the new rows need. MC calculates each value during a pass, or reads it with one indexed query when the panel refreshes. There is no migration (decision 2): the historian per-run data stays in memory for each session.
  • The panel refreshes less often, and render does no reads.

Screenshots

Rendered from the compiled sidebar slot with OpenTUI's testRender, with the OpenCode dark theme colours and fixture values (the values of the #839 mocks).

Expanded Incident (Health in the warning tone)

Changes

Snapshot data

All new SidebarSnapshot fields are optional, so an older RPC server still works with the new view.

Field Source Cost per refresh
historianRun Kept in memory for each session (at most 256 sessions, cleared on session deletion). It records the outcome, the model that produced the published output, the fallback flag, the primary attempts and rejections, and the totals since the last clean run. none
waitingMessages The last value that the compartment trigger calculated. none
proactiveFloor getProactiveCompartmentTriggerPercentage(executeThreshold) none
queuedDropTokens One query. The plan uses idx_pending_ops_session_tag_id and the tags primary key. 1 query
cachedM0MaterializedAt, summariesSinceCache, memoriesSinceCache session_meta, then two counts. The plans use sqlite_autoindex_compartments_1 and idx_memories_project_status_expires. The memory count uses the same workspace visibility rules as m[1]. 2 counts
configReloadFailure The live config reader. none

A historian attempt counts against the model that produced it. A primary attempt counts as rejected when its output fails validation, or when the host answers with a different model. An invalid fallback output does not count against the primary.

OpenCode 1 and OpenCode 2 use the same snapshot builder. In Rust transform mode, historianRun and waitingMessages are missing, because the TypeScript historian does not run.

Refresh

  • A 200 ms debounce on host events, and at most one read each second while a step streams.
  • One read in flight at a time. After a failed read, the panel keeps the last snapshot and waits 30 s.
  • A 2 s poll only while the historian, the dreamer or a recomp runs. This replaces the recomp poll loop.
  • loadSidebarSnapshot has a new opt-in throwOnFailure, so that scheduled reads can see a failure. Other callers do not change.
  • The OpenCode 2 text fallback sidebar read data during render. It now uses the same scheduler.

View

  • The Health wording follows the shared CortexKit sidebar standard: stat rows in the warning or error tone, no glyphs, and at most one muted hint row, /ctx-status shows details.
  • The context gauge uses the warning tone at the session's execute threshold and the error tone at 85%.
  • An absent value shows —. An unknown usage shows no reading, not 100%.
  • Removed: the token legend, Hygiene, the dreamer backlog row for each task, the second dreamer progress line, and Stats · Total tokens.
  • The existing section preferences still apply: historian to History, status to Prompt cache and the notes rows, memory to Memories, dreamer to Dreamer. The preferences file format does not change.
  • With compaction off, Context shows the native window pressure, and History, Prompt cache and the historian Health rows are not shown.

Build (decision 3)

  • scripts/build-tui.ts bundles @cortexkit/common-auth/quota-sidebar with the Solid transform bound to the host runtime ids, plus a raw variant. This is the same method that anthropic-auth uses. The change is +69/−5 lines, and the two bundles are 34,365 B (raw) and 34,631 B (host). I do not think this is heavy.
  • One risk: the committed bundle depends on the Bun version. Bun 1.4.0 renames one shadowed local (hours to hours2), and Bun 1.4.4 does not. CI uses bun-version: latest, which is 1.4.4 now, so check:tui-compiled passes. A later Bun release can change the output for each contributor. A pinned Bun version in CI would prevent this.

Not in this draft

Tests

  • New tests: the historian attribution cases (host switch, repair, explicit fallback, invalid fallback output, unknown producer), the snapshot fields with their query plans, the refresh scheduler, the OpenCode 2 fallback without render reads, and 12 render cases of the compiled slot (healthy, incident, older snapshot, compaction off, preferences, unknown usage, recomp row, errors, gauge tones, theme change, raw frame bundle, badge contrast).
  • Full plugin suite on Bun 1.4: 9,800 pass, 16 fail, 103 skip, before the last commit. One failure came from this branch (the Windows console flag on the render test helper); the last commit corrects it. The other 15 do not come from this branch:
    • 5: npm 12 returns an object from npm pack --json, and scripts/tui-pack-graph.test.ts and the 4 packed review-bundle tests read [0].files. tui-pack-graph fails the same way without this branch.
    • 5: the unpacked review-bundle tests need a built dist/. They pass after bun run build in packages/plugin and packages/pi-plugin.
    • 5: four timeouts and one helper start under CPU load. Each passes when its file runs alone.
  • After the rebase on 064262aa1: typecheck passes, build:tui on Bun 1.4.4 writes no file, check:tui-compiled passes, and the focused TUI, v2 TUI, snapshot, historian, event-handler and event-loop tests pass (315 of 315).

Harness coverage (required)

For each entry select: covered / not applicable — surface does not exist there / NOT covered.

  • OpenCode 1: covered. Shared snapshot builder and TUI slot.
  • OpenCode 2: covered. Same snapshot builder; the text fallback uses the same scheduler.
  • Pi: not applicable. Pi has no sidebar.
  • OMP: not applicable. OMP has no sidebar.
  • Rust module: not applicable. The sidebar is TypeScript; in Rust transform mode the historian fields are missing.

@iceteaSA
iceteaSA force-pushed the feat/sidebar-option-b branch from 331693b to 14ff34d Compare November 6, 2026 16:40
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​cortexkit/​common-auth@​0.38.0871007996100

View full report

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant