Skip to content

Fix: Toggle agentop's spend drawer with $, and leave esc to the pane - #1356

Merged
huang195 merged 2 commits into
rossoctl:mainfrom
huang195:feat/agentop-cost-toggle
Oct 10, 2026
Merged

huang195 merged 2 commits into
rossoctl:mainfrom
huang195:feat/agentop-cost-toggle

Conversation

@huang195

@huang195 huang195 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

$ now opens and closes agentop's spend drawer. Esc no longer closes it.

The problem: the drawer handled Esc before the pane did. With the drawer open, the first Esc closed the drawer and the second one left the pane. The drawer's hint line also said esc closes, so nothing on screen said that $ already closed it.

What changed

  • Esc is no longer handled by the drawer (tui/keys.go). It always reaches the pane, so leaving a pane takes one press. The drawer stays open, as it already did when you moved between panes.
  • The hint line says [$] closes instead of esc closes. It's the same width, so the layout doesn't move.
  • The ? overlay says the drawer is "opened and closed with $" and no longer lists Esc. There is no separate $ close row, because TestGlobalKeys_AdvertiseNoKeyTwice forbids the overlay listing one key for two things, and a toggle is one thing.
  • The README example and keybinding table are updated to match.

Tests

  • "esc closes it where it does show" is replaced by a test that Esc on the Events pane backs out to Sessions in one press, with the drawer still open there. I put the old Esc handling back temporarily and checked that this test fails against it.
  • The test that closing the drawer disowns its poll chain now covers $ only, since that is the only way to close it.
  • gofmt and go vet are clean in cmd/agentop, and go test ./... passes.

Deferred from review

  • cmd/agentop/tui/help_overlay.go:155: helpGlobalGroups's doc says the drawer block on a refused pane would be "three keys of pure noise"; with the $ · esc row gone it is two (nit).
  • scripts/readme-demo/capture_test.go:87: nothing asserts the drawer actually closed before Usage, so a regression shows up only downstream as the missed tool manifest and the stale SVG; assert the usage screen lacks WHERE IT WENT (nit).

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Summary by CodeRabbit

  • Updates
    • The spend drawer now opens and closes with $. When the drawer is open, Esc no longer closes it and continues to work for pane navigation.
    • Updated the spend-drawer help text and hints to show $ as the close key, keeping the on-screen guidance consistent with the keyboard behavior.

The drawer took esc before the pane did, so with it open, leaving a pane
took two presses. Its hint line also advertised esc as the way to close
it, so `$` closing it went unnoticed. `$` is now the only close: esc
always reaches the pane, and the hint line and the ? overlay say `$`.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a59f6038-f4d0-4195-9440-60e11c6ffd48

📥 Commits

Reviewing files that changed from the base of the PR and between 91faa68 and df105a2.


📒 Files selected for processing (5)
  • cmd/agentop/README.md
  • cmd/agentop/tui/help_overlay.go
  • cmd/agentop/tui/keys.go
  • cmd/agentop/tui/spend_drawer.go
  • cmd/agentop/tui/spend_drawer_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The spend drawer now closes with $ instead of Escape. Escape continues to the pane’s back-navigation handling, and drawer hints, help text, tests, and README text reflect the updated controls.

Changes

Spend drawer key handling

Layer / File(s) Summary
Toggle and verify spend drawer controls
cmd/agentop/tui/keys.go, cmd/agentop/tui/spend_drawer.go, cmd/agentop/tui/spend_drawer_test.go, cmd/agentop/tui/help_overlay.go, cmd/agentop/README.md
The drawer no longer handles Escape as a close control; Escape reaches pane navigation. $ closes the drawer. Tests check that Escape leaves the drawer open and that $ closes it, clears its snapshot, and advances reqSeq. Help text and hints identify $ as the close control. The README example documents Escape as backing out of the pane; its keybinding-table entry is unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: esnible


Merge Risk: ⚪ Minimal · up to df105

The updated controls and documented behavior are consistent; no merge-blocking issue is identified.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. (1 skipped: 1 …
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the main change: $ toggles the spend drawer, while Esc remains available to the pane.


✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Fixes review: the README demo storyboard and its capture test closed the drawer with esc, and the committed SVG showed "esc closes"
Files:
- docs/assets/cortex-demo.svg
- scripts/readme-demo/capture_test.go
- scripts/readme-demo/demo.yaml

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>

@esnible esnible left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The change is correct and well-tested. Esc no longer goes to the drawer. The poll-chain invalidation is untouched on the $ path, which is now the only close. The new Events→Sessions subtest checks both that Esc reaches the pane and that the drawer survives. I also checked the overlay comment's claim: a {"$", "close"} row would trip TestGlobalKeys_AdvertiseNoKeyTwice, since $ is already a jump target. Merged with current main (after #1352), go vet and go test ./tui/ pass in cmd/agentop. scripts/readme-demo's asset staleness check also passes, so the one-line SVG change still matches after main's SVG edits.

One stale reference is outside the diff, so it can't go inline. cmd/agentop/tui/app.go:1783-1784 (the spendDrawerTickMsg case) still says "see the esc handler, which leaves the flag alone precisely so returning finds the drawer as the operator left it". That handler is the one this PR deletes. The same sentence in spend_drawer_test.go:1387 was updated to "only $ clears it, so returning finds the drawer as the operator left it", and the same rewording fits here. (nit)

Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (agentop TUI, readme-demo), Docs (agentop README), YAML (demo storyboard), generated SVG
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes (both use Assisted-By)
CI status: passing (Spellcheck skipped)

Comment thread cmd/agentop/tui/keys.go
// reaching the pane, so with the drawer open, leaving a pane took two presses, and which
// press did what depended on whether the drawer was open. The drawer is not modal (it
// stays open alongside the table, and `a`/`w` are the only keys it takes), so esc keeps
// its one meaning on every pane: go back.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion (not blocking): In picker mode, Esc on Sessions goes back to the Pods picker and tears down the port-forward and SSE stream. The old Esc-closes-drawer path also protected that: someone who pressed Esc to dismiss the drawer lost nothing. Now that press costs the connection. When they pick the pod again the drawer is still open, because expanded survives.

The back-out block's own rule (keys.go:459-460) is that "a key-opened surface returning to its caller must never cost the connection", and the drawer is opened by a key. The [$] closes hint probably makes this acceptable. If so, it's worth saying here that Sessions in picker mode is the one place this choice has a cost.

@huang195
huang195 merged commit edd65b9 into rossoctl:main Oct 10, 2026
29 checks passed
@huang195
huang195 deleted the feat/agentop-cost-toggle branch October 10, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants