feat(tui): open /context or /cost from the sidebar token-usage reading#3813
Open
aheritier wants to merge 4 commits into
Open
feat(tui): open /context or /cost from the sidebar token-usage reading#3813aheritier wants to merge 4 commits into
aheritier wants to merge 4 commits into
Conversation
…egment width The Token Usage section's click zone used to span the whole tab, including the "Token Usage" title line, so clicking the title opened the cost dialog just like clicking the reading below it. Replace the half-open usageZoneStart/usageZoneEnd range with usageReadingLine (the exact reading-line index) and usageSectionEnd (covering any budget lines below it), excluding the title line from the click zone. Also record usageContextSegWidth, the rendered width of the reading line's context segment (glyph, token count, and context %/compacting marker) — unused for now, but needed by the next commit to split the reading line's click target between the context and cost dialogs.
Split the Token Usage reading line's click target: an offset within usageContextSegWidth (the glyph, token count, and context %/compacting marker) now reports the new ClickUsageContext, while the rest of the line (cost figure, ⚠ capped marker, sub-session count) keeps reporting ClickUsage. Budget lines below the reading stay ClickUsage. Apply the same offset split in both the vertical branch and the collapsed band's shared-line/own-line branches of HandleClickType.
Add TargetSidebarUsageContext to the hit-test enum, map sidebar.ClickUsageContext to it, and open ShowContextDialogMsg on a left click, mirroring the existing ClickUsage -> ShowCostDialogMsg routing for the cost segment.
Update the sidebar usage-click description in the TUI feature doc and add a changelog entry for the new /context click target.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Clicking the sidebar Token Usage reading used to open the
/costdialog no matter where you clicked. This splits the click by segment so each part opens the dialog it describes:(NN%)·(compacting…)→/contextdialog$…·⚠ capped· sub-session count →/costdialog/costWorks in both the vertical sidebar and the collapsed top band.
How
ClickUsageContextclick result routed to a newTargetSidebarUsageContext, split from the existing cost path by the rendered X-width of the context segment (usageContextSegWidth, measured withlipgloss.Widthso it's ANSI/terminal-cell aware).Commits
feat(tui): make sidebar usage title non-clickable and track context-segment widthfeat(tui): add ClickUsageContext and segment-aware usage click detectionfeat(tui): route sidebar context clicks to the context dialogdocs(tui): document the context/cost click splitStacked on #3811
Depends on
feat/context-compaction-limit-visibility(#3811) for the⚠ capped/agentCompactionModelrendering the segment split keys off. This PR targets that branch and will retarget tomainonce #3811 merges.Validation
go build ./...— cleango test ./pkg/tui/components/sidebar/... ./pkg/tui/page/chat/...— greentask lint— 0 issuesNote
The onboarding tour's cost step (matches
ShowCostDialogMsg) no longer completes via a context-segment click — behavior-neutral for cost-segment clicks.Plan:
usage-click-split-context-cost