chore: scrub stray "pi" references from source comments
Five leftover comments in internal/tui/ mentioned "pi" / "pi's" / "pi-style" / "pi's cli-highlight" / "pi's extToLang" from the old development era. Rewritten to describe the behaviour on its own terms with no external reference. Also renamed the two tui helpers piFormatTokens -> formatTokens and piContextUsage -> contextUsage so the source grep stays clean. No behaviour change, all tests pass.
- commit
- 961f99da9e0feea6e6edc3336ef2c01f8d94aaba
- author
- patriceckhart · · 2026-04-19 15:06 UTC
- parent
- 99c9ba8
- signature
- unsigned
- refs
- tag: v0.0.36
2 files · +21 -21
M internal/tui/highlight.go +4 -4
| @@ -144,8 +144,8 @@ var ( | |||
| 144 | 144 | // "fruity" style if the builder fails for any reason. | |
| 145 | 145 | func buildZotStyle() *chroma.Style { | |
| 146 | 146 | builder := styles.Get("monokai").Builder() | |
| 147 | - | // Override the most visible tokens with explicit colors that match | |
| 148 | - | // pi's cli-highlight look on a dark terminal. | |
| 147 | + | // Override the most visible tokens with explicit colors that | |
| 148 | + | // read well on a dark terminal. | |
| 149 | 149 | builder.Add(chroma.Keyword, "#81a1c1 bold") // imports, funcs, control flow | |
| 150 | 150 | builder.Add(chroma.KeywordConstant, "#81a1c1") // true, false, null | |
| 151 | 151 | builder.Add(chroma.KeywordDeclaration, "#81a1c1") // const, let, var, type | |
| @@ -173,8 +173,8 @@ func buildZotStyle() *chroma.Style { | |||
| 173 | 173 | return s | |
| 174 | 174 | } | |
| 175 | 175 | ||
| 176 | - | // extLang mirrors pi's extToLang. Only extensions that chroma supports | |
| 177 | - | // are included. | |
| 176 | + | // extLang maps file extensions to chroma lexer names. Only | |
| 177 | + | // extensions that chroma supports are included. | |
| 178 | 178 | var extLang = map[string]string{ | |
| 179 | 179 | "ts": "typescript", | |
| 180 | 180 | "tsx": "tsx", | |
| @@ -144,8 +144,8 @@ var ( | |||||
| 144 | // "fruity" style if the builder fails for any reason. | 144 | // "fruity" style if the builder fails for any reason. | ||
| 145 | func buildZotStyle() *chroma.Style { | 145 | func buildZotStyle() *chroma.Style { | ||
| 146 | builder := styles.Get("monokai").Builder() | 146 | builder := styles.Get("monokai").Builder() | ||
| 147 | - | // Override the most visible tokens with explicit colors that match | 147 | + | // Override the most visible tokens with explicit colors that |
| 148 | - | // pi's cli-highlight look on a dark terminal. | 148 | + | // read well on a dark terminal. |
| 149 | builder.Add(chroma.Keyword, "#81a1c1 bold") // imports, funcs, control flow | 149 | builder.Add(chroma.Keyword, "#81a1c1 bold") // imports, funcs, control flow | ||
| 150 | builder.Add(chroma.KeywordConstant, "#81a1c1") // true, false, null | 150 | builder.Add(chroma.KeywordConstant, "#81a1c1") // true, false, null | ||
| 151 | builder.Add(chroma.KeywordDeclaration, "#81a1c1") // const, let, var, type | 151 | builder.Add(chroma.KeywordDeclaration, "#81a1c1") // const, let, var, type | ||
| @@ -173,8 +173,8 @@ func buildZotStyle() *chroma.Style { | |||||
| 173 | return s | 173 | return s | ||
| 174 | } | 174 | } | ||
| 175 | 175 | ||||
| 176 | - | // extLang mirrors pi's extToLang. Only extensions that chroma supports | 176 | + | // extLang maps file extensions to chroma lexer names. Only |
| 177 | - | // are included. | 177 | + | // extensions that chroma supports are included. |
| 178 | var extLang = map[string]string{ | 178 | var extLang = map[string]string{ | ||
| 179 | "ts": "typescript", | 179 | "ts": "typescript", | ||
| 180 | "tsx": "tsx", | 180 | "tsx": "tsx", | ||
M internal/tui/view.go +17 -17
| @@ -772,7 +772,7 @@ func truncateLines(s string, n int) string { | |||
| 772 | 772 | } | |
| 773 | 773 | ||
| 774 | 774 | // StatusBarParams groups the many bits of state the status bar needs. | |
| 775 | - | // Grew from a flat argument list once we started matching pi's format. | |
| 775 | + | // Grew from a flat argument list once we settled on the layout. | |
| 776 | 776 | type StatusBarParams struct { | |
| 777 | 777 | Theme Theme | |
| 778 | 778 | Provider string | |
| @@ -786,8 +786,8 @@ type StatusBarParams struct { | |||
| 786 | 786 | Usage provider.Usage | |
| 787 | 787 | // Subscription is true when the credential is an OAuth token (claude | |
| 788 | 788 | // pro/max, chatgpt plus/pro) rather than a paid api key. We still | |
| 789 | - | // compute a cost for visibility, but pi-style we append "(sub)" so | |
| 790 | - | // the user knows no money actually moved. | |
| 789 | + | // compute a cost for visibility and append "(sub)" so the user | |
| 790 | + | // knows no real money moved. | |
| 791 | 791 | Subscription bool | |
| 792 | 792 | ||
| 793 | 793 | // Last turn's input+cache tokens (approximates current live context). | |
| @@ -820,24 +820,24 @@ type StatusBarParams struct { | |||
| 820 | 820 | func StatusBar(p StatusBarParams) []string { | |
| 821 | 821 | th := p.Theme | |
| 822 | 822 | ||
| 823 | - | // Token stats: only include each segment when non-zero (pi's | |
| 824 | - | // behavior). Keeps the bar compact on brand-new sessions. | |
| 823 | + | // Token stats: only include each segment when non-zero. Keeps | |
| 824 | + | // the bar compact on brand-new sessions. | |
| 825 | 825 | var stats []string | |
| 826 | 826 | if p.Usage.InputTokens > 0 { | |
| 827 | - | stats = append(stats, fmt.Sprintf("↑%s", piFormatTokens(p.Usage.InputTokens))) | |
| 827 | + | stats = append(stats, fmt.Sprintf("↑%s", formatTokens(p.Usage.InputTokens))) | |
| 828 | 828 | } | |
| 829 | 829 | if p.Usage.OutputTokens > 0 { | |
| 830 | - | stats = append(stats, fmt.Sprintf("↓%s", piFormatTokens(p.Usage.OutputTokens))) | |
| 830 | + | stats = append(stats, fmt.Sprintf("↓%s", formatTokens(p.Usage.OutputTokens))) | |
| 831 | 831 | } | |
| 832 | 832 | if p.Usage.CacheReadTokens > 0 { | |
| 833 | - | stats = append(stats, fmt.Sprintf("R%s", piFormatTokens(p.Usage.CacheReadTokens))) | |
| 833 | + | stats = append(stats, fmt.Sprintf("R%s", formatTokens(p.Usage.CacheReadTokens))) | |
| 834 | 834 | } | |
| 835 | 835 | if p.Usage.CacheWriteTokens > 0 { | |
| 836 | - | stats = append(stats, fmt.Sprintf("W%s", piFormatTokens(p.Usage.CacheWriteTokens))) | |
| 836 | + | stats = append(stats, fmt.Sprintf("W%s", formatTokens(p.Usage.CacheWriteTokens))) | |
| 837 | 837 | } | |
| 838 | 838 | ||
| 839 | 839 | // Cost: always show the dollar value computed from token counts, | |
| 840 | - | // even on subscription — lets you see what the equivalent api cost | |
| 840 | + | // even on subscription. Lets you see what the equivalent api cost | |
| 841 | 841 | // would be (handy for gauging subscription value). Append "(sub)" | |
| 842 | 842 | // only as a hint that no real money moved. | |
| 843 | 843 | var costStr string | |
| @@ -852,7 +852,7 @@ func StatusBar(p StatusBarParams) []string { | |||
| 852 | 852 | } | |
| 853 | 853 | ||
| 854 | 854 | // Context %. Color-coded: yellow >70, red >90. | |
| 855 | - | ctx, ctxColor := piContextUsage(th, p.ContextUsed, p.ContextMax) | |
| 855 | + | ctx, ctxColor := contextUsage(th, p.ContextUsed, p.ContextMax) | |
| 856 | 856 | if ctx != "" { | |
| 857 | 857 | if p.AutoCompacting { | |
| 858 | 858 | ctx += " (auto)" | |
| @@ -898,17 +898,17 @@ func StatusBar(p StatusBarParams) []string { | |||
| 898 | 898 | return []string{primary, cwdRendered} | |
| 899 | 899 | } | |
| 900 | 900 | ||
| 901 | - | // piContextUsage renders the "N%/ctxMax" fragment, returning the | |
| 901 | + | // contextUsage renders the "N%/ctxMax" fragment, returning the | |
| 902 | 902 | // rendered string plus the colour to wrap it in. | |
| 903 | - | func piContextUsage(th Theme, used, max int) (string, int) { | |
| 903 | + | func contextUsage(th Theme, used, max int) (string, int) { | |
| 904 | 904 | if max <= 0 { | |
| 905 | 905 | if used <= 0 { | |
| 906 | 906 | return "", th.Muted | |
| 907 | 907 | } | |
| 908 | - | return piFormatTokens(used), th.Muted | |
| 908 | + | return formatTokens(used), th.Muted | |
| 909 | 909 | } | |
| 910 | 910 | pct := float64(used) / float64(max) * 100 | |
| 911 | - | text := fmt.Sprintf("%.1f%%/%s", pct, piFormatTokens(max)) | |
| 911 | + | text := fmt.Sprintf("%.1f%%/%s", pct, formatTokens(max)) | |
| 912 | 912 | switch { | |
| 913 | 913 | case pct > 90: | |
| 914 | 914 | return text, th.Error | |
| @@ -918,14 +918,14 @@ func piContextUsage(th Theme, used, max int) (string, int) { | |||
| 918 | 918 | return text, th.Muted | |
| 919 | 919 | } | |
| 920 | 920 | ||
| 921 | - | // piFormatTokens footer formatter: | |
| 921 | + | // formatTokens footer formatter: | |
| 922 | 922 | // | |
| 923 | 923 | // < 1000 -> "42" | |
| 924 | 924 | // < 10_000 -> "2.7k" | |
| 925 | 925 | // < 1_000_000 -> "35k" | |
| 926 | 926 | // < 10M -> "1.1M" | |
| 927 | 927 | // else -> "12M" | |
| 928 | - | func piFormatTokens(n int) string { | |
| 928 | + | func formatTokens(n int) string { | |
| 929 | 929 | switch { | |
| 930 | 930 | case n < 0: | |
| 931 | 931 | return "0" | |
| @@ -772,7 +772,7 @@ func truncateLines(s string, n int) string { | |||||
| 772 | } | 772 | } | ||
| 773 | 773 | ||||
| 774 | // StatusBarParams groups the many bits of state the status bar needs. | 774 | // StatusBarParams groups the many bits of state the status bar needs. | ||
| 775 | - | // Grew from a flat argument list once we started matching pi's format. | 775 | + | // Grew from a flat argument list once we settled on the layout. |
| 776 | type StatusBarParams struct { | 776 | type StatusBarParams struct { | ||
| 777 | Theme Theme | 777 | Theme Theme | ||
| 778 | Provider string | 778 | Provider string | ||
| @@ -786,8 +786,8 @@ type StatusBarParams struct { | |||||
| 786 | Usage provider.Usage | 786 | Usage provider.Usage | ||
| 787 | // Subscription is true when the credential is an OAuth token (claude | 787 | // Subscription is true when the credential is an OAuth token (claude | ||
| 788 | // pro/max, chatgpt plus/pro) rather than a paid api key. We still | 788 | // pro/max, chatgpt plus/pro) rather than a paid api key. We still | ||
| 789 | - | // compute a cost for visibility, but pi-style we append "(sub)" so | 789 | + | // compute a cost for visibility and append "(sub)" so the user |
| 790 | - | // the user knows no money actually moved. | 790 | + | // knows no real money moved. |
| 791 | Subscription bool | 791 | Subscription bool | ||
| 792 | 792 | ||||
| 793 | // Last turn's input+cache tokens (approximates current live context). | 793 | // Last turn's input+cache tokens (approximates current live context). | ||
| @@ -820,24 +820,24 @@ type StatusBarParams struct { | |||||
| 820 | func StatusBar(p StatusBarParams) []string { | 820 | func StatusBar(p StatusBarParams) []string { | ||
| 821 | th := p.Theme | 821 | th := p.Theme | ||
| 822 | 822 | ||||
| 823 | - | // Token stats: only include each segment when non-zero (pi's | 823 | + | // Token stats: only include each segment when non-zero. Keeps |
| 824 | - | // behavior). Keeps the bar compact on brand-new sessions. | 824 | + | // the bar compact on brand-new sessions. |
| 825 | var stats []string | 825 | var stats []string | ||
| 826 | if p.Usage.InputTokens > 0 { | 826 | if p.Usage.InputTokens > 0 { | ||
| 827 | - | stats = append(stats, fmt.Sprintf("↑%s", piFormatTokens(p.Usage.InputTokens))) | 827 | + | stats = append(stats, fmt.Sprintf("↑%s", formatTokens(p.Usage.InputTokens))) |
| 828 | } | 828 | } | ||
| 829 | if p.Usage.OutputTokens > 0 { | 829 | if p.Usage.OutputTokens > 0 { | ||
| 830 | - | stats = append(stats, fmt.Sprintf("↓%s", piFormatTokens(p.Usage.OutputTokens))) | 830 | + | stats = append(stats, fmt.Sprintf("↓%s", formatTokens(p.Usage.OutputTokens))) |
| 831 | } | 831 | } | ||
| 832 | if p.Usage.CacheReadTokens > 0 { | 832 | if p.Usage.CacheReadTokens > 0 { | ||
| 833 | - | stats = append(stats, fmt.Sprintf("R%s", piFormatTokens(p.Usage.CacheReadTokens))) | 833 | + | stats = append(stats, fmt.Sprintf("R%s", formatTokens(p.Usage.CacheReadTokens))) |
| 834 | } | 834 | } | ||
| 835 | if p.Usage.CacheWriteTokens > 0 { | 835 | if p.Usage.CacheWriteTokens > 0 { | ||
| 836 | - | stats = append(stats, fmt.Sprintf("W%s", piFormatTokens(p.Usage.CacheWriteTokens))) | 836 | + | stats = append(stats, fmt.Sprintf("W%s", formatTokens(p.Usage.CacheWriteTokens))) |
| 837 | } | 837 | } | ||
| 838 | 838 | ||||
| 839 | // Cost: always show the dollar value computed from token counts, | 839 | // Cost: always show the dollar value computed from token counts, | ||
| 840 | - | // even on subscription — lets you see what the equivalent api cost | 840 | + | // even on subscription. Lets you see what the equivalent api cost |
| 841 | // would be (handy for gauging subscription value). Append "(sub)" | 841 | // would be (handy for gauging subscription value). Append "(sub)" | ||
| 842 | // only as a hint that no real money moved. | 842 | // only as a hint that no real money moved. | ||
| 843 | var costStr string | 843 | var costStr string | ||
| @@ -852,7 +852,7 @@ func StatusBar(p StatusBarParams) []string { | |||||
| 852 | } | 852 | } | ||
| 853 | 853 | ||||
| 854 | // Context %. Color-coded: yellow >70, red >90. | 854 | // Context %. Color-coded: yellow >70, red >90. | ||
| 855 | - | ctx, ctxColor := piContextUsage(th, p.ContextUsed, p.ContextMax) | 855 | + | ctx, ctxColor := contextUsage(th, p.ContextUsed, p.ContextMax) |
| 856 | if ctx != "" { | 856 | if ctx != "" { | ||
| 857 | if p.AutoCompacting { | 857 | if p.AutoCompacting { | ||
| 858 | ctx += " (auto)" | 858 | ctx += " (auto)" | ||
| @@ -898,17 +898,17 @@ func StatusBar(p StatusBarParams) []string { | |||||
| 898 | return []string{primary, cwdRendered} | 898 | return []string{primary, cwdRendered} | ||
| 899 | } | 899 | } | ||
| 900 | 900 | ||||
| 901 | - | // piContextUsage renders the "N%/ctxMax" fragment, returning the | 901 | + | // contextUsage renders the "N%/ctxMax" fragment, returning the |
| 902 | // rendered string plus the colour to wrap it in. | 902 | // rendered string plus the colour to wrap it in. | ||
| 903 | - | func piContextUsage(th Theme, used, max int) (string, int) { | 903 | + | func contextUsage(th Theme, used, max int) (string, int) { |
| 904 | if max <= 0 { | 904 | if max <= 0 { | ||
| 905 | if used <= 0 { | 905 | if used <= 0 { | ||
| 906 | return "", th.Muted | 906 | return "", th.Muted | ||
| 907 | } | 907 | } | ||
| 908 | - | return piFormatTokens(used), th.Muted | 908 | + | return formatTokens(used), th.Muted |
| 909 | } | 909 | } | ||
| 910 | pct := float64(used) / float64(max) * 100 | 910 | pct := float64(used) / float64(max) * 100 | ||
| 911 | - | text := fmt.Sprintf("%.1f%%/%s", pct, piFormatTokens(max)) | 911 | + | text := fmt.Sprintf("%.1f%%/%s", pct, formatTokens(max)) |
| 912 | switch { | 912 | switch { | ||
| 913 | case pct > 90: | 913 | case pct > 90: | ||
| 914 | return text, th.Error | 914 | return text, th.Error | ||
| @@ -918,14 +918,14 @@ func piContextUsage(th Theme, used, max int) (string, int) { | |||||
| 918 | return text, th.Muted | 918 | return text, th.Muted | ||
| 919 | } | 919 | } | ||
| 920 | 920 | ||||
| 921 | - | // piFormatTokens footer formatter: | 921 | + | // formatTokens footer formatter: |
| 922 | // | 922 | // | ||
| 923 | // < 1000 -> "42" | 923 | // < 1000 -> "42" | ||
| 924 | // < 10_000 -> "2.7k" | 924 | // < 10_000 -> "2.7k" | ||
| 925 | // < 1_000_000 -> "35k" | 925 | // < 1_000_000 -> "35k" | ||
| 926 | // < 10M -> "1.1M" | 926 | // < 10M -> "1.1M" | ||
| 927 | // else -> "12M" | 927 | // else -> "12M" | ||
| 928 | - | func piFormatTokens(n int) string { | 928 | + | func formatTokens(n int) string { |
| 929 | switch { | 929 | switch { | ||
| 930 | case n < 0: | 930 | case n < 0: | ||
| 931 | return "0" | 931 | return "0" | ||