Skip to content

feat: add context window command and breakdown rendering#122

Merged
yashdev9274 merged 2 commits into
mainfrom
supercode-cli
Jun 26, 2026
Merged

feat: add context window command and breakdown rendering#122
yashdev9274 merged 2 commits into
mainfrom
supercode-cli

Conversation

@yashdev9274

@yashdev9274 yashdev9274 commented Jun 26, 2026

Copy link
Copy Markdown
Owner
  • Introduced a new slash command /context to display context window usage and breakdown.
  • Implemented renderContextBreakdown function to format and output context information in the CLI.
  • Updated command handling to include the new context command and adjusted the slash command list accordingly.
  • Enhanced chat loop to track session usage and elapsed time for better context management.

Summary by CodeRabbit

  • New Features
    • Added a new CLI /context command to display session metadata and token/context usage.
    • Updated the website Compare experience (new feature set and updated “Get started free” CTA).
  • Bug Fixes
    • Improved CLI chat loop tracking and ensured the slash-command list layout accounts for the new command.
  • Style
    • Refreshed Compare page UI (table structure, badges, cards, score bars) and updated navbar/footer Compare links.

- Introduced a new slash command `/context` to display context window usage and breakdown.
- Implemented `renderContextBreakdown` function to format and output context information in the CLI.
- Updated command handling to include the new context command and adjusted the slash command list accordingly.
- Enhanced chat loop to track session usage and elapsed time for better context management.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
supercli Ready Ready Preview, Comment Jun 26, 2026 11:49am
supercli-client Ready Ready Preview, Comment Jun 26, 2026 11:49am
supercli-docs Ready Ready Preview, Comment Jun 26, 2026 11:49am

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e50fd265-8e60-4fe6-8fd4-af9767d45fbe

📥 Commits

Reviewing files that changed from the base of the PR and between d14862a and 5b2ef8c.

📒 Files selected for processing (1)
  • apps/supercode-cli/server/package.json
✅ Files skipped from review due to trivial changes (1)
  • apps/supercode-cli/server/package.json

Walkthrough

Adds a /context CLI slash command that renders chat context usage, refreshes the web compare page and navigation links, and bumps the server package version.

Changes

CLI context command

Layer / File(s) Summary
Slash command contract
apps/supercode-cli/server/src/cli/commands/slashCommands/index.ts
Extends the slash-command result union and registry with the context variant and /context entry.
Context window renderer
apps/supercode-cli/server/src/cli/commands/slashCommands/context-window.ts
Adds the context-window state shape, formatting helpers, and terminal breakdown renderer.
Chat loop wiring
apps/supercode-cli/server/src/cli/ai/chat/chat.ts
Imports the renderer, adds /context to the chat slash list, tracks session usage and elapsed time, and renders the breakdown on the context result.

Compare page refresh

Layer / File(s) Summary
Comparison data model
apps/web/app/(pages)/compare/page.tsx
Reworks the tool list, feature schema, comparison matrices, score bars, and score values for the new tool set.
Hero and stats
apps/web/app/(pages)/compare/page.tsx
Updates the stat cards, hero badge and description, section intro text, and pricing-cell styling.
Feature tables
apps/web/app/(pages)/compare/page.tsx
Restyles the comparison table headers, dividers, rows, and at-a-glance score rendering around the new tool columns.
CTA and compare links
apps/web/app/(pages)/compare/page.tsx, apps/web/components/homepage/navbar.tsx, apps/web/components/homepage/footer.tsx
Updates the difference card content, CTA block, navbar compare entry, and footer compare links.

Server package version bump

Layer / File(s) Summary
Package version
apps/supercode-cli/server/package.json
Changes the server package version from 0.1.14 to 0.1.15.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant chatLoop
  participant slashCommandsIndex
  participant renderContextBreakdown
  participant stdout

  User->>chatLoop: "/context"
  chatLoop->>slashCommandsIndex: resolve result type
  slashCommandsIndex-->>chatLoop: { type: "context" }
  chatLoop->>renderContextBreakdown: pass model, context window, usage, elapsed
  renderContextBreakdown->>stdout: write framed breakdown
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

