Commit 716b9bd
sikongyue
feat(ai): Show context window usage as absolute tokens (e.g. 112k / 1M)
Display absolute token counts alongside percentages in AI Agent context
window usage UI, so users can judge when to compact or hand off based
on actual token counts rather than relative percentages.
- Add context_window_tokens and context_window_limit fields to ConversationUsageInfo
- Add context_window_tokens() method in conversation.rs, computed by summing segment token counts
- Pass context window token data through terminal/view.rs
- Update conversation_usage_view.rs display format:
- With limit: "112k / 1M (41%)"
- Without limit: "112k (41%)"
- Fallback: "41%" (when no segment data available)
- Update agent input footer tooltip: "41% context remaining (112k / 1M)"
- Fix struct initialization in gql_convert.rs and test files
Closes issue: Show context window usage as absolute tokens1 parent 2b4a66f commit 716b9bd
6 files changed
Lines changed: 133 additions & 8 deletions
File tree
- app/src
- ai
- agent
- blocklist
- usage
- terminal
- workspaces
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
767 | 779 | | |
768 | 780 | | |
769 | 781 | | |
| |||
Lines changed: 43 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2059 | 2059 | | |
2060 | 2060 | | |
2061 | 2061 | | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
2062 | 2103 | | |
2063 | 2104 | | |
2064 | 2105 | | |
2065 | 2106 | | |
2066 | 2107 | | |
2067 | 2108 | | |
2068 | | - | |
2069 | 2109 | | |
2070 | | - | |
| 2110 | + | |
2071 | 2111 | | |
2072 | | - | |
| 2112 | + | |
2073 | 2113 | | |
2074 | 2114 | | |
2075 | 2115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
| |||
466 | 470 | | |
467 | 471 | | |
468 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
469 | 476 | | |
470 | | - | |
471 | | - | |
472 | | - | |
| 477 | + | |
| 478 | + | |
473 | 479 | | |
474 | | - | |
| 480 | + | |
475 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
476 | 512 | | |
477 | 513 | | |
478 | 514 | | |
479 | 515 | | |
480 | 516 | | |
481 | | - | |
| 517 | + | |
482 | 518 | | |
483 | 519 | | |
484 | 520 | | |
| |||
1182 | 1218 | | |
1183 | 1219 | | |
1184 | 1220 | | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
1185 | 1242 | | |
1186 | 1243 | | |
1187 | 1244 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6895 | 6895 | | |
6896 | 6896 | | |
6897 | 6897 | | |
| 6898 | + | |
| 6899 | + | |
| 6900 | + | |
| 6901 | + | |
6898 | 6902 | | |
6899 | 6903 | | |
6900 | 6904 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
323 | 331 | | |
324 | 332 | | |
325 | 333 | | |
326 | 334 | | |
327 | 335 | | |
328 | 336 | | |
329 | 337 | | |
| 338 | + | |
| 339 | + | |
330 | 340 | | |
331 | 341 | | |
332 | 342 | | |
| |||
0 commit comments