@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,1098 +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, Text, render, useFocus, useFocusManager } from "ink";
6
- import { handleCommand } from "../commands/handler.js";
7
- import { normalizeRuntimeConfig, resolveRuntimeConfig } from "../config/runtimeConfig.js";
8
- import type { AvailableModel, ReasoningLevel } from "../config/settings.js";
9
- import { createFallbackModelCapabilities, getSelectableModelCapabilities } from "../core/models/codexModelCapabilities.js";
10
- import { buildProviderRegistry } from "../core/providerLauncher/registry.js";
11
- import { BottomComposer } from "./BottomComposer.js";
12
- import { getFocusTargetForScreen } from "./focus.js";
13
- import { ModelPickerScreen } from "./ModelPickerScreen.js";
14
- import { PlanActionPicker } from "./PlanActionPicker.js";
15
- import { ProviderPicker } from "./ProviderPicker.js";
16
- import { createLayoutSnapshot } from "./layout.js";
17
- import { TextEntryPanel } from "./TextEntryPanel.js";
18
- import { ThemeProvider } from "./theme.js";
19
- import { shouldBumpComposerInstance } from "./themeFlow.js";
20
-
21
- class TestInput extends PassThrough {
22
- readonly isTTY = true;
23
-
24
- setRawMode(): this {
25
- return this;
26
- }
27
-
28
- override resume(): this {
29
- return this;
30
- }
31
-
32
- override pause(): this {
33
- return this;
34
- }
35
-
36
- ref(): this {
37
- return this;
38
- }
39
-
40
- unref(): this {
41
- return this;
42
- }
43
- }
44
-
45
- class TestOutput extends PassThrough {
46
- readonly isTTY = true;
47
- columns = 120;
48
- rows = 40;
49
- }
50
-
51
- const TEST_LAYOUT = createLayoutSnapshot(120, 40);
52
- const TEST_MODEL_CAPABILITIES = getSelectableModelCapabilities(createFallbackModelCapabilities());
53
- const TEST_COMMAND_CONTEXT = {
54
- config: {
55
- runtime: normalizeRuntimeConfig({
56
- provider: "codex-subprocess",
57
- model: "gpt-5.4",
58
- mode: "suggest",
59
- reasoningLevel: "high",
60
- }),
61
- diagnostics: {
62
- projectRoot: "C:\\Workspace",
63
- projectTrusted: false,
64
- selectedProfile: null,
65
- selectedProfileSource: null,
66
- cliOverrides: [],
67
- layers: [
68
- { label: "Built-in defaults", status: "loaded" as const },
69
- { label: "User config", status: "missing" as const, path: "C:\\Users\\Test\\.codex\\config.toml" },
70
- ],
71
- ignoredEntries: [],
72
- fieldSources: {
73
- provider: "Built-in defaults",
74
- model: "Built-in defaults",
75
- reasoningLevel: "Built-in defaults",
76
- mode: "Built-in defaults",
77
- planMode: "Built-in defaults",
78
- geminiCommandPath: "Built-in defaults",
79
- "policy.approvalPolicy": "Built-in defaults",
80
- "policy.sandboxMode": "Built-in defaults",
81
- "policy.networkAccess": "Built-in defaults",
82
- "policy.writableRoots": "Built-in defaults",
83
- "policy.serviceTier": "Built-in defaults",
84
- "policy.personality": "Built-in defaults",
85
- },
86
- },
87
- },
88
- runtime: normalizeRuntimeConfig({
89
- provider: "codex-subprocess",
90
- model: "gpt-5.4",
91
- mode: "suggest",
92
- reasoningLevel: "high",
93
- }),
94
- resolvedRuntime: resolveRuntimeConfig(
95
- normalizeRuntimeConfig({
96
- provider: "codex-subprocess",
97
- model: "gpt-5.4",
98
- mode: "suggest",
99
- reasoningLevel: "high",
100
- }),
101
- ),
102
- settings: {
103
- workspaceDisplayMode: "dir" as const,
104
- terminalTitleMode: "dir" as const,
105
- showBusyLoader: true,
106
- },
107
- workspace: {
108
- root: "C:\\Workspace",
109
- summaryMessage: [
110
- "Active workspace:",
111
- " C:\\Workspace",
112
- "",
113
- "Launch mode: installed codexa",
114
- ].join("\n"),
115
- },
116
- tokensUsed: 1200,
117
- };
118
-
119
- function stripAnsi(value: string): string {
120
- return value.replace(/\u001B\[[0-?]*[ -/]*[@-~]/g, "");
121
- }
122
-
123
- function sleep(ms = 50): Promise<void> {
124
- return new Promise((resolve) => setTimeout(resolve, ms));
125
- }
126
-
127
- function getLastComposerValue(output: string): string | null {
128
- const lines = output.match(/value:[^\n]*/g) ?? [];
129
- const lastLine = lines[lines.length - 1];
130
- if (!lastLine) return null;
131
-
132
- try {
133
- return JSON.parse(lastLine.slice("value:".length)) as string;
134
- } catch {
135
- return null;
136
- }
137
- }
138
-
139
- function createInkHarness(node: React.ReactElement) {
140
- const stdin = new TestInput();
141
- const stdout = new TestOutput();
142
- let output = "";
143
-
144
- stdout.on("data", (chunk) => {
145
- output += chunk.toString();
146
- });
147
-
148
- const instance = render(node, {
149
- stdin: stdin as unknown as NodeJS.ReadStream,
150
- stdout: stdout as unknown as NodeJS.WriteStream,
151
- stderr: stdout as unknown as NodeJS.WriteStream,
152
- debug: true,
153
- exitOnCtrlC: false,
154
- patchConsole: false,
155
- });
156
-
157
- return {
158
- stdin,
159
- stdout,
160
- instance,
161
- getOutput(): string {
162
- return stripAnsi(output);
163
- },
164
- async cleanup() {
165
- instance.cleanup();
166
- await sleep(20);
167
- },
168
- };
169
- }
170
-
171
- function FocusProbe({ id, label }: { id: string; label: string }) {
172
- const { isFocused } = useFocus({ id, autoFocus: true });
173
- return <Text>{label}:{isFocused ? "focused" : "blurred"}</Text>;
174
- }
175
-
176
- function FocusRoutingHarness({ screen }: { screen: "main" | "model-picker" | "permissions-panel" | "settings-panel" }) {
177
- const focusManager = useFocusManager();
178
-
179
- React.useEffect(() => {
180
- focusManager.focus(getFocusTargetForScreen(screen));
181
- }, [focusManager, screen]);
182
-
183
- return (
184
- <Box flexDirection="column">
185
- {screen === "main" && <FocusProbe id="composer" label="composer" />}
186
- {screen === "model-picker" && <FocusProbe id="model-picker" label="model" />}
187
- {screen === "permissions-panel" && <FocusProbe id="permissions-panel" label="permissions" />}
188
- {screen === "settings-panel" && <FocusProbe id="settings-panel" label="settings" />}
189
- </Box>
190
- );
191
- }
192
-
193
- function ModelPickerComposerHarness() {
194
- const focusManager = useFocusManager();
195
- const [screen, setScreen] = React.useState<"main" | "model-picker">("model-picker");
196
- const [model, setModel] = React.useState<AvailableModel>("gpt-5.4");
197
- const [reasoningLevel, setReasoningLevel] = React.useState<ReasoningLevel>("high");
198
- const [value, setValue] = React.useState("");
199
- const [cursor, setCursor] = React.useState(0);
200
- const [composerInstanceKey, setComposerInstanceKey] = React.useState(0);
201
- const previousScreenRef = React.useRef<"main" | "model-picker">("model-picker");
202
-
203
- React.useEffect(() => {
204
- const previousScreen = previousScreenRef.current;
205
- if (shouldBumpComposerInstance(previousScreen, screen)) {
206
- setComposerInstanceKey((currentKey) => currentKey + 1);
207
- }
208
- previousScreenRef.current = screen;
209
- }, [screen]);
210
-
211
- React.useEffect(() => {
212
- focusManager.focus(getFocusTargetForScreen(screen));
213
- }, [composerInstanceKey, focusManager, screen]);
214
-
215
- return (
216
- <ThemeProvider theme="purple">
217
- {screen === "model-picker" ? (
218
- <ModelPickerScreen
219
- layout={TEST_LAYOUT}
220
- models={TEST_MODEL_CAPABILITIES}
221
- currentModel={model}
222
- currentReasoning={reasoningLevel}
223
- onSelect={(nextModel, nextReasoning) => {
224
- const resolvedModel = nextModel as AvailableModel;
225
- setModel(resolvedModel);
226
- setReasoningLevel(nextReasoning as ReasoningLevel);
227
- setScreen("main");
228
- }}
229
- onCancel={() => setScreen("main")}
230
- />
231
- ) : (
232
- <BottomComposer
233
- key={composerInstanceKey}
234
- layout={TEST_LAYOUT}
235
- uiState={{ kind: "IDLE" }}
236
- value={value}
237
- cursor={cursor}
238
- onChangeInput={(nextValue, nextCursor) => {
239
- setValue(nextValue);
240
- setCursor(nextCursor);
241
- }}
242
- onSubmit={() => {}}
243
- onCancel={() => {}}
244
- onChangeValue={setValue}
245
- onChangeCursor={setCursor}
246
- onHistoryUp={() => {}}
247
- onHistoryDown={() => {}}
248
- onOpenBackendPicker={() => {}}
249
- onOpenModelPicker={() => {}}
250
- onOpenModePicker={() => {}}
251
- onOpenThemePicker={() => {}}
252
- onOpenAuthPanel={() => {}}
253
- onTogglePlanMode={() => {}}
254
- onClear={() => {}}
255
- onCycleMode={() => {}}
256
- onQuit={() => {}}
257
- />
258
- )}
259
- </ThemeProvider>
260
- );
261
- }
262
-
263
- function PasteComposerHarness() {
264
- const [value, setValue] = React.useState("");
265
- const [cursor, setCursor] = React.useState(0);
266
- const [submitCount, setSubmitCount] = React.useState(0);
267
-
268
- return (
269
- <ThemeProvider theme="purple">
270
- <Box flexDirection="column">
271
- <BottomComposer
272
- layout={TEST_LAYOUT}
273
- uiState={{ kind: "IDLE" }}
274
- value={value}
275
- cursor={cursor}
276
- onChangeInput={(nextValue, nextCursor) => {
277
- setValue(nextValue);
278
- setCursor(nextCursor);
279
- }}
280
- onSubmit={() => {
281
- setSubmitCount((count) => count + 1);
282
- }}
283
- onCancel={() => {}}
284
- onChangeValue={setValue}
285
- onChangeCursor={setCursor}
286
- onHistoryUp={() => {}}
287
- onHistoryDown={() => {}}
288
- onOpenBackendPicker={() => {}}
289
- onOpenModelPicker={() => {}}
290
- onOpenModePicker={() => {}}
291
- onOpenThemePicker={() => {}}
292
- onOpenAuthPanel={() => {}}
293
- onTogglePlanMode={() => {}}
294
- onClear={() => {}}
295
- onCycleMode={() => {}}
296
- onQuit={() => {}}
297
- />
298
- <Text>{`submit:${submitCount}`}</Text>
299
- <Text>{`value:${JSON.stringify(value)}`}</Text>
300
- </Box>
301
- </ThemeProvider>
302
- );
303
- }
304
-
305
- function PlanToggleComposerHarness() {
306
- const [planMode, setPlanMode] = React.useState(false);
307
- const [value, setValue] = React.useState("");
308
- const [cursor, setCursor] = React.useState(0);
309
- const [submitCount, setSubmitCount] = React.useState(0);
310
-
311
- return (
312
- <ThemeProvider theme="purple">
313
- <Box flexDirection="column">
314
- <BottomComposer
315
- layout={TEST_LAYOUT}
316
- uiState={{ kind: "IDLE" }}
317
- value={value}
318
- cursor={cursor}
319
- planMode={planMode}
320
- onChangeInput={(nextValue, nextCursor) => {
321
- setValue(nextValue);
322
- setCursor(nextCursor);
323
- }}
324
- onSubmit={() => {
325
- setSubmitCount((count) => count + 1);
326
- }}
327
- onCancel={() => {}}
328
- onChangeValue={setValue}
329
- onChangeCursor={setCursor}
330
- onHistoryUp={() => {}}
331
- onHistoryDown={() => {}}
332
- onOpenBackendPicker={() => {}}
333
- onOpenModelPicker={() => {}}
334
- onOpenModePicker={() => {}}
335
- onOpenThemePicker={() => {}}
336
- onOpenAuthPanel={() => {}}
337
- onTogglePlanMode={() => setPlanMode((current) => !current)}
338
- onClear={() => {}}
339
- onCycleMode={() => {}}
340
- onQuit={() => {}}
341
- />
342
- <Text>{`plan:${planMode ? "on" : "off"}`}</Text>
343
- <Text>{`submit:${submitCount}`}</Text>
344
- <Text>{`value:${JSON.stringify(value)}`}</Text>
345
- </Box>
346
- </ThemeProvider>
347
- );
348
- }
349
-
350
- function ShortcutModelPickerHarness() {
351
- const focusManager = useFocusManager();
352
- const [screen, setScreen] = React.useState<"main" | "model-picker">("main");
353
- const [model, setModel] = React.useState<AvailableModel>("gpt-5.4");
354
- const [reasoningLevel, setReasoningLevel] = React.useState<ReasoningLevel>("high");
355
- const [value, setValue] = React.useState("");
356
- const [cursor, setCursor] = React.useState(0);
357
- const [submitCount, setSubmitCount] = React.useState(0);
358
- const [composerInstanceKey, setComposerInstanceKey] = React.useState(0);
359
- const previousScreenRef = React.useRef<"main" | "model-picker">("main");
360
-
361
- React.useEffect(() => {
362
- const previousScreen = previousScreenRef.current;
363
- if (shouldBumpComposerInstance(previousScreen, screen)) {
364
- setComposerInstanceKey((currentKey) => currentKey + 1);
365
- }
366
- previousScreenRef.current = screen;
367
- }, [screen]);
368
-
369
- React.useEffect(() => {
370
- focusManager.focus(getFocusTargetForScreen(screen));
371
- }, [composerInstanceKey, focusManager, screen]);
372
-
373
- return (
374
- <ThemeProvider theme="purple">
375
- <Box flexDirection="column">
376
- <Text>{`screen:${screen}`}</Text>
377
- <Text>{`model:${model}`}</Text>
378
- <Text>{`submit:${submitCount}`}</Text>
379
- <Text>{`value:${JSON.stringify(value)}`}</Text>
380
- {screen === "model-picker" ? (
381
- <ModelPickerScreen
382
- layout={TEST_LAYOUT}
383
- models={TEST_MODEL_CAPABILITIES}
384
- currentModel={model}
385
- currentReasoning={reasoningLevel}
386
- onSelect={(nextModel, nextReasoning) => {
387
- const resolvedModel = nextModel as AvailableModel;
388
- setModel(resolvedModel);
389
- setReasoningLevel(nextReasoning as ReasoningLevel);
390
- setScreen("main");
391
- }}
392
- onCancel={() => setScreen("main")}
393
- />
394
- ) : (
395
- <BottomComposer
396
- key={composerInstanceKey}
397
- layout={TEST_LAYOUT}
398
- uiState={{ kind: "IDLE" }}
399
- value={value}
400
- cursor={cursor}
401
- onChangeInput={(nextValue, nextCursor) => {
402
- setValue(nextValue);
403
- setCursor(nextCursor);
404
- }}
405
- onSubmit={() => {
406
- setSubmitCount((count) => count + 1);
407
- }}
408
- onCancel={() => {}}
409
- onChangeValue={setValue}
410
- onChangeCursor={setCursor}
411
- onHistoryUp={() => {}}
412
- onHistoryDown={() => {}}
413
- onOpenBackendPicker={() => {}}
414
- onOpenModelPicker={() => setScreen("model-picker")}
415
- onOpenModePicker={() => {}}
416
- onOpenThemePicker={() => {}}
417
- onOpenAuthPanel={() => {}}
418
- onTogglePlanMode={() => {}}
419
- onClear={() => {}}
420
- onCycleMode={() => {}}
421
- onQuit={() => {}}
422
- />
423
- )}
424
- </Box>
425
- </ThemeProvider>
426
- );
427
- }
428
-
429
- function ShortcutProviderPickerHarness() {
430
- const focusManager = useFocusManager();
431
- const [screen, setScreen] = React.useState<"main" | "provider-picker">("main");
432
- const [value, setValue] = React.useState("");
433
- const [cursor, setCursor] = React.useState(0);
434
- const [submitCount, setSubmitCount] = React.useState(0);
435
- const [composerInstanceKey, setComposerInstanceKey] = React.useState(0);
436
- const previousScreenRef = React.useRef<"main" | "provider-picker">("main");
437
- const providers = React.useMemo(() => buildProviderRegistry({ activeModel: "gpt-5.4" }), []);
438
-
439
- React.useEffect(() => {
440
- const previousScreen = previousScreenRef.current;
441
- if (shouldBumpComposerInstance(previousScreen, screen)) {
442
- setComposerInstanceKey((currentKey) => currentKey + 1);
443
- }
444
- previousScreenRef.current = screen;
445
- }, [screen]);
446
-
447
- React.useEffect(() => {
448
- focusManager.focus(getFocusTargetForScreen(screen));
449
- }, [composerInstanceKey, focusManager, screen]);
450
-
451
- return (
452
- <ThemeProvider theme="purple">
453
- <Box flexDirection="column">
454
- <Text>{`screen:${screen}`}</Text>
455
- <Text>{`submit:${submitCount}`}</Text>
456
- <Text>{`value:${JSON.stringify(value)}`}</Text>
457
- {screen === "provider-picker" ? (
458
- <ProviderPicker
459
- layout={TEST_LAYOUT}
460
- providers={providers}
461
- onAction={() => setScreen("main")}
462
- onCancel={() => setScreen("main")}
463
- />
464
- ) : (
465
- <BottomComposer
466
- key={composerInstanceKey}
467
- layout={TEST_LAYOUT}
468
- uiState={{ kind: "IDLE" }}
469
- value={value}
470
- cursor={cursor}
471
- onChangeInput={(nextValue, nextCursor) => {
472
- setValue(nextValue);
473
- setCursor(nextCursor);
474
- }}
475
- onSubmit={() => {
476
- setSubmitCount((count) => count + 1);
477
- const result = handleCommand(value, TEST_COMMAND_CONTEXT);
478
- if (result?.action === "open_provider_picker") {
479
- setScreen("provider-picker");
480
- }
481
- setValue("");
482
- setCursor(0);
483
- }}
484
- onCancel={() => {}}
485
- onChangeValue={setValue}
486
- onChangeCursor={setCursor}
487
- onHistoryUp={() => {}}
488
- onHistoryDown={() => {}}
489
- onOpenBackendPicker={() => {}}
490
- onOpenModelPicker={() => {}}
491
- onOpenModePicker={() => {}}
492
- onOpenThemePicker={() => {}}
493
- onOpenAuthPanel={() => {}}
494
- onTogglePlanMode={() => {}}
495
- onClear={() => {}}
496
- onCycleMode={() => {}}
497
- onQuit={() => {}}
498
- />
499
- )}
500
- </Box>
501
- </ThemeProvider>
502
- );
503
- }
504
-
505
- function ShortcutModelReasoningPickerHarness({ delayedModels = false }: { delayedModels?: boolean } = {}) {
506
- const focusManager = useFocusManager();
507
- const [screen, setScreen] = React.useState<"main" | "model-picker">("main");
508
- const [model, setModel] = React.useState<AvailableModel>("gpt-5.4");
509
- const [reasoningLevel, setReasoningLevel] = React.useState<ReasoningLevel>("high");
510
- const [models, setModels] = React.useState(() => delayedModels ? [] : TEST_MODEL_CAPABILITIES);
511
- const [value, setValue] = React.useState("");
512
- const [cursor, setCursor] = React.useState(0);
513
- const [submitCount, setSubmitCount] = React.useState(0);
514
- const [composerInstanceKey, setComposerInstanceKey] = React.useState(0);
515
- const previousScreenRef = React.useRef<"main" | "model-picker">("main");
516
-
517
- React.useEffect(() => {
518
- if (!delayedModels) return;
519
-
520
- const timer = setTimeout(() => setModels(TEST_MODEL_CAPABILITIES), 90);
521
- return () => clearTimeout(timer);
522
- }, [delayedModels]);
523
-
524
- const returnToChatMode = React.useCallback(() => {
525
- setScreen("main");
526
- focusManager.focus("composer");
527
- }, [focusManager]);
528
-
529
- React.useEffect(() => {
530
- const previousScreen = previousScreenRef.current;
531
- if (shouldBumpComposerInstance(previousScreen, screen)) {
532
- setComposerInstanceKey((currentKey) => currentKey + 1);
533
- }
534
- previousScreenRef.current = screen;
535
- }, [screen]);
536
-
537
- React.useEffect(() => {
538
- focusManager.focus(getFocusTargetForScreen(screen));
539
- }, [composerInstanceKey, focusManager, screen]);
540
-
541
- return (
542
- <ThemeProvider theme="purple">
543
- <Box flexDirection="column">
544
- <Text>{`screen:${screen}`}</Text>
545
- <Text>{`model:${model}`}</Text>
546
- <Text>{`reasoning:${reasoningLevel}`}</Text>
547
- <Text>{`submit:${submitCount}`}</Text>
548
- <Text>{`value:${JSON.stringify(value)}`}</Text>
549
- {screen === "model-picker" ? (
550
- <ModelPickerScreen
551
- layout={TEST_LAYOUT}
552
- models={models}
553
- currentModel={model}
554
- currentReasoning={reasoningLevel}
555
- isLoading={models.length === 0}
556
- onSelect={(nextModel, nextReasoning) => {
557
- setModel(nextModel as AvailableModel);
558
- setReasoningLevel(nextReasoning as ReasoningLevel);
559
- returnToChatMode();
560
- }}
561
- onCancel={returnToChatMode}
562
- />
563
- ) : (
564
- <BottomComposer
565
- key={composerInstanceKey}
566
- layout={TEST_LAYOUT}
567
- uiState={{ kind: "IDLE" }}
568
- value={value}
569
- cursor={cursor}
570
- onChangeInput={(nextValue, nextCursor) => {
571
- setValue(nextValue);
572
- setCursor(nextCursor);
573
- }}
574
- onSubmit={() => {
575
- setSubmitCount((count) => count + 1);
576
- setValue("");
577
- setCursor(0);
578
- }}
579
- onCancel={() => {}}
580
- onChangeValue={setValue}
581
- onChangeCursor={setCursor}
582
- onHistoryUp={() => {}}
583
- onHistoryDown={() => {}}
584
- onOpenBackendPicker={() => {}}
585
- onOpenModelPicker={() => setScreen((currentScreen) => currentScreen === "model-picker" ? currentScreen : "model-picker")}
586
- onOpenModePicker={() => {}}
587
- onOpenThemePicker={() => {}}
588
- onOpenAuthPanel={() => {}}
589
- onTogglePlanMode={() => {}}
590
- onClear={() => {}}
591
- onCycleMode={() => {}}
592
- onQuit={() => {}}
593
- />
594
- )}
595
- </Box>
596
- </ThemeProvider>
597
- );
598
- }
599
-
600
- function PlanActionPickerHarness() {
601
- const [selection, setSelection] = React.useState<string>("none");
602
- const [cancelCount, setCancelCount] = React.useState(0);
603
-
604
- return (
605
- <ThemeProvider theme="purple">
606
- <Box flexDirection="column">
607
- <PlanActionPicker
608
- onSelect={(value) => setSelection(value)}
609
- onCancel={() => setCancelCount((count) => count + 1)}
610
- />
611
- <Text>{`selection:${selection}`}</Text>
612
- <Text>{`cancel:${cancelCount}`}</Text>
613
- </Box>
614
- </ThemeProvider>
615
- );
616
- }
617
-
618
- function PlanFeedbackHarness() {
619
- const [screen, setScreen] = React.useState<"picker" | "feedback">("picker");
620
- const [submitted, setSubmitted] = React.useState("");
621
-
622
- return (
623
- <ThemeProvider theme="purple">
624
- <Box flexDirection="column">
625
- {screen === "picker" ? (
626
- <PlanActionPicker
627
- onSelect={(value) => {
628
- if (value === "revise") {
629
- setScreen("feedback");
630
- }
631
- }}
632
- onCancel={() => {}}
633
- />
634
- ) : (
635
- <TextEntryPanel
636
- focusId="composer"
637
- title="Revise plan"
638
- subtitle="Describe the revision."
639
- inputLabel="Revision"
640
- footerHint="Enter regenerate Esc back Backspace delete"
641
- onSubmit={(value) => {
642
- setSubmitted(value);
643
- setScreen("picker");
644
- }}
645
- onCancel={() => setScreen("picker")}
646
- />
647
- )}
648
- <Text>{`screen:${screen}`}</Text>
649
- <Text>{`submitted:${JSON.stringify(submitted)}`}</Text>
650
- </Box>
651
- </ThemeProvider>
652
- );
653
- }
654
-
655
- test("focus manager targets the active panel and returns to the composer", async () => {
656
- const harness = createInkHarness(<FocusRoutingHarness screen="model-picker" />);
657
-
658
- try {
659
- await sleep();
660
- harness.instance.rerender(<FocusRoutingHarness screen="main" />);
661
- await sleep();
662
-
663
- const output = harness.getOutput();
664
- assert.match(output, /model:focused/);
665
- assert.ok(output.trim().endsWith("composer:focused"));
666
- } finally {
667
- await harness.cleanup();
668
- }
669
- });
670
-
671
- test("focus manager routes through the permissions panel and back to the composer", async () => {
672
- const harness = createInkHarness(<FocusRoutingHarness screen="permissions-panel" />);
673
-
674
- try {
675
- await sleep();
676
- harness.instance.rerender(<FocusRoutingHarness screen="main" />);
677
- await sleep();
678
-
679
- const output = harness.getOutput();
680
- assert.match(output, /permissions:focused/);
681
- assert.ok(output.trim().endsWith("composer:focused"));
682
- } finally {
683
- await harness.cleanup();
684
- }
685
- });
686
-
687
- test("model picker hands focus back to the composer so typing works immediately", async () => {
688
- const harness = createInkHarness(<ModelPickerComposerHarness />);
689
-
690
- try {
691
- await sleep();
692
- harness.stdin.write("\u001b[B");
693
- await sleep();
694
- harness.stdin.write("\r");
695
- await sleep(80);
696
- harness.stdin.write("x");
697
- await sleep(20);
698
- harness.stdin.write("y");
699
- await sleep(20);
700
- harness.stdin.write("z");
701
- await sleep(80);
702
-
703
- const output = harness.getOutput();
704
- assert.match(output, /gpt-5\.4-mini/);
705
- assert.match(output, /❯\s+xyz/);
706
- } finally {
707
- await harness.cleanup();
708
- }
709
- });
710
-
711
- test("bracketed multi-line paste stays in the composer and preserves layout", async () => {
712
- const harness = createInkHarness(<PasteComposerHarness />);
713
-
714
- try {
715
- await sleep();
716
- harness.stdin.write("\u001b[200~alpha\nbeta\u001b[201~");
717
- await sleep(80);
718
-
719
- const output = harness.getOutput();
720
- assert.match(output, /submit:0/);
721
- assert.match(output, /value:"alpha\\nbeta"/);
722
- assert.match(output, /alpha/);
723
- assert.match(output, /beta/);
724
- } finally {
725
- await harness.cleanup();
726
- }
727
- });
728
-
729
- test("ctrl+j inserts a newline without submitting the composer", async () => {
730
- const harness = createInkHarness(<PasteComposerHarness />);
731
-
732
- try {
733
- await sleep();
734
- harness.stdin.write("a");
735
- await sleep(20);
736
- harness.stdin.write("\n");
737
- await sleep(20);
738
- harness.stdin.write("b");
739
- await sleep(80);
740
-
741
- const output = harness.getOutput();
742
- assert.match(output, /submit:0/);
743
- assert.match(output, /value:"a\\nb"/);
744
- assert.match(output, /a/);
745
- assert.match(output, /b/);
746
- } finally {
747
- await harness.cleanup();
748
- }
749
- });
750
-
751
- test("shift+tab toggles plan mode without submitting or mutating the input", async () => {
752
- const harness = createInkHarness(<PlanToggleComposerHarness />);
753
-
754
- try {
755
- await sleep();
756
- harness.stdin.write("a");
757
- await sleep(20);
758
- harness.stdin.write("\u001b[Z");
759
- await sleep(80);
760
- harness.stdin.write("\u001b[Z");
761
- await sleep(80);
762
-
763
- const output = harness.getOutput();
764
- assert.match(output, /plan:on/);
765
- assert.match(output, /plan:off/);
766
- assert.match(output, /submit:0/);
767
- assert.equal(getLastComposerValue(output), "a");
768
- } finally {
769
- await harness.cleanup();
770
- }
771
- });
772
-
773
- test("ctrl+o opens the existing model picker path without submitting", async () => {
774
- const harness = createInkHarness(<ShortcutModelPickerHarness />);
775
-
776
- try {
777
- await sleep();
778
- harness.stdin.write("a");
779
- await sleep(20);
780
- harness.stdin.write("\x0F"); // Ctrl+O
781
- await sleep(120);
782
- harness.stdin.write("\u001b[B");
783
- await sleep(40);
784
- harness.stdin.write("\r");
785
- await sleep(80);
786
- harness.stdin.write("z");
787
- await sleep(80);
788
-
789
- const output = harness.getOutput();
790
- assert.match(output, /screen:model-picker/);
791
- assert.match(output, /Select model/);
792
- assert.match(output, /screen:main/);
793
- assert.match(output, /model:gpt-5\.4-mini/);
794
- assert.match(output, /submit:0/);
795
- assert.equal(getLastComposerValue(output), "az");
796
- } finally {
797
- await harness.cleanup();
798
- }
799
- });
800
-
801
- test("accepting the provider suggestion opens the provider picker and manual alias entry does too", async () => {
802
- const harness = createInkHarness(<ShortcutProviderPickerHarness />);
803
-
804
- try {
805
- await sleep();
806
- harness.stdin.write("/pro");
807
- await sleep(40);
808
- harness.stdin.write("\t");
809
- await sleep(40);
810
- harness.stdin.write("\r");
811
- await sleep(120);
812
- harness.stdin.write("\u001b");
813
- await sleep(80);
814
- harness.stdin.write("/provider");
815
- await sleep(40);
816
- harness.stdin.write("\r");
817
- await sleep(120);
818
-
819
- const output = harness.getOutput();
820
- assert.match(output, /screen:provider-picker/);
821
- assert.match(output, /Providers/);
822
- assert.match(output, /screen:main/);
823
- assert.match(output, /submit:2/);
824
- } finally {
825
- await harness.cleanup();
826
- }
827
- });
828
-
829
- test("ctrl+o model reasoning picker returns to chat after escape and selection", async () => {
830
- const harness = createInkHarness(<ShortcutModelReasoningPickerHarness />);
831
-
832
- try {
833
- await sleep();
834
- harness.stdin.write("\x0F"); // Ctrl+O immediately after startup
835
- await sleep(120);
836
- harness.stdin.write("\u001b");
837
- await sleep(120);
838
- harness.stdin.write("a");
839
- await sleep(40);
840
- harness.stdin.write("\r");
841
- await sleep(120);
842
- harness.stdin.write("\x0F");
843
- await sleep(120);
844
- harness.stdin.write("\u001b[B");
845
- await sleep(40);
846
- harness.stdin.write("\r");
847
- await sleep(120);
848
- harness.stdin.write("b");
849
- await sleep(40);
850
- harness.stdin.write("\r");
851
- await sleep(120);
852
-
853
- const output = harness.getOutput();
854
- assert.match(output, /screen:model-picker/);
855
- assert.match(output, /screen:main/);
856
- assert.match(output, /model:gpt-5\.4-mini/);
857
- assert.match(output, /submit:2/);
858
- assert.equal(getLastComposerValue(output), "");
859
- } finally {
860
- await harness.cleanup();
861
- }
862
- });
863
-
864
- test("ctrl+o remains usable when startup model loading resolves while picker is open", async () => {
865
- const harness = createInkHarness(<ShortcutModelReasoningPickerHarness delayedModels />);
866
-
867
- try {
868
- await sleep();
869
- harness.stdin.write("\x0F"); // Ctrl+O immediately after startup
870
- await sleep(180);
871
- harness.stdin.write("\u001b");
872
- await sleep(100);
873
- harness.stdin.write("/");
874
- await sleep(20);
875
- harness.stdin.write("h");
876
- await sleep(20);
877
- harness.stdin.write("e");
878
- await sleep(20);
879
- harness.stdin.write("l");
880
- await sleep(20);
881
- harness.stdin.write("p");
882
- await sleep(20);
883
- harness.stdin.write("\r");
884
- await sleep(120);
885
-
886
- const output = harness.getOutput();
887
- assert.match(output, /Discovering models from the Codex runtime/);
888
- assert.match(output, /screen:model-picker/);
889
- assert.match(output, /screen:main/);
890
- assert.match(output, /submit:1/);
891
- assert.equal(getLastComposerValue(output), "");
892
- } finally {
893
- await harness.cleanup();
894
- }
895
- });
896
-
897
- test("ctrl+m opens the existing model picker path without submitting", async () => {
898
- const harness = createInkHarness(<ShortcutModelPickerHarness />);
899
-
900
- try {
901
- await sleep();
902
- harness.stdin.write("a");
903
- await sleep(20);
904
- harness.stdin.write("\u001b[109;5u");
905
- await sleep(120);
906
- harness.stdin.write("\u001b[B");
907
- await sleep(40);
908
- harness.stdin.write("\r");
909
- await sleep(80);
910
- harness.stdin.write("z");
911
- await sleep(80);
912
-
913
- const output = harness.getOutput();
914
- assert.match(output, /screen:model-picker/);
915
- assert.match(output, /Select model/);
916
- assert.match(output, /screen:main/);
917
- assert.match(output, /model:gpt-5\.4-mini/);
918
- assert.match(output, /submit:0/);
919
- assert.equal(getLastComposerValue(output), "az");
920
- } finally {
921
- await harness.cleanup();
922
- }
923
- });
924
-
925
- test("ctrl+m also opens the model picker when the terminal reports ctrl+enter as CSI-u", async () => {
926
- const harness = createInkHarness(<ShortcutModelPickerHarness />);
927
-
928
- try {
929
- await sleep();
930
- harness.stdin.write("a");
931
- await sleep(20);
932
- harness.stdin.write("\u001b[13;5u");
933
- await sleep(120);
934
- harness.stdin.write("\u001b");
935
- await sleep(80);
936
-
937
- const output = harness.getOutput();
938
- assert.match(output, /screen:model-picker/);
939
- assert.match(output, /Select model/);
940
- assert.match(output, /screen:main/);
941
- assert.match(output, /submit:0/);
942
- assert.equal(getLastComposerValue(output), "a");
943
- } finally {
944
- await harness.cleanup();
945
- }
946
- });
947
-
948
- test("plain enter still submits without opening the model picker", async () => {
949
- const harness = createInkHarness(<ShortcutModelPickerHarness />);
950
-
951
- try {
952
- await sleep();
953
- harness.stdin.write("a");
954
- await sleep(20);
955
- harness.stdin.write("\r");
956
- await sleep(80);
957
-
958
- const output = harness.getOutput();
959
- assert.match(output, /screen:main/);
960
- assert.match(output, /submit:1/);
961
- assert.equal(getLastComposerValue(output), "a");
962
- assert.doesNotMatch(output, /Select model/);
963
- } finally {
964
- await harness.cleanup();
965
- }
966
- });
967
-
968
- test("focus manager routes through the settings panel and back to the composer", async () => {
969
- const harness = createInkHarness(<FocusRoutingHarness screen="settings-panel" />);
970
-
971
- try {
972
- await sleep();
973
- harness.instance.rerender(<FocusRoutingHarness screen="main" />);
974
- await sleep();
975
-
976
- const output = harness.getOutput();
977
- assert.match(output, /settings:focused/);
978
- assert.ok(output.trim().endsWith("composer:focused"));
979
- } finally {
980
- await harness.cleanup();
981
- }
982
- });
983
-
984
- test("plan action picker supports focused hotkeys and esc cancel", async () => {
985
- const harness = createInkHarness(<PlanActionPickerHarness />);
986
-
987
- try {
988
- await sleep();
989
- harness.stdin.write("u");
990
- await sleep(80);
991
-
992
- const output = harness.getOutput();
993
- assert.match(output, /selection:\s*revise/);
994
-
995
- harness.stdin.write("\u001b");
996
- await sleep(80);
997
-
998
- const finalOutput = harness.getOutput();
999
- assert.match(finalOutput, /cancel:\s*1/);
1000
- } finally {
1001
- await harness.cleanup();
1002
- }
1003
- });
1004
-
1005
- test("plan action picker ignores SGR mouse escape sequences", async () => {
1006
- const harness = createInkHarness(<PlanActionPickerHarness />);
1007
-
1008
- try {
1009
- await sleep();
1010
-
1011
- // Simulate terminal mouse event (button press + scroll) sent to raw stdin
1012
- harness.stdin.write("\x1b[<0;83;19M");
1013
- harness.stdin.write("\x1b[<64;83;19M");
1014
- await sleep(80);
1015
-
1016
- const output = harness.getOutput();
1017
- // Neither mouse sequence should appear as selection or visible text
1018
- assert.ok(!output.includes("[<0;83;19M"), "mouse sequence must not appear in output");
1019
- assert.ok(!output.includes("[<64;83;19M"), "scroll sequence must not appear in output");
1020
- // selection should still be "none" — no accidental trigger
1021
- assert.match(output, /selection:\s*none/);
1022
- } finally {
1023
- await harness.cleanup();
1024
- }
1025
- });
1026
-
1027
- test("plan feedback entry returns to the picker on esc and submits on enter", async () => {
1028
- const harness = createInkHarness(<PlanFeedbackHarness />);
1029
-
1030
- try {
1031
- await sleep();
1032
- harness.stdin.write("u");
1033
- await sleep(80);
1034
- harness.stdin.write("\u001b");
1035
- await sleep(80);
1036
- harness.stdin.write("u");
1037
- await sleep(80);
1038
- harness.stdin.write("s");
1039
- await sleep(20);
1040
- harness.stdin.write("c");
1041
- await sleep(20);
1042
- harness.stdin.write("o");
1043
- await sleep(20);
1044
- harness.stdin.write("p");
1045
- await sleep(20);
1046
- harness.stdin.write("e");
1047
- await sleep(20);
1048
- harness.stdin.write("\r");
1049
- await sleep(80);
1050
-
1051
- const output = harness.getOutput();
1052
- assert.match(output, /screen:feedback/);
1053
- assert.match(output, /screen:picker/);
1054
- assert.match(output, /submitted:"scope"/);
1055
- } finally {
1056
- await harness.cleanup();
1057
- }
1058
- });
1059
-
1060
- test("treats raw DEL (\\u007f) as backspace in the composer", async () => {
1061
- const harness = createInkHarness(<PasteComposerHarness />);
1062
-
1063
- try {
1064
- await sleep();
1065
- harness.stdin.write("H");
1066
- await sleep(20);
1067
- harness.stdin.write("=");
1068
- await sleep(20);
1069
- harness.stdin.write("\u007f");
1070
- await sleep(80);
1071
-
1072
- const output = harness.getOutput();
1073
- assert.equal(getLastComposerValue(output), "H");
1074
- } finally {
1075
- await harness.cleanup();
1076
- }
1077
- });
1078
-
1079
- test("keeps ANSI delete (ESC[3~) as forward delete behavior", async () => {
1080
- const harness = createInkHarness(<PasteComposerHarness />);
1081
-
1082
- try {
1083
- await sleep();
1084
- harness.stdin.write("a");
1085
- await sleep(20);
1086
- harness.stdin.write("b");
1087
- await sleep(20);
1088
- harness.stdin.write("\u001b[D");
1089
- await sleep(20);
1090
- harness.stdin.write("\u001b[3~");
1091
- await sleep(80);
1092
-
1093
- const output = harness.getOutput();
1094
- assert.equal(getLastComposerValue(output), "a");
1095
- } finally {
1096
- await harness.cleanup();
1097
- }
1098
- });