A rabbit tapped the terminal light,
And /context bloomed in framed delight.
The compare page hopped into view,
With links and scores and colors new.
I wiggle my nose—this patch feels bright! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a context window slash command and its breakdown renderer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch supercode-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/supercode-cli/server/src/cli/commands/slashCommands/context-window.ts`:
- Around line 223-232: The Context Window frame width is being calculated from
an ANSI-colored title string, which makes the top border misalign with the
bottom border. Update the width logic in context-window.ts to measure the
visible text for the title using stripAnsi (as done in chatStatusBar in tui.ts),
then compute topFill from that visible length so the border spans the full
terminal width. While fixing this, remove the redundant extra
chalk.hex(theme.green) wrapping around titlePart/top so the title is only
colored once, and confirm stripAnsi is available from the shared TUI utilities
before importing it.

In `@apps/web/app/`(pages)/compare/page.tsx:
- Around line 197-198: The page is showing two different Supercode versions, so
update the version label used in the compare page to match the footer
component’s displayed version. Locate the hardcoded version text in the compare
page and make it consistent with the value rendered by the footer, or better
yet, source both from the same shared version constant so the header badge and
footer cannot drift apart.
- Around line 136-142: The hardcoded score values in the compare page are out of
sync with the feature matrix, making the “At a glance” section inconsistent with
the table. Update the scores used in the `scores` array in `compare/page.tsx` so
`OpenCode` and `Cursor` match the totals from `rows`, or derive the totals
directly from `rows` inside the compare page logic to prevent future drift.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b1d4a327-ab5b-48a3-ac09-2987b23c4170

📥 Commits

Reviewing files that changed from the base of the PR and between c61b8c0 and d14862a.

📒 Files selected for processing (6)
  • apps/supercode-cli/server/src/cli/ai/chat/chat.ts
  • apps/supercode-cli/server/src/cli/commands/slashCommands/context-window.ts
  • apps/supercode-cli/server/src/cli/commands/slashCommands/index.ts
  • apps/web/app/(pages)/compare/page.tsx
  • apps/web/components/homepage/footer.tsx
  • apps/web/components/homepage/navbar.tsx

Comment on lines +223 to +232
const title = `${dim("┏━━")} ${chalk.hex(theme.green).bold("Context Window")} ${dim("━━")}`
const titlePart = chalk.hex(theme.green)(`${title}`)
const titleVisible = title.length
const topFill = Math.max(0, w - titleVisible - 1)

// top: full top border line
const top = chalk.hex(theme.green)(titlePart) + chalk.hex(theme.greenDim)("━".repeat(topFill)) + chalk.hex(theme.green)("┓")

// bottom: full bottom border line (just fill + corner)
const bottom = chalk.hex(theme.greenDim)("━".repeat(w - 2)) + chalk.hex(theme.green)("┛")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Top border width is computed from ANSI-coded string length, so the frame collapses/misaligns.

title already contains chalk hex escape sequences, so titleVisible = title.length (Line 225) counts the invisible escape bytes, not the rendered glyphs. With a typical 80‑col terminal titleVisible exceeds w, driving topFill to 0. The result: the top border stops right after the title while the bottom border (Line 232) spans the full width, so the two never line up.

The existing TUI helper handles this by measuring with stripAnsi (see chatStatusBar in tui.ts). Apply the same here. Also note titlePart/top wrap the already-colored title in chalk.hex(theme.green) two more times (Lines 224, 229) — redundant.

🔧 Suggested fix using visible length
-    const title = `${dim("┏━━")} ${chalk.hex(theme.green).bold("Context Window")} ${dim("━━")}`
-    const titlePart = chalk.hex(theme.green)(`${title}`)
-    const titleVisible = title.length
-    const topFill = Math.max(0, w - titleVisible - 1)
-
-    // top: full top border line
-    const top = chalk.hex(theme.green)(titlePart) + chalk.hex(theme.greenDim)("━".repeat(topFill)) + chalk.hex(theme.green)("┓")
+    const title = `${dim("┏━━")} ${chalk.hex(theme.green).bold("Context Window")} ${dim("━━")}`
+    const titleVisible = stripAnsi(title).length
+    const topFill = Math.max(0, w - titleVisible - 1)
+
+    // top: full top border line
+    const top = title + chalk.hex(theme.greenDim)("━".repeat(topFill)) + chalk.hex(theme.green)("┓")

This requires importing stripAnsi (already used elsewhere in tui.ts).

Please confirm stripAnsi is exported/available from the shared TUI utils before wiring the import.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const title = `${dim("┏━━")} ${chalk.hex(theme.green).bold("Context Window")} ${dim("━━")}`
const titlePart = chalk.hex(theme.green)(`${title}`)
const titleVisible = title.length
const topFill = Math.max(0, w - titleVisible - 1)
// top: full top border line
const top = chalk.hex(theme.green)(titlePart) + chalk.hex(theme.greenDim)("━".repeat(topFill)) + chalk.hex(theme.green)("┓")
// bottom: full bottom border line (just fill + corner)
const bottom = chalk.hex(theme.greenDim)("━".repeat(w - 2)) + chalk.hex(theme.green)("┛")
const title = `${dim("┏━━")} ${chalk.hex(theme.green).bold("Context Window")} ${dim("━━")}`
const titleVisible = stripAnsi(title).length
const topFill = Math.max(0, w - titleVisible - 1)
// top: full top border line
const top = title + chalk.hex(theme.greenDim)("━".repeat(topFill)) + chalk.hex(theme.green)("┓")
// bottom: full bottom border line (just fill + corner)
const bottom = chalk.hex(theme.greenDim)("━".repeat(w - 2)) + chalk.hex(theme.green)("┛")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/cli/commands/slashCommands/context-window.ts`
around lines 223 - 232, The Context Window frame width is being calculated from
an ANSI-colored title string, which makes the top border misalign with the
bottom border. Update the width logic in context-window.ts to measure the
visible text for the title using stripAnsi (as done in chatStatusBar in tui.ts),
then compute topFill from that visible length so the border spans the full
terminal width. While fixing this, remove the redundant extra
chalk.hex(theme.green) wrapping around titlePart/top so the title is only
colored once, and confirm stripAnsi is available from the shared TUI utilities
before importing it.

