Skip to content

feat(tui): open the /cost dialog when clicking the sidebar cost reading#3754

Merged
dgageot merged 2 commits into
docker:mainfrom
dgageot:feat/sidebar-cost-click
Jul 20, 2026
Merged

feat(tui): open the /cost dialog when clicking the sidebar cost reading#3754
dgageot merged 2 commits into
docker:mainfrom
dgageot:feat/sidebar-cost-click

Conversation

@dgageot

@dgageot dgageot commented Jul 20, 2026

Copy link
Copy Markdown
Member

The sidebar already displays token usage and estimated cost, but there was no way to click into the detail view — users had to know about the /cost command to see the breakdown. This makes the cost reading interactive, consistent with how other sidebar elements behave.

Clicking the token usage/cost reading in the sidebar now opens the /cost dialog, the same dialog triggered by typing /cost in the input. A new ClickUsage hit-test result was added to the sidebar's hit-testing logic. The vertical Token Usage section records its line range while rendering, and the collapsed band correctly hit-tests the usage reading in both layouts: when it shares the working-directory row (right-aligned) and when it occupies its own row. The chat page maps the new TargetSidebarUsage to ShowCostDialogMsg on left-click.

A follow-up fix ensures clicks on the sidebar scrollbar column and gap are never swallowed by the content click zones (usage, agents, title), so scrollbar-driven scrolling continues to work correctly. The fix also refreshes stale doc comments on ClickResult variants. New tests cover vertical mode, collapsed shared-line, collapsed own-line, hidden-usage, and the scrollbar regression.

@dgageot
dgageot requested a review from a team as a code owner July 20, 2026 11:40

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assessment: 🟢 APPROVE

The PR introduces ClickUsage hit-testing to the sidebar so clicking the token usage/cost reading opens the /cost dialog. The implementation is correct and the new tests provide good coverage across vertical mode, collapsed shared-line, collapsed own-line, hidden-usage, and the scrollbar regression.

The drafter found no high- or medium-severity issues. All observations were low-severity edge cases with negligible practical impact:

  • appendSection correctly sets usageZoneStart to the index after gap lines (not including them), so gap-line clicks are not falsely attributed to ClickUsage.
  • The scrollbar exclusion guard (cachedNeedsScrollbar && adjustedX >= contentWidth) correctly relies on a prior View() call, which always precedes click processing in practice.
  • The collapsed shared-line usage check has no explicit right-bound column guard, but out-of-bounds clicks don't reach the sidebar handler in normal operation.

No changes requested.

@aheritier aheritier added the status/ready-for-review Ready for implementation, design review, or final review label Jul 20, 2026
@dgageot
dgageot merged commit cb46d6d into docker:main Jul 20, 2026
10 of 11 checks passed
aheritier added a commit that referenced this pull request Jul 21, 2026
…3754

Clicking the token-usage / cost reading in the sidebar now opens the
/cost dialog directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/ready-for-review Ready for implementation, design review, or final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants