@golba98/codexa 1.0.2 → 1.0.4

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 (206) hide show
  1. package/README.md +396 -100
  2. package/bin/codexa.js +62 -144
  3. package/package.json +14 -8
  4. package/src/app.tsx +596 -306
  5. package/src/commands/handler.ts +6 -6
  6. package/src/config/buildInfo.ts +2 -2
  7. package/src/config/layeredConfig.ts +1 -1
  8. package/src/config/persistence.ts +10 -0
  9. package/src/config/runtimeConfig.ts +1 -1
  10. package/src/config/settings.ts +8 -16
  11. package/src/config/trustStore.ts +1 -1
  12. package/src/config/updateCheckCache.ts +19 -1
  13. package/src/core/README.md +52 -0
  14. package/src/core/agent/loop.ts +282 -0
  15. package/src/core/agent/protocol.ts +211 -0
  16. package/src/core/agent/tools.ts +414 -0
  17. package/src/core/{codexExecArgs.ts → codex/codexExecArgs.ts} +2 -2
  18. package/src/core/{codexLaunch.ts → codex/codexLaunch.ts} +3 -3
  19. package/src/core/{codexPrompt.ts → codex/codexPrompt.ts} +3 -3
  20. package/src/core/debug/modelStateDebug.ts +34 -0
  21. package/src/core/executables/antigravityExecutable.ts +48 -0
  22. package/src/core/executables/codexExecutable.ts +1 -0
  23. package/src/core/executables/executableResolver.ts +65 -43
  24. package/src/core/perf/renderDebug.ts +10 -6
  25. package/src/core/process/processValidation.ts +9 -5
  26. package/src/core/providerLauncher/launcher.ts +59 -42
  27. package/src/core/providerLauncher/registry.ts +30 -14
  28. package/src/core/providerLauncher/types.ts +11 -9
  29. package/src/core/providerLauncher/workspaceConfig.ts +41 -26
  30. package/src/core/providerRuntime/anthropic.ts +7 -1
  31. package/src/core/providerRuntime/antigravity.ts +305 -0
  32. package/src/core/providerRuntime/claudeCodeDiscovery.ts +268 -22
  33. package/src/core/providerRuntime/claudeCodeDiscoveryDebug.ts +55 -0
  34. package/src/core/providerRuntime/contextMetadata.ts +12 -24
  35. package/src/core/providerRuntime/local.ts +129 -51
  36. package/src/core/providerRuntime/models.ts +22 -11
  37. package/src/core/providerRuntime/registry.ts +58 -31
  38. package/src/core/providerRuntime/types.ts +19 -14
  39. package/src/core/providers/codexSubprocess.ts +2 -2
  40. package/src/core/providers/types.ts +1 -1
  41. package/src/core/{attachments.ts → shared/attachments.ts} +27 -4
  42. package/src/core/{cleanupFastFail.ts → shared/cleanupFastFail.ts} +1 -1
  43. package/src/core/{hollowResponseFormat.ts → shared/hollowResponseFormat.ts} +1 -1
  44. package/src/core/terminal/clearFrameBoundary.ts +814 -0
  45. package/src/core/terminal/frameLock.ts +109 -0
  46. package/src/core/terminal/inkRenderReset.ts +123 -0
  47. package/src/core/terminal/terminalControl.ts +22 -0
  48. package/src/core/terminal/terminalTitle.ts +16 -102
  49. package/src/core/version/channel.ts +23 -0
  50. package/src/core/version/updateCheck.ts +193 -0
  51. package/src/core/{launchContext.ts → workspace/launchContext.ts} +32 -39
  52. package/src/core/{planStorage.ts → workspace/planStorage.ts} +2 -2
  53. package/src/core/{workspaceGuard.ts → workspace/workspaceGuard.ts} +97 -13
  54. package/src/headless/execRunner.ts +2 -2
  55. package/src/index.tsx +43 -89
  56. package/src/session/appSession.ts +10 -7
  57. package/src/session/chatLifecycle.ts +1 -1
  58. package/src/session/liveRenderScheduler.ts +1 -1
  59. package/src/session/types.ts +3 -2
  60. package/src/ui/ActionRequiredBlock.tsx +5 -5
  61. package/src/ui/ActivityBars.tsx +3 -3
  62. package/src/ui/ActivityIndicator.tsx +6 -6
  63. package/src/ui/AgentBlock.tsx +6 -6
  64. package/src/ui/AnimatedStatusText.tsx +1 -1
  65. package/src/ui/AppShell.tsx +670 -719
  66. package/src/ui/AttachmentImportPanel.tsx +8 -8
  67. package/src/ui/AuthPanel.tsx +20 -20
  68. package/src/ui/BottomComposer.tsx +158 -118
  69. package/src/ui/DashCard.tsx +3 -3
  70. package/src/ui/Markdown.tsx +17 -17
  71. package/src/ui/ModelPickerScreen.tsx +222 -42
  72. package/src/ui/ModelReasoningPicker.tsx +15 -15
  73. package/src/ui/Panel.tsx +3 -3
  74. package/src/ui/PlanActionPicker.tsx +6 -6
  75. package/src/ui/PlanReviewPanel.tsx +9 -9
  76. package/src/ui/ProviderPicker.tsx +735 -321
  77. package/src/ui/RunFooter.tsx +3 -3
  78. package/src/ui/RuntimeStatusBar.tsx +108 -0
  79. package/src/ui/SelectionPanel.tsx +8 -4
  80. package/src/ui/SettingsPanel.tsx +9 -9
  81. package/src/ui/Spinner.tsx +1 -1
  82. package/src/ui/TextEntryPanel.tsx +11 -11
  83. package/src/ui/ThinkingBlock.tsx +8 -8
  84. package/src/ui/Timeline.tsx +1625 -1472
  85. package/src/ui/TopHeader.tsx +437 -293
  86. package/src/ui/TranscriptShell.tsx +322 -0
  87. package/src/ui/TurnGroup.tsx +33 -33
  88. package/src/ui/UpdateAvailableCard.tsx +41 -0
  89. package/src/ui/UpdatePromptPanel.tsx +197 -0
  90. package/src/ui/focus.ts +3 -0
  91. package/src/ui/layout.ts +299 -25
  92. package/src/ui/layoutListWindow.ts +145 -0
  93. package/src/ui/logoVariants.ts +103 -0
  94. package/src/ui/modeDisplay.ts +12 -12
  95. package/src/ui/runtimeDisplay.ts +112 -0
  96. package/src/ui/textLayout.ts +15 -4
  97. package/src/ui/theme.tsx +274 -395
  98. package/src/ui/timelineMeasure.ts +218 -136
  99. package/scripts/audit-codexa-capabilities.mjs +0 -466
  100. package/scripts/gen-build-info.mjs +0 -33
  101. package/scripts/smoke-terminal-bench.mjs +0 -35
  102. package/src/appRenderStability.test.ts +0 -131
  103. package/src/commands/handler.test.ts +0 -655
  104. package/src/config/launchArgs.test.ts +0 -189
  105. package/src/config/layeredConfig.test.ts +0 -143
  106. package/src/config/persistence.test.ts +0 -114
  107. package/src/config/runtimeConfig.test.ts +0 -218
  108. package/src/config/settings.test.ts +0 -155
  109. package/src/config/trustStore.test.ts +0 -29
  110. package/src/core/attachments.test.ts +0 -155
  111. package/src/core/auth/codexAuth.test.ts +0 -68
  112. package/src/core/cleanupFastFail.test.ts +0 -76
  113. package/src/core/codex.ts +0 -124
  114. package/src/core/codexExecArgs.test.ts +0 -195
  115. package/src/core/codexLaunch.test.ts +0 -205
  116. package/src/core/codexPrompt.test.ts +0 -252
  117. package/src/core/executables/codexExecutable.test.ts +0 -212
  118. package/src/core/executables/executableResolver.test.ts +0 -129
  119. package/src/core/executables/geminiExecutable.test.ts +0 -116
  120. package/src/core/executables/pathSanityScan.test.ts +0 -47
  121. package/src/core/githubDiagnostics.test.ts +0 -92
  122. package/src/core/hollowResponseFormat.test.ts +0 -58
  123. package/src/core/launchContext.test.ts +0 -157
  124. package/src/core/models/codexCapabilities.test.ts +0 -45
  125. package/src/core/models/codexModelCapabilities.test.ts +0 -246
  126. package/src/core/models/modelSpecs.test.ts +0 -283
  127. package/src/core/perf/renderDebug.test.ts +0 -230
  128. package/src/core/planStorage.test.ts +0 -143
  129. package/src/core/process/CommandRunner.test.ts +0 -105
  130. package/src/core/projectInstructions.test.ts +0 -50
  131. package/src/core/providerLauncher/launcher.test.ts +0 -238
  132. package/src/core/providerLauncher/registry.test.ts +0 -324
  133. package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
  134. package/src/core/providerRuntime/anthropic.test.ts +0 -1120
  135. package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
  136. package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
  137. package/src/core/providerRuntime/gemini.test.ts +0 -437
  138. package/src/core/providerRuntime/lmstudio.test.ts +0 -168
  139. package/src/core/providerRuntime/local.test.ts +0 -787
  140. package/src/core/providerRuntime/registry.test.ts +0 -233
  141. package/src/core/providers/codexJsonStream.test.ts +0 -148
  142. package/src/core/providers/codexSubprocess.test.ts +0 -68
  143. package/src/core/providers/codexTranscript.test.ts +0 -284
  144. package/src/core/terminal/startupClear.test.ts +0 -55
  145. package/src/core/terminal/terminalCapabilities.test.ts +0 -93
  146. package/src/core/terminal/terminalControl.test.ts +0 -75
  147. package/src/core/terminal/terminalSanitize.test.ts +0 -22
  148. package/src/core/terminal/terminalSelection.test.ts +0 -42
  149. package/src/core/terminal/terminalTitle.test.ts +0 -328
  150. package/src/core/updateCheck.test.ts +0 -194
  151. package/src/core/updateCheck.ts +0 -172
  152. package/src/core/workspaceActivity.test.ts +0 -163
  153. package/src/core/workspaceGuard.test.ts +0 -151
  154. package/src/core/workspaceRoot.test.ts +0 -23
  155. package/src/exec.test.ts +0 -13
  156. package/src/headless/execArgs.test.ts +0 -147
  157. package/src/headless/execRunner.test.ts +0 -436
  158. package/src/index.test.tsx +0 -620
  159. package/src/session/appSession.test.ts +0 -897
  160. package/src/session/chatLifecycle.test.ts +0 -64
  161. package/src/session/liveRenderScheduler.test.ts +0 -201
  162. package/src/session/planFlow.test.ts +0 -103
  163. package/src/session/planTranscript.test.ts +0 -65
  164. package/src/session/promptRunSchedule.test.ts +0 -36
  165. package/src/ui/ActivityIndicator.test.tsx +0 -58
  166. package/src/ui/AgentBlock.test.ts +0 -6
  167. package/src/ui/AnimatedStatusText.test.ts +0 -16
  168. package/src/ui/AppShell.test.tsx +0 -1776
  169. package/src/ui/AttachmentImportPanel.test.tsx +0 -204
  170. package/src/ui/BottomComposer.test.ts +0 -674
  171. package/src/ui/CodexLogo.tsx +0 -55
  172. package/src/ui/Markdown.test.ts +0 -157
  173. package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
  174. package/src/ui/ModelPickerScreen.test.tsx +0 -99
  175. package/src/ui/ModelPickerState.test.tsx +0 -151
  176. package/src/ui/ModelReasoningPicker.test.tsx +0 -447
  177. package/src/ui/PlanReviewPanel.test.tsx +0 -267
  178. package/src/ui/PromptCardBorder.test.tsx +0 -161
  179. package/src/ui/ProviderPicker.test.tsx +0 -289
  180. package/src/ui/ProviderShortcut.test.tsx +0 -143
  181. package/src/ui/SettingsPanel.test.tsx +0 -233
  182. package/src/ui/StaticTranscriptItem.tsx +0 -56
  183. package/src/ui/Timeline.test.ts +0 -2067
  184. package/src/ui/TimelineNavigation.test.tsx +0 -201
  185. package/src/ui/TopHeader.test.tsx +0 -254
  186. package/src/ui/TurnGroup.test.tsx +0 -365
  187. package/src/ui/busyStatusAnimation.test.ts +0 -30
  188. package/src/ui/commandNormalize.test.ts +0 -142
  189. package/src/ui/diffRenderer.test.ts +0 -102
  190. package/src/ui/focusFlow.test.tsx +0 -1098
  191. package/src/ui/inputBuffer.test.ts +0 -151
  192. package/src/ui/layout.test.ts +0 -146
  193. package/src/ui/modeDisplay.test.ts +0 -42
  194. package/src/ui/runActivityView.test.ts +0 -89
  195. package/src/ui/runLifecycleView.test.tsx +0 -237
  196. package/src/ui/statusRenderIsolation.test.tsx +0 -654
  197. package/src/ui/terminalAnswerFormat.test.ts +0 -19
  198. package/src/ui/textLayout.test.ts +0 -18
  199. package/src/ui/themeFlow.test.ts +0 -53
  200. package/src/ui/timelineMeasureCache.test.ts +0 -986
  201. /package/src/core/{inputDebug.ts → debug/inputDebug.ts} +0 -0
  202. /package/src/core/{clipboard.ts → shared/clipboard.ts} +0 -0
  203. /package/src/core/{githubDiagnostics.ts → shared/githubDiagnostics.ts} +0 -0
  204. /package/src/core/{projectInstructions.ts → workspace/projectInstructions.ts} +0 -0
  205. /package/src/core/{workspaceActivity.ts → workspace/workspaceActivity.ts} +0 -0
  206. /package/src/core/{workspaceRoot.ts → workspace/workspaceRoot.ts} +0 -0
@@ -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
- });