Comment on lines 136 to +142
const scores = [
{ label: "Supercode", value: 12 },
{ label: "OpenCode", value: 5 },
{ label: "Claude Code", value: 3 },
{ label: "Hermes Agent", value: 5 },
{ label: "Warp", value: 3 },
{ label: "Cursor", value: 6 },
{ label: "Supercode", value: 11 },
{ label: "OpenCode", value: 9 },
{ label: "FreeBuff", value: 8 },
{ label: "CommandCode", value: 7 },
{ label: "Claude Code", value: 5 },
{ label: "Cursor", value: 5 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fix the score totals before shipping this comparison.

These hardcoded values no longer match the feature matrix above: OpenCode currently totals 8 enabled features, and Cursor totals 4, not 9 and 5. That makes the “At a glance” section factually inconsistent with the table on the same page. Please either correct the numbers or derive them from rows so they can’t drift again.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/app/`(pages)/compare/page.tsx around lines 136 - 142, The hardcoded
score values in the compare page are out of sync with the feature matrix, making
the “At a glance” section inconsistent with the table. Update the scores used in
the `scores` array in `compare/page.tsx` so `OpenCode` and `Cursor` match the
totals from `rows`, or derive the totals directly from `rows` inside the compare
page logic to prevent future drift.

Comment on lines +197 to +198
<span className="inline-block text-[12px] font-mono uppercase tracking-[0.25em] text-primary mb-6">
$ Supercode v0.1.14

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the displayed version consistent across the page.

This badge now says v0.1.14, but the supplied footer component on the same page still renders v0.1.7. Users will see two different versions at once.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/app/`(pages)/compare/page.tsx around lines 197 - 198, The page is
showing two different Supercode versions, so update the version label used in
the compare page to match the footer component’s displayed version. Locate the
hardcoded version text in the compare page and make it consistent with the value
rendered by the footer, or better yet, source both from the same shared version
constant so the header badge and footer cannot drift apart.

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