@golba98/codexa 1.0.2 → 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 (150) hide show
  1. package/README.md +391 -94
  2. package/package.json +12 -7
  3. package/src/app.tsx +149 -117
  4. package/src/commands/handler.ts +4 -4
  5. package/src/config/buildInfo.ts +2 -2
  6. package/src/config/persistence.ts +10 -0
  7. package/src/config/settings.ts +7 -15
  8. package/src/config/updateCheckCache.ts +19 -1
  9. package/src/core/channel.ts +23 -0
  10. package/src/core/executables/codexExecutable.ts +1 -0
  11. package/src/core/executables/executableResolver.ts +61 -43
  12. package/src/core/launchContext.ts +33 -33
  13. package/src/core/process/processValidation.ts +9 -5
  14. package/src/core/providerLauncher/launcher.ts +59 -42
  15. package/src/core/updateCheck.ts +111 -95
  16. package/src/session/types.ts +2 -1
  17. package/src/ui/ActionRequiredBlock.tsx +5 -5
  18. package/src/ui/ActivityBars.tsx +3 -3
  19. package/src/ui/ActivityIndicator.tsx +6 -6
  20. package/src/ui/AgentBlock.tsx +6 -6
  21. package/src/ui/AnimatedStatusText.tsx +1 -1
  22. package/src/ui/AppShell.tsx +9 -24
  23. package/src/ui/AttachmentImportPanel.tsx +8 -8
  24. package/src/ui/AuthPanel.tsx +20 -20
  25. package/src/ui/BottomComposer.tsx +117 -78
  26. package/src/ui/DashCard.tsx +3 -3
  27. package/src/ui/Markdown.tsx +17 -17
  28. package/src/ui/ModelPickerScreen.tsx +10 -10
  29. package/src/ui/ModelReasoningPicker.tsx +14 -14
  30. package/src/ui/Panel.tsx +3 -3
  31. package/src/ui/PlanActionPicker.tsx +6 -6
  32. package/src/ui/PlanReviewPanel.tsx +8 -8
  33. package/src/ui/ProviderPicker.tsx +18 -18
  34. package/src/ui/RunFooter.tsx +3 -3
  35. package/src/ui/SelectionPanel.tsx +4 -4
  36. package/src/ui/SettingsPanel.tsx +8 -8
  37. package/src/ui/Spinner.tsx +1 -1
  38. package/src/ui/TextEntryPanel.tsx +10 -10
  39. package/src/ui/ThinkingBlock.tsx +8 -8
  40. package/src/ui/Timeline.tsx +21 -17
  41. package/src/ui/TopHeader.tsx +421 -293
  42. package/src/ui/TurnGroup.tsx +31 -31
  43. package/src/ui/UpdateAvailableCard.tsx +41 -0
  44. package/src/ui/UpdatePromptPanel.tsx +203 -0
  45. package/src/ui/focus.ts +3 -0
  46. package/src/ui/layout.ts +1 -1
  47. package/src/ui/logoVariants.ts +107 -0
  48. package/src/ui/modeDisplay.ts +12 -12
  49. package/src/ui/runtimeDisplay.ts +100 -0
  50. package/src/ui/theme.tsx +274 -395
  51. package/src/ui/timelineMeasure.ts +29 -19
  52. package/scripts/audit-codexa-capabilities.mjs +0 -466
  53. package/scripts/gen-build-info.mjs +0 -33
  54. package/scripts/smoke-terminal-bench.mjs +0 -35
  55. package/src/appRenderStability.test.ts +0 -131
  56. package/src/commands/handler.test.ts +0 -655
  57. package/src/config/launchArgs.test.ts +0 -189
  58. package/src/config/layeredConfig.test.ts +0 -143
  59. package/src/config/persistence.test.ts +0 -114
  60. package/src/config/runtimeConfig.test.ts +0 -218
  61. package/src/config/settings.test.ts +0 -155
  62. package/src/config/trustStore.test.ts +0 -29
  63. package/src/core/attachments.test.ts +0 -155
  64. package/src/core/auth/codexAuth.test.ts +0 -68
  65. package/src/core/cleanupFastFail.test.ts +0 -76
  66. package/src/core/codexExecArgs.test.ts +0 -195
  67. package/src/core/codexLaunch.test.ts +0 -205
  68. package/src/core/codexPrompt.test.ts +0 -252
  69. package/src/core/executables/codexExecutable.test.ts +0 -212
  70. package/src/core/executables/executableResolver.test.ts +0 -129
  71. package/src/core/executables/geminiExecutable.test.ts +0 -116
  72. package/src/core/executables/pathSanityScan.test.ts +0 -47
  73. package/src/core/githubDiagnostics.test.ts +0 -92
  74. package/src/core/hollowResponseFormat.test.ts +0 -58
  75. package/src/core/launchContext.test.ts +0 -157
  76. package/src/core/models/codexCapabilities.test.ts +0 -45
  77. package/src/core/models/codexModelCapabilities.test.ts +0 -246
  78. package/src/core/models/modelSpecs.test.ts +0 -283
  79. package/src/core/perf/renderDebug.test.ts +0 -230
  80. package/src/core/planStorage.test.ts +0 -143
  81. package/src/core/process/CommandRunner.test.ts +0 -105
  82. package/src/core/projectInstructions.test.ts +0 -50
  83. package/src/core/providerLauncher/launcher.test.ts +0 -238
  84. package/src/core/providerLauncher/registry.test.ts +0 -324
  85. package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
  86. package/src/core/providerRuntime/anthropic.test.ts +0 -1120
  87. package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
  88. package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
  89. package/src/core/providerRuntime/gemini.test.ts +0 -437
  90. package/src/core/providerRuntime/lmstudio.test.ts +0 -168
  91. package/src/core/providerRuntime/local.test.ts +0 -787
  92. package/src/core/providerRuntime/registry.test.ts +0 -233
  93. package/src/core/providers/codexJsonStream.test.ts +0 -148
  94. package/src/core/providers/codexSubprocess.test.ts +0 -68
  95. package/src/core/providers/codexTranscript.test.ts +0 -284
  96. package/src/core/terminal/startupClear.test.ts +0 -55
  97. package/src/core/terminal/terminalCapabilities.test.ts +0 -93
  98. package/src/core/terminal/terminalControl.test.ts +0 -75
  99. package/src/core/terminal/terminalSanitize.test.ts +0 -22
  100. package/src/core/terminal/terminalSelection.test.ts +0 -42
  101. package/src/core/terminal/terminalTitle.test.ts +0 -328
  102. package/src/core/updateCheck.test.ts +0 -194
  103. package/src/core/workspaceActivity.test.ts +0 -163
  104. package/src/core/workspaceGuard.test.ts +0 -151
  105. package/src/core/workspaceRoot.test.ts +0 -23
  106. package/src/exec.test.ts +0 -13
  107. package/src/headless/execArgs.test.ts +0 -147
  108. package/src/headless/execRunner.test.ts +0 -436
  109. package/src/index.test.tsx +0 -620
  110. package/src/session/appSession.test.ts +0 -897
  111. package/src/session/chatLifecycle.test.ts +0 -64
  112. package/src/session/liveRenderScheduler.test.ts +0 -201
  113. package/src/session/planFlow.test.ts +0 -103
  114. package/src/session/planTranscript.test.ts +0 -65
  115. package/src/session/promptRunSchedule.test.ts +0 -36
  116. package/src/ui/ActivityIndicator.test.tsx +0 -58
  117. package/src/ui/AgentBlock.test.ts +0 -6
  118. package/src/ui/AnimatedStatusText.test.ts +0 -16
  119. package/src/ui/AppShell.test.tsx +0 -1776
  120. package/src/ui/AttachmentImportPanel.test.tsx +0 -204
  121. package/src/ui/BottomComposer.test.ts +0 -674
  122. package/src/ui/CodexLogo.tsx +0 -55
  123. package/src/ui/Markdown.test.ts +0 -157
  124. package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
  125. package/src/ui/ModelPickerScreen.test.tsx +0 -99
  126. package/src/ui/ModelPickerState.test.tsx +0 -151
  127. package/src/ui/ModelReasoningPicker.test.tsx +0 -447
  128. package/src/ui/PlanReviewPanel.test.tsx +0 -267
  129. package/src/ui/PromptCardBorder.test.tsx +0 -161
  130. package/src/ui/ProviderPicker.test.tsx +0 -289
  131. package/src/ui/ProviderShortcut.test.tsx +0 -143
  132. package/src/ui/SettingsPanel.test.tsx +0 -233
  133. package/src/ui/Timeline.test.ts +0 -2067
  134. package/src/ui/TimelineNavigation.test.tsx +0 -201
  135. package/src/ui/TopHeader.test.tsx +0 -254
  136. package/src/ui/TurnGroup.test.tsx +0 -365
  137. package/src/ui/busyStatusAnimation.test.ts +0 -30
  138. package/src/ui/commandNormalize.test.ts +0 -142
  139. package/src/ui/diffRenderer.test.ts +0 -102
  140. package/src/ui/focusFlow.test.tsx +0 -1098
  141. package/src/ui/inputBuffer.test.ts +0 -151
  142. package/src/ui/layout.test.ts +0 -146
  143. package/src/ui/modeDisplay.test.ts +0 -42
  144. package/src/ui/runActivityView.test.ts +0 -89
  145. package/src/ui/runLifecycleView.test.tsx +0 -237
  146. package/src/ui/statusRenderIsolation.test.tsx +0 -654
  147. package/src/ui/terminalAnswerFormat.test.ts +0 -19
  148. package/src/ui/textLayout.test.ts +0 -18
  149. package/src/ui/themeFlow.test.ts +0 -53
  150. 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,146 +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)), 7);
