@golba98/codexa 1.0.2 → 1.0.3

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 (150) hide show
  1. package/README.md +391 -94
  2. package/package.json +12 -7
  3. package/src/app.tsx +149 -117
  4. package/src/commands/handler.ts +4 -4
  5. package/src/config/buildInfo.ts +2 -2
  6. package/src/config/persistence.ts +10 -0
  7. package/src/config/settings.ts +7 -15
  8. package/src/config/updateCheckCache.ts +19 -1
  9. package/src/core/channel.ts +23 -0
  10. package/src/core/executables/codexExecutable.ts +1 -0
  11. package/src/core/executables/executableResolver.ts +61 -43
  12. package/src/core/launchContext.ts +33 -33
  13. package/src/core/process/processValidation.ts +9 -5
  14. package/src/core/providerLauncher/launcher.ts +59 -42
  15. package/src/core/updateCheck.ts +111 -95
  16. package/src/session/types.ts +2 -1
  17. package/src/ui/ActionRequiredBlock.tsx +5 -5
  18. package/src/ui/ActivityBars.tsx +3 -3
  19. package/src/ui/ActivityIndicator.tsx +6 -6
  20. package/src/ui/AgentBlock.tsx +6 -6
  21. package/src/ui/AnimatedStatusText.tsx +1 -1
  22. package/src/ui/AppShell.tsx +9 -24
  23. package/src/ui/AttachmentImportPanel.tsx +8 -8
  24. package/src/ui/AuthPanel.tsx +20 -20
  25. package/src/ui/BottomComposer.tsx +117 -78
  26. package/src/ui/DashCard.tsx +3 -3
  27. package/src/ui/Markdown.tsx +17 -17
  28. package/src/ui/ModelPickerScreen.tsx +10 -10
  29. package/src/ui/ModelReasoningPicker.tsx +14 -14
  30. package/src/ui/Panel.tsx +3 -3
  31. package/src/ui/PlanActionPicker.tsx +6 -6
  32. package/src/ui/PlanReviewPanel.tsx +8 -8
  33. package/src/ui/ProviderPicker.tsx +18 -18
  34. package/src/ui/RunFooter.tsx +3 -3
  35. package/src/ui/SelectionPanel.tsx +4 -4
  36. package/src/ui/SettingsPanel.tsx +8 -8
  37. package/src/ui/Spinner.tsx +1 -1
  38. package/src/ui/TextEntryPanel.tsx +10 -10
  39. package/src/ui/ThinkingBlock.tsx +8 -8
  40. package/src/ui/Timeline.tsx +21 -17
  41. package/src/ui/TopHeader.tsx +421 -293
  42. package/src/ui/TurnGroup.tsx +31 -31
  43. package/src/ui/UpdateAvailableCard.tsx +41 -0
  44. package/src/ui/UpdatePromptPanel.tsx +203 -0
  45. package/src/ui/focus.ts +3 -0
  46. package/src/ui/layout.ts +1 -1
  47. package/src/ui/logoVariants.ts +107 -0
  48. package/src/ui/modeDisplay.ts +12 -12
  49. package/src/ui/runtimeDisplay.ts +100 -0
  50. package/src/ui/theme.tsx +274 -395
  51. package/src/ui/timelineMeasure.ts +29 -19
  52. package/scripts/audit-codexa-capabilities.mjs +0 -466
  53. package/scripts/gen-build-info.mjs +0 -33
  54. package/scripts/smoke-terminal-bench.mjs +0 -35
  55. package/src/appRenderStability.test.ts +0 -131
  56. package/src/commands/handler.test.ts +0 -655
  57. package/src/config/launchArgs.test.ts +0 -189
  58. package/src/config/layeredConfig.test.ts +0 -143
  59. package/src/config/persistence.test.ts +0 -114
  60. package/src/config/runtimeConfig.test.ts +0 -218
  61. package/src/config/settings.test.ts +0 -155
  62. package/src/config/trustStore.test.ts +0 -29
  63. package/src/core/attachments.test.ts +0 -155
  64. package/src/core/auth/codexAuth.test.ts +0 -68
  65. package/src/core/cleanupFastFail.test.ts +0 -76
  66. package/src/core/codexExecArgs.test.ts +0 -195
  67. package/src/core/codexLaunch.test.ts +0 -205
  68. package/src/core/codexPrompt.test.ts +0 -252
  69. package/src/core/executables/codexExecutable.test.ts +0 -212
  70. package/src/core/executables/executableResolver.test.ts +0 -129
  71. package/src/core/executables/geminiExecutable.test.ts +0 -116
  72. package/src/core/executables/pathSanityScan.test.ts +0 -47
  73. package/src/core/githubDiagnostics.test.ts +0 -92
  74. package/src/core/hollowResponseFormat.test.ts +0 -58
  75. package/src/core/launchContext.test.ts +0 -157
  76. package/src/core/models/codexCapabilities.test.ts +0 -45
  77. package/src/core/models/codexModelCapabilities.test.ts +0 -246
  78. package/src/core/models/modelSpecs.test.ts +0 -283
  79. package/src/core/perf/renderDebug.test.ts +0 -230
  80. package/src/core/planStorage.test.ts +0 -143
  81. package/src/core/process/CommandRunner.test.ts +0 -105
  82. package/src/core/projectInstructions.test.ts +0 -50
  83. package/src/core/providerLauncher/launcher.test.ts +0 -238
  84. package/src/core/providerLauncher/registry.test.ts +0 -324
  85. package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
  86. package/src/core/providerRuntime/anthropic.test.ts +0 -1120
  87. package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
  88. package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
  89. package/src/core/providerRuntime/gemini.test.ts +0 -437
  90. package/src/core/providerRuntime/lmstudio.test.ts +0 -168
  91. package/src/core/providerRuntime/local.test.ts +0 -787
  92. package/src/core/providerRuntime/registry.test.ts +0 -233
  93. package/src/core/providers/codexJsonStream.test.ts +0 -148
  94. package/src/core/providers/codexSubprocess.test.ts +0 -68
  95. package/src/core/providers/codexTranscript.test.ts +0 -284
  96. package/src/core/terminal/startupClear.test.ts +0 -55
  97. package/src/core/terminal/terminalCapabilities.test.ts +0 -93
  98. package/src/core/terminal/terminalControl.test.ts +0 -75
  99. package/src/core/terminal/terminalSanitize.test.ts +0 -22
  100. package/src/core/terminal/terminalSelection.test.ts +0 -42
  101. package/src/core/terminal/terminalTitle.test.ts +0 -328
  102. package/src/core/updateCheck.test.ts +0 -194
  103. package/src/core/workspaceActivity.test.ts +0 -163
  104. package/src/core/workspaceGuard.test.ts +0 -151
  105. package/src/core/workspaceRoot.test.ts +0 -23
  106. package/src/exec.test.ts +0 -13
  107. package/src/headless/execArgs.test.ts +0 -147
  108. package/src/headless/execRunner.test.ts +0 -436
  109. package/src/index.test.tsx +0 -620
  110. package/src/session/appSession.test.ts +0 -897
  111. package/src/session/chatLifecycle.test.ts +0 -64
  112. package/src/session/liveRenderScheduler.test.ts +0 -201
  113. package/src/session/planFlow.test.ts +0 -103
  114. package/src/session/planTranscript.test.ts +0 -65
  115. package/src/session/promptRunSchedule.test.ts +0 -36
  116. package/src/ui/ActivityIndicator.test.tsx +0 -58
  117. package/src/ui/AgentBlock.test.ts +0 -6
  118. package/src/ui/AnimatedStatusText.test.ts +0 -16
  119. package/src/ui/AppShell.test.tsx +0 -1776
  120. package/src/ui/AttachmentImportPanel.test.tsx +0 -204
  121. package/src/ui/BottomComposer.test.ts +0 -674
  122. package/src/ui/CodexLogo.tsx +0 -55
  123. package/src/ui/Markdown.test.ts +0 -157
  124. package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
  125. package/src/ui/ModelPickerScreen.test.tsx +0 -99
  126. package/src/ui/ModelPickerState.test.tsx +0 -151
  127. package/src/ui/ModelReasoningPicker.test.tsx +0 -447
  128. package/src/ui/PlanReviewPanel.test.tsx +0 -267
  129. package/src/ui/PromptCardBorder.test.tsx +0 -161
  130. package/src/ui/ProviderPicker.test.tsx +0 -289
  131. package/src/ui/ProviderShortcut.test.tsx +0 -143
  132. package/src/ui/SettingsPanel.test.tsx +0 -233
  133. package/src/ui/Timeline.test.ts +0 -2067
  134. package/src/ui/TimelineNavigation.test.tsx +0 -201
  135. package/src/ui/TopHeader.test.tsx +0 -254
  136. package/src/ui/TurnGroup.test.tsx +0 -365
  137. package/src/ui/busyStatusAnimation.test.ts +0 -30
  138. package/src/ui/commandNormalize.test.ts +0 -142
  139. package/src/ui/diffRenderer.test.ts +0 -102
  140. package/src/ui/focusFlow.test.tsx +0 -1098
  141. package/src/ui/inputBuffer.test.ts +0 -151
  142. package/src/ui/layout.test.ts +0 -146
  143. package/src/ui/modeDisplay.test.ts +0 -42
  144. package/src/ui/runActivityView.test.ts +0 -89
  145. package/src/ui/runLifecycleView.test.tsx +0 -237
  146. package/src/ui/statusRenderIsolation.test.tsx +0 -654
  147. package/src/ui/terminalAnswerFormat.test.ts +0 -19
  148. package/src/ui/textLayout.test.ts +0 -18
  149. package/src/ui/themeFlow.test.ts +0 -53
  150. package/src/ui/timelineMeasureCache.test.ts +0 -986
