@linxiraos/pi-tui 1.4.11 → 1.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/CHANGELOG.md +30 -233
  2. package/README.md +4 -1
  3. package/THIRD-PARTY-NOTICES.txt +4 -5
  4. package/dist/types/apps/shell-visualizer.d.ts +24 -0
  5. package/dist/types/autocomplete.d.ts +20 -0
  6. package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
  7. package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
  8. package/dist/types/chat/display-preferences.d.ts +2 -0
  9. package/dist/types/chat/extension-types.d.ts +72 -1
  10. package/dist/types/chat/image-loading.d.ts +2 -2
  11. package/dist/types/chat/messages.d.ts +2 -3
  12. package/dist/types/chat/read-tool-group.d.ts +15 -2
  13. package/dist/types/chat/skill-message.d.ts +1 -0
  14. package/dist/types/chat/spotlight.d.ts +203 -0
  15. package/dist/types/chat/tool-execution.d.ts +26 -5
  16. package/dist/types/chat/transcript-actions.d.ts +11 -0
  17. package/dist/types/chat/transcript-browser.d.ts +9 -0
  18. package/dist/types/chat/transcript-presentation.d.ts +164 -0
  19. package/dist/types/chat/ttsr-notification.d.ts +2 -0
  20. package/dist/types/chrome/message-frame.d.ts +2 -0
  21. package/dist/types/chrome/transcript-container.d.ts +27 -6
  22. package/dist/types/components/loader.d.ts +0 -2
  23. package/dist/types/components/markdown.d.ts +11 -1
  24. package/dist/types/components/settings-list.d.ts +12 -2
  25. package/dist/types/frame-rate.d.ts +18 -0
  26. package/dist/types/hotkeys-markdown.d.ts +2 -0
  27. package/dist/types/index.d.ts +3 -0
  28. package/dist/types/keybinding-matchers.d.ts +4 -1
  29. package/dist/types/kitty-graphics.d.ts +1 -1
  30. package/dist/types/motion-effects.d.ts +10 -0
  31. package/dist/types/native/encode.d.ts +2 -0
  32. package/dist/types/native/measure.d.ts +10 -0
  33. package/dist/types/native/overlay.d.ts +1 -1
  34. package/dist/types/native/quiet.d.ts +5 -0
  35. package/dist/types/native/reconcile.d.ts +6 -1
  36. package/dist/types/native/spans.d.ts +6 -0
  37. package/dist/types/native/state.d.ts +4 -0
  38. package/dist/types/overlays/agent-hub.d.ts +6 -0
  39. package/dist/types/overlays/link-browser.d.ts +55 -0
  40. package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
  41. package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
  42. package/dist/types/prompt/composer-attachments.d.ts +5 -2
  43. package/dist/types/prompt/composer-cache.d.ts +7 -2
  44. package/dist/types/prompt/composer.d.ts +6 -11
  45. package/dist/types/prompt/custom-editor.d.ts +8 -2
  46. package/dist/types/prompt/gradient-highlight.d.ts +2 -2
  47. package/dist/types/prompt/magic-keywords.d.ts +2 -0
  48. package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
  49. package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
  50. package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
  51. package/dist/types/prompt/welcome.d.ts +19 -0
  52. package/dist/types/render/extension-links.d.ts +0 -6
  53. package/dist/types/render/index.d.ts +1 -0
  54. package/dist/types/render/link-hints.d.ts +78 -0
  55. package/dist/types/render/render-utils.d.ts +0 -2
  56. package/dist/types/setup/scenes/types.d.ts +8 -0
  57. package/dist/types/setup/scenes/updates.d.ts +6 -0
  58. package/dist/types/setup/wizard.d.ts +7 -2
  59. package/dist/types/spinner-clock.d.ts +34 -0
  60. package/dist/types/status-line/component.d.ts +8 -4
  61. package/dist/types/status-line/host.d.ts +62 -0
  62. package/dist/types/status-line/index.d.ts +1 -0
  63. package/dist/types/status-line/prompt-cache.d.ts +14 -0
  64. package/dist/types/status-line/schema.d.ts +1 -1
  65. package/dist/types/status-line/startup.d.ts +6 -0
  66. package/dist/types/status-line/types.d.ts +8 -21
  67. package/dist/types/theme/schema.d.ts +28 -1
  68. package/dist/types/theme/symbols.d.ts +1 -1
  69. package/dist/types/theme/theme-class.d.ts +12 -2
  70. package/dist/types/theme/theme.d.ts +1 -1
  71. package/dist/types/theme/tui-adapters.d.ts +7 -0
  72. package/dist/types/thinking.d.ts +12 -0
  73. package/dist/types/tools/ask.d.ts +1 -1
  74. package/dist/types/tools/bash.d.ts +21 -0
  75. package/dist/types/tools/find.d.ts +9 -1
  76. package/dist/types/tools/grep.d.ts +2 -1
  77. package/dist/types/tools/grouped-file-output.d.ts +17 -0
  78. package/dist/types/tools/job-widget.d.ts +2 -2
  79. package/dist/types/tools/lsp.d.ts +4 -2
  80. package/dist/types/tools/native-view.d.ts +4 -0
  81. package/dist/types/tools/renderer.d.ts +9 -1
  82. package/dist/types/tools/shell-trace.d.ts +10 -0
  83. package/dist/types/tools/shell-viz-render.d.ts +6 -0
  84. package/dist/types/tools/shell-viz.d.ts +16 -0
  85. package/dist/types/tools/wait.d.ts +2 -2
  86. package/dist/types/tools/web-search-types.d.ts +1 -0
  87. package/dist/types/tools/write.d.ts +2 -0
  88. package/dist/types/tui.d.ts +15 -1
  89. package/package.json +15 -11
  90. package/src/apps/shell-visualizer.d.ts +24 -0
  91. package/src/apps/shell-visualizer.ts +167 -0
  92. package/src/autocomplete.d.ts +20 -0
  93. package/src/autocomplete.ts +14 -0
  94. package/src/chat/assistant-message.ts +11 -6
  95. package/src/chat/cache-invalidation-marker.d.ts +15 -7
  96. package/src/chat/cache-invalidation-marker.ts +18 -9
  97. package/src/chat/chat-transcript-builder.d.ts +5 -3
  98. package/src/chat/chat-transcript-builder.ts +16 -12
  99. package/src/chat/display-preferences.d.ts +2 -0
  100. package/src/chat/display-preferences.ts +3 -0
  101. package/src/chat/extension-types.d.ts +72 -1
  102. package/src/chat/extension-types.ts +74 -1
  103. package/src/chat/image-loading.d.ts +2 -2
  104. package/src/chat/image-loading.ts +2 -2
  105. package/src/chat/messages.d.ts +2 -3
  106. package/src/chat/messages.ts +3 -8
  107. package/src/chat/read-tool-group.d.ts +15 -2
  108. package/src/chat/read-tool-group.ts +201 -41
  109. package/src/chat/skill-message.d.ts +1 -0
  110. package/src/chat/skill-message.ts +4 -0
  111. package/src/chat/spotlight.d.ts +203 -0
  112. package/src/chat/spotlight.ts +460 -0
  113. package/src/chat/tool-execution.d.ts +26 -5
  114. package/src/chat/tool-execution.ts +360 -38
  115. package/src/chat/transcript-actions.d.ts +11 -0
  116. package/src/chat/transcript-actions.ts +13 -1
  117. package/src/chat/transcript-browser.d.ts +9 -0
  118. package/src/chat/transcript-browser.ts +18 -0
  119. package/src/chat/transcript-presentation.d.ts +164 -0
  120. package/src/chat/transcript-presentation.ts +642 -0
  121. package/src/chat/ttsr-notification.d.ts +25 -0
  122. package/src/chat/ttsr-notification.ts +5 -0
  123. package/src/chrome/message-frame.d.ts +2 -0
  124. package/src/chrome/message-frame.ts +7 -0
  125. package/src/chrome/message-notice.d.ts +58 -0
  126. package/src/chrome/transcript-container.d.ts +27 -6
  127. package/src/chrome/transcript-container.ts +317 -66
  128. package/src/components/editor.ts +25 -1
  129. package/src/components/loader.d.ts +0 -2
  130. package/src/components/loader.ts +30 -18
  131. package/src/components/markdown.d.ts +11 -1
  132. package/src/components/markdown.ts +41 -16
  133. package/src/components/settings-list.d.ts +12 -2
  134. package/src/components/settings-list.ts +29 -13
  135. package/src/frame-rate.d.ts +18 -0
  136. package/src/frame-rate.ts +36 -0
  137. package/src/hotkeys-markdown.ts +9 -2
  138. package/src/index.d.ts +3 -0
  139. package/src/index.ts +3 -0
  140. package/src/keybinding-matchers.d.ts +4 -1
  141. package/src/keybinding-matchers.ts +13 -12
  142. package/src/kitty-graphics.d.ts +1 -1
  143. package/src/kitty-graphics.ts +3 -2
  144. package/src/motion-effects.d.ts +10 -0
  145. package/src/motion-effects.ts +27 -0
  146. package/src/native/backend.ts +66 -7
  147. package/src/native/encode.d.ts +2 -0
  148. package/src/native/encode.ts +2 -0
  149. package/src/native/measure.d.ts +10 -0
  150. package/src/native/measure.ts +185 -0
  151. package/src/native/overlay.d.ts +1 -1
  152. package/src/native/overlay.ts +1 -1
  153. package/src/native/quiet.d.ts +5 -0
  154. package/src/native/quiet.ts +105 -0
  155. package/src/native/reconcile.d.ts +6 -1
  156. package/src/native/reconcile.ts +16 -10
  157. package/src/native/spans.d.ts +6 -0
  158. package/src/native/spans.ts +40 -0
  159. package/src/native/state.d.ts +4 -0
  160. package/src/native/state.ts +18 -0
  161. package/src/overlays/agent-hub.ts +15 -2
  162. package/src/overlays/ask-dialog.ts +1 -0
  163. package/src/overlays/btw-history-panel.ts +73 -6
  164. package/src/overlays/link-browser.ts +295 -0
  165. package/src/overlays/running-subagent-badge.ts +2 -9
  166. package/src/overlays/settings-defs.ts +1 -1
  167. package/src/overlays/settings-selector.ts +17 -3
  168. package/src/overlays/spotlight-sheet.ts +478 -0
  169. package/src/overlays/usage-dashboard.ts +6 -5
  170. package/src/prompt/composer-attachments.d.ts +5 -2
  171. package/src/prompt/composer-attachments.ts +6 -6
  172. package/src/prompt/composer-cache.ts +17 -16
  173. package/src/prompt/composer.ts +30 -123
  174. package/src/prompt/custom-editor.ts +17 -13
  175. package/src/prompt/gradient-highlight.d.ts +2 -2
  176. package/src/prompt/gradient-highlight.ts +5 -4
  177. package/src/prompt/magic-keywords.d.ts +2 -0
  178. package/src/prompt/magic-keywords.ts +4 -1
  179. package/src/prompt/model-mention-autocomplete.ts +73 -20
  180. package/src/prompt/model-mention-syntax.d.ts +6 -0
  181. package/src/prompt/model-mention-syntax.ts +9 -0
  182. package/src/prompt/prompt-action-autocomplete.ts +49 -33
  183. package/src/prompt/tips.txt +1 -0
  184. package/src/prompt/welcome.ts +104 -2
  185. package/src/render/extension-links.d.ts +0 -6
  186. package/src/render/extension-links.ts +0 -20
  187. package/src/render/index.d.ts +1 -0
  188. package/src/render/index.ts +1 -0
  189. package/src/render/link-hints.d.ts +78 -0
  190. package/src/render/link-hints.ts +299 -0
  191. package/src/render/render-utils.d.ts +0 -2
  192. package/src/render/render-utils.ts +0 -5
  193. package/src/setup/scenes/glyph.ts +1 -1
  194. package/src/setup/scenes/types.ts +8 -0
  195. package/src/setup/scenes/updates.ts +116 -0
  196. package/src/setup/wizard.ts +19 -8
  197. package/src/spinner-clock.d.ts +34 -0
  198. package/src/spinner-clock.ts +79 -0
  199. package/src/status-line/component.ts +145 -53
  200. package/src/status-line/host.ts +51 -0
  201. package/src/status-line/index.ts +1 -0
  202. package/src/status-line/presets.ts +3 -1
  203. package/src/status-line/prompt-cache.ts +154 -0
  204. package/src/status-line/schema.ts +1 -1
  205. package/src/status-line/segments.ts +33 -22
  206. package/src/status-line/startup.ts +22 -4
  207. package/src/status-line/types.ts +8 -22
  208. package/src/stdin-buffer.ts +89 -46
  209. package/src/terminal-capabilities.ts +3 -3
  210. package/src/terminal.ts +1 -8
  211. package/src/theme/loader.ts +3 -2
  212. package/src/theme/schema.d.ts +28 -1
  213. package/src/theme/schema.ts +30 -1
  214. package/src/theme/symbols.d.ts +1 -1
  215. package/src/theme/symbols.ts +15 -3
  216. package/src/theme/theme-class.d.ts +12 -2
  217. package/src/theme/theme-class.ts +23 -0
  218. package/src/theme/theme-schema.json +1 -1
  219. package/src/theme/theme.d.ts +1 -1
  220. package/src/theme/theme.ts +3 -7
  221. package/src/theme/tui-adapters.d.ts +7 -0
  222. package/src/theme/tui-adapters.ts +33 -1
  223. package/src/thinking.d.ts +12 -0
  224. package/src/thinking.ts +31 -0
  225. package/src/tools/ask.d.ts +1 -1
  226. package/src/tools/ask.ts +99 -38
  227. package/src/tools/ast-edit.ts +51 -32
  228. package/src/tools/ast-grep.ts +31 -19
  229. package/src/tools/bash.d.ts +21 -0
  230. package/src/tools/bash.ts +166 -24
  231. package/src/tools/find.d.ts +9 -1
  232. package/src/tools/find.ts +23 -2
  233. package/src/tools/grep.d.ts +2 -1
  234. package/src/tools/grep.ts +52 -36
  235. package/src/tools/grouped-file-output.d.ts +17 -0
  236. package/src/tools/grouped-file-output.ts +20 -2
  237. package/src/tools/job-widget.d.ts +2 -2
  238. package/src/tools/job-widget.ts +2 -2
  239. package/src/tools/lsp.d.ts +4 -2
  240. package/src/tools/lsp.ts +537 -642
  241. package/src/tools/native-view.d.ts +4 -0
  242. package/src/tools/native-view.ts +8 -2
  243. package/src/tools/renderer.d.ts +9 -1
  244. package/src/tools/renderer.ts +9 -1
  245. package/src/tools/shell-trace.d.ts +10 -0
  246. package/src/tools/shell-trace.ts +80 -0
  247. package/src/tools/shell-viz-render.d.ts +6 -0
  248. package/src/tools/shell-viz-render.ts +156 -0
  249. package/src/tools/shell-viz.d.ts +16 -0
  250. package/src/tools/shell-viz.ts +181 -0
  251. package/src/tools/streaming-output.ts +18 -8
  252. package/src/tools/wait.d.ts +2 -2
  253. package/src/tools/wait.ts +39 -34
  254. package/src/tools/web-search-types.d.ts +1 -0
  255. package/src/tools/web-search-types.ts +1 -0
  256. package/src/tools/write.d.ts +2 -0
  257. package/src/tools/write.ts +2 -0
  258. package/src/tui.d.ts +15 -1
  259. package/src/tui.ts +63 -6
  260. package/src/windows-input-mode.ts +7 -1
  261. package/dist/types/chat/collab-prompt-message.d.ts +0 -14
  262. package/dist/types/chrome/collab-qrcode.d.ts +0 -35
  263. package/src/chat/collab-prompt-message.d.ts +0 -14
  264. package/src/chat/collab-prompt-message.ts +0 -46
  265. package/src/chrome/collab-qrcode.ts +0 -99