89
- assert.equal(measureTopHeaderRows(createLayoutSnapshot(80, 24)), 10);
90
- assert.equal(measureTopHeaderRows(createLayoutSnapshot(50, 24)), 1);
91
- });
92
-
93
- test("header hero switches from stacked to wide only when metadata has room", () => {
94
- assert.equal(getHeaderHeroLayout(createLayoutSnapshot(110, 30)).mode, "stacked");
95
- assert.equal(getHeaderHeroLayout(createLayoutSnapshot(130, 30)).mode, "wide");
96
- });
97
-
98
- test("preserves the previous layout when resize values are invalid", () => {
99
- const previous = createLayoutSnapshot(80, 30);
100
- const next = createLayoutSnapshot(0, -1, previous);
101
-
102
- assert.deepEqual(next, previous);
103
- });
104
-
105
- test("marks undersized restore samples as unstable without discarding the last stable layout", () => {
106
- const stable = createTerminalViewport(120, 40);
107
- const invalidSamples = [
108
- advanceTerminalViewport(stable, 1, 1),
109
- advanceTerminalViewport(stable, 2, 1),
110
- advanceTerminalViewport(stable, 1, 24),
111
- advanceTerminalViewport(stable, 24, 1),
112
- // Medium-invalid: pass old <=1 check but fail MIN_VIEWPORT thresholds
113
- advanceTerminalViewport(stable, 15, 8),
114
- advanceTerminalViewport(stable, 19, 24),
115
- advanceTerminalViewport(stable, 120, 9),
116
- ];
117
-
118
- for (const sample of invalidSamples) {
119
- assert.equal(sample.unstable, true);
120
- assert.equal(sample.cols, stable.cols);
121
- assert.equal(sample.rows, stable.rows);
122
- assert.equal(sample.layoutEpoch, stable.layoutEpoch);
123
- }
124
- });
125
-
126
- test("bumps the layout epoch when the terminal recovers from an unstable restore", () => {
127
- const stable = createTerminalViewport(120, 40);
128
- const unstable = advanceTerminalViewport(stable, 1, 1);
129
- const recovered = advanceTerminalViewport(unstable, 100, 30);
130
-
131
- assert.equal(unstable.unstable, true);
132
- assert.equal(recovered.unstable, false);
133
- assert.equal(recovered.cols, 100);
134
- assert.equal(recovered.rows, 30);
135
- assert.equal(recovered.layoutEpoch, stable.layoutEpoch + 1);
136
- });
137
-
138
- test("measures visual width instead of raw string length", () => {
139
- assert.equal("⚡".length, 1);
140
- assert.equal(getVisualWidth("⚡"), 2);
141
- });
142
-
143
- test("clamps text to a visual width budget", () => {
144
- assert.equal(clampVisualText("ACTION REQUIRED", 8), "ACTION …");
145
- assert.equal(clampVisualText("⚡⚡", 3), "⚡…");
146
- });
@@ -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
- });