@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,151 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import {
4
- clampScrollToCursor,
5
- createInputViewport,
6
- deleteInputBackward,
7
- deleteInputForward,
8
- insertInputText,
9
- locateCursor,
10
- moveCursorLeft,
11
- moveCursorRight,
12
- normalizeInputText,
13
- stripMouseEscapes,
14
- wrapInputRows,
15
- } from "./inputBuffer.js";
16
-
17
- test("normalizes windows line endings for the composer buffer", () => {
18
- assert.equal(normalizeInputText("a\r\nb\rc"), "a\nb\nc");
19
- });
20
-
21
- test("wraps multiline input into stable viewport rows", () => {
22
- const rows = wrapInputRows("alpha\nbeta gamma", 5);
23
- assert.deepEqual(rows.map((row) => row.text), ["alpha", "beta ", "gamma"]);
24
- assert.deepEqual(rows.map((row) => row.breakType), ["hard", "soft", "end"]);
25
- });
26
-
27
- test("keeps the cursor visible by scrolling the composer viewport", () => {
28
- assert.equal(clampScrollToCursor(0, 7, 4), 4);
29
- });
30
-
31
- test("keeps cursor mapping stable at hard newlines and soft wrap boundaries", () => {
32
- const multilineRows = wrapInputRows("alpha\nbeta", 20);
33
- assert.deepEqual(locateCursor(multilineRows, 5), { row: 0, column: 5 });
34
- assert.deepEqual(locateCursor(multilineRows, 6), { row: 1, column: 0 });
35
-
36
- const wrappedRows = wrapInputRows("alpha beta", 5);
37
- assert.deepEqual(locateCursor(wrappedRows, 5), { row: 0, column: 5 });
38
- assert.deepEqual(locateCursor(wrappedRows, 6), { row: 1, column: 1 });
39
- });
40
-
41
- test("uses code-point-safe cursor movement and deletion", () => {
42
- const text = "A😀B";
43
- assert.equal(moveCursorRight(text, 0), 1);
44
- assert.equal(moveCursorRight(text, 1), 3);
45
- assert.equal(moveCursorLeft(text, 3), 1);
46
-
47
- const inserted = insertInputText({ value: "A", cursorOffset: 1, text: "\nB" });
48
- assert.deepEqual(inserted, { value: "A\nB", cursorOffset: 3 });
49
-
50
- const deleted = deleteInputBackward({ value: text, cursorOffset: 3 });
51
- assert.deepEqual(deleted, { value: "AB", cursorOffset: 1 });
52
-
53
- const forwardDeleted = deleteInputForward({ value: text, cursorOffset: 1 });
54
- assert.deepEqual(forwardDeleted, { value: "AB", cursorOffset: 1 });
55
- });
56
-
57
- test("creates a bounded input viewport for large pasted content", () => {
58
- const viewport = createInputViewport({
59
- text: Array.from({ length: 12 }, (_, index) => `line-${index + 1}`).join("\n"),
60
- cursorOffset: "line-1\nline-2\nline-3\nline-4\nline-5\nline-6\nline-7\nline-8\nline-9\nline-10\nline-11\nline-12".length,
61
- width: 20,
62
- maxVisibleRows: 4,
63
- });
64
-
65
- assert.equal(viewport.visibleRows.length, 4);
66
- assert.equal(viewport.visibleRows[0]?.text, "line-9");
67
- assert.equal(viewport.visibleRows[3]?.text, "line-12");
68
- });
69
-
70
- test("reclamps scroll state when resize reduces the wrapped row count", () => {
71
- const narrowViewport = createInputViewport({
72
- text: "alpha beta gamma delta epsilon",
73
- cursorOffset: "alpha beta gamma delta epsilon".length,
74
- width: 5,
75
- maxVisibleRows: 2,
76
- });
77
-
78
- const wideViewport = createInputViewport({
79
- text: "alpha beta gamma delta epsilon",
80
- cursorOffset: "alpha beta gamma delta epsilon".length,
81
- width: 40,
82
- maxVisibleRows: 2,
83
- scrollRow: narrowViewport.scrollRow,
84
- });
85
-
86
- assert.equal(narrowViewport.scrollRow > 0, true);
87
- assert.equal(wideViewport.scrollRow, 0);
88
- assert.deepEqual(wideViewport.visibleRows.map((row) => row.text), ["alpha beta gamma delta epsilon"]);
89
- });
90
-
91
- test("strips leaked SGR mouse escape sequence fragments from input", () => {
92
- const leaked = "[<0;26;24M[<0;26;24m";
93
- assert.equal(normalizeInputText(leaked), "");
94
-
95
- const partial = "text[<0;26;24Mmore";
96
- assert.equal(normalizeInputText(partial), "textmore");
97
- });
98
-
99
- test("stripMouseEscapes: removes complete SGR sequences (ESC-prefixed)", () => {
100
- assert.equal(stripMouseEscapes("\x1b[<0;83;19M"), "");
101
- assert.equal(stripMouseEscapes("\x1b[<64;83;19M"), "");
102
- assert.equal(stripMouseEscapes("\x1b[<64;83;19m"), ""); // lowercase m
103
- });
104
-
105
- test("stripMouseEscapes: removes leaked SGR fragments (ESC already stripped by readline)", () => {
106
- assert.equal(stripMouseEscapes("[<0;83;19M"), "");
107
- });
108
-
109
- test("stripMouseEscapes: strips mouse sequences embedded in surrounding text", () => {
110
- assert.equal(stripMouseEscapes("hello\x1b[<0;83;19M"), "hello");
111
- assert.equal(stripMouseEscapes("\x1b[<0;83;19Mhello"), "hello");
112
- assert.equal(stripMouseEscapes("hello[<64;83;19Mworld"), "helloworld");
113
- });
114
-
115
- test("stripMouseEscapes: preserves normal text and returns it unchanged", () => {
116
- assert.equal(stripMouseEscapes("hello world"), "hello world");
117
- assert.equal(stripMouseEscapes("git status"), "git status");
118
- assert.equal(stripMouseEscapes(""), "");
119
- assert.equal(stripMouseEscapes("I"), "I");
120
- assert.equal(stripMouseEscapes("yes"), "yes");
121
- });
122
-
123
- // NOTE: Partial chunk splitting (e.g. "\x1b[<0;" then "83;19M" as two separate writes)
124
- // is not filterable at the string level — each chunk alone does not match the pattern.
125
- // Robust partial-chunk handling requires stateful stdin buffering (not implemented here
126
- // or in BottomComposer). In practice, terminals send mouse sequences as atomic stdin
127
- // writes so this case does not arise in normal usage.
128
-
129
- test("robustness: rapid sequential typing and deletion", () => {
130
- let state = { value: "", cursorOffset: 0 };
131
-
132
- // Simulate typing "hello"
133
- for (const char of "hello") {
134
- state = insertInputText({ ...state, text: char });
135
- }
136
- assert.deepEqual(state, { value: "hello", cursorOffset: 5 });
137
-
138
- // Simulate backspacing "o" and "l"
139
- state = deleteInputBackward(state);
140
- state = deleteInputBackward(state);
141
- assert.deepEqual(state, { value: "hel", cursorOffset: 3 });
142
-
143
- // Simulate inserting "p" in the middle
144
- state.cursorOffset = 2; // after "e"
145
- state = insertInputText({ ...state, text: "p" });
146
- assert.deepEqual(state, { value: "hepl", cursorOffset: 3 });
147
-
148
- // Simulate forward delete of "l"
149
- state = deleteInputForward(state);
150
- assert.deepEqual(state, { value: "hep", cursorOffset: 3 });
151
- });
@@ -1,145 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import {
4
- advanceTerminalViewport,
5
- clampVisualText,
6
- createTerminalViewport,
7
- createLayoutSnapshot,
8
- getShellHeight,
9
- getShellWidth,
10
- getUsableShellWidth,
11
- getVisualWidth,
12
- resolveStartupHeaderMode,
13
- } from "./layout.js";
14
- import { getHeaderHeroLayout, measureTopHeaderRows } from "./TopHeader.js";
15
-
16
- test("leaves a one-column gutter to avoid edge-triggered scrollbars", () => {
17
- assert.equal(getShellWidth(120), 119);
18
- assert.equal(getShellWidth(80), 79);
19
- });
20
-
21
- test("keeps a sensible minimum shell width on tiny terminals", () => {
22
- assert.equal(getShellWidth(20), 20);
23
- assert.equal(getShellWidth(10), 20);
24
- assert.equal(getShellWidth(undefined), 119);
25
- });
26
-
27
- test("derives usable shell width from the guttered viewport width", () => {
28
- assert.equal(getUsableShellWidth(120, 6), 113);
29
- assert.equal(getUsableShellWidth(20, 30), 1);
30
- });
31
-
32
- test("leaves a one-row gutter to avoid edge-triggered bottom scrolling", () => {
33
- assert.equal(getShellHeight(40), 39);
34
- assert.equal(getShellHeight(24), 23);
35
- });
36
-
37
- test("keeps a sensible minimum shell height on tiny terminals", () => {
38
- assert.equal(getShellHeight(10), 10);
39
- assert.equal(getShellHeight(5), 10);
40
- assert.equal(getShellHeight(undefined), 23);
41
- });
42
-
43
- test("keeps breakpoint modes stable at the edges", () => {
44
- assert.equal(createLayoutSnapshot(110, 24).mode, "full");
45
- assert.equal(createLayoutSnapshot(109, 24).mode, "compact");
46
- assert.equal(createLayoutSnapshot(60, 24).mode, "compact");
47
- assert.equal(createLayoutSnapshot(59, 24).mode, "micro");
48
- });
49
-
50
- test("chooses startup header mode from measured row budget", () => {
51
- assert.equal(resolveStartupHeaderMode({
52
- cols: 120,
53
- rows: 30,
54
- introRows: 7,
55
- composerRows: 6,
56
- }), "large");
57
-
58
- assert.equal(resolveStartupHeaderMode({
59
- cols: 120,
60
- rows: 16,
61
- introRows: 7,
62
- composerRows: 6,
63
- }), "compact");
64
-
65
- assert.equal(resolveStartupHeaderMode({
66
- cols: 100,
67
- rows: 24,
68
- introRows: 7,
69
- composerRows: 5,
70
- }), "compact");
71
-
72
- assert.equal(resolveStartupHeaderMode({
73
- cols: 39,
74
- rows: 24,
75
- introRows: 7,
76
- composerRows: 5,
77
- }), "tiny");
78
-
79
- assert.equal(resolveStartupHeaderMode({
80
- cols: 100,
81
- rows: 13,
82
- introRows: 7,
83
- composerRows: 5,
84
- }), "tiny");
85
- });
86
-
87
- test("measures the header rows for full and compact layouts", () => {
88
- assert.equal(measureTopHeaderRows(createLayoutSnapshot(120, 30)), 8);
89
- assert.equal(measureTopHeaderRows(createLayoutSnapshot(80, 24)), 1);
90
- });
91
-
92
- test("header hero switches from stacked to wide only when metadata has room", () => {
93
- assert.equal(getHeaderHeroLayout(createLayoutSnapshot(110, 30)).mode, "stacked");
94
- assert.equal(getHeaderHeroLayout(createLayoutSnapshot(130, 30)).mode, "wide");
95
- });
96
-
97
- test("preserves the previous layout when resize values are invalid", () => {
98
- const previous = createLayoutSnapshot(80, 30);
99
- const next = createLayoutSnapshot(0, -1, previous);
100
-
101
- assert.deepEqual(next, previous);
102
- });
103
-
104
- test("marks undersized restore samples as unstable without discarding the last stable layout", () => {
105
- const stable = createTerminalViewport(120, 40);
106
- const invalidSamples = [
107
- advanceTerminalViewport(stable, 1, 1),
108
- advanceTerminalViewport(stable, 2, 1),
109
- advanceTerminalViewport(stable, 1, 24),
110
- advanceTerminalViewport(stable, 24, 1),
111
- // Medium-invalid: pass old <=1 check but fail MIN_VIEWPORT thresholds
112
- advanceTerminalViewport(stable, 15, 8),
113
- advanceTerminalViewport(stable, 19, 24),
114
- advanceTerminalViewport(stable, 120, 9),
115
- ];
116
-
117
- for (const sample of invalidSamples) {
118
- assert.equal(sample.unstable, true);
119
- assert.equal(sample.cols, stable.cols);
120
- assert.equal(sample.rows, stable.rows);
121
- assert.equal(sample.layoutEpoch, stable.layoutEpoch);
122
- }
123
- });
124
-
125
- test("bumps the layout epoch when the terminal recovers from an unstable restore", () => {
126
- const stable = createTerminalViewport(120, 40);
127
- const unstable = advanceTerminalViewport(stable, 1, 1);
128
- const recovered = advanceTerminalViewport(unstable, 100, 30);
129
-
130
- assert.equal(unstable.unstable, true);
131
- assert.equal(recovered.unstable, false);
132
- assert.equal(recovered.cols, 100);
133
- assert.equal(recovered.rows, 30);
134
- assert.equal(recovered.layoutEpoch, stable.layoutEpoch + 1);
135
- });
136
-
137
- test("measures visual width instead of raw string length", () => {
138
- assert.equal("⚡".length, 1);
139
- assert.equal(getVisualWidth("⚡"), 2);
140
- });
141
-
142
- test("clamps text to a visual width budget", () => {
143
- assert.equal(clampVisualText("ACTION REQUIRED", 8), "ACTION …");
144
- assert.equal(clampVisualText("⚡⚡", 3), "⚡…");
145
- });
@@ -1,42 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { getModeDisplaySpec } from "./modeDisplay.js";
4
- import { THEMES, theme } from "./theme.js";
5
-
6
- test("maps internal modes to Codex-aligned display labels", () => {
7
- assert.equal(getModeDisplaySpec("suggest", theme).label, "Read-only");
8
- assert.equal(getModeDisplaySpec("auto-edit", theme).label, "Auto");
9
- assert.equal(getModeDisplaySpec("full-auto", theme).label, "Full Access");
10
- });
11
-
12
- test("uses distinct ring glyphs and theme tokens for each mode", () => {
13
- const readOnly = getModeDisplaySpec("suggest", theme);
14
- const auto = getModeDisplaySpec("auto-edit", theme);
15
- const fullAccess = getModeDisplaySpec("full-auto", theme);
16
-
17
- assert.equal(readOnly.ringGlyph, "○");
18
- assert.equal(readOnly.ringColor, theme.SUCCESS);
19
- assert.equal(readOnly.ringFill, theme.PANEL_SOFT);
20
-
21
- assert.equal(auto.ringGlyph, "◎");
22
- assert.equal(auto.ringColor, theme.BORDER_ACTIVE);
23
- assert.equal(auto.ringFill, theme.PANEL_ALT);
24
-
25
- assert.equal(fullAccess.ringGlyph, "◉");
26
- assert.equal(fullAccess.ringColor, theme.WARNING);
27
- assert.equal(fullAccess.ringFill, theme.BORDER_SUBTLE);
28
- });
29
-
30
- test("keeps the mode ring meaningful across every built-in theme", () => {
31
- for (const [themeName, activeTheme] of Object.entries(THEMES)) {
32
- const specs = [
33
- getModeDisplaySpec("suggest", activeTheme),
34
- getModeDisplaySpec("auto-edit", activeTheme),
35
- getModeDisplaySpec("full-auto", activeTheme),
36
- ];
37
-
38
- assert.equal(new Set(specs.map((spec) => spec.ringGlyph)).size, 3, themeName);
39
- assert.equal(new Set(specs.map((spec) => spec.ringColor)).size, 3, themeName);
40
- assert.ok(specs.every((spec) => spec.ringFill.length > 0), themeName);
41
- }
42
- });
@@ -1,89 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import type { RunEvent } from "../session/types.js";
4
- import { summarizeRunActivity } from "../core/workspaceActivity.js";
5
- import { TEST_RUNTIME } from "../test/runtimeTestUtils.js";
6
- import {
7
- formatRunActivityStats,
8
- getVisibleRawOutputLines,
9
- selectVisibleRunActivity,
10
- shouldShowRawOutputFallback,
11
- } from "./runActivityView.js";
12
-
13
- function makeRunEvent(overrides: Partial<RunEvent> = {}): RunEvent {
14
- const activity = overrides.activity ?? [];
15
- return {
16
- id: 1,
17
- type: "run",
18
- createdAt: 1,
19
- startedAt: 1,
20
- durationMs: null,
21
- backendId: "codex-subprocess",
22
- backendLabel: "Codex CLI",
23
- runtime: TEST_RUNTIME,
24
- prompt: "Build something",
25
- progressEntries: [],
26
- status: "running",
27
- summary: "Running",
28
- truncatedOutput: false,
29
- toolActivities: overrides.toolActivities ?? [],
30
- activity,
31
- touchedFileCount: overrides.touchedFileCount ?? new Set(activity.map((item) => item.path)).size,
32
- activitySummary: overrides.activitySummary ?? summarizeRunActivity(activity),
33
- errorMessage: null,
34
- turnId: overrides.turnId ?? 1,
35
- ...overrides,
36
- };
37
- }
38
-
39
- test("does not surface raw output fallback while a run is active", () => {
40
- const event = makeRunEvent({
41
- progressEntries: [],
42
- activity: [{ path: "src/app.tsx", operation: "modified", detectedAt: 1 }],
43
- });
44
-
45
- assert.equal(shouldShowRawOutputFallback(event), false);
46
- assert.deepEqual(getVisibleRawOutputLines(event), []);
47
- });
48
-
49
- test("keeps raw output hidden even when no structured activity exists yet", () => {
50
- const event = makeRunEvent({
51
- progressEntries: [],
52
- });
53
-
54
- assert.equal(shouldShowRawOutputFallback(event), false);
55
- assert.deepEqual(getVisibleRawOutputLines(event), []);
56
- });
57
-
58
- test("keeps only the compact recent activity for completed runs", () => {
59
- const activity = Array.from({ length: 6 }, (_, index) => ({
60
- path: `src/file-${index}.ts`,
61
- operation: "modified" as const,
62
- detectedAt: index,
63
- }));
64
- const event = makeRunEvent({
65
- status: "completed",
66
- activity,
67
- activitySummary: summarizeRunActivity(activity),
68
- });
69
-
70
- const { visible, hiddenCount } = selectVisibleRunActivity(event);
71
- assert.equal(visible.length, 4);
72
- assert.equal(hiddenCount, 2);
73
- assert.equal(visible[0]?.path, "src/file-2.ts");
74
- });
75
-
76
- test("formats touched-file stats for the run card header", () => {
77
- const activity = [
78
- { path: "README.md", operation: "created" as const, detectedAt: 1 },
79
- { path: "src/app.tsx", operation: "modified" as const, detectedAt: 2 },
80
- { path: "old.txt", operation: "deleted" as const, detectedAt: 3 },
81
- ];
82
- const event = makeRunEvent({
83
- activity,
84
- touchedFileCount: 3,
85
- activitySummary: summarizeRunActivity(activity),
86
- });
87
-
88
- assert.equal(formatRunActivityStats(event), "3 files touched +1 ~1 -1");
89
- });
@@ -1,237 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import React from "react";
4
- import { PassThrough } from "node:stream";
5
- import { Box, render } from "ink";
6
- import type { UIState } from "../session/types.js";
7
- import { isBusy } from "../session/types.js";
8
- import { BottomComposer } from "./BottomComposer.js";
9
- import { createLayoutSnapshot } from "./layout.js";
10
- import { getRunFooterStatus, RunFooter } from "./RunFooter.js";
11
- import { ThemeProvider } from "./theme.js";
12
-
13
- class TestInput extends PassThrough {
14
- readonly isTTY = true;
15
-
16
- setRawMode(): this {
17
- return this;
18
- }
19
-
20
- override resume(): this {
21
- return this;
22
- }
23
-
24
- override pause(): this {
25
- return this;
26
- }
27
-
28
- ref(): this {
29
- return this;
30
- }
31
-
32
- unref(): this {
33
- return this;
34
- }
35
- }
36
-
37
- class TestOutput extends PassThrough {
38
- readonly isTTY = true;
39
- columns = 120;
40
- rows = 40;
41
- }
42
-
43
- function stripAnsi(value: string): string {
44
- return value.replace(/\u001B\[[0-?]*[ -/]*[@-~]/g, "");
45
- }
46
-
47
- function sleep(ms = 50): Promise<void> {
48
- return new Promise((resolve) => setTimeout(resolve, ms));
49
- }
50
-
51
- const TEST_LAYOUT = createLayoutSnapshot(120, 40);
52
-
53
- test("idle footer status is empty by contract", () => {
54
- assert.equal(getRunFooterStatus({ kind: "IDLE" }), "");
55
- });
56
-
57
- function LifecycleHarness({ uiState, value, showBusyLoader = true }: { uiState: UIState; value: string; showBusyLoader?: boolean }) {
58
- const showComposer = !isBusy(uiState);
59
-
60
- return (
61
- <ThemeProvider theme="purple">
62
- <Box flexDirection="column" width="100%">
63
- {showComposer ? (
64
- <BottomComposer
65
- layout={TEST_LAYOUT}
66
- uiState={uiState}
67
- mode="suggest"
68
- model="gpt-5.4"
69
- reasoningLevel="balanced"
70
- tokensUsed={100}
71
- value={value}
72
- cursor={value.length}
73
- onChangeInput={() => {}}
74
- onSubmit={() => {}}
75
- onCancel={() => {}}
76
- onChangeValue={() => {}}
77
- onChangeCursor={() => {}}
78
- onHistoryUp={() => {}}
79
- onHistoryDown={() => {}}
80
- onOpenBackendPicker={() => {}}
81
- onOpenModelPicker={() => {}}
82
- onOpenModePicker={() => {}}
83
- onOpenThemePicker={() => {}}
84
- onOpenAuthPanel={() => {}}
85
- onTogglePlanMode={() => {}}
86
- onClear={() => {}}
87
- onCycleMode={() => {}}
88
- onQuit={() => {}}
89
- />
90
- ) : (
91
- <RunFooter uiState={uiState} showBusyLoader={showBusyLoader} onCancel={() => {}} onQuit={() => {}} />
92
- )}
93
- </Box>
94
- </ThemeProvider>
95
- );
96
- }
97
-
98
- test("collapses composer during thinking so input buffer artifacts are removed", async () => {
99
- const stdin = new TestInput();
100
- const stdout = new TestOutput();
101
- let output = "";
102
- stdout.on("data", (chunk) => {
103
- output += chunk.toString();
104
- });
105
-
106
- const instance = render(
107
- <LifecycleHarness uiState={{ kind: "IDLE" }} value="draft prompt" />,
108
- {
109
- stdin: stdin as unknown as NodeJS.ReadStream,
110
- stdout: stdout as unknown as NodeJS.WriteStream,
111
- stderr: stdout as unknown as NodeJS.WriteStream,
112
- debug: true,
113
- exitOnCtrlC: false,
114
- },
115
- );
116
-
117
- await sleep();
118
- let frame = stripAnsi(output);
119
- assert.match(frame, /draft prompt/i);
120
-
121
- output = "";
122
- instance.rerender(<LifecycleHarness uiState={{ kind: "THINKING", turnId: 1 }} value="draft prompt" />);
123
- await sleep();
124
- frame = stripAnsi(output);
125
- assert.doesNotMatch(frame, /draft prompt/i);
126
- assert.match(frame, /Codexa is thinking/i);
127
-
128
- instance.unmount();
129
- });
130
-
131
- test("busy footer advances from local status state without a parent rerender", async () => {
132
- const stdin = new TestInput();
133
- const stdout = new TestOutput();
134
- let output = "";
135
-
136
- stdout.on("data", (chunk) => {
137
- output += chunk.toString();
138
- });
139
-
140
- const instance = render(
141
- <LifecycleHarness uiState={{ kind: "THINKING", turnId: 1 }} value="" />,
142
- {
143
- stdin: stdin as unknown as NodeJS.ReadStream,
144
- stdout: stdout as unknown as NodeJS.WriteStream,
145
- stderr: stdout as unknown as NodeJS.WriteStream,
146
- debug: true,
147
- exitOnCtrlC: false,
148
- },
149
- );
150
-
151
- await sleep();
152
- let frame = stripAnsi(output);
153
- assert.match(frame, /Codexa is thinking \./);
154
-
155
- output = "";
156
- await sleep(950);
157
- frame = stripAnsi(output);
158
- assert.match(frame, /Codexa is thinking \.\./);
159
-
160
- instance.unmount();
161
- });
162
-
163
- test("busy footer omits loader frames when disabled", async () => {
164
- const stdin = new TestInput();
165
- const stdout = new TestOutput();
166
- let output = "";
167
-
168
- stdout.on("data", (chunk) => {
169
- output += chunk.toString();
170
- });
171
-
172
- const instance = render(
173
- <LifecycleHarness uiState={{ kind: "THINKING", turnId: 1 }} value="" showBusyLoader={false} />,
174
- {
175
- stdin: stdin as unknown as NodeJS.ReadStream,
176
- stdout: stdout as unknown as NodeJS.WriteStream,
177
- stderr: stdout as unknown as NodeJS.WriteStream,
178
- debug: true,
179
- exitOnCtrlC: false,
180
- },
181
- );
182
-
183
- try {
184
- await sleep();
185
- let frame = stripAnsi(output);
186
- assert.match(frame, /Codexa is thinking/);
187
- assert.doesNotMatch(frame, /Codexa is thinking \./);
188
-
189
- output = "";
190
- await sleep(950);
191
- frame = stripAnsi(output);
192
- assert.equal(frame, "");
193
- } finally {
194
- instance.unmount();
195
- }
196
- });
197
-
198
- test("static status debug flag reserves status text without dot ticks", async () => {
199
- const previous = process.env.CODEXA_DEBUG_STATIC_STATUS;
200
- process.env.CODEXA_DEBUG_STATIC_STATUS = "1";
201
- const stdin = new TestInput();
202
- const stdout = new TestOutput();
203
- let output = "";
204
-
205
- stdout.on("data", (chunk) => {
206
- output += chunk.toString();
207
- });
208
-
209
- const instance = render(
210
- <LifecycleHarness uiState={{ kind: "THINKING", turnId: 1 }} value="" />,
211
- {
212
- stdin: stdin as unknown as NodeJS.ReadStream,
213
- stdout: stdout as unknown as NodeJS.WriteStream,
214
- stderr: stdout as unknown as NodeJS.WriteStream,
215
- debug: true,
216
- exitOnCtrlC: false,
217
- },
218
- );
219
-
220
- try {
221
- await sleep();
222
- let frame = stripAnsi(output);
223
- assert.match(frame, /Codexa is thinking \.\.\./);
224
-
225
- output = "";
226
- await sleep(950);
227
- frame = stripAnsi(output);
228
- assert.equal(frame, "");
229
- } finally {
230
- instance.unmount();
231
- if (previous === undefined) {
232
- delete process.env.CODEXA_DEBUG_STATIC_STATUS;
233
- } else {
234
- process.env.CODEXA_DEBUG_STATIC_STATUS = previous;
235
- }
236
- }
237
- });