@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,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
- });