on main help sign in
fix(ui): cap context percentage at 100%, add landing state to FullHelp
8add8b4iko
internal/ui/common/elements.go+3
@@ -115,6 +115,9 @@ func formatTokensAndCost(t *styles.Styles, tokens, contextWindow int64, cost flo
115 if contextWindow > 0 {
115 if contextWindow > 0 {
116 percentage = (float64(tokens) / float64(contextWindow)) * 100
116 percentage = (float64(tokens) / float64(contextWindow)) * 100
117 }
117 }
118+ if percentage > 100 {
119+ percentage = 100
120+ }
118
121
119 formattedCost := t.ModelInfo.Cost.Render(fmt.Sprintf("$%.2f", cost))
122 formattedCost := t.ModelInfo.Cost.Render(fmt.Sprintf("$%.2f", cost))
120
123
internal/ui/model/header.go+3
@@ -228,6 +228,9 @@ func renderHeaderDetails(
228 model := com.Config().GetModelByType(agentCfg.Model)
228 model := com.Config().GetModelByType(agentCfg.Model)
229 if model != nil && model.ContextWindow > 0 {
229 if model != nil && model.ContextWindow > 0 {
230 percentage := (float64(session.CompletionTokens+session.PromptTokens) / float64(model.ContextWindow)) * 100
230 percentage := (float64(session.CompletionTokens+session.PromptTokens) / float64(model.ContextWindow)) * 100
231+ if percentage > 100 {
232+ percentage = 100
233+ }
231 percentageText := fmt.Sprintf("%d%%", int(percentage))
234 percentageText := fmt.Sprintf("%d%%", int(percentage))
232 if session.EstimatedUsage {
235 if session.EstimatedUsage {
233 percentageText = "~" + percentageText
236 percentageText = "~" + percentageText
internal/ui/model/ui.go+32
@@ -2878,6 +2878,38 @@ func (m *UI) FullHelp() [][]key.Binding {
2878 binds = append(binds, []key.Binding{k.Chat.PillLeft})
2878 binds = append(binds, []key.Binding{k.Chat.PillLeft})
2879 }
2879 }
2880 }
2880 }
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+ }
2881 default:
2913 default:
2882 if m.session == nil {
2914 if m.session == nil {
2883 // no session selected
2915 // no session selected