@@ -14,7 +14,10 @@ import {
14
14
  type ComposerStyle,
15
15
  claudeComposerStyle,
16
16
  padding,
17
- SPINNER_ADVANCE_MS,
17
+ motionEffectsEnabled,
18
+ spinnerAnimated,
19
+ spinnerInterval,
20
+ spinnerTickDelay,
18
21
  truncateToWidth,
19
22
  visibleWidth,
20
23
  } from "../index";
@@ -23,6 +26,7 @@ import type {
23
26
  ActiveRepoContext,
24
27
  StatusAccountIdentity as OAuthAccountIdentity,
25
28
  StatusLineHost,
29
+ PromptCacheStatus,
26
30
  StatusLineSession,
27
31
  } from "./host";
28
32
  import type { Editor } from "../components/editor";
@@ -39,15 +43,15 @@ import { canReuseCachedPr, createPrCacheContext, isSamePrCacheContext, type PrCa
39
43
  import { summarizeUsageResetCredits } from "../overlays/usage-display";
40
44
  import { getPreset } from "./presets";
41
45
  import { describeSegment, renderSegment, type SegmentContext } from "./segments";
46
+ import { promptCacheBrief } from "./prompt-cache";
42
47
  import type { TspMeterMark, TspProps } from "@linxiraos/pi-wire";
43
48
  import type { NativeNode, NativeUiEvent } from "../native/node";
44
- import { col, node, span } from "../native/describe";
49
+ import { col, node, propNode, span, text } from "../native/describe";
45
50
  import { getContextMeterThresholds } from "../chrome/context-thresholds";
46
51
  import { isNativeRendering, onNativeRenderingChange } from "../native/state";
47
52
  import { getSeparator } from "./separators";
48
53
  import { formatJobWidgetGlance, type JobWidgetEntry, latestJobWidget } from "../tools/job-widget";
49
54
  import type {
50
- CollabStatus,
51
55
  ComposerFacts,
52
56
  ComposerFactsSource,
53
57
  EffectiveStatusLineSettings,
@@ -63,10 +67,16 @@ import type {
63
67
  /** Sparkline cells the ANSI jobs segment draws after the freshest widget's headline. */
64
68
  const JOBS_SEGMENT_SPARK_CELLS = 8;
65
69
 
66
- /** What a click on a native status segment asks zeta to open. */
67
- export type StatusLineNativeAction = "status.model" | "status.context" | "status.git" | "status.cost" | "status.path";
70
+ /** What a click on a native status segment asks omp to open. */
71
+ export type StatusLineNativeAction =
72
+ | "status.model"
73
+ | "status.context"
74
+ | "status.git"
75
+ | "status.cost"
76
+ | "status.path"
77
+ | "status.cache";
68
78
 
69
- /** Click action per native segment: quick model picker, `/context`, `/git`, `/usage`, the project directory. */
79
+ /** Click action per native segment: quick model picker, `/context`, `/git`, `/usage`, the project directory, `/session`. */
70
80
  const NATIVE_SEGMENT_ACTIONS: Partial<Record<string, StatusLineNativeAction>> = {
71
81
  model: "status.model",
72
82
  context_pct: "status.context",
@@ -74,6 +84,7 @@ const NATIVE_SEGMENT_ACTIONS: Partial<Record<string, StatusLineNativeAction>> =
74
84
  git: "status.git",
75
85
  cost: "status.cost",
76
86
  path: "status.path",
87
+ cache: "status.cache",
77
88
  };
78
89
 
79
90
  /** Segments that outlast every other one as the native bar narrows (model, context, git branch). */
@@ -144,6 +155,26 @@ function describeSeg(key: string, props: TspProps<"seg">, view: SegmentView, dim
144
155
  return node("seg", props, view.motion, key);
145
156
  }
146
157
 
158
+ /**
159
+ * The `cache` fact's own props: it sits at the facts' right end, beside the
160
+ * usage, names its glyph by the card's first line, and its hover card says
161
+ * until when the next message reads the cache (or why not) and what it sends,
162
+ * in absolute times, since the terminal shows the card later without repainting.
163
+ */
164
+ function promptCacheFactProps(status: PromptCacheStatus, nowMs: number): TspProps<"seg"> {
165
+ const [head, next] = promptCacheBrief(status, nowMs);
166
+ const card = col([text(status.state === "cold" ? [span(head, "warning")] : head), text([span(next, "muted")])], {
167
+ role: "zeta.composer.cache.card",
168
+ });
169
+ return {
170
+ role: "zeta.composer.cache",
171
+ side: "right",
172
+ aria: head,
173
+ title: `${head}\n${next}`,
174
+ hovercard: propNode(card),
175
+ };
176
+ }
177
+
147
178
  /**
148
179
  * Freshness window for the git segment's working-tree counts. A whole-worktree
149
180
  * `git status` costs ~1 CPU-second on large repos and every open session polls
@@ -166,10 +197,13 @@ const WATCHER_FAILURE_POLL_TTL_MS = 5000;
166
197
  const BRAND_FADE_MS = 450;
167
198
  /** Repaint cadence while the brand fade is in flight (rust zeta's `FADE_FRAME`). */
168
199
  const BRAND_FADE_FRAME_MS = 40;
169
- /** Repaint cadence while a turn's active-processing window is open: keeps the
200
+ /** Shortest repaint cadence while a turn's active-processing window is open: keeps the
170
201
  * status bar's clock-driven readouts (pi spinner, turn timer) animating when
171
- * no other component is requesting renders. */
202
+ * no other component is requesting renders. The armed period is this rounded up to a
203
+ * whole number of spinner frames, so the ticker lands on the working row's own ticks. */
172
204
  const ACTIVE_WINDOW_REPAINT_MS = 250;
205
+ /** Turn-window repaint cadence under a static spinner: only the one-second timers still move. */
206
+ const STATIC_SPINNER_REPAINT_MS = 1_000;
173
207
 
174
208
  /**
175
209
  * Providers whose subscription quota is a single monthly bucket, so their
@@ -726,11 +760,15 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
726
760
  #pricingTimer: NodeJS.Timeout | undefined;
727
761
  #pricingTimerCost: ModelCost | undefined;
728
762
  #pricingTransition: number | undefined;
763
+ /** One wall-clock wakeup when the warm prompt-cache entry expires, so the marker turns without ticking. */
764
+ #promptCacheTimer: NodeJS.Timeout | undefined;
765
+ #promptCacheWakeAt: number | undefined;
729
766
  #hookStatuses: Map<string, string> = new Map();
730
767
  #sortedHookStatuses: readonly string[] = [];
731
768
  #subagentCount: number = 0;
732
769
  #runningSubagentIds = new Set<string>();
733
770
  #subagentTreeCost = 0;
771
+ #pinnedSessionIds = new Set<string>();
734
772
  /**
735
773
  * Active-processing accounting for the `time_spent` segment, keyed per
736
774
  * {@link StatusLineSession} so the focus-controller mid-turn attach path
@@ -762,7 +800,6 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
762
800
  * dependency graph; interactive-mode wires it to VibeSessionRegistry.
763
801
  */
764
802
  #vibeWorkerTokenRate: (() => number | null) | null = null;
765
- #collabStatus: CollabStatus | null = null;
766
803
  #streamStatus: { viewers: number } | null = null;
767
804
  #recording = false;
768
805
  #focusedAgentId: string | undefined;
@@ -1216,19 +1253,6 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1216
1253
  this.#invalidateStatusLineRenderCache();
1217
1254
  }
1218
1255
 
1219
- setCollabStatus(status: CollabStatus | null): void {
1220
- if (
1221
- !this.#collabStatus?.stateOverride &&
1222
- !status?.stateOverride &&
1223
- this.#collabStatus?.role === status?.role &&
1224
- this.#collabStatus?.participantCount === status?.participantCount
1225
- ) {
1226
- return;
1227
- }
1228
- this.#collabStatus = status;
1229
- this.#invalidateStatusLineRenderCache();
1230
- }
1231
-
1232
1256
  setStreamStatus(status: { viewers: number } | null): void {
1233
1257
  if (this.#streamStatus?.viewers === status?.viewers) return;
1234
1258
  this.#streamStatus = status;
@@ -1242,6 +1266,24 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1242
1266
  this.#invalidateStatusLineRenderCache();
1243
1267
  }
1244
1268
 
1269
+ /** Mark one session pinned or unpinned; `session_name` shows the pin for the viewed session. */
1270
+ setSessionPinned(sessionId: string, pinned: boolean): void {
1271
+ if (this.#pinnedSessionIds.has(sessionId) === pinned) return;
1272
+ if (pinned) this.#pinnedSessionIds.add(sessionId);
1273
+ else this.#pinnedSessionIds.delete(sessionId);
1274
+ this.#invalidateStatusLineRenderCache();
1275
+ }
1276
+
1277
+ /** Replace the whole pinned-session set (a fresh read of the pins file). */
1278
+ setPinnedSessionIds(sessionIds: ReadonlySet<string>): void {
1279
+ this.#pinnedSessionIds = new Set(sessionIds);
1280
+ this.#invalidateStatusLineRenderCache();
1281
+ }
1282
+
1283
+ isSessionPinned(sessionId: string | undefined): boolean {
1284
+ return sessionId !== undefined && this.#pinnedSessionIds.has(sessionId);
1285
+ }
1286
+
1245
1287
  /** Set the callback that presents detected Codex reset celebrations, or clear it with `undefined`. */
1246
1288
  setCodexResetFireworksHandler(handler: ((event: CodexResetFireworksEvent) => void) | undefined): void {
1247
1289
  this.#onCodexResetFireworks = handler;
@@ -1320,6 +1362,7 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1320
1362
  this.#stopBrandFadeTimer();
1321
1363
  this.#stopActiveWindowRepaint();
1322
1364
  this.#stopPricingTimer();
1365
+ this.#stopPromptCacheTimer();
1323
1366
  this.#clearUsageStartTimer();
1324
1367
  this.#unwatchNativeRendering?.();
1325
1368
  this.#unwatchNativeRendering = undefined;
@@ -1336,8 +1379,9 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1336
1379
  * the first render after speculation leaves the running state.
1337
1380
  */
1338
1381
  #syncSpeculationBlink(state: "idle" | "running" | "armed"): void {
1339
- // A TSP terminal pulses the icon itself (`fx: "pulse"`).
1340
- if (state === "running" && !this.#disposed && !isNativeRendering()) {
1382
+ // A TSP terminal pulses the icon itself (`fx: "pulse"`, dropped by `quietMotion` when effects are
1383
+ // off); here `tui.motion` switches the JS blink off.
1384
+ if (state === "running" && !this.#disposed && !isNativeRendering() && motionEffectsEnabled()) {
1341
1385
  this.#speculationBlinkTimer ??= setInterval(() => {
1342
1386
  this.#speculationBlinkOn = !this.#speculationBlinkOn;
1343
1387
  this.invalidate();
@@ -1371,14 +1415,19 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1371
1415
  const now = Date.now();
1372
1416
  if (working !== this.#brandWorking) {
1373
1417
  const previousTargetHex = this.#brandWorking ? workingHex : idleHex;
1374
- this.#brandFade = {
1375
- fromHex: this.#sampleBrandHex(previousTargetHex, now),
1376
- toHex: working ? workingHex : idleHex,
1377
- startedAt: now,
1378
- };
1379
1418
  this.#brandWorking = working;
1380
- // Only a visible `pi` segment needs fade frames; other bars stay quiet.
1381
- if (brandVisible) this.#startBrandFadeTimer();
1419
+ // With decorative motion off the brand snaps to its settled color; otherwise it eases over.
1420
+ if (motionEffectsEnabled()) {
1421
+ this.#brandFade = {
1422
+ fromHex: this.#sampleBrandHex(previousTargetHex, now),
1423
+ toHex: working ? workingHex : idleHex,
1424
+ startedAt: now,
1425
+ };
1426
+ // Only a visible `pi` segment needs fade frames; other bars stay quiet.
1427
+ if (brandVisible) this.#startBrandFadeTimer();
1428
+ } else {
1429
+ this.#brandFade = null;
1430
+ }
1382
1431
  }
1383
1432
  const hex = this.#sampleBrandHex(working ? workingHex : idleHex, now);
1384
1433
  return getSessionAccentAnsi(hex) ?? theme.getFgAnsi(working ? "accent" : "dim");
@@ -1430,7 +1479,7 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1430
1479
  * Keep the status bar repainting while a turn's active-processing window
1431
1480
  * is open. The `pi` segment's spinner and turn timer are painted from the
1432
1481
  * wall clock at render time, so they only animate when frames flow; during
1433
- * a quiet turn the working-row loader's 80 ms tick is normally the sole
1482
+ * a quiet turn the working-row loader's tick is normally the sole
1434
1483
  * repaint source, and paths that stop or bypass that loader mid-turn (an
1435
1484
  * error banner, a stale retry/compaction loader reference) froze the
1436
1485
  * spinner until the next keystroke. The status line owns the active
@@ -1442,21 +1491,33 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1442
1491
  this.#stopActiveWindowRepaint();
1443
1492
  return;
1444
1493
  }
1445
- if (this.#activeWindowRepaintTimer) return;
1446
- const timer = setInterval(() => {
1447
- if (this.#disposed || isNativeRendering() || this.getTurnElapsedMs() === null) {
1448
- this.#stopActiveWindowRepaint();
1449
- return;
1450
- }
1494
+ if (!this.#activeWindowRepaintTimer) this.#armActiveWindowRepaint();
1495
+ }
1496
+
1497
+ /**
1498
+ * One tick on the shared clock's next boundary (see {@link spinnerTickDelay}); re-arms itself,
1499
+ * re-reading the period. The period is a whole number of spinner frames no shorter than the
1500
+ * 250 ms safety net, so every tick coincides with one of the working row's own and the two cost
1501
+ * one frame; with static spinners it is the turn timer's 1 s.
1502
+ */
1503
+ #armActiveWindowRepaint(): void {
1504
+ const frameMs = spinnerInterval();
1505
+ const periodMs = spinnerAnimated()
1506
+ ? Math.ceil(ACTIVE_WINDOW_REPAINT_MS / frameMs - 1e-6) * frameMs
1507
+ : STATIC_SPINNER_REPAINT_MS;
1508
+ const timer = setTimeout(() => {
1509
+ this.#activeWindowRepaintTimer = undefined;
1510
+ if (this.#disposed || isNativeRendering() || this.getTurnElapsedMs() === null) return;
1451
1511
  this.#onBranchChange?.();
1452
- }, ACTIVE_WINDOW_REPAINT_MS);
1512
+ this.#armActiveWindowRepaint();
1513
+ }, spinnerTickDelay(periodMs));
1453
1514
  timer.unref?.();
1454
1515
  this.#activeWindowRepaintTimer = timer;
1455
1516
  }
1456
1517
 
1457
1518
  #stopActiveWindowRepaint(): void {
1458
1519
  if (!this.#activeWindowRepaintTimer) return;
1459
- clearInterval(this.#activeWindowRepaintTimer);
1520
+ clearTimeout(this.#activeWindowRepaintTimer);
1460
1521
  this.#activeWindowRepaintTimer = undefined;
1461
1522
  }
1462
1523
 
@@ -1500,6 +1561,36 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1500
1561
  timer.unref();
1501
1562
  }
1502
1563
 
1564
+ #stopPromptCacheTimer(): void {
1565
+ clearTimeout(this.#promptCacheTimer);
1566
+ this.#promptCacheTimer = undefined;
1567
+ this.#promptCacheWakeAt = undefined;
1568
+ }
1569
+
1570
+ /**
1571
+ * One wakeup when the warm prompt cache lapses, so the marker turns without
1572
+ * ticking; a warm refresh moves the expiry and re-arms it on the next build.
1573
+ */
1574
+ #syncPromptCacheTimer(status: PromptCacheStatus | undefined, now: number): void {
1575
+ const wakeAt =
1576
+ status?.state === "warm" && status.ttlMs !== undefined ? status.touchedAt + status.ttlMs : undefined;
1577
+ if (this.#disposed || !this.#onBranchChange || wakeAt === undefined || wakeAt <= now) {
1578
+ this.#stopPromptCacheTimer();
1579
+ return;
1580
+ }
1581
+ if (this.#promptCacheWakeAt === wakeAt) return;
1582
+ this.#stopPromptCacheTimer();
1583
+ this.#promptCacheWakeAt = wakeAt;
1584
+ const timer = setTimeout(() => {
1585
+ if (this.#disposed || this.#promptCacheTimer !== timer) return;
1586
+ this.#stopPromptCacheTimer();
1587
+ this.invalidate();
1588
+ this.#onBranchChange?.();
1589
+ }, wakeAt - now);
1590
+ this.#promptCacheTimer = timer;
1591
+ timer.unref();
1592
+ }
1593
+
1503
1594
  #clearUsageStartTimer(): void {
1504
1595
  if (!this.#usageStartTimer) return;
1505
1596
  clearTimeout(this.#usageStartTimer);
@@ -2575,21 +2666,12 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2575
2666
 
2576
2667
  let contextWindow = state.model?.contextWindow ?? this.session.model?.contextWindow ?? 0;
2577
2668
  const breakdown = this.getCachedContextBreakdown();
2578
- let contextTokens = breakdown.usedTokens;
2669
+ const contextTokens = breakdown.usedTokens;
2579
2670
  contextWindow = breakdown.contextWindow || contextWindow;
2580
- let contextPercent: number | null =
2671
+ const contextPercent: number | null =
2581
2672
  contextWindow > 0 && !this.#contextUsageCache?.percentUnknown
2582
2673
  ? (breakdown.usedTokens / contextWindow) * 100
2583
2674
  : null;
2584
- // Collab guest: context comes from the host's state frames — the local
2585
- // replica does no accounting of its own.
2586
- const collabState = this.#collabStatus?.stateOverride;
2587
- if (collabState?.contextUsage) {
2588
- contextWindow = collabState.contextUsage.contextWindow || contextWindow;
2589
- contextTokens = collabState.contextUsage.tokens ?? contextTokens;
2590
- contextPercent = collabState.contextUsage.percent ?? contextPercent;
2591
- }
2592
-
2593
2675
  const shouldResolveActiveRepo = this.#gitEnabled() && (includePath || includeGit || includePr);
2594
2676
  const projectDir = getProjectDir();
2595
2677
  const activeRepoCache = shouldResolveActiveRepo
@@ -2613,11 +2695,17 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2613
2695
  const sessionAccentEnabled = settings.sessionAccent !== false;
2614
2696
  const brandVisible = settings.leftSegments.includes("pi") || settings.rightSegments.includes("pi");
2615
2697
  const turnElapsedMs = this.getTurnElapsedMs();
2698
+ const promptCache =
2699
+ settings.leftSegments.includes("cache") || settings.rightSegments.includes("cache")
2700
+ ? this.session.getPromptCacheStatus?.(nowMs, breakdown.usedTokens)
2701
+ : undefined;
2702
+ this.#syncPromptCacheTimer(promptCache, nowMs);
2616
2703
  return {
2617
2704
  session: this.session,
2618
2705
  focusedAgentId: this.#focusedAgentId,
2619
2706
  sessionAccent: sessionAccentEnabled,
2620
2707
  previewTitle,
2708
+ isPinned: this.isSessionPinned(this.session.sessionManager?.getSessionId?.()),
2621
2709
  activeRepo: activeRepoCache.activeRepo,
2622
2710
  width,
2623
2711
  options: segmentOptions ?? {},
@@ -2633,7 +2721,6 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2633
2721
  goalStatusInFooter: this.#goalModeStatus ? this.host.goalStatusInFooter(this.session) : false,
2634
2722
  vibeMode: this.#vibeModeStatus,
2635
2723
  vim: this.#vimStatus,
2636
- collab: this.#collabStatus,
2637
2724
  stream: this.#streamStatus,
2638
2725
  recording: this.#recording,
2639
2726
  usageStats,
@@ -2658,6 +2745,7 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2658
2745
  },
2659
2746
  worktree: activeRepoCache.worktree,
2660
2747
  usage: this.#cachedUsage,
2748
+ promptCache,
2661
2749
  };
2662
2750
  }
2663
2751
 
@@ -2903,7 +2991,10 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2903
2991
  this.#focusedAgentId === undefined &&
2904
2992
  (leftSegments.includes("pi") || rightSegments.includes("pi"))
2905
2993
  ) {
2906
- return Math.floor(nowMs / SPINNER_ADVANCE_MS);
2994
+ // The brand spinner follows the shared clock. With a static spinner the brand's elapsed
2995
+ // timer still advances once a second, and a brand fade repaints on its own frame cadence.
2996
+ if (spinnerAnimated()) return Math.floor(nowMs / spinnerInterval());
2997
+ return this.#brandFade !== null ? Math.floor(nowMs / BRAND_FADE_FRAME_MS) : Math.floor(nowMs / 1_000);
2907
2998
  }
2908
2999
  const includesTime = leftSegments.includes("time") || rightSegments.includes("time");
2909
3000
  if (
@@ -3702,6 +3793,7 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
3702
3793
  };
3703
3794
  const action = NATIVE_SEGMENT_ACTIONS[id];
3704
3795
  if (action) props.actions = { click: action };
3796
+ if (id === "cache" && ctx.promptCache) Object.assign(props, promptCacheFactProps(ctx.promptCache, nowMs));
3705
3797
  facts.push(describeSeg(id, props, view, dim));
3706
3798
  });
3707
3799
  };
@@ -20,6 +20,52 @@ export interface ActiveRepoContext {
20
20
  source: "single-direct-child-repo";
21
21
  }
22
22
 
23
+ /** Why the next request rewrites the cached prompt prefix instead of reading it. */
24
+ export type PromptCacheColdReason =
25
+ | { kind: "expired"; at: number }
26
+ /** omp's warm refresh found the entry gone. */
27
+ | { kind: "refresh-missed" }
28
+ | { kind: "model"; from: string; to: string }
29
+ | { kind: "thinking"; from: string; to: string }
30
+ | { kind: "tools" }
31
+ | { kind: "system-prompt" }
32
+ | { kind: "retention" }
33
+ | { kind: "compaction" };
34
+
35
+ /** omp's cache warmer as it concerns the entry. */
36
+ export interface PromptCacheWarming {
37
+ /** `scheduled`: a refresh decision is armed; `refreshing`: a refresh was sent and is in flight. */
38
+ state: "scheduled" | "refreshing" | "inactive";
39
+ /** When the armed refresh decides. */
40
+ nextWarmAt?: number;
41
+ /** When warming gives up: its 60-minute streaming or 30-minute idle safety window. */
42
+ stopsAt?: number;
43
+ /** Why nothing is scheduled. */
44
+ reason?: string;
45
+ }
46
+
47
+ /** What the next request finds in the prompt cache: the `cache` segment's marker and its details. */
48
+ export interface PromptCacheStatus {
49
+ /** `cold`: the next request rewrites the cached prefix. */
50
+ state: "warm" | "cold";
51
+ /** Why it is cold; absent while warm. */
52
+ reason?: PromptCacheColdReason;
53
+ /** Read off the transcript of a reopened session, not a response this process saw: thinking level, tools and credential are unknown. */
54
+ inferred: boolean;
55
+ /** Retention tier the entry was written under: `short` (5m) or `long` (1h). */
56
+ tier: "short" | "long";
57
+ /** Send time of the last request that read or wrote the entry. */
58
+ touchedAt: number;
59
+ /** Lifetime after the last touch; undefined when the provider never expires the entry. */
60
+ ttlMs?: number;
61
+ /** Prompt tokens of the request that wrote or last read the entry: what a warm cache serves. */
62
+ cachedTokens: number;
63
+ /** Estimated prompt tokens of the next request. */
64
+ nextTokens: number;
65
+ /** Absent when the entry was inferred. */
66
+ warming?: PromptCacheWarming;
67
+ }
68
+
23
69
  export interface StatusLineSession {
24
70
  state: { model?: Model; thinkingLevel?: ThinkingLevel; messages: readonly AgentMessage[] };
25
71
  model?: Model;
@@ -66,6 +112,11 @@ export interface StatusLineSession {
66
112
  getAdvisorStatusOverview?(): { configured: boolean; advisors: readonly { status: string; yielded: boolean }[] };
67
113
  getAdvisorCost?(): number;
68
114
  isAdvisorUsingSubscription?(): boolean;
115
+ /**
116
+ * What the next request finds in the prompt cache at `nowMs`; undefined when there is nothing to reason about.
117
+ * `nextTokens` is the caller's current context token count, so the session need not recount it.
118
+ */
119
+ getPromptCacheStatus?(nowMs: number, nextTokens?: number): PromptCacheStatus | undefined;
69
120
  }
70
121
 
71
122
  export interface FooterSession {
@@ -1,6 +1,7 @@
1
1
  export * from "./component";
2
2
  export * from "./metrics";
3
3
  export * from "./presets";
4
+ export * from "./prompt-cache";
4
5
  export * from "./segments";
5
6
  export * from "./separators";
6
7
  export * from "./types";
@@ -3,7 +3,7 @@ import type { PresetDef, StatusLinePreset } from "./types";
3
3
 
4
4
  export const STATUS_LINE_PRESETS: Record<StatusLinePreset, PresetDef> = {
5
5
  default: {
6
- leftSegments: ["pi", "vim", "model", "mode", "collab", "stream", "path", "git", "pr", "context_pct", "cost"],
6
+ leftSegments: ["pi", "vim", "model", "mode", "stream", "path", "git", "pr", "context_pct", "cost"],
7
7
  rightSegments: ["session_name"],
8
8
  separator: "powerline-thin",
9
9
  segmentOptions: {
@@ -42,6 +42,7 @@ export const STATUS_LINE_PRESETS: Record<StatusLinePreset, PresetDef> = {
42
42
  "token_out",
43
43
  "token_rate",
44
44
  "cache_read",
45
+ "cache",
45
46
  "cost",
46
47
  "context_pct",
47
48
  "time_spent",
@@ -66,6 +67,7 @@ export const STATUS_LINE_PRESETS: Record<StatusLinePreset, PresetDef> = {
66
67
  "cache_read",
67
68
  "cache_write",
68
69
  "token_rate",
70
+ "cache",
69
71
  "cost",
70
72
  "context_pct",
71
73
  "context_total",
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Prompt-cache text beyond the `cache` marker: the two lines of its hover card
3
+ * (Tern) and the rows of `/session`'s Prompt Cache section.
4
+ */
5
+ import { formatDuration, formatNumber } from "@linxiraos/pi-utils";
6
+ import { sanitizeStatusText } from "../chrome/shared";
7
+ import type { PromptCacheColdReason, PromptCacheStatus, PromptCacheWarming } from "./host";
8
+
9
+ /** One `label: value` line of the prompt-cache details. */
10
+ export interface PromptCacheDetailRow {
11
+ label: string;
12
+ value: string;
13
+ tone?: "warning";
14
+ }
15
+
16
+ function sameDay(at: number, nowMs: number): boolean {
17
+ return new Date(at).toDateString() === new Date(nowMs).toDateString();
18
+ }
19
+
20
+ /** `4:53 PM` on `nowMs`'s local day; `Oct 17, 5:12 PM` on any other, which a bare clock time would misdate. */
21
+ function when(at: number, nowMs: number): string {
22
+ return sameDay(at, nowMs)
23
+ ? new Date(at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })
24
+ : new Date(at).toLocaleString([], { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" });
25
+ }
26
+
27
+ /** ` (in 41 min)` / ` (3 h ago)` / ` (12 days ago)`. */
28
+ function relative(at: number, nowMs: number): string {
29
+ const minutes = Math.round(Math.abs(at - nowMs) / 60_000);
30
+ if (minutes === 0) return at >= nowMs ? " (in under a minute)" : " (just now)";
31
+ const span =
32
+ minutes < 60
33
+ ? `${minutes} min`
34
+ : minutes < 48 * 60
35
+ ? `${Math.round(minutes / 60)} h`
36
+ : `${Math.round(minutes / (24 * 60))} days`;
37
+ return at >= nowMs ? ` (in ${span})` : ` (${span} ago)`;
38
+ }
39
+
40
+ /**
41
+ * Why the next message re-sends the prefix, as one phrase. With `nowMs` an expiry says when; the hover card
42
+ * omits it, since the terminal shows the card later without repainting it.
43
+ */
44
+ function coldReasonText(reason: PromptCacheColdReason, nowMs?: number): string {
45
+ switch (reason.kind) {
46
+ case "expired":
47
+ if (nowMs === undefined) return "expired";
48
+ return `expired ${sameDay(reason.at, nowMs) ? "at " : ""}${when(reason.at, nowMs)}${relative(reason.at, nowMs)}`;
49
+ case "refresh-missed":
50
+ return "omp's refresh found the entry gone";
51
+ case "model":
52
+ return `model changed: ${sanitizeStatusText(reason.from)} → ${sanitizeStatusText(reason.to)}`;
53
+ case "thinking":
54
+ return `thinking level changed: ${sanitizeStatusText(reason.from)} → ${sanitizeStatusText(reason.to)}`;
55
+ case "tools":
56
+ return "tool set changed";
57
+ case "system-prompt":
58
+ return "system prompt changed";
59
+ case "retention":
60
+ return "cache retention setting changed";
61
+ case "compaction":
62
+ return "context was compacted";
63
+ }
64
+ }
65
+
66
+ function warmingText(warming: PromptCacheWarming, nowMs: number): string {
67
+ switch (warming.state) {
68
+ case "scheduled": {
69
+ const next =
70
+ warming.nextWarmAt === undefined ? "refresh scheduled" : `next refresh ${when(warming.nextWarmAt, nowMs)}`;
71
+ return warming.stopsAt === undefined ? next : `${next}, gives up by ${when(warming.stopsAt, nowMs)}`;
72
+ }
73
+ case "refreshing":
74
+ return "refreshing now";
75
+ case "inactive": {
76
+ const reason = warming.reason === undefined ? "" : sanitizeStatusText(warming.reason);
77
+ return reason ? `off: ${reason}` : "off";
78
+ }
79
+ }
80
+ }
81
+
82
+ /**
83
+ * What the next message re-sends uncached. A lapsed entry, a missed refresh, another
84
+ * model or another tool set (the first cached block) leaves nothing to read. Any
85
+ * other change keeps the cached blocks ahead of it (tools, then the system prompt),
86
+ * whose share omp cannot see, so the whole prompt is only the most it re-sends.
87
+ */
88
+ function resendText(status: PromptCacheStatus): string {
89
+ const tokens = `~${formatNumber(status.nextTokens)}`;
90
+ switch (status.reason?.kind) {
91
+ case "expired":
92
+ case "refresh-missed":
93
+ case "model":
94
+ case "tools":
95
+ return `re-sends ${tokens}`;
96
+ default:
97
+ return `re-sends up to ${tokens}`;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * The hover card's two lines: whether the next message reads the cache (until when, or why not), then what it
103
+ * sends. The terminal shows the card later without repainting it, so it names no time relative to now.
104
+ */
105
+ export function promptCacheBrief(status: PromptCacheStatus, nowMs: number): readonly [string, string] {
106
+ if (status.state === "cold") {
107
+ const why = status.reason ? ` — ${coldReasonText(status.reason)}` : "";
108
+ return [`Not cached${why}`, `Next message ${resendText(status)}`];
109
+ }
110
+ const cached = status.inferred ? "Likely cached" : "Cached";
111
+ const until = status.ttlMs === undefined ? ", no expiry" : ` until ${when(status.touchedAt + status.ttlMs, nowMs)}`;
112
+ const reads = formatNumber(Math.min(status.cachedTokens, status.nextTokens));
113
+ return [`${cached}${until}`, `Next message reads ~${reads} from cache`];
114
+ }
115
+
116
+ /** The `/session` rows, in display order; times say how long ago or ahead of `nowMs` they are. */
117
+ export function promptCacheDetails(status: PromptCacheStatus, nowMs: number): PromptCacheDetailRow[] {
118
+ const tier: PromptCacheDetailRow = {
119
+ label: "Tier",
120
+ value: status.ttlMs === undefined ? "no expiry" : formatDuration(status.ttlMs),
121
+ };
122
+ const warming: PromptCacheDetailRow[] = status.warming
123
+ ? [{ label: "Warming", value: warmingText(status.warming, nowMs) }]
124
+ : [];
125
+ if (status.state === "cold") {
126
+ return [
127
+ { label: "State", value: "Not cached", tone: "warning" },
128
+ ...(status.reason
129
+ ? [{ label: "Why not cached", value: coldReasonText(status.reason, nowMs), tone: "warning" as const }]
130
+ : []),
131
+ tier,
132
+ ...warming,
133
+ { label: "Next message", value: `${resendText(status)} uncached` },
134
+ ];
135
+ }
136
+ const expiresAt = status.ttlMs === undefined ? undefined : status.touchedAt + status.ttlMs;
137
+ const reads = Math.min(status.cachedTokens, status.nextTokens);
138
+ return [
139
+ { label: "State", value: status.inferred ? "Likely cached" : "Cached" },
140
+ {
141
+ label: "Expires",
142
+ value:
143
+ expiresAt === undefined
144
+ ? "never (the provider keeps it)"
145
+ : `${when(expiresAt, nowMs)}${relative(expiresAt, nowMs)}`,
146
+ },
147
+ tier,
148
+ ...warming,
149
+ {
150
+ label: "Next message",
151
+ value: `reads ~${formatNumber(reads)} from cache, sends ~${formatNumber(status.nextTokens - reads)} new`,
152
+ },
153
+ ];
154
+ }
@@ -22,10 +22,10 @@ export const STATUS_LINE_SEGMENT_IDS = [
22
22
  "cache_read",
23
23
  "cache_write",
24
24
  "cache_hit",
25
+ "cache",
25
26
  "session_name",
26
27
  "usage",
27
28
  "turn_stats",
28
- "collab",
29
29
  "stream",
30
30
  "vim",
31
31
  ] as const;