Commit 792976d
committed
fix(plugin): replace misleading Cache:% status-bar metric with raw cache token display
The Cache:XX% segment derived from context_window.current_usage only reflects
the most recent API call, not session-wide cache efficiency. Users frequently
misread it as cumulative cache hit rate.
Replace compute_cache_hit_rate() with format_cache_segment() that renders raw
token values (e.g. ♻2k/3.5k) with the following semantics:
- numerator = cache_read_input_tokens
- denominator = input_tokens + cache_creation_input_tokens + cache_read_input_tokens
- values represent the latest API call, not session totals
Also add format_compact_tokens() helper for k-suffix compact rendering
(532 → 532, 1000 → 1k, 1500 → 1.5k, 128000 → 128k).
Safe fallback: when current_usage is missing/null/zero, the cache segment
is omitted entirely so the status line still renders without a broken slot.
Test coverage (#1354):
- format_cache_segment: 7 cases covering empty, null, input-only, partial,
full, large-value k-format, and no-percent regression
- format_status_line integration: 3 cases locking in the new output contract
and guarding against Cache:% regression
Closes #1355
Closes #13541 parent 8078a7a commit 792976d
2 files changed
Lines changed: 145 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
137 | 169 | | |
138 | | - | |
| 170 | + | |
139 | 171 | | |
140 | | - | |
141 | | - | |
142 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
143 | 175 | | |
144 | 176 | | |
145 | 177 | | |
146 | | - | |
147 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
148 | 181 | | |
149 | 182 | | |
150 | 183 | | |
| |||
378 | 411 | | |
379 | 412 | | |
380 | 413 | | |
381 | | - | |
| 414 | + | |
382 | 415 | | |
383 | 416 | | |
384 | 417 | | |
| |||
390 | 423 | | |
391 | 424 | | |
392 | 425 | | |
393 | | - | |
394 | | - | |
395 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
396 | 430 | | |
397 | 431 | | |
398 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 99 | + | |
| 100 | + | |
102 | 101 | | |
103 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
104 | 118 | | |
105 | | - | |
| 119 | + | |
106 | 120 | | |
107 | 121 | | |
108 | 122 | | |
109 | | - | |
| 123 | + | |
| 124 | + | |
110 | 125 | | |
111 | | - | |
| 126 | + | |
| 127 | + | |
112 | 128 | | |
113 | 129 | | |
114 | 130 | | |
115 | 131 | | |
116 | 132 | | |
117 | | - | |
118 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
119 | 137 | | |
120 | | - | |
| 138 | + | |
| 139 | + | |
121 | 140 | | |
122 | 141 | | |
123 | 142 | | |
124 | 143 | | |
125 | 144 | | |
126 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
127 | 215 | | |
128 | 216 | | |
129 | 217 | | |
| |||
0 commit comments