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