@@ -1,674 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import {
4
- getCommandSuggestionState,
5
- getComposerToFooterGapRows,
6
- getComposerPersona,
7
- getTokenBarDisplay,
8
- getVisibleComposerStatusLine,
9
- measureBottomComposerRows,
10
- } from "./BottomComposer.js";
11
- import { createLayoutSnapshot } from "./layout.js";
12
- import { getSlashCommandSuggestions } from "./slashCommands.js";
13
- import type { PendingModelSpec, VerifiedModelSpec } from "../core/models/modelSpecs.js";
14
-
15
- test("maps the idle state to the idle composer persona", () => {
16
- assert.equal(getComposerPersona({ kind: "IDLE" }), "idle");
17
- });
18
-
19
- test("maps busy, answer, and error states to the right personas", () => {
20
- assert.equal(getComposerPersona({ kind: "THINKING", turnId: 1 }), "busy");
21
- assert.equal(getComposerPersona({ kind: "RESPONDING", turnId: 1 }), "busy");
22
- assert.equal(getComposerPersona({ kind: "SHELL_RUNNING", shellId: 7 }), "busy");
23
- assert.equal(getComposerPersona({ kind: "AWAITING_USER_ACTION", turnId: 2, question: "Need Redis?" }), "answer");
24
- assert.equal(getComposerPersona({ kind: "ERROR", turnId: 3, message: "Boom" }), "error");
25
- });
26
-
27
- test("measures the standard composer rows from the rendered prompt state", () => {
28
- const rows = measureBottomComposerRows({
29
- layout: createLayoutSnapshot(100, 30),
30
- uiState: { kind: "IDLE" },
31
- mode: "auto-edit",
32
- model: "gpt-5.4",
33
- reasoningLevel: "medium",
34
- tokensUsed: 1200,
35
- value: "",
36
- cursor: 0,
37
- });
38
-
39
- assert.equal(rows, 7);
40
- });
41
-
42
- test("adds a measured footer gap only when the viewport has room", () => {
43
- assert.equal(getComposerToFooterGapRows(createLayoutSnapshot(100, 30)), 1);
44
- assert.equal(getComposerToFooterGapRows(createLayoutSnapshot(100, 24)), 0);
45
- assert.equal(getComposerToFooterGapRows(createLayoutSnapshot(39, 30)), 0);
46
- });
47
-
48
- test("uses the run footer row budget in cramped busy viewports", () => {
49
- const rows = measureBottomComposerRows({
50
- layout: createLayoutSnapshot(80, 24),
51
- uiState: { kind: "THINKING", turnId: 1 },
52
- value: "",
53
- cursor: 0,
54
- });
55
-
56
- assert.equal(rows, 4);
57
- });
58
-
59
- test("does not render an exact slash command draft as a suggestion row", () => {
60
- const exact = getCommandSuggestionState({
61
- value: "/clear",
62
- allowCommands: true,
63
- inputLocked: false,
64
- });
65
-
66
- assert.equal(exact.showSuggestions, true);
67
- assert.equal(exact.reserveSuggestionRow, true);
68
- assert.deepEqual(exact.suggestions.map((suggestion) => suggestion.cmd), []);
69
- });
70
-
71
- test("keeps partial slash command suggestions visible", () => {
72
- const partial = getCommandSuggestionState({
73
- value: "/clea",
74
- allowCommands: true,
75
- inputLocked: false,
76
- });
77
-
78
- assert.equal(partial.showSuggestions, true);
79
- assert.equal(partial.reserveSuggestionRow, true);
80
- assert.deepEqual(partial.suggestions.map((suggestion) => suggestion.cmd), ["/clear"]);
81
- });
82
-
83
- test("surfaces the provider picker suggestion for root prefixes and alias input", () => {
84
- const rootSuggestions = getCommandSuggestionState({
85
- value: "/",
86
- allowCommands: true,
87
- inputLocked: false,
88
- });
89
-
90
- assert.equal(rootSuggestions.showSuggestions, true);
91
- assert.ok(rootSuggestions.suggestions.map((suggestion) => suggestion.cmd).includes("/providers"));
92
-
93
- const pSuggestions = getCommandSuggestionState({
94
- value: "/p",
95
- allowCommands: true,
96
- inputLocked: false,
97
- });
98
-
99
- assert.ok(pSuggestions.suggestions.map((suggestion) => suggestion.cmd).includes("/providers"));
100
-
101
- const shortProviderSuggestions = getCommandSuggestionState({
102
- value: "/pro",
103
- allowCommands: true,
104
- inputLocked: false,
105
- });
106
-
107
- assert.ok(shortProviderSuggestions.suggestions.map((suggestion) => suggestion.cmd).includes("/providers"));
108
-
109
- const prefixProviderSuggestions = getCommandSuggestionState({
110
- value: "/pr",
111
- allowCommands: true,
112
- inputLocked: false,
113
- });
114
-
115
- assert.ok(prefixProviderSuggestions.suggestions.map((suggestion) => suggestion.cmd).includes("/providers"));
116
-
117
- const providerSuggestions = getCommandSuggestionState({
118
- value: "/provider",
119
- allowCommands: true,
120
- inputLocked: false,
121
- });
122
-
123
- assert.equal(providerSuggestions.showSuggestions, true);
124
- assert.deepEqual(providerSuggestions.suggestions.map((suggestion) => suggestion.cmd), ["/providers"]);
125
-
126
- const exactProviderSuggestions = getCommandSuggestionState({
127
- value: "/providers",
128
- allowCommands: true,
129
- inputLocked: false,
130
- });
131
-
132
- assert.equal(exactProviderSuggestions.showSuggestions, true);
133
- assert.deepEqual(exactProviderSuggestions.suggestions.map((suggestion) => suggestion.cmd), ["/providers"]);
134
-
135
- const aliasMetadata = getSlashCommandSuggestions("/provider").find((suggestion) => suggestion.cmd === "/providers");
136
- assert.deepEqual(aliasMetadata?.aliases, ["/provider"]);
137
- });
138
-
139
- test("keeps exact and partial slash command row budgets stable", () => {
140
- const layout = createLayoutSnapshot(100, 30);
141
- const base = {
142
- layout,
143
- uiState: { kind: "IDLE" } as const,
144
- value: "",
145
- cursor: 0,
146
- };
147
-
148
- const partialRows = measureBottomComposerRows({
149
- ...base,
150
- value: "/clea",
151
- cursor: "/clea".length,
152
- });
153
- const exactRows = measureBottomComposerRows({
154
- ...base,
155
- value: "/clear",
156
- cursor: "/clear".length,
157
- });
158
-
159
- assert.equal(exactRows, partialRows);
160
- });
161
-
162
- test("suppresses completed response status while a slash command draft is active", () => {
163
- assert.equal(
164
- getVisibleComposerStatusLine({
165
- uiState: { kind: "ANSWER_VISIBLE", turnId: 1 },
166
- value: "/clear",
167
- allowCommands: true,
168
- }),
169
- "",
170
- );
171
-
172
- assert.equal(
173
- getVisibleComposerStatusLine({
174
- uiState: { kind: "ANSWER_VISIBLE", turnId: 1 },
175
- value: "next prompt",
176
- allowCommands: true,
177
- }),
178
- "✧ Codexa response complete",
179
- );
180
- });
181
-
182
- test("shows Gemini-specific status when THINKING with google provider at 0 seconds", () => {
183
- assert.equal(
184
- getVisibleComposerStatusLine({
185
- uiState: { kind: "THINKING", turnId: 1 },
186
- value: "",
187
- allowCommands: true,
188
- activeProviderId: "google",
189
- runElapsedSeconds: 0,
190
- }),
191
- "Starting Gemini CLI",
192
- );
193
- });
194
-
195
- test("includes elapsed timer in Gemini status after first second", () => {
196
- assert.equal(
197
- getVisibleComposerStatusLine({
198
- uiState: { kind: "THINKING", turnId: 1 },
199
- value: "",
200
- allowCommands: true,
201
- activeProviderId: "google",
202
- runElapsedSeconds: 3,
203
- }),
204
- "Starting Gemini CLI 00:03",
205
- );
206
- });
207
-
208
- test("shows reassurance message in Gemini status at 5 seconds", () => {
209
- assert.equal(
210
- getVisibleComposerStatusLine({
211
- uiState: { kind: "THINKING", turnId: 1 },
212
- value: "",
213
- allowCommands: true,
214
- activeProviderId: "google",
215
- runElapsedSeconds: 5,
216
- }),
217
- "Gemini CLI is still starting. The upstream CLI can take a moment 00:05",
218
- );
219
- });
220
-
221
- test("shows still waiting message in Gemini status at 15 seconds", () => {
222
- assert.equal(
223
- getVisibleComposerStatusLine({
224
- uiState: { kind: "THINKING", turnId: 1 },
225
- value: "",
226
- allowCommands: true,
227
- activeProviderId: "google",
228
- runElapsedSeconds: 15,
229
- }),
230
- "Still waiting for Gemini CLI 00:15",
231
- );
232
- });
233
-
234
- test("shows generic thinking status for unknown/local provider", () => {
235
- assert.equal(
236
- getVisibleComposerStatusLine({
237
- uiState: { kind: "THINKING", turnId: 1 },
238
- value: "",
239
- allowCommands: true,
240
- activeProviderId: "local",
241
- runElapsedSeconds: 10,
242
- }),
243
- "✧ Codexa is thinking",
244
- );
245
- });
246
-
247
- test("shows Starting Claude Code at 0 seconds for anthropic provider", () => {
248
- assert.equal(
249
- getVisibleComposerStatusLine({
250
- uiState: { kind: "THINKING", turnId: 1 },
251
- value: "",
252
- allowCommands: true,
253
- activeProviderId: "anthropic",
254
- runElapsedSeconds: 0,
255
- }),
256
- "Starting Claude Code",
257
- );
258
- });
259
-
260
- test("includes elapsed timer in Claude Code status after first second", () => {
261
- assert.equal(
262
- getVisibleComposerStatusLine({
263
- uiState: { kind: "THINKING", turnId: 1 },
264
- value: "",
265
- allowCommands: true,
266
- activeProviderId: "anthropic",
267
- runElapsedSeconds: 3,
268
- }),
269
- "Starting Claude Code 00:03",
270
- );
271
- });
272
-
273
- test("shows reassurance message at 5 seconds for Claude Code", () => {
274
- assert.equal(
275
- getVisibleComposerStatusLine({
276
- uiState: { kind: "THINKING", turnId: 1 },
277
- value: "",
278
- allowCommands: true,
279
- activeProviderId: "anthropic",
280
- runElapsedSeconds: 5,
281
- }),
282
- "Claude Code is still starting. The upstream CLI can take a moment 00:05",
283
- );
284
- });
285
-
286
- test("shows still waiting message at 15 seconds for Claude Code", () => {
287
- assert.equal(
288
- getVisibleComposerStatusLine({
289
- uiState: { kind: "THINKING", turnId: 1 },
290
- value: "",
291
- allowCommands: true,
292
- activeProviderId: "anthropic",
293
- runElapsedSeconds: 15,
294
- }),
295
- "Still waiting for Claude Code 00:15",
296
- );
297
- });
298
-
299
- test("shows Starting Codex CLI at 0 seconds for openai provider", () => {
300
- assert.equal(
301
- getVisibleComposerStatusLine({
302
- uiState: { kind: "THINKING", turnId: 1 },
303
- value: "",
304
- allowCommands: true,
305
- activeProviderId: "openai",
306
- runElapsedSeconds: 0,
307
- }),
308
- "Starting Codex CLI",
309
- );
310
- });
311
-
312
- test("includes elapsed timer in Codex CLI status after first second", () => {
313
- assert.equal(
314
- getVisibleComposerStatusLine({
315
- uiState: { kind: "THINKING", turnId: 1 },
316
- value: "",
317
- allowCommands: true,
318
- activeProviderId: "openai",
319
- runElapsedSeconds: 3,
320
- }),
321
- "Starting Codex CLI 00:03",
322
- );
323
- });
324
-
325
- test("shows Gemini ready status when RESPONDING with google provider", () => {
326
- assert.equal(
327
- getVisibleComposerStatusLine({
328
- uiState: { kind: "RESPONDING", turnId: 1 },
329
- value: "",
330
- allowCommands: true,
331
- activeProviderId: "google",
332
- }),
333
- "✧ Gemini ready",
334
- );
335
- });
336
-
337
- test("shows Claude ready status when RESPONDING with anthropic provider", () => {
338
- assert.equal(
339
- getVisibleComposerStatusLine({
340
- uiState: { kind: "RESPONDING", turnId: 1 },
341
- value: "",
342
- allowCommands: true,
343
- activeProviderId: "anthropic",
344
- }),
345
- "✧ Claude ready",
346
- );
347
- });
348
-
349
- test("shows Codex ready status when RESPONDING with openai provider", () => {
350
- assert.equal(
351
- getVisibleComposerStatusLine({
352
- uiState: { kind: "RESPONDING", turnId: 1 },
353
- value: "",
354
- allowCommands: true,
355
- activeProviderId: "openai",
356
- }),
357
- "✧ Codex ready",
358
- );
359
- });
360
-
361
- test("shows generic thinking status when RESPONDING with unknown provider", () => {
362
- assert.equal(
363
- getVisibleComposerStatusLine({
364
- uiState: { kind: "RESPONDING", turnId: 1 },
365
- value: "",
366
- allowCommands: true,
367
- activeProviderId: "local",
368
- }),
369
- "✧ Codexa is thinking",
370
- );
371
- });
372
-
373
- test("shows error message in status for google provider in ERROR state regardless of elapsed time", () => {
374
- assert.equal(
375
- getVisibleComposerStatusLine({
376
- uiState: { kind: "ERROR", turnId: 1, message: "Gemini CLI failed to start" },
377
- value: "",
378
- allowCommands: true,
379
- activeProviderId: "google",
380
- runElapsedSeconds: 30,
381
- }),
382
- "Gemini CLI failed to start",
383
- );
384
- });
385
-
386
- test("shows error message in status for anthropic provider in ERROR state regardless of elapsed time", () => {
387
- assert.equal(
388
- getVisibleComposerStatusLine({
389
- uiState: { kind: "ERROR", turnId: 1, message: "Claude Code failed to start" },
390
- value: "",
391
- allowCommands: true,
392
- activeProviderId: "anthropic",
393
- runElapsedSeconds: 30,
394
- }),
395
- "Claude Code failed to start",
396
- );
397
- });
398
-
399
- test("getTokenBarDisplay returns null percentage (not 0) for an unknown spec", () => {
400
- const spec: PendingModelSpec = {
401
- status: "unknown",
402
- contextWindow: null,
403
- maxOutputTokens: null,
404
- sourceUrl: "",
405
- verifiedAt: null,
406
- error: null,
407
- };
408
- const display = getTokenBarDisplay(5_000, spec);
409
- assert.equal(display.percentage, null, "percentage must be null, not 0, for unknown specs");
410
- assert.equal(display.usedText, "Context");
411
- assert.equal(display.limitText, "Unknown");
412
- assert.equal(display.isEstimatedLimit, false);
413
- assert.equal(display.hasKnownLimit, false);
414
- });
415
-
416
- test("getTokenBarDisplay returns correct non-null percentage for a verified spec", () => {
417
- const spec: VerifiedModelSpec = {
418
- status: "verified",
419
- contextWindow: 200_000,
420
- maxOutputTokens: 64_000,
421
- sourceUrl: "",
422
- verifiedAt: 0,
423
- };
424
- const display = getTokenBarDisplay(10_000, spec);
425
- assert.equal(display.percentage, 5);
426
- assert.notEqual(display.percentage, null);
427
- assert.equal(display.isEstimatedLimit, false);
428
- assert.equal(display.hasKnownLimit, true);
429
- assert.equal(display.usedText, "10,000", "usedText should be exact number with thousands separator");
430
- });
431
-
432
- test("getTokenBarDisplay formats refreshed LM Studio context meter", () => {
433
- const spec: VerifiedModelSpec = {
434
- status: "verified",
435
- contextWindow: 32_000,
436
- maxOutputTokens: 32_000,
437
- sourceUrl: "lmstudio-api",
438
- verifiedAt: 0,
439
- };
440
- const display = getTokenBarDisplay(0, spec);
441
- assert.equal(display.usedText, "0");
442
- assert.equal(display.limitText, "32,000");
443
- assert.equal(display.percentage, 0);
444
- assert.equal(display.hasKnownLimit, true);
445
- });
446
-
447
- test("getTokenBarDisplay does not add ~ prefix for a documented verified context window", () => {
448
- const spec: VerifiedModelSpec = {
449
- status: "verified",
450
- contextWindow: 200_000,
451
- maxOutputTokens: 64_000,
452
- sourceUrl: "",
453
- verifiedAt: 0,
454
- };
455
- const display = getTokenBarDisplay(10_000, spec);
456
- assert.equal(display.isEstimatedLimit, false);
457
- assert.ok(!display.limitText.startsWith("~"), "verified limitText must not start with ~");
458
- });
459
-
460
- // ─── externalCliStatus: provider readiness gate ───────────────────────────────
461
-
462
- test("shows 'Codexa is thinking' (not startup message) when provider is ready and THINKING — google", () => {
463
- assert.equal(
464
- getVisibleComposerStatusLine({
465
- uiState: { kind: "THINKING", turnId: 2 },
466
- value: "",
467
- allowCommands: true,
468
- activeProviderId: "google",
469
- runElapsedSeconds: 0,
470
- externalCliStatus: "ready",
471
- }),
472
- "✧ Codexa is thinking",
473
- );
474
- });
475
-
476
- test("shows 'Codexa is thinking' even at 20 seconds elapsed when provider is ready — google", () => {
477
- assert.equal(
478
- getVisibleComposerStatusLine({
479
- uiState: { kind: "THINKING", turnId: 2 },
480
- value: "",
481
- allowCommands: true,
482
- activeProviderId: "google",
483
- runElapsedSeconds: 20,
484
- externalCliStatus: "ready",
485
- }),
486
- "✧ Codexa is thinking",
487
- );
488
- });
489
-
490
- test("shows 'Codexa is thinking' (not startup message) when provider is ready and THINKING — anthropic", () => {
491
- assert.equal(
492
- getVisibleComposerStatusLine({
493
- uiState: { kind: "THINKING", turnId: 2 },
494
- value: "",
495
- allowCommands: true,
496
- activeProviderId: "anthropic",
497
- runElapsedSeconds: 0,
498
- externalCliStatus: "ready",
499
- }),
500
- "✧ Codexa is thinking",
501
- );
502
- });
503
-
504
- test("shows 'Codexa is thinking' (not startup message) when provider is ready and THINKING — openai", () => {
505
- assert.equal(
506
- getVisibleComposerStatusLine({
507
- uiState: { kind: "THINKING", turnId: 2 },
508
- value: "",
509
- allowCommands: true,
510
- activeProviderId: "openai",
511
- runElapsedSeconds: 0,
512
- externalCliStatus: "ready",
513
- }),
514
- "✧ Codexa is thinking",
515
- );
516
- });
517
-
518
- test("still shows startup messages when externalCliStatus is 'starting' — google at 0 seconds", () => {
519
- assert.equal(
520
- getVisibleComposerStatusLine({
521
- uiState: { kind: "THINKING", turnId: 1 },
522
- value: "",
523
- allowCommands: true,
524
- activeProviderId: "google",
525
- runElapsedSeconds: 0,
526
- externalCliStatus: "starting",
527
- }),
528
- "Starting Gemini CLI",
529
- );
530
- });
531
-
532
- test("still shows 'Still waiting' when externalCliStatus is 'starting' at 15 seconds — google", () => {
533
- assert.equal(
534
- getVisibleComposerStatusLine({
535
- uiState: { kind: "THINKING", turnId: 1 },
536
- value: "",
537
- allowCommands: true,
538
- activeProviderId: "google",
539
- runElapsedSeconds: 15,
540
- externalCliStatus: "starting",
541
- }),
542
- "Still waiting for Gemini CLI 00:15",
543
- );
544
- });
545
-
546
- test("still shows startup messages when externalCliStatus is 'idle' (first prompt, not yet starting)", () => {
547
- assert.equal(
548
- getVisibleComposerStatusLine({
549
- uiState: { kind: "THINKING", turnId: 1 },
550
- value: "",
551
- allowCommands: true,
552
- activeProviderId: "google",
553
- runElapsedSeconds: 0,
554
- externalCliStatus: "idle",
555
- }),
556
- "Starting Gemini CLI",
557
- );
558
- });
559
-
560
- test("regression: second prompt with ready provider never shows 'Still waiting for Gemini CLI'", () => {
561
- const statusLine = getVisibleComposerStatusLine({
562
- uiState: { kind: "THINKING", turnId: 2 },
563
- value: "",
564
- allowCommands: true,
565
- activeProviderId: "google",
566
- runElapsedSeconds: 20,
567
- externalCliStatus: "ready",
568
- });
569
- assert.ok(
570
- !/Still waiting for Gemini CLI|Starting Gemini CLI|Checking Gemini/i.test(statusLine),
571
- `Expected no startup text but got: "${statusLine}"`,
572
- );
573
- });
574
-
575
- // ─── getTokenBarDisplay — new format ─────────────────────────────────────────
576
-
577
- test("getTokenBarDisplay(0, 64k spec) shows '0' usedText and '64,000' limitText, not Unknown", () => {
578
- const spec: VerifiedModelSpec = {
579
- status: "verified",
580
- contextWindow: 64_000,
581
- maxOutputTokens: 64_000,
582
- sourceUrl: "",
583
- verifiedAt: 0,
584
- };
585
- const display = getTokenBarDisplay(0, spec);
586
- assert.equal(display.hasKnownLimit, true, "64k verified spec must have known limit");
587
- assert.equal(display.usedText, "0", "0 tokens used renders as '0'");
588
- assert.equal(display.limitText, "64,000");
589
- assert.equal(display.percentage, 0);
590
- });
591
-
592
- test("getTokenBarDisplay uses Math.floor — 1999/200000 rounds down to 0%", () => {
593
- const spec: VerifiedModelSpec = {
594
- status: "verified",
595
- contextWindow: 200_000,
596
- maxOutputTokens: 200_000,
597
- sourceUrl: "",
598
- verifiedAt: 0,
599
- };
600
- const display = getTokenBarDisplay(1_999, spec);
601
- // floor(1999/200000*100) = floor(0.9995) = 0; Math.round would give 1
602
- assert.equal(display.percentage, 0, "percentage must use Math.floor, not Math.round");
603
- });
604
-
605
- test("getTokenBarDisplay unknown spec regression — hasKnownLimit is false", () => {
606
- const spec: PendingModelSpec = {
607
- status: "unknown",
608
- contextWindow: null,
609
- maxOutputTokens: null,
610
- sourceUrl: "",
611
- verifiedAt: null,
612
- error: null,
613
- };
614
- assert.equal(getTokenBarDisplay(99_999, spec).hasKnownLimit, false);
615
- });
616
-
617
- // ─── getTokenBarDisplay — estimated specs ─────────────────────────────────────
618
-
619
- test("getTokenBarDisplay with isEstimated spec returns limitText with ~ prefix and compact format", () => {
620
- const spec: VerifiedModelSpec = {
621
- status: "verified",
622
- contextWindow: 400_000,
623
- maxOutputTokens: 400_000,
624
- sourceUrl: "known-registry",
625
- verifiedAt: 0,
626
- isEstimated: true,
627
- };
628
- const display = getTokenBarDisplay(0, spec);
629
- assert.equal(display.limitText, "~400K");
630
- assert.equal(display.isEstimatedLimit, true);
631
- assert.equal(display.hasKnownLimit, true);
632
- });
633
-
634
- test("getTokenBarDisplay with isEstimated spec still has correct percentage", () => {
635
- const spec: VerifiedModelSpec = {
636
- status: "verified",
637
- contextWindow: 400_000,
638
- maxOutputTokens: 400_000,
639
- sourceUrl: "known-registry",
640
- verifiedAt: 0,
641
- isEstimated: true,
642
- };
643
- const display = getTokenBarDisplay(40_000, spec);
644
- assert.equal(display.percentage, 10);
645
- assert.equal(display.hasKnownLimit, true);
646
- });
647
-
648
- test("getTokenBarDisplay with isEstimated uses compact M suffix for 1M context", () => {
649
- const spec: VerifiedModelSpec = {
650
- status: "verified",
651
- contextWindow: 1_048_576,
652
- maxOutputTokens: 1_048_576,
653
- sourceUrl: "known-registry",
654
- verifiedAt: 0,
655
- isEstimated: true,
656
- };
657
- const display = getTokenBarDisplay(0, spec);
658
- assert.equal(display.limitText, "~1.0M");
659
- assert.equal(display.isEstimatedLimit, true);
660
- });
661
-
662
- test("getTokenBarDisplay with isEstimated: false uses comma format (regression guard)", () => {
663
- const spec: VerifiedModelSpec = {
664
- status: "verified",
665
- contextWindow: 400_000,
666
- maxOutputTokens: 400_000,
667
- sourceUrl: "",
668
- verifiedAt: 0,
669
- isEstimated: false,
670
- };
671
- const display = getTokenBarDisplay(0, spec);
672
- assert.equal(display.limitText, "400,000");
673
- assert.equal(display.isEstimatedLimit, false);
674
- });