@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,654 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { existsSync, readFileSync, rmSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { PassThrough } from "node:stream";
6
- import test from "node:test";
7
- import React from "react";
8
- import { render } from "ink";
9
- import type { TimelineEvent, UIState } from "../session/types.js";
10
- import { TEST_RUNTIME } from "../test/runtimeTestUtils.js";
11
- import * as renderDebug from "../core/perf/renderDebug.js";
12
- import { AppShell } from "./AppShell.js";
13
- import { Timeline } from "./Timeline.js";
14
- import { BottomComposer, measureBottomComposerRows } from "./BottomComposer.js";
15
- import { createLayoutSnapshot } from "./layout.js";
16
- import { ThemeProvider } from "./theme.js";
17
-
18
- class TestInput extends PassThrough {
19
- readonly isTTY = true;
20
-
21
- setRawMode(): this {
22
- return this;
23
- }
24
-
25
- override resume(): this {
26
- return this;
27
- }
28
-
29
- override pause(): this {
30
- return this;
31
- }
32
-
33
- ref(): this {
34
- return this;
35
- }
36
-
37
- unref(): this {
38
- return this;
39
- }
40
- }
41
-
42
- class TestOutput extends PassThrough {
43
- readonly isTTY = true;
44
- columns = 120;
45
- rows = 40;
46
- }
47
-
48
- function sleep(ms = 50): Promise<void> {
49
- return new Promise((resolve) => setTimeout(resolve, ms));
50
- }
51
-
52
- function readRecords(path: string): Array<Record<string, unknown>> {
53
- if (!existsSync(path)) return [];
54
- const text = readFileSync(path, "utf8").trim();
55
- return text ? text.split("\n").map((line) => JSON.parse(line) as Record<string, unknown>) : [];
56
- }
57
-
58
- function countMatching(records: Array<Record<string, unknown>>, predicate: (record: Record<string, unknown>) => boolean): number {
59
- return records.filter(predicate).length;
60
- }
61
-
62
- type ActionStatus = "running" | "completed";
63
-
64
- function makeToolActivity(id: string, command: string, status: ActionStatus, streamSeq: number) {
65
- return {
66
- id,
67
- command,
68
- status,
69
- startedAt: streamSeq + 1,
70
- completedAt: status === "completed" ? streamSeq + 3 : null,
71
- summary: status === "completed" ? "Read 12 lines" : null,
72
- streamSeq,
73
- };
74
- }
75
-
76
- function makeActiveEvents(actionStatus: ActionStatus | null = "completed", secondActionStatus?: ActionStatus): TimelineEvent[] {
77
- const toolActivities = actionStatus === null
78
- ? []
79
- : [
80
- makeToolActivity("tool-1", "Get-Content README.md", actionStatus, 2),
81
- ...(secondActionStatus ? [makeToolActivity("tool-2", "Get-Content package.json", secondActionStatus, 3)] : []),
82
- ];
83
- return [
84
- {
85
- id: 1,
86
- type: "user",
87
- createdAt: 1,
88
- prompt: "What is the point of 5-Date Verification",
89
- turnId: 1,
90
- },
91
- {
92
- id: 2,
93
- type: "run",
94
- createdAt: 2,
95
- startedAt: 2,
96
- durationMs: null,
97
- backendId: "codex-subprocess",
98
- backendLabel: "Codexa",
99
- runtime: TEST_RUNTIME,
100
- prompt: "What is the point of 5-Date Verification",
101
- progressEntries: [{
102
- id: "thinking-1",
103
- source: "reasoning",
104
- text: "Checking the verification rule.",
105
- sequence: 1,
106
- createdAt: 2,
107
- updatedAt: 2,
108
- pendingNewlineCount: 0,
109
- blocks: [{
110
- id: "thinking-1-block-1",
111
- text: "Checking the verification rule.",
112
- sequence: 1,
113
- createdAt: 2,
114
- updatedAt: 2,
115
- status: "completed",
116
- streamSeq: 1,
117
- }],
118
- }],
119
- status: "running",
120
- summary: "Running",
121
- truncatedOutput: false,
122
- toolActivities,
123
- activity: [],
124
- touchedFileCount: 0,
125
- errorMessage: null,
126
- turnId: 1,
127
- streamItems: [
128
- { kind: "thinking", streamSeq: 1, refId: "thinking-1-block-1" },
129
- ...toolActivities.map((tool) => ({ kind: "action" as const, streamSeq: tool.streamSeq, refId: tool.id })),
130
- ],
131
- responseSegments: [],
132
- lastStreamSeq: toolActivities.at(-1)?.streamSeq ?? 1,
133
- activeResponseSegmentId: null,
134
- },
135
- ];
136
- }
137
-
138
- function Harness({
139
- actionStatus = "completed",
140
- secondActionStatus,
141
- mouseCapture = false,
142
- }: {
143
- actionStatus?: ActionStatus | null;
144
- secondActionStatus?: ActionStatus;
145
- mouseCapture?: boolean;
146
- }) {
147
- const layout = createLayoutSnapshot(120, 40);
148
- const uiState: UIState = { kind: "THINKING", turnId: 1 };
149
- const composerRows = measureBottomComposerRows({
150
- layout,
151
- uiState,
152
- mode: "suggest",
153
- model: "gpt-5.4",
154
- reasoningLevel: "balanced",
155
- value: "",
156
- cursor: 0,
157
- });
158
-
159
- return (
160
- <ThemeProvider theme="purple">
161
- <AppShell
162
- layout={layout}
163
- screen="main"
164
- authState="authenticated"
165
- workspaceLabel="workspace"
166
- runtimeSummary={null}
167
- staticEvents={[]}
168
- activeEvents={makeActiveEvents(actionStatus, secondActionStatus)}
169
- uiState={uiState}
170
- composerRows={composerRows}
171
- panel={null}
172
- mouseCapture={mouseCapture}
173
- composer={(
174
- <BottomComposer
175
- layout={layout}
176
- uiState={uiState}
177
- mode="suggest"
178
- model="gpt-5.4"
179
- reasoningLevel="balanced"
180
- tokensUsed={100}
181
- value=""
182
- cursor={0}
183
- onChangeInput={() => {}}
184
- onSubmit={() => {}}
185
- onCancel={() => {}}
186
- onChangeValue={() => {}}
187
- onChangeCursor={() => {}}
188
- onHistoryUp={() => {}}
189
- onHistoryDown={() => {}}
190
- onOpenBackendPicker={() => {}}
191
- onOpenModelPicker={() => {}}
192
- onOpenModePicker={() => {}}
193
- onOpenThemePicker={() => {}}
194
- onOpenAuthPanel={() => {}}
195
- onTogglePlanMode={() => {}}
196
- onClear={() => {}}
197
- onCycleMode={() => {}}
198
- onQuit={() => {}}
199
- />
200
- )}
201
- />
202
- </ThemeProvider>
203
- );
204
- }
205
-
206
- function AppShellHarness({
207
- staticEvents,
208
- activeEvents,
209
- uiState,
210
- workspaceLabel = "13-Custom-CLI-Normal",
211
- mouseCapture = false,
212
- }: {
213
- staticEvents: TimelineEvent[];
214
- activeEvents: TimelineEvent[];
215
- uiState: UIState;
216
- workspaceLabel?: string;
217
- mouseCapture?: boolean;
218
- }) {
219
- const layout = createLayoutSnapshot(120, 40);
220
- const composerRows = measureBottomComposerRows({
221
- layout,
222
- uiState,
223
- mode: "suggest",
224
- model: "gpt-5.4",
225
- reasoningLevel: "balanced",
226
- value: "",
227
- cursor: 0,
228
- });
229
-
230
- return (
231
- <ThemeProvider theme="purple">
232
- <AppShell
233
- layout={layout}
234
- screen="main"
235
- authState="authenticated"
236
- workspaceLabel={workspaceLabel}
237
- runtimeSummary={null}
238
- staticEvents={staticEvents}
239
- activeEvents={activeEvents}
240
- uiState={uiState}
241
- composerRows={composerRows}
242
- panel={null}
243
- mouseCapture={mouseCapture}
244
- composer={(
245
- <BottomComposer
246
- layout={layout}
247
- uiState={uiState}
248
- mode="suggest"
249
- model="gpt-5.4"
250
- reasoningLevel="balanced"
251
- tokensUsed={100}
252
- value=""
253
- cursor={0}
254
- onChangeInput={() => {}}
255
- onSubmit={() => {}}
256
- onCancel={() => {}}
257
- onChangeValue={() => {}}
258
- onChangeCursor={() => {}}
259
- onHistoryUp={() => {}}
260
- onHistoryDown={() => {}}
261
- onOpenBackendPicker={() => {}}
262
- onOpenModelPicker={() => {}}
263
- onOpenModePicker={() => {}}
264
- onOpenThemePicker={() => {}}
265
- onOpenAuthPanel={() => {}}
266
- onTogglePlanMode={() => {}}
267
- onClear={() => {}}
268
- onCycleMode={() => {}}
269
- onQuit={() => {}}
270
- />
271
- )}
272
- />
273
- </ThemeProvider>
274
- );
275
- }
276
-
277
- function stripAnsi(text: string): string {
278
- return text.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "");
279
- }
280
-
281
- test("status dot ticks do not invalidate timeline rendering", async () => {
282
- const logPath = join(tmpdir(), `codexa-status-isolation-${process.pid}.jsonl`);
283
- rmSync(logPath, { force: true });
284
- renderDebug.configureRenderDebug({
285
- CODEXA_DEBUG_RENDER_TRACE: "1",
286
- CODEXA_RENDER_DEBUG_FILE: logPath,
287
- });
288
-
289
- const stdin = new TestInput();
290
- const stdout = new TestOutput();
291
- const instance = render(<Harness />, {
292
- stdin: stdin as unknown as NodeJS.ReadStream,
293
- stdout: stdout as unknown as NodeJS.WriteStream,
294
- stderr: stdout as unknown as NodeJS.WriteStream,
295
- debug: true,
296
- exitOnCtrlC: false,
297
- });
298
-
299
- try {
300
- await sleep(100);
301
- const beforeTick = readRecords(logPath);
302
-
303
- await sleep(950);
304
- const afterTick = readRecords(logPath);
305
- const tickWindow = afterTick.slice(beforeTick.length);
306
-
307
- assert.equal(countMatching(tickWindow, (record) => record.kind === "status" && record.event === "tick"), 1);
308
- assert(countMatching(tickWindow, (record) => record.kind === "render" && record.component === "Status") >= 1);
309
- assert.equal(countMatching(tickWindow, (record) => record.kind === "render" && record.component === "Timeline"), 0);
310
- assert.equal(countMatching(tickWindow, (record) => record.kind === "timeline" && record.event === "rowGeneration"), 0);
311
- assert.equal(countMatching(tickWindow, (record) => record.kind === "viewport" && record.event === "slice"), 0);
312
- assert.equal(countMatching(tickWindow, (record) => record.kind === "render" && record.component === "ActionLog"), 0);
313
- } finally {
314
- instance.unmount();
315
- renderDebug.configureRenderDebug({});
316
- rmSync(logPath, { force: true });
317
- }
318
- });
319
-
320
- test("app-scroll action rows update without remounting when a running action completes", async () => {
321
- const logPath = join(tmpdir(), `codexa-action-remount-${process.pid}.jsonl`);
322
- rmSync(logPath, { force: true });
323
- renderDebug.configureRenderDebug({
324
- CODEXA_DEBUG_RENDER_TRACE: "1",
325
- CODEXA_RENDER_DEBUG_FILE: logPath,
326
- });
327
-
328
- const stdin = new TestInput();
329
- const stdout = new TestOutput();
330
- const instance = render(<Harness actionStatus="running" mouseCapture={true} />, {
331
- stdin: stdin as unknown as NodeJS.ReadStream,
332
- stdout: stdout as unknown as NodeJS.WriteStream,
333
- stderr: stdout as unknown as NodeJS.WriteStream,
334
- debug: true,
335
- exitOnCtrlC: false,
336
- });
337
-
338
- try {
339
- await sleep(100);
340
- const beforeCompletion = readRecords(logPath);
341
- const mountedActionRows = beforeCompletion
342
- .filter((record) => record.kind === "flicker" && record.event === "timelineRowMount")
343
- .map((record) => String(record.rowKey ?? ""))
344
- .filter((rowKey) => rowKey.includes("-action-"));
345
-
346
- assert.ok(mountedActionRows.length > 0, "expected action rows to mount in the initial frame");
347
-
348
- instance.rerender(<Harness actionStatus="completed" mouseCapture={true} />);
349
- await sleep(100);
350
-
351
- const afterCompletion = readRecords(logPath).slice(beforeCompletion.length);
352
- const unmountedActionRows = afterCompletion
353
- .filter((record) => record.kind === "flicker" && record.event === "timelineRowUnmount")
354
- .map((record) => String(record.rowKey ?? ""))
355
- .filter((rowKey) => rowKey.includes("-action-"));
356
-
357
- assert.deepEqual(unmountedActionRows, []);
358
- } finally {
359
- instance.unmount();
360
- renderDebug.configureRenderDebug({});
361
- rmSync(logPath, { force: true });
362
- }
363
- });
364
-
365
- test("first action activity keeps the shell frame mounted and visible", async () => {
366
- const logPath = join(tmpdir(), `codexa-first-action-shell-${process.pid}.jsonl`);
367
- rmSync(logPath, { force: true });
368
- renderDebug.configureRenderDebug({
369
- CODEXA_RENDER_DEBUG: "1",
370
- CODEXA_RENDER_DEBUG_FILE: logPath,
371
- });
372
- const stdin = new TestInput();
373
- const stdout = new TestOutput();
374
- let output = "";
375
- stdout.on("data", (chunk) => {
376
- output += chunk.toString();
377
- });
378
-
379
- const instance = render(<Harness actionStatus={null} />, {
380
- stdin: stdin as unknown as NodeJS.ReadStream,
381
- stdout: stdout as unknown as NodeJS.WriteStream,
382
- stderr: stdout as unknown as NodeJS.WriteStream,
383
- debug: true,
384
- exitOnCtrlC: false,
385
- });
386
-
387
- try {
388
- await sleep(100);
389
- instance.rerender(<Harness actionStatus="running" />);
390
- await sleep(100);
391
-
392
- const frame = stripAnsi(output);
393
- assert.match(frame, /workspace/);
394
- assert.match(frame, /What is the point of 5-Date Verification/);
395
- assert.match(frame, /Codexa is thinking/i);
396
- assert.match(frame, /Get-Content README\.md/);
397
-
398
- const records = readRecords(logPath);
399
- const unexpectedUnmounts = records
400
- .filter((record) => record.kind === "lifecycle" && record.event === "unmount")
401
- .map((record) => String(record.component ?? ""))
402
- .filter((component) => ["AppShell", "Timeline", "Header", "Composer", "Status"].includes(component));
403
- assert.deepEqual(unexpectedUnmounts, []);
404
- assert.equal(
405
- countMatching(records, (record) =>
406
- record.kind === "blankFrame" && record.reason === "visible-rows-zero-with-events"
407
- ),
408
- 0,
409
- );
410
- } finally {
411
- instance.unmount();
412
- renderDebug.configureRenderDebug({});
413
- rmSync(logPath, { force: true });
414
- }
415
- });
416
-
417
- test("appending a second action does not remount existing action rows", async () => {
418
- const logPath = join(tmpdir(), `codexa-action-append-${process.pid}.jsonl`);
419
- rmSync(logPath, { force: true });
420
- renderDebug.configureRenderDebug({
421
- CODEXA_DEBUG_RENDER_TRACE: "1",
422
- CODEXA_RENDER_DEBUG_FILE: logPath,
423
- });
424
-
425
- const stdin = new TestInput();
426
- const stdout = new TestOutput();
427
- const instance = render(<Harness actionStatus="running" />, {
428
- stdin: stdin as unknown as NodeJS.ReadStream,
429
- stdout: stdout as unknown as NodeJS.WriteStream,
430
- stderr: stdout as unknown as NodeJS.WriteStream,
431
- debug: true,
432
- exitOnCtrlC: false,
433
- });
434
-
435
- try {
436
- await sleep(100);
437
- const beforeUpdates = readRecords(logPath);
438
- const firstActionMounts = beforeUpdates
439
- .filter((record) => record.kind === "flicker" && record.event === "timelineRowMount")
440
- .map((record) => String(record.rowKey ?? ""))
441
- .filter((rowKey) => rowKey.includes("-action-2-"));
442
-
443
- assert.ok(firstActionMounts.length > 0, "expected first action rows to mount in the initial frame");
444
-
445
- instance.rerender(<Harness actionStatus="completed" />);
446
- await sleep(100);
447
- const beforeAppend = readRecords(logPath);
448
-
449
- instance.rerender(<Harness actionStatus="completed" secondActionStatus="running" />);
450
- await sleep(100);
451
-
452
- const appendWindow = readRecords(logPath).slice(beforeAppend.length);
453
- const firstActionUnmounts = appendWindow
454
- .filter((record) => record.kind === "flicker" && record.event === "timelineRowUnmount")
455
- .map((record) => String(record.rowKey ?? ""))
456
- .filter((rowKey) => rowKey.includes("-action-2-"));
457
-
458
- assert.deepEqual(firstActionUnmounts, []);
459
- } finally {
460
- instance.unmount();
461
- renderDebug.configureRenderDebug({});
462
- rmSync(logPath, { force: true });
463
- }
464
- });
465
-
466
- test("native AppShell finalize keeps transcript rows in one keyed tree", async () => {
467
- const logPath = join(tmpdir(), `codexa-native-finalize-${process.pid}.jsonl`);
468
- rmSync(logPath, { force: true });
469
- renderDebug.configureRenderDebug({
470
- CODEXA_DEBUG_RENDER_TRACE: "1",
471
- CODEXA_RENDER_DEBUG_FILE: logPath,
472
- });
473
-
474
- const stdin = new TestInput();
475
- const stdout = new TestOutput();
476
- let output = "";
477
- stdout.on("data", (chunk) => {
478
- output += chunk.toString();
479
- });
480
-
481
- const runningEvents = makeActiveEvents("completed");
482
- const completedEvents = JSON.parse(JSON.stringify(runningEvents)) as TimelineEvent[];
483
- const completedRun = completedEvents.find((event): event is Extract<TimelineEvent, { type: "run" }> => event.type === "run");
484
- assert.ok(completedRun);
485
- completedRun.status = "completed";
486
- completedRun.durationMs = 1234;
487
- completedRun.responseSegments = [{
488
- id: "response-2-3",
489
- streamSeq: 3,
490
- chunks: ["Hello"],
491
- status: "completed",
492
- startedAt: 5,
493
- }];
494
- completedRun.streamItems = [
495
- ...(completedRun.streamItems ?? []),
496
- { kind: "response", streamSeq: 3, refId: "response-2-3" },
497
- ];
498
- completedEvents.push({
499
- id: 3,
500
- type: "assistant",
501
- createdAt: 6,
502
- content: "Hello",
503
- contentChunks: [],
504
- turnId: 1,
505
- });
506
-
507
- const instance = render(
508
- <AppShellHarness
509
- staticEvents={[]}
510
- activeEvents={runningEvents}
511
- uiState={{ kind: "THINKING", turnId: 1 }}
512
- mouseCapture={false}
513
- />,
514
- {
515
- stdin: stdin as unknown as NodeJS.ReadStream,
516
- stdout: stdout as unknown as NodeJS.WriteStream,
517
- stderr: stdout as unknown as NodeJS.WriteStream,
518
- debug: true,
519
- exitOnCtrlC: false,
520
- },
521
- );
522
-
523
- try {
524
- await sleep(100);
525
- const beforeFinalize = readRecords(logPath);
526
-
527
- instance.rerender(
528
- <AppShellHarness
529
- staticEvents={completedEvents}
530
- activeEvents={[]}
531
- uiState={{ kind: "IDLE" }}
532
- mouseCapture={false}
533
- />,
534
- );
535
- await sleep(100);
536
-
537
- const finalizeWindow = readRecords(logPath).slice(beforeFinalize.length);
538
- const unmountedActionRows = finalizeWindow
539
- .filter((record) => record.kind === "flicker" && record.event === "timelineRowUnmount")
540
- .map((record) => String(record.rowKey ?? ""))
541
- .filter((rowKey) => rowKey.includes("-action-"));
542
- const majorUnmounts = finalizeWindow
543
- .filter((record) => record.kind === "lifecycle" && record.event === "unmount")
544
- .map((record) => String(record.component ?? ""))
545
- .filter((component) => ["AppShell", "Header", "Composer"].includes(component));
546
-
547
- assert.deepEqual(unmountedActionRows, []);
548
- assert.deepEqual(majorUnmounts, []);
549
- const frame = stripAnsi(output);
550
- assert.match(frame, /13-Custom-CLI-Normal/);
551
- assert.match(frame, /Hello/);
552
- } finally {
553
- instance.unmount();
554
- renderDebug.configureRenderDebug({});
555
- rmSync(logPath, { force: true });
556
- }
557
- });
558
-
559
-
560
- test("THINKING -> RESPONDING -> FINALIZE_RUN preserves action rows and renders response below", async () => {
561
- const logPath = join(tmpdir(), `codexa-action-response-finalize-${process.pid}.jsonl`);
562
- rmSync(logPath, { force: true });
563
- renderDebug.configureRenderDebug({
564
- CODEXA_DEBUG_RENDER_TRACE: "1",
565
- CODEXA_RENDER_DEBUG_FILE: logPath,
566
- });
567
-
568
- const stdin = new TestInput();
569
- const stdout = new TestOutput();
570
- let output = "";
571
- stdout.on("data", (chunk) => {
572
- output += chunk.toString();
573
- });
574
-
575
- let runningEvents: TimelineEvent[] = makeActiveEvents("running");
576
- let uiState: UIState = { kind: "THINKING", turnId: 1 };
577
-
578
- const TestTimeline = (props: {
579
- staticEvents: TimelineEvent[];
580
- activeEvents: TimelineEvent[];
581
- uiState: UIState;
582
- }) => {
583
- const layout = createLayoutSnapshot(120, 40);
584
- return <Timeline
585
- staticEvents={props.staticEvents}
586
- activeEvents={props.activeEvents}
587
- layout={layout}
588
- uiState={props.uiState}
589
- viewportRows={30}
590
- verboseMode={true}
591
- />;
592
- };
593
-
594
- const instance = render(<TestTimeline staticEvents={[]} activeEvents={runningEvents} uiState={uiState} />, {
595
- stdin: stdin as unknown as NodeJS.ReadStream,
596
- stdout: stdout as unknown as NodeJS.WriteStream,
597
- stderr: stdout as unknown as NodeJS.WriteStream,
598
- debug: true,
599
- exitOnCtrlC: false,
600
- });
601
-
602
- try {
603
- await sleep(100);
604
- const beforeUpdates = readRecords(logPath);
605
-
606
- // RESPONDING
607
- let streamingEvents = JSON.parse(JSON.stringify(runningEvents)) as TimelineEvent[];
608
- let streamingTurn = streamingEvents[1] as Extract<TimelineEvent, { type: "run" }>;
609
- streamingTurn.toolActivities[0].status = "completed";
610
- streamingTurn.responseSegments = [{
611
- id: "resp-1",
612
- streamSeq: 3,
613
- chunks: ["Final response text"],
614
- status: "active",
615
- startedAt: 5,
616
- }];
617
- streamingTurn.streamItems = [
618
- ...(streamingTurn.streamItems ?? []),
619
- { kind: "response", streamSeq: 3, refId: "resp-1" },
620
- ];
621
- uiState = { kind: "RESPONDING", turnId: 1 };
622
-
623
- instance.rerender(<TestTimeline staticEvents={[]} activeEvents={streamingEvents} uiState={uiState} />);
624
- await sleep(100);
625
-
626
- // FINALIZE_RUN
627
- let completedEvents = JSON.parse(JSON.stringify(streamingEvents)) as TimelineEvent[];
628
- let completedTurn = completedEvents[1] as Extract<TimelineEvent, { type: "run" }>;
629
- completedTurn.status = "completed";
630
- completedTurn.responseSegments = (completedTurn.responseSegments ?? []).map((segment, index) =>
631
- index === 0 ? { ...segment, status: "completed" } : segment
632
- );
633
- uiState = { kind: "IDLE" };
634
-
635
- instance.rerender(<TestTimeline staticEvents={completedEvents} activeEvents={[]} uiState={uiState} />);
636
- await sleep(100);
637
-
638
- const frame = stripAnsi(output);
639
-
640
- const unmounts = readRecords(logPath)
641
- .filter((record) => record.kind === "flicker" && record.event === "timelineRowUnmount")
642
- .map((record) => String(record.rowKey ?? ""))
643
- .filter((rowKey) => rowKey.includes("-action-"));
644
-
645
- assert.deepEqual(unmounts, [], "Action rows should not unmount during response and finalize");
646
- assert.match(frame, /Final response text/i, "Answer text should appear");
647
- assert.match(frame, /action/i, "Action card should remain");
648
-
649
- } finally {
650
- instance.unmount();
651
- renderDebug.configureRenderDebug({});
652
- rmSync(logPath, { force: true });
653
- }
654
- });
@@ -1,19 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { formatTerminalAnswerInline } from "./terminalAnswerFormat.js";
4
-
5
- test("terminal answer formatting collapses local markdown links and Windows paths", () => {
6
- const formatted = formatTerminalAnswerInline([
7
- "- [`src/App.tsx`](C:/Users/Example/Projects/Project/src/App.tsx#L22)",
8
- "- [README.md](file:///C:/Users/Example/Projects/Project/README.md)",
9
- "- C:\\Users\\Example\\Projects\\Project\\docs\\proof.md#L26",
10
- "- [OpenAI](https://platform.openai.com/docs)",
11
- ].join("\n"));
12
-
13
- assert.match(formatted, /src\/App\.tsx:22/);
14
- assert.match(formatted, /README\.md/);
15
- assert.match(formatted, /docs\/proof\.md:26/);
16
- assert.match(formatted, /\[OpenAI\]\(https:\/\/platform\.openai\.com\/docs\)/);
17
- assert.doesNotMatch(formatted, /C:\/Users|C:\\Users|file:\/\//);
18
- assert.doesNotMatch(formatted, /\]\(C:/);
19
- });
@@ -1,18 +0,0 @@
1
- import test from "node:test";
2
- import assert from "node:assert/strict";
3
- import { wrapCommandText } from "./textLayout.js";
4
-
5
- test("wrapCommandText breaks on spaces and indents continuation lines", () => {
6
- const result = wrapCommandText("if (Get-Command rg) { rg --files } else { Get-ChildItem -Recurse -File }", 40);
7
- assert.equal(result.length, 2);
8
- assert.equal(result[0].trimEnd(), "if (Get-Command rg) { rg --files } else");
9
- assert.equal(result[1].trimEnd(), " { Get-ChildItem -Recurse -File }");
10
- });
11
-
12
- test("wrapCommandText handles extremely long unbroken tokens by breaking them", () => {
13
- const result = wrapCommandText("A_Very_Long_Token_Without_Spaces_That_Exceeds_Max_Width", 20);
14
- assert.equal(result.length, 3);
15
- assert.equal(result[0], "A_Very_Long_Token_Wi");
16
- assert.equal(result[1], " thout_Spaces_That_");
17
- assert.equal(result[2], " Exceeds_Max_Width");
18
- });