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