on main help sign in
fix(ui): cap context percentage at 100%, add landing state to FullHelp

- formatTokensAndCost: cap percentage at 100 when tokens exceed context window, preventing confusing displays like '150%' - renderHeaderDetails: same cap in the compact header percentage - FullHelp: add uiLanding case with useful keybindings (commands, models, sessions, yolo, editor binds, attachment binds) instead of showing nothing when in landing state with a session

commit8add8b4e93d046716622116f6b17eb4c1b9f2c61 authoriko <mail@iko.soy> dateWed 8 Jul 2026, 21:13 (3 months ago) parent9cc1cc3
3 files changed+38
internal/ui/common/elements.go+3 internal/ui/model/header.go+3 internal/ui/model/ui.go+32
internal/ui/common/elements.go+3
@@ -115,6 +115,9 @@ func formatTokensAndCost(t *styles.Styles, tokens, contextWindow int64, cost flo
115115 if contextWindow > 0 {
116116 percentage = (float64(tokens) / float64(contextWindow)) * 100
117117 }
118+ if percentage > 100 {
119+ percentage = 100
120+ }
118121
119122 formattedCost := t.ModelInfo.Cost.Render(fmt.Sprintf("$%.2f", cost))
120123
internal/ui/model/header.go+3
@@ -228,6 +228,9 @@ func renderHeaderDetails(
228228 model := com.Config().GetModelByType(agentCfg.Model)
229229 if model != nil && model.ContextWindow > 0 {
230230 percentage := (float64(session.CompletionTokens+session.PromptTokens) / float64(model.ContextWindow)) * 100
231+ if percentage > 100 {
232+ percentage = 100
233+ }
231234 percentageText := fmt.Sprintf("%d%%", int(percentage))
232235 if session.EstimatedUsage {
233236 percentageText = "~" + percentageText
internal/ui/model/ui.go+32
@@ -2878,6 +2878,38 @@ func (m *UI) FullHelp() [][]key.Binding {
28782878 binds = append(binds, []key.Binding{k.Chat.PillLeft})
28792879 }
28802880 }
2881+ case uiLanding:
2882+ binds = append(
2883+ binds,
2884+ []key.Binding{
2885+ commands,
2886+ k.Models,
2887+ k.Sessions,
2888+ k.ToggleYolo,
2889+ },
2890+ )
2891+ editorBinds := []key.Binding{
2892+ k.Editor.Newline,
2893+ k.Editor.MentionFile,
2894+ k.Editor.OpenEditor,
2895+ }
2896+ if m.currentModelSupportsImages() {
2897+ editorBinds = append(editorBinds, k.Editor.AddImage, k.Editor.PasteImage)
2898+ }
2899+ if m.textarea.Value() == "" {
2900+ editorBinds = append(editorBinds, k.Editor.ShellCommand)
2901+ }
2902+ binds = append(binds, editorBinds)
2903+ if hasAttachments {
2904+ binds = append(
2905+ binds,
2906+ []key.Binding{
2907+ k.Editor.AttachmentDeleteMode,
2908+ k.Editor.DeleteAllAttachments,
2909+ k.Editor.Escape,
2910+ },
2911+ )
2912+ }
28812913 default:
28822914 if m.session == nil {
28832915 // no session selected