@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,64 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { appendStaticEvents } from "./chatLifecycle.js";
4
- import type { TimelineEvent } from "./types.js";
5
-
6
- test("appendStaticEvents deduplicates consecutive identical system events", () => {
7
- const events: TimelineEvent[] = [
8
- { id: 1, type: "system", createdAt: 100, title: "T1", content: "C1" },
9
- ];
10
- const additions: TimelineEvent[] = [
11
- { id: 2, type: "system", createdAt: 200, title: "T1", content: "C1" }, // Duplicate
12
- { id: 3, type: "system", createdAt: 300, title: "T2", content: "C2" }, // Different
13
- ];
14
-
15
- const result = appendStaticEvents(events, additions);
16
- assert.equal(result.length, 2);
17
- assert.equal(result[0]?.id, 1);
18
- assert.equal(result[1]?.id, 3);
19
- });
20
-
21
- test("appendStaticEvents deduplicates consecutive identical error events", () => {
22
- const events: TimelineEvent[] = [
23
- { id: 1, type: "error", createdAt: 100, title: "E1", content: "M1" },
24
- ];
25
- const additions: TimelineEvent[] = [
26
- { id: 2, type: "error", createdAt: 200, title: "E1", content: "M1" }, // Duplicate
27
- { id: 3, type: "error", createdAt: 300, title: "E2", content: "M2" }, // Different
28
- ];
29
-
30
- const result = appendStaticEvents(events, additions);
31
- assert.equal(result.length, 2);
32
- assert.equal(result[0]?.id, 1);
33
- assert.equal(result[1]?.id, 3);
34
- });
35
-
36
- test("appendStaticEvents does not deduplicate different event types with same content", () => {
37
- const events: TimelineEvent[] = [
38
- { id: 1, type: "system", createdAt: 100, title: "Same", content: "Same" },
39
- ];
40
- const additions: TimelineEvent[] = [
41
- { id: 2, type: "error", createdAt: 200, title: "Same", content: "Same" },
42
- ];
43
-
44
- const result = appendStaticEvents(events, additions);
45
- assert.equal(result.length, 2);
46
- assert.equal(result[0]?.id, 1);
47
- assert.equal(result[1]?.id, 2);
48
- });
49
-
50
- test("appendStaticEvents does not deduplicate non-consecutive duplicates", () => {
51
- const events: TimelineEvent[] = [
52
- { id: 1, type: "system", createdAt: 100, title: "T1", content: "C1" },
53
- ];
54
- const additions: TimelineEvent[] = [
55
- { id: 2, type: "system", createdAt: 200, title: "T2", content: "C2" },
56
- { id: 3, type: "system", createdAt: 300, title: "T1", content: "C1" }, // Identical to first, but not consecutive
57
- ];
58
-
59
- const result = appendStaticEvents(events, additions);
60
- assert.equal(result.length, 3);
61
- assert.equal(result[0]?.id, 1);
62
- assert.equal(result[1]?.id, 2);
63
- assert.equal(result[2]?.id, 3);
64
- });
@@ -1,201 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { createLiveRenderScheduler, type LiveRenderUpdate } from "./liveRenderScheduler.js";
4
-
5
- type FakeTimer = {
6
- callback: () => void;
7
- delayMs: number;
8
- cleared: boolean;
9
- };
10
-
11
- function createFakeTimers() {
12
- const timers: FakeTimer[] = [];
13
- return {
14
- timers,
15
- setTimer(callback: () => void, delayMs: number) {
16
- const timer: FakeTimer = { callback, delayMs, cleared: false };
17
- timers.push(timer);
18
- return timer as unknown as ReturnType<typeof setTimeout>;
19
- },
20
- clearTimer(timer: ReturnType<typeof setTimeout>) {
21
- (timer as unknown as FakeTimer).cleared = true;
22
- },
23
- };
24
- }
25
-
26
- function progress(id: string, text: string): LiveRenderUpdate {
27
- return { type: "progress", update: { id, source: "reasoning", text } };
28
- }
29
-
30
- function tool(id: string, status: "running" | "completed"): LiveRenderUpdate {
31
- return {
32
- type: "tool",
33
- activity: {
34
- id,
35
- command: "Get-Content README.md",
36
- status,
37
- startedAt: 1,
38
- completedAt: status === "completed" ? 2 : undefined,
39
- },
40
- };
41
- }
42
-
43
- test("coalesces adjacent assistant chunks at the cadence flush", () => {
44
- const flushed: LiveRenderUpdate[][] = [];
45
- const fakeTimers = createFakeTimers();
46
- const scheduler = createLiveRenderScheduler({
47
- assistantFlushMs: 50,
48
- progressOnlyFlushMs: 50,
49
- flush: (updates) => flushed.push(updates),
50
- setTimer: fakeTimers.setTimer,
51
- clearTimer: fakeTimers.clearTimer,
52
- });
53
-
54
- scheduler.enqueue({ type: "assistant", chunk: "Hello" });
55
- scheduler.enqueue({ type: "assistant", chunk: ", world" });
56
-
57
- assert.equal(flushed.length, 0);
58
- assert.equal(fakeTimers.timers.length, 1);
59
- assert.equal(fakeTimers.timers[0]?.delayMs, 50);
60
- fakeTimers.timers[0]!.callback();
61
-
62
- assert.equal(flushed.length, 1);
63
- assert.deepEqual(flushed[0], [{ type: "assistant", chunk: "Hello, world" }]);
64
- });
65
-
66
- test("first progress-only update waits for the progress cadence", () => {
67
- const flushed: LiveRenderUpdate[][] = [];
68
- const fakeTimers = createFakeTimers();
69
- const scheduler = createLiveRenderScheduler({
70
- assistantFlushMs: 50,
71
- progressOnlyFlushMs: 50,
72
- flush: (updates) => flushed.push(updates),
73
- setTimer: fakeTimers.setTimer,
74
- clearTimer: fakeTimers.clearTimer,
75
- });
76
-
77
- scheduler.enqueue(tool("t1", "running"));
78
-
79
- assert.equal(flushed.length, 0);
80
- assert.equal(fakeTimers.timers.length, 1);
81
- assert.equal(fakeTimers.timers[0]?.delayMs, 50);
82
-
83
- fakeTimers.timers[0]!.callback();
84
- assert.deepEqual(flushed[0]?.map((update) => update.type), ["tool"]);
85
- });
86
-
87
- test("preserves event order while keeping only the latest same-id progress update", () => {
88
- const flushed: LiveRenderUpdate[][] = [];
89
- const scheduler = createLiveRenderScheduler({
90
- assistantFlushMs: 50,
91
- progressOnlyFlushMs: 50,
92
- flush: (updates) => flushed.push(updates),
93
- });
94
-
95
- scheduler.enqueue(progress("p1", "Thinking"));
96
- scheduler.enqueue(tool("t1", "running"));
97
- scheduler.enqueue({ type: "assistant", chunk: "First" });
98
- scheduler.enqueue({ type: "assistant", chunk: " segment" });
99
- scheduler.enqueue(progress("p1", "Thinking harder"));
100
- scheduler.flushNow();
101
-
102
- assert.deepEqual(flushed[0]?.map((update) => update.type), ["progress", "tool", "assistant"]);
103
- assert.equal((flushed[0]?.[2] as Extract<LiveRenderUpdate, { type: "assistant" }>).chunk, "First segment");
104
- assert.equal((flushed[0]?.[0] as Extract<LiveRenderUpdate, { type: "progress" }>).update.text, "Thinking harder");
105
- });
106
-
107
- test("coalesces repeated keyed progress and tool updates across a noisy flush window", () => {
108
- const flushed: LiveRenderUpdate[][] = [];
109
- const scheduler = createLiveRenderScheduler({
110
- assistantFlushMs: 50,
111
- progressOnlyFlushMs: 175,
112
- flush: (updates) => flushed.push(updates),
113
- });
114
-
115
- scheduler.enqueue(progress("p1", "Reading file 1"));
116
- scheduler.enqueue(tool("t1", "running"));
117
- scheduler.enqueue(progress("p1", "Reading file 2"));
118
- scheduler.enqueue(tool("t1", "completed"));
119
- scheduler.enqueue(progress("p2", "Listing files"));
120
- scheduler.flushNow();
121
-
122
- assert.deepEqual(flushed[0]?.map((update) => update.type), ["progress", "tool", "progress"]);
123
- assert.equal((flushed[0]?.[0] as Extract<LiveRenderUpdate, { type: "progress" }>).update.text, "Reading file 2");
124
- assert.equal((flushed[0]?.[1] as Extract<LiveRenderUpdate, { type: "tool" }>).activity.status, "completed");
125
- });
126
-
127
- test("records scheduler flush diagnostics", () => {
128
- const flushed: LiveRenderUpdate[][] = [];
129
- const fakeTimers = createFakeTimers();
130
- const scheduler = createLiveRenderScheduler({
131
- assistantFlushMs: 50,
132
- progressOnlyFlushMs: 175,
133
- flush: (updates) => flushed.push(updates),
134
- setTimer: fakeTimers.setTimer,
135
- clearTimer: fakeTimers.clearTimer,
136
- });
137
-
138
- scheduler.enqueue(progress("p1", "Listing files"));
139
- assert.equal(scheduler.getStats().providerEvents, 1);
140
- assert.equal(fakeTimers.timers[0]?.delayMs, 175);
141
- fakeTimers.timers[0]!.callback();
142
-
143
- scheduler.enqueue({ type: "assistant", chunk: "hello" });
144
- assert.equal(fakeTimers.timers[1]?.delayMs, 50);
145
- fakeTimers.timers[1]!.callback();
146
-
147
- const stats = scheduler.getStats();
148
- assert.equal(stats.providerEvents, 2);
149
- assert.equal(stats.flushes, 2);
150
- assert.ok(stats.maxFlushIntervalMs >= 0);
151
- assert.ok(stats.averageFlushIntervalMs >= 0);
152
- });
153
-
154
- test("prevents reentrant flushes when a producer enqueues during a flush", () => {
155
- const flushed: LiveRenderUpdate[][] = [];
156
- let inFlush = false;
157
- let scheduler: ReturnType<typeof createLiveRenderScheduler>;
158
-
159
- scheduler = createLiveRenderScheduler({
160
- assistantFlushMs: 50,
161
- progressOnlyFlushMs: 50,
162
- flush: (updates) => {
163
- assert.equal(inFlush, false, "flush should not reenter itself");
164
- inFlush = true;
165
- flushed.push(updates);
166
- if (flushed.length === 1) {
167
- scheduler.enqueue({ type: "assistant", chunk: "queued during flush" });
168
- }
169
- inFlush = false;
170
- },
171
- });
172
-
173
- scheduler.enqueue({ type: "assistant", chunk: "first" });
174
-
175
- assert.equal(scheduler.flushNow(), true);
176
- assert.equal(flushed.length, 2);
177
- assert.equal((flushed[0]?.[0] as Extract<LiveRenderUpdate, { type: "assistant" }>).chunk, "first");
178
- assert.equal((flushed[1]?.[0] as Extract<LiveRenderUpdate, { type: "assistant" }>).chunk, "queued during flush");
179
- });
180
-
181
- test("flushNow drains queued updates before finalization", () => {
182
- const flushed: LiveRenderUpdate[][] = [];
183
- const fakeTimers = createFakeTimers();
184
- const scheduler = createLiveRenderScheduler({
185
- assistantFlushMs: 50,
186
- progressOnlyFlushMs: 50,
187
- flush: (updates) => flushed.push(updates),
188
- setTimer: fakeTimers.setTimer,
189
- clearTimer: fakeTimers.clearTimer,
190
- });
191
-
192
- scheduler.enqueue({ type: "assistant", chunk: "final chunk" });
193
-
194
- assert.equal(scheduler.flushNow(), true);
195
- assert.equal(flushed.length, 1);
196
- assert.equal(scheduler.hasPendingUpdates(), false);
197
-
198
- assert.equal(fakeTimers.timers[0]?.cleared, true);
199
- fakeTimers.timers[0]?.callback();
200
- assert.equal(flushed.length, 1);
201
- });
@@ -1,103 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import {
4
- approvePlanExecution,
5
- beginPlanFeedback,
6
- cancelPlanFeedback,
7
- createInitialPlanFlowState,
8
- finishPlanGeneration,
9
- resetPlanFlow,
10
- startPlanGeneration,
11
- submitPlanFeedback,
12
- } from "./planFlow.js";
13
-
14
- test("starts a fresh plan generation flow from idle", () => {
15
- const state = startPlanGeneration("Build a hello world script", "auto-edit");
16
-
17
- assert.deepEqual(createInitialPlanFlowState(), { kind: "idle" });
18
- assert.equal(state.kind, "generating");
19
- assert.equal(state.originalPrompt, "Build a hello world script");
20
- assert.equal(state.executionMode, "auto-edit");
21
- assert.deepEqual(state.constraints, []);
22
- assert.equal(state.planFilePath, null);
23
- assert.equal(state.currentPlan, null);
24
- assert.equal(state.pendingFeedback, null);
25
- });
26
-
27
- test("finishes plan generation into an awaiting-action state with a plan file path", () => {
28
- const state = finishPlanGeneration(
29
- startPlanGeneration("Build a hello world script", "auto-edit"),
30
- "## Files\n- hello_world.py",
31
- "C:\\Workspace\\.codexa\\last-plan.md",
32
- );
33
-
34
- assert.equal(state.kind, "awaiting_action");
35
- assert.equal(state.currentPlan, "## Files\n- hello_world.py");
36
- assert.equal(state.planFilePath, "C:\\Workspace\\.codexa\\last-plan.md");
37
- });
38
-
39
- test("revising the plan keeps constraints and records revision feedback", () => {
40
- const awaiting = finishPlanGeneration(
41
- startPlanGeneration("Build a hello world script", "auto-edit"),
42
- "Plan v1",
43
- "C:\\Workspace\\.codexa\\last-plan.md",
44
- );
45
- const collecting = beginPlanFeedback(awaiting, "revise");
46
- const generating = submitPlanFeedback(collecting, "Keep it to a single file.");
47
-
48
- assert.equal(collecting.kind, "collecting_feedback");
49
- assert.equal(collecting.mode, "revise");
50
- assert.equal(generating.kind, "generating");
51
- assert.equal(generating.currentPlan, "Plan v1");
52
- assert.equal(generating.planFilePath, "C:\\Workspace\\.codexa\\last-plan.md");
53
- assert.deepEqual(generating.constraints, []);
54
- assert.deepEqual(generating.pendingFeedback, {
55
- mode: "revise",
56
- text: "Keep it to a single file.",
57
- });
58
- });
59
-
60
- test("adding constraints accumulates them before the next plan pass", () => {
61
- const awaiting = finishPlanGeneration(
62
- startPlanGeneration("Build a hello world script", "auto-edit"),
63
- "Plan v1",
64
- "C:\\Workspace\\.codexa\\last-plan.md",
65
- );
66
- const collecting = beginPlanFeedback(awaiting, "constraints");
67
- const generating = submitPlanFeedback(collecting, "Do not touch any other files.");
68
-
69
- assert.equal(generating.kind, "generating");
70
- assert.deepEqual(generating.constraints, ["Do not touch any other files."]);
71
- assert.deepEqual(generating.pendingFeedback, {
72
- mode: "constraints",
73
- text: "Do not touch any other files.",
74
- });
75
- });
76
-
77
- test("canceling feedback returns to the action picker without losing the plan", () => {
78
- const awaiting = finishPlanGeneration(
79
- startPlanGeneration("Build a hello world script", "auto-edit"),
80
- "Plan v1",
81
- "C:\\Workspace\\.codexa\\last-plan.md",
82
- );
83
- const collecting = beginPlanFeedback(awaiting, "revise");
84
- const canceled = cancelPlanFeedback(collecting);
85
-
86
- assert.equal(canceled.kind, "awaiting_action");
87
- assert.equal(canceled.currentPlan, "Plan v1");
88
- assert.equal(canceled.planFilePath, "C:\\Workspace\\.codexa\\last-plan.md");
89
- });
90
-
91
- test("approving execution moves to executing and reset returns to idle", () => {
92
- const awaiting = finishPlanGeneration(
93
- startPlanGeneration("Build a hello world script", "auto-edit"),
94
- "Plan v1",
95
- "C:\\Workspace\\.codexa\\last-plan.md",
96
- );
97
- const executing = approvePlanExecution(awaiting);
98
-
99
- assert.equal(executing.kind, "executing");
100
- assert.equal(executing.executionMode, "auto-edit");
101
- assert.equal(executing.planFilePath, "C:\\Workspace\\.codexa\\last-plan.md");
102
- assert.deepEqual(resetPlanFlow(), { kind: "idle" });
103
- });
@@ -1,65 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { TEST_RUNTIME } from "../test/runtimeTestUtils.js";
4
- import type { RunEvent, TimelineEvent } from "./types.js";
5
- import { hasFinalizedTranscriptPlan } from "./planTranscript.js";
6
-
7
- function makeRun(overrides: Partial<RunEvent> = {}): RunEvent {
8
- return {
9
- id: 1,
10
- type: "run",
11
- createdAt: 1,
12
- startedAt: 1,
13
- durationMs: 10,
14
- backendId: "codex-subprocess",
15
- backendLabel: "Codexa",
16
- runtime: TEST_RUNTIME,
17
- prompt: "Plan work",
18
- progressEntries: [],
19
- status: "completed",
20
- summary: "completed",
21
- truncatedOutput: false,
22
- toolActivities: [],
23
- activity: [],
24
- touchedFileCount: 0,
25
- errorMessage: null,
26
- turnId: 1,
27
- streamItems: [{ kind: "plan", streamSeq: 1, refId: "plan-1" }],
28
- responseSegments: [],
29
- lastStreamSeq: 1,
30
- activeResponseSegmentId: null,
31
- plan: {
32
- id: "plan-1",
33
- streamSeq: 1,
34
- chunks: ["1. Inspect\n2. Update"],
35
- status: "completed",
36
- startedAt: 1,
37
- },
38
- ...overrides,
39
- };
40
- }
41
-
42
- test("approval visibility requires a non-empty finalized transcript plan", () => {
43
- assert.equal(hasFinalizedTranscriptPlan([], "1. Inspect"), false);
44
- assert.equal(hasFinalizedTranscriptPlan([makeRun()], ""), false);
45
- assert.equal(hasFinalizedTranscriptPlan([makeRun({ plan: null })], "1. Inspect"), false);
46
- assert.equal(
47
- hasFinalizedTranscriptPlan([
48
- makeRun({
49
- status: "running",
50
- plan: {
51
- id: "plan-1",
52
- streamSeq: 1,
53
- chunks: ["1. Inspect"],
54
- status: "active",
55
- startedAt: 1,
56
- },
57
- }),
58
- ], "1. Inspect"),
59
- false,
60
- );
61
- assert.equal(
62
- hasFinalizedTranscriptPlan([makeRun()] satisfies TimelineEvent[], "1. Inspect\n2. Update"),
63
- true,
64
- );
65
- });
@@ -1,36 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { schedulePromptRunStartAfterVisibleCommit } from "./promptRunSchedule.js";
4
-
5
- function waitForTimerTurn(): Promise<void> {
6
- return new Promise((resolve) => setTimeout(resolve, 0));
7
- }
8
-
9
- test("schedulePromptRunStartAfterVisibleCommit waits past the reducer microtask before starting work", async () => {
10
- const order: string[] = [];
11
-
12
- schedulePromptRunStartAfterVisibleCommit(() => {
13
- order.push("provider-started");
14
- });
15
- order.push("visible-run-dispatched");
16
-
17
- await Promise.resolve();
18
- assert.deepEqual(order, ["visible-run-dispatched"]);
19
-
20
- await waitForTimerTurn();
21
- assert.deepEqual(order, ["visible-run-dispatched", "provider-started"]);
22
- });
23
-
24
- test("schedulePromptRunStartAfterVisibleCommit can be canceled before provider start", async () => {
25
- let started = false;
26
-
27
- const cancel = schedulePromptRunStartAfterVisibleCommit(() => {
28
- started = true;
29
- });
30
- cancel();
31
-
32
- await Promise.resolve();
33
- await waitForTimerTurn();
34
-
35
- assert.equal(started, false);
36
- });
@@ -1,58 +0,0 @@
1
- import test from "node:test";
2
- import assert from "node:assert/strict";
3
- import React from "react";
4
- import { PassThrough } from "node:stream";
5
- import { render } from "ink";
6
- import { ActivityIndicator } from "./ActivityIndicator.js";
7
-
8
- class TestOutput extends PassThrough {
9
- readonly isTTY = true;
10
- columns = 120;
11
- rows = 40;
12
- }
13
-
14
- function renderIndicator(props: any): Promise<string> {
15
- const stdout = new TestOutput();
16
- let output = "";
17
- stdout.on("data", (chunk) => {
18
- output += chunk.toString();
19
- });
20
- const instance = render(<ActivityIndicator {...props} />, { stdout: stdout as unknown as NodeJS.WriteStream });
21
- instance.unmount();
22
- return Promise.resolve(output);
23
- }
24
-
25
- test("idle state renders static subtle indicator", async () => {
26
- const output = await renderIndicator({ uiState: { kind: "IDLE" }, externalCliStatus: "idle" });
27
- assert.ok(output.includes("?"));
28
- });
29
-
30
- test("error state renders error indicator", async () => {
31
- const output = await renderIndicator({ uiState: { kind: "ERROR", turnId: 1, message: "err" } });
32
- assert.ok(output.includes("�"));
33
- });
34
-
35
- test("tool/action state renders action indicator", async () => {
36
- const output = await renderIndicator({ uiState: { kind: "SHELL_RUNNING", shellId: 1 } });
37
- assert.ok(output.includes("?"));
38
- });
39
-
40
- test("waiting/thinking state renders animated indicator frame", async () => {
41
- const output = await renderIndicator({ uiState: { kind: "THINKING", turnId: 1 } });
42
- assert.ok(output.includes("?"));
43
- });
44
-
45
- test("streaming state renders streaming indicator frame", async () => {
46
- const output = await renderIndicator({ uiState: { kind: "RESPONDING", turnId: 1 } });
47
- assert.ok(output.includes("?")); // first frame
48
- });
49
-
50
- test("provider loading renders animated indicator frame", async () => {
51
- const output = await renderIndicator({ uiState: { kind: "IDLE" }, externalCliStatus: "starting" });
52
- assert.ok(output.includes("?"));
53
- });
54
-
55
- test("provider failed renders error indicator", async () => {
56
- const output = await renderIndicator({ uiState: { kind: "IDLE" }, externalCliStatus: "failed" });
57
- assert.ok(output.includes("�"));
58
- });
@@ -1,6 +0,0 @@
1
- import test from "node:test";
2
-
3
- test("AgentBlock output streams organically without layout truncation", () => {
4
- // buildStreamingPreviewRows has been intentionally removed to support
5
- // true variable-height scrolling transcript behavior per project requirements.
6
- });
@@ -1,16 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { readFileSync } from "node:fs";
3
- import { fileURLToPath } from "node:url";
4
- import { dirname, join } from "node:path";
5
- import test from "node:test";
6
-
7
- const here = dirname(fileURLToPath(import.meta.url));
8
-
9
- test("busy status text owns the local animation timer", () => {
10
- const source = readFileSync(join(here, "AnimatedStatusText.tsx"), "utf8");
11
-
12
- assert.match(source, /setInterval/);
13
- assert.match(source, /useEffect/);
14
- assert.match(source, /useState/);
15
- assert.doesNotMatch(source, /useAnimatedDots|useThrottledValue/);
16
- });