@golba98/codexa 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -18
- package/bin/codexa.js +62 -144
- package/package.json +4 -3
- package/src/app.tsx +533 -275
- package/src/commands/handler.ts +2 -2
- package/src/config/buildInfo.ts +2 -2
- package/src/config/layeredConfig.ts +1 -1
- package/src/config/runtimeConfig.ts +1 -1
- package/src/config/settings.ts +1 -1
- package/src/config/trustStore.ts +1 -1
- package/src/core/README.md +52 -0
- package/src/core/agent/loop.ts +282 -0
- package/src/core/agent/protocol.ts +211 -0
- package/src/core/agent/tools.ts +414 -0
- package/src/core/{codexExecArgs.ts → codex/codexExecArgs.ts} +2 -2
- package/src/core/{codexLaunch.ts → codex/codexLaunch.ts} +3 -3
- package/src/core/{codexPrompt.ts → codex/codexPrompt.ts} +3 -3
- package/src/core/debug/modelStateDebug.ts +34 -0
- package/src/core/executables/antigravityExecutable.ts +48 -0
- package/src/core/executables/executableResolver.ts +5 -1
- package/src/core/perf/renderDebug.ts +10 -6
- package/src/core/providerLauncher/registry.ts +30 -14
- package/src/core/providerLauncher/types.ts +11 -9
- package/src/core/providerLauncher/workspaceConfig.ts +41 -26
- package/src/core/providerRuntime/anthropic.ts +7 -1
- package/src/core/providerRuntime/antigravity.ts +305 -0
- package/src/core/providerRuntime/claudeCodeDiscovery.ts +268 -22
- package/src/core/providerRuntime/claudeCodeDiscoveryDebug.ts +55 -0
- package/src/core/providerRuntime/contextMetadata.ts +12 -24
- package/src/core/providerRuntime/local.ts +129 -51
- package/src/core/providerRuntime/models.ts +22 -11
- package/src/core/providerRuntime/registry.ts +58 -31
- package/src/core/providerRuntime/types.ts +19 -14
- package/src/core/providers/codexSubprocess.ts +2 -2
- package/src/core/providers/types.ts +1 -1
- package/src/core/{attachments.ts → shared/attachments.ts} +27 -4
- package/src/core/{cleanupFastFail.ts → shared/cleanupFastFail.ts} +1 -1
- package/src/core/{hollowResponseFormat.ts → shared/hollowResponseFormat.ts} +1 -1
- package/src/core/terminal/clearFrameBoundary.ts +814 -0
- package/src/core/terminal/frameLock.ts +109 -0
- package/src/core/terminal/inkRenderReset.ts +123 -0
- package/src/core/terminal/terminalControl.ts +22 -0
- package/src/core/terminal/terminalTitle.ts +16 -102
- package/src/core/{channel.ts → version/channel.ts} +1 -1
- package/src/core/{updateCheck.ts → version/updateCheck.ts} +10 -5
- package/src/core/{launchContext.ts → workspace/launchContext.ts} +9 -16
- package/src/core/{planStorage.ts → workspace/planStorage.ts} +2 -2
- package/src/core/{workspaceGuard.ts → workspace/workspaceGuard.ts} +97 -13
- package/src/headless/execRunner.ts +2 -2
- package/src/index.tsx +43 -89
- package/src/session/appSession.ts +10 -7
- package/src/session/chatLifecycle.ts +1 -1
- package/src/session/liveRenderScheduler.ts +1 -1
- package/src/session/types.ts +1 -1
- package/src/ui/AppShell.tsx +672 -706
- package/src/ui/AttachmentImportPanel.tsx +2 -2
- package/src/ui/BottomComposer.tsx +145 -144
- package/src/ui/ModelPickerScreen.tsx +216 -36
- package/src/ui/ModelReasoningPicker.tsx +1 -1
- package/src/ui/PlanReviewPanel.tsx +1 -1
- package/src/ui/ProviderPicker.tsx +735 -321
- package/src/ui/RuntimeStatusBar.tsx +108 -0
- package/src/ui/SelectionPanel.tsx +4 -0
- package/src/ui/SettingsPanel.tsx +1 -1
- package/src/ui/TextEntryPanel.tsx +1 -1
- package/src/ui/Timeline.tsx +1619 -1470
- package/src/ui/TopHeader.tsx +46 -30
- package/src/ui/TranscriptShell.tsx +322 -0
- package/src/ui/TurnGroup.tsx +2 -2
- package/src/ui/UpdateAvailableCard.tsx +3 -3
- package/src/ui/UpdatePromptPanel.tsx +16 -22
- package/src/ui/layout.ts +298 -24
- package/src/ui/layoutListWindow.ts +145 -0
- package/src/ui/logoVariants.ts +4 -8
- package/src/ui/runtimeDisplay.ts +15 -3
- package/src/ui/textLayout.ts +15 -4
- package/src/ui/timelineMeasure.ts +194 -122
- package/src/core/codex.ts +0 -124
- package/src/ui/StaticTranscriptItem.tsx +0 -56
- /package/src/core/{inputDebug.ts → debug/inputDebug.ts} +0 -0
- /package/src/core/{clipboard.ts → shared/clipboard.ts} +0 -0
- /package/src/core/{githubDiagnostics.ts → shared/githubDiagnostics.ts} +0 -0
- /package/src/core/{projectInstructions.ts → workspace/projectInstructions.ts} +0 -0
- /package/src/core/{workspaceActivity.ts → workspace/workspaceActivity.ts} +0 -0
- /package/src/core/{workspaceRoot.ts → workspace/workspaceRoot.ts} +0 -0
package/src/ui/AppShell.tsx
CHANGED
|
@@ -1,706 +1,672 @@
|
|
|
1
|
-
import React, { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { Box, Text, useStdin } from "ink";
|
|
3
|
-
import { useTheme } from "./theme.js";
|
|
4
|
-
import type { RuntimeSummary } from "../config/runtimeConfig.js";
|
|
5
|
-
import type { CodexAuthState } from "../core/auth/codexAuth.js";
|
|
6
|
-
import { HEADER_CONFIG_DEFAULTS, type HeaderConfig } from "../config/settings.js";
|
|
7
|
-
import * as renderDebug from "../core/perf/renderDebug.js";
|
|
8
|
-
import type { Screen, TimelineEvent, UIState } from "../session/types.js";
|
|
9
|
-
import { isBusy } from "../session/types.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
shellRows
|
|
90
|
-
|
|
91
|
-
composerRows
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}: {
|
|
95
|
-
shellRows
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
</Box>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
}, [
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
>
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
{
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
* would display stale input. Non-main panels are compared so picker content can
|
|
674
|
-
* refresh while the active screen stays unchanged, such as model discovery
|
|
675
|
-
* replacing the loading model picker with the interactive picker.
|
|
676
|
-
*/
|
|
677
|
-
export const AppShell = memo(AppShellInner, (prev, next) => {
|
|
678
|
-
const panelPropsEqual = next.screen === "main"
|
|
679
|
-
? prev.mainPanel === next.mainPanel
|
|
680
|
-
: (prev.panel === next.panel && prev.panelHint === next.panelHint);
|
|
681
|
-
|
|
682
|
-
return (
|
|
683
|
-
prev.layout.cols === next.layout.cols &&
|
|
684
|
-
prev.layout.rows === next.layout.rows &&
|
|
685
|
-
prev.layout.mode === next.layout.mode &&
|
|
686
|
-
prev.layout.layoutEpoch === next.layout.layoutEpoch &&
|
|
687
|
-
prev.screen === next.screen &&
|
|
688
|
-
prev.authState === next.authState &&
|
|
689
|
-
prev.workspaceLabel === next.workspaceLabel &&
|
|
690
|
-
prev.workspaceRoot === next.workspaceRoot &&
|
|
691
|
-
prev.runtimeSummary === next.runtimeSummary &&
|
|
692
|
-
prev.staticEvents === next.staticEvents &&
|
|
693
|
-
prev.activeEvents === next.activeEvents &&
|
|
694
|
-
prev.uiState === next.uiState &&
|
|
695
|
-
prev.composerRows === next.composerRows &&
|
|
696
|
-
prev.composer === next.composer &&
|
|
697
|
-
prev.mainPanel === next.mainPanel &&
|
|
698
|
-
prev.mainPanelMode === next.mainPanelMode &&
|
|
699
|
-
prev.verboseMode === next.verboseMode &&
|
|
700
|
-
prev.mouseCapture === next.mouseCapture &&
|
|
701
|
-
prev.onMouseActivity === next.onMouseActivity &&
|
|
702
|
-
prev.clearCount === next.clearCount &&
|
|
703
|
-
prev.updateAvailable === next.updateAvailable &&
|
|
704
|
-
panelPropsEqual
|
|
705
|
-
);
|
|
706
|
-
});
|
|
1
|
+
import React, { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Box, Text, useStdin } from "ink";
|
|
3
|
+
import { useTheme } from "./theme.js";
|
|
4
|
+
import type { RuntimeSummary } from "../config/runtimeConfig.js";
|
|
5
|
+
import type { CodexAuthState } from "../core/auth/codexAuth.js";
|
|
6
|
+
import { HEADER_CONFIG_DEFAULTS, type HeaderConfig } from "../config/settings.js";
|
|
7
|
+
import * as renderDebug from "../core/perf/renderDebug.js";
|
|
8
|
+
import type { Screen, TimelineEvent, UIState } from "../session/types.js";
|
|
9
|
+
import { isBusy } from "../session/types.js";
|
|
10
|
+
import {
|
|
11
|
+
ActivePanelLayoutContext,
|
|
12
|
+
type ActivePanelLayout,
|
|
13
|
+
AppLayoutBudgetContext,
|
|
14
|
+
computeAppLayoutBudget,
|
|
15
|
+
getContentWidth,
|
|
16
|
+
getShellHeight,
|
|
17
|
+
getShellWidth,
|
|
18
|
+
isCrampedTerminal,
|
|
19
|
+
PanelAvailableRowsContext,
|
|
20
|
+
type Layout,
|
|
21
|
+
type LayoutMode,
|
|
22
|
+
type PanelLayout,
|
|
23
|
+
PanelLayoutContext,
|
|
24
|
+
MIN_TERMINAL_COLS,
|
|
25
|
+
MIN_TERMINAL_ROWS,
|
|
26
|
+
type TerminalViewport,
|
|
27
|
+
} from "./layout.js";
|
|
28
|
+
import {
|
|
29
|
+
buildActiveRenderItems,
|
|
30
|
+
buildStaticRenderItems,
|
|
31
|
+
buildTimelineItems,
|
|
32
|
+
parseTimelineNavigationInput,
|
|
33
|
+
Timeline,
|
|
34
|
+
TimelineRowView,
|
|
35
|
+
type TimelineItem,
|
|
36
|
+
} from "./Timeline.js";
|
|
37
|
+
import { buildNativeTranscriptParts, type NativeTranscriptRowItem, type TimelineRow } from "./timelineMeasure.js";
|
|
38
|
+
import type { TerminalSelectionProfile } from "../core/terminal/terminalSelection.js";
|
|
39
|
+
import { MemoizedTopHeader, measureTopHeaderRows, type UpdateAvailableInfo } from "./TopHeader.js";
|
|
40
|
+
|
|
41
|
+
const COMPACT_HEADER_TO_COMPOSER_GAP_ROWS = 1;
|
|
42
|
+
const MEDIUM_HEADER_TO_COMPOSER_GAP_ROWS = 1;
|
|
43
|
+
const TALL_HEADER_TO_COMPOSER_GAP_ROWS = 1;
|
|
44
|
+
|
|
45
|
+
// ─── Types & constants ────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
type AppShellLayout = TerminalViewport;
|
|
48
|
+
type NativeStaticItem =
|
|
49
|
+
{ type: "rows" } & NativeTranscriptRowItem;
|
|
50
|
+
|
|
51
|
+
export interface AppShellProps {
|
|
52
|
+
layout: AppShellLayout;
|
|
53
|
+
screen: Screen;
|
|
54
|
+
authState: CodexAuthState;
|
|
55
|
+
workspaceLabel: string;
|
|
56
|
+
workspaceRoot?: string | null;
|
|
57
|
+
runtimeSummary?: RuntimeSummary | null;
|
|
58
|
+
staticEvents: TimelineEvent[];
|
|
59
|
+
activeEvents: TimelineEvent[];
|
|
60
|
+
uiState: UIState;
|
|
61
|
+
panel: React.ReactNode;
|
|
62
|
+
mainPanel?: React.ReactNode;
|
|
63
|
+
mainPanelMode?: "viewport" | "full-output";
|
|
64
|
+
composer: React.ReactNode;
|
|
65
|
+
composerRows: number;
|
|
66
|
+
panelHint?: React.ReactNode;
|
|
67
|
+
verboseMode?: boolean;
|
|
68
|
+
mouseCapture?: boolean;
|
|
69
|
+
onMouseActivity?: () => void;
|
|
70
|
+
selectionProfile?: TerminalSelectionProfile;
|
|
71
|
+
clearCount?: number;
|
|
72
|
+
headerConfig?: HeaderConfig;
|
|
73
|
+
updateAvailable?: UpdateAvailableInfo | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ─── Helpers & subcomponents ─────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
export function isCrampedViewport(rows: number | undefined): boolean {
|
|
79
|
+
return (rows ?? 24) <= 24;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function calculateNativeSpacerRows({
|
|
83
|
+
shellRows,
|
|
84
|
+
introRows,
|
|
85
|
+
composerRows,
|
|
86
|
+
staticRows,
|
|
87
|
+
liveRows,
|
|
88
|
+
}: {
|
|
89
|
+
shellRows: number;
|
|
90
|
+
introRows: number;
|
|
91
|
+
composerRows: number;
|
|
92
|
+
staticRows: number;
|
|
93
|
+
liveRows: number;
|
|
94
|
+
}): number {
|
|
95
|
+
const availableBodyRows = Math.max(0, shellRows - introRows - composerRows);
|
|
96
|
+
const visibleBodyContentRows = Math.max(0, staticRows) + Math.max(0, liveRows);
|
|
97
|
+
return Math.max(0, availableBodyRows - visibleBodyContentRows);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function calculateColdStartSpacerRows({
|
|
101
|
+
shellRows,
|
|
102
|
+
headerRows,
|
|
103
|
+
composerRows,
|
|
104
|
+
layoutMode,
|
|
105
|
+
availableRows,
|
|
106
|
+
}: {
|
|
107
|
+
shellRows: number;
|
|
108
|
+
headerRows: number;
|
|
109
|
+
composerRows: number;
|
|
110
|
+
layoutMode: LayoutMode;
|
|
111
|
+
availableRows: number;
|
|
112
|
+
}): number {
|
|
113
|
+
if (availableRows <= 0) return 0;
|
|
114
|
+
|
|
115
|
+
const rowsAfterHeaderAndComposer = Math.max(0, shellRows - headerRows - composerRows);
|
|
116
|
+
const preferredRows = layoutMode === "compact" || shellRows <= 18
|
|
117
|
+
? 1
|
|
118
|
+
: shellRows >= 36
|
|
119
|
+
? TALL_HEADER_TO_COMPOSER_GAP_ROWS
|
|
120
|
+
: shellRows >= 28
|
|
121
|
+
? MEDIUM_HEADER_TO_COMPOSER_GAP_ROWS
|
|
122
|
+
: COMPACT_HEADER_TO_COMPOSER_GAP_ROWS;
|
|
123
|
+
|
|
124
|
+
return Math.max(0, Math.min(availableRows, rowsAfterHeaderAndComposer, preferredRows));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function calculateHeaderToContentGapRows(layout: Layout): number {
|
|
128
|
+
if (layout.mode === "compact" || layout.rows <= 18) return 0;
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function NativeRowsItem({ rows }: { rows: TimelineRow[] }) {
|
|
133
|
+
return (
|
|
134
|
+
<Box flexDirection="column">
|
|
135
|
+
{rows.map((row) => (
|
|
136
|
+
<TimelineRowView key={row.key} row={row} />
|
|
137
|
+
))}
|
|
138
|
+
</Box>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function NativePauseBar({ unseenRows }: { unseenRows: number }) {
|
|
143
|
+
return (
|
|
144
|
+
<Box width="100%" paddingX={1}>
|
|
145
|
+
<Text dimColor>
|
|
146
|
+
{unseenRows > 0
|
|
147
|
+
? `↓ ${unseenRows} new rows · End to follow`
|
|
148
|
+
: "↓ New output · End to follow"}
|
|
149
|
+
</Text>
|
|
150
|
+
</Box>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function CrampedView({ layout }: { layout: Layout }) {
|
|
155
|
+
const theme = useTheme();
|
|
156
|
+
return (
|
|
157
|
+
<Box
|
|
158
|
+
flexDirection="column"
|
|
159
|
+
width="100%"
|
|
160
|
+
height={getShellHeight(layout.rows)}
|
|
161
|
+
alignItems="center"
|
|
162
|
+
justifyContent="center"
|
|
163
|
+
>
|
|
164
|
+
<Box borderStyle="round" borderColor={theme.error} paddingX={2} paddingY={1}>
|
|
165
|
+
<Text color={theme.error} bold>
|
|
166
|
+
Terminal too small — resize to at least {MIN_TERMINAL_COLS} x {MIN_TERMINAL_ROWS}
|
|
167
|
+
</Text>
|
|
168
|
+
</Box>
|
|
169
|
+
<Box marginTop={1}>
|
|
170
|
+
<Text dimColor>
|
|
171
|
+
Current: {layout.cols} x {layout.rows}
|
|
172
|
+
</Text>
|
|
173
|
+
</Box>
|
|
174
|
+
</Box>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function injectPanelLayout(
|
|
179
|
+
element: React.ReactNode,
|
|
180
|
+
availableRows: number,
|
|
181
|
+
activePanelLayout: ActivePanelLayout,
|
|
182
|
+
panelLayout: PanelLayout
|
|
183
|
+
): React.ReactNode {
|
|
184
|
+
if (!React.isValidElement(element)) {
|
|
185
|
+
return element;
|
|
186
|
+
}
|
|
187
|
+
if (element.type === React.Fragment) {
|
|
188
|
+
const fragment = element as React.ReactElement<{ children?: React.ReactNode }>;
|
|
189
|
+
return React.cloneElement(
|
|
190
|
+
fragment,
|
|
191
|
+
fragment.props,
|
|
192
|
+
React.Children.map(fragment.props.children, (child) =>
|
|
193
|
+
injectPanelLayout(child, availableRows, activePanelLayout, panelLayout)
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return React.cloneElement(
|
|
198
|
+
element as React.ReactElement<{
|
|
199
|
+
availableRows?: number;
|
|
200
|
+
activePanelLayout?: ActivePanelLayout;
|
|
201
|
+
panelLayout?: PanelLayout;
|
|
202
|
+
}>,
|
|
203
|
+
{ availableRows, activePanelLayout, panelLayout }
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ─── Component ────────────────────────────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
function AppShellInner({
|
|
210
|
+
layout,
|
|
211
|
+
screen,
|
|
212
|
+
authState,
|
|
213
|
+
workspaceLabel,
|
|
214
|
+
workspaceRoot = null,
|
|
215
|
+
runtimeSummary = null,
|
|
216
|
+
staticEvents,
|
|
217
|
+
activeEvents,
|
|
218
|
+
uiState,
|
|
219
|
+
panel,
|
|
220
|
+
mainPanel,
|
|
221
|
+
mainPanelMode = "viewport",
|
|
222
|
+
composer,
|
|
223
|
+
composerRows,
|
|
224
|
+
panelHint,
|
|
225
|
+
verboseMode = false,
|
|
226
|
+
mouseCapture = false,
|
|
227
|
+
onMouseActivity,
|
|
228
|
+
selectionProfile,
|
|
229
|
+
clearCount = 0,
|
|
230
|
+
headerConfig = HEADER_CONFIG_DEFAULTS,
|
|
231
|
+
updateAvailable = null,
|
|
232
|
+
}: AppShellProps) {
|
|
233
|
+
const theme = useTheme();
|
|
234
|
+
renderDebug.useRenderDebug("AppShell", {
|
|
235
|
+
cols: layout.cols,
|
|
236
|
+
rows: layout.rows,
|
|
237
|
+
mode: layout.mode,
|
|
238
|
+
layoutEpoch: layout.layoutEpoch,
|
|
239
|
+
screen,
|
|
240
|
+
authState,
|
|
241
|
+
workspaceLabel,
|
|
242
|
+
workspaceRoot,
|
|
243
|
+
runtimeSummary,
|
|
244
|
+
staticEvents,
|
|
245
|
+
activeEvents,
|
|
246
|
+
uiState,
|
|
247
|
+
composer,
|
|
248
|
+
composerRows,
|
|
249
|
+
verboseMode,
|
|
250
|
+
});
|
|
251
|
+
renderDebug.useLifecycleDebug("AppShell", {
|
|
252
|
+
screen,
|
|
253
|
+
cols: layout.cols,
|
|
254
|
+
rows: layout.rows,
|
|
255
|
+
mode: layout.mode,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
if (layout.isCramped && !mouseCapture) {
|
|
259
|
+
return <CrampedView layout={layout} />;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const shellWidth = getShellWidth(layout.cols);
|
|
263
|
+
const shellHeight = getShellHeight(layout.rows);
|
|
264
|
+
const headerRows = measureTopHeaderRows(layout, headerConfig, !!updateAvailable);
|
|
265
|
+
|
|
266
|
+
const showComposer = true;
|
|
267
|
+
const showMainPanel = screen === "main" && mainPanel !== undefined && mainPanel !== null;
|
|
268
|
+
const showMainPanelFullOutput = showMainPanel && mainPanelMode === "full-output";
|
|
269
|
+
const showTimeline = screen === "main" && !showMainPanel;
|
|
270
|
+
const showPanelStage = screen !== "main";
|
|
271
|
+
const hasUserPrompt = useMemo(
|
|
272
|
+
() => staticEvents.some((e) => e.type === "user") || activeEvents.some((e) => e.type === "user"),
|
|
273
|
+
[staticEvents, activeEvents],
|
|
274
|
+
);
|
|
275
|
+
const previousMeasurements = useRef<{
|
|
276
|
+
timelineRows: number;
|
|
277
|
+
composerRows: number;
|
|
278
|
+
shellHeight: number;
|
|
279
|
+
shellWidth: number;
|
|
280
|
+
} | null>(null);
|
|
281
|
+
|
|
282
|
+
// ── Native mode scroll-pause state ────────────────────────────────────────
|
|
283
|
+
// When the user presses Page Up or Home during streaming, we freeze nativeAllRows
|
|
284
|
+
// so Ink's lastOutputHeight stays constant and the terminal stops auto-scrolling.
|
|
285
|
+
const [nativePaused, setNativePaused] = useState(false);
|
|
286
|
+
const nativePausedRef = useRef(false);
|
|
287
|
+
const frozenNativeRowsRef = useRef<TimelineRow[]>([]);
|
|
288
|
+
const frozenLiveRowCountRef = useRef(0);
|
|
289
|
+
const { stdin } = useStdin();
|
|
290
|
+
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
nativePausedRef.current = nativePaused;
|
|
293
|
+
}, [nativePaused]);
|
|
294
|
+
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
const handleRawInput = (chunk: Buffer | string) => {
|
|
297
|
+
if (!showTimeline || !isBusy(uiState)) return;
|
|
298
|
+
const raw = typeof chunk === "string" ? chunk : chunk.toString();
|
|
299
|
+
const actions = parseTimelineNavigationInput(raw);
|
|
300
|
+
if (actions.length === 0) return;
|
|
301
|
+
|
|
302
|
+
if (actions.some((action) => action === "pageUp" || action === "home" || action === "wheelUp")) {
|
|
303
|
+
setNativePaused(true);
|
|
304
|
+
} else if (actions.some((action) => action === "pageDown" || action === "end" || action === "wheelDown")) {
|
|
305
|
+
setNativePaused(false);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
if (stdin.isTTY) {
|
|
310
|
+
stdin.on("data", handleRawInput);
|
|
311
|
+
return () => {
|
|
312
|
+
stdin.off("data", handleRawInput);
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}, [stdin, uiState, showTimeline]);
|
|
316
|
+
|
|
317
|
+
// Auto-unpause when busy state ends.
|
|
318
|
+
useEffect(() => {
|
|
319
|
+
if (!isBusy(uiState) && nativePaused) {
|
|
320
|
+
setNativePaused(false);
|
|
321
|
+
}
|
|
322
|
+
}, [uiState, nativePaused]);
|
|
323
|
+
|
|
324
|
+
// ── End native mode scroll-pause state ────────────────────────────────────
|
|
325
|
+
|
|
326
|
+
const effectiveShowComposer = showComposer;
|
|
327
|
+
const panelHintRows = showPanelStage && panelHint ? 2 : 0;
|
|
328
|
+
|
|
329
|
+
// ─── App Layout Budget ────────────────────────────────────────────────────
|
|
330
|
+
|
|
331
|
+
const appLayoutBudget = computeAppLayoutBudget({
|
|
332
|
+
cols: layout.cols,
|
|
333
|
+
rows: layout.rows,
|
|
334
|
+
composerRows,
|
|
335
|
+
panelHintRows,
|
|
336
|
+
headerRows,
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
const headerToContentGapRows = appLayoutBudget.headerGapRows;
|
|
340
|
+
const effectiveComposerRows = appLayoutBudget.composerRows;
|
|
341
|
+
const bottomChromeRows = appLayoutBudget.bottomChromeBudget.totalRows;
|
|
342
|
+
|
|
343
|
+
const finalTimelineRows = appLayoutBudget.transcriptRows;
|
|
344
|
+
const finalShellHeight = shellHeight;
|
|
345
|
+
const finalShellWidth = shellWidth;
|
|
346
|
+
|
|
347
|
+
const { finalTimelineRows: resolvedTimelineRows } = useMemo(() => {
|
|
348
|
+
const prev = previousMeasurements.current;
|
|
349
|
+
const isValid = shellHeight > 0
|
|
350
|
+
&& shellWidth > 0
|
|
351
|
+
&& Number.isFinite(shellHeight)
|
|
352
|
+
&& Number.isFinite(shellWidth)
|
|
353
|
+
&& Number.isFinite(finalTimelineRows)
|
|
354
|
+
&& finalTimelineRows >= 2;
|
|
355
|
+
|
|
356
|
+
if (!isValid && prev) {
|
|
357
|
+
return {
|
|
358
|
+
finalTimelineRows: prev.timelineRows,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return {
|
|
363
|
+
finalTimelineRows: Math.max(2, finalTimelineRows),
|
|
364
|
+
};
|
|
365
|
+
}, [shellHeight, shellWidth, finalTimelineRows]);
|
|
366
|
+
|
|
367
|
+
// ─── Native mode transcript ───────────────────────────────────────────────
|
|
368
|
+
|
|
369
|
+
const nativeTranscriptParts = useMemo(() => {
|
|
370
|
+
if (mouseCapture) {
|
|
371
|
+
return { staticItems: [], liveRows: [] };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const staticItems = buildTimelineItems(staticEvents);
|
|
375
|
+
const activeItems = buildTimelineItems(activeEvents);
|
|
376
|
+
const turnIds = [...staticItems, ...activeItems]
|
|
377
|
+
.filter((item): item is Extract<TimelineItem, { type: "turn" }> => item.type === "turn")
|
|
378
|
+
.map((item) => item.turnId);
|
|
379
|
+
|
|
380
|
+
const parts = buildNativeTranscriptParts(
|
|
381
|
+
[
|
|
382
|
+
...buildStaticRenderItems(staticItems, turnIds, null, null, null),
|
|
383
|
+
...buildActiveRenderItems(activeItems, turnIds, uiState),
|
|
384
|
+
],
|
|
385
|
+
{
|
|
386
|
+
totalWidth: finalShellWidth,
|
|
387
|
+
verboseMode,
|
|
388
|
+
debugLabel: "app-shell-native",
|
|
389
|
+
workspaceRoot,
|
|
390
|
+
},
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
if (!showTimeline) {
|
|
394
|
+
return { ...parts, liveRows: [] };
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return parts;
|
|
398
|
+
}, [activeEvents, finalShellWidth, mouseCapture, showTimeline, staticEvents, uiState, verboseMode, workspaceRoot]);
|
|
399
|
+
|
|
400
|
+
// ─── Spacer logic for native mode ─────────────────────────────────────────
|
|
401
|
+
|
|
402
|
+
const nativeStaticTranscriptRows = useMemo(
|
|
403
|
+
() => nativeTranscriptParts.staticItems.reduce((total, item) => total + item.rows.length, 0),
|
|
404
|
+
[nativeTranscriptParts.staticItems],
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
const nativeSpacerRows = useMemo(() => {
|
|
408
|
+
if (mouseCapture || !effectiveShowComposer || showMainPanel) return 0;
|
|
409
|
+
const rows = calculateNativeSpacerRows({
|
|
410
|
+
shellRows: finalShellHeight,
|
|
411
|
+
introRows: headerRows + headerToContentGapRows,
|
|
412
|
+
composerRows: bottomChromeRows,
|
|
413
|
+
staticRows: nativeStaticTranscriptRows,
|
|
414
|
+
liveRows: nativeTranscriptParts.liveRows.length,
|
|
415
|
+
});
|
|
416
|
+
if (!hasUserPrompt) {
|
|
417
|
+
return calculateColdStartSpacerRows({
|
|
418
|
+
shellRows: finalShellHeight,
|
|
419
|
+
headerRows,
|
|
420
|
+
composerRows: bottomChromeRows,
|
|
421
|
+
layoutMode: layout.mode,
|
|
422
|
+
availableRows: rows,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
return rows;
|
|
426
|
+
}, [mouseCapture, effectiveShowComposer, showMainPanel, finalShellHeight, headerRows, headerToContentGapRows, bottomChromeRows, layout.mode, nativeStaticTranscriptRows, nativeTranscriptParts.liveRows.length, hasUserPrompt]);
|
|
427
|
+
|
|
428
|
+
const nativeStaticAllItems = useMemo<NativeStaticItem[]>(
|
|
429
|
+
() => {
|
|
430
|
+
if (mouseCapture) return [];
|
|
431
|
+
return nativeTranscriptParts.staticItems.map((item) => ({ ...item, type: "rows" as const }));
|
|
432
|
+
},
|
|
433
|
+
[mouseCapture, nativeTranscriptParts.staticItems],
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
const nativeAllRows = useMemo<TimelineRow[]>(
|
|
437
|
+
() => {
|
|
438
|
+
if (mouseCapture) return [];
|
|
439
|
+
|
|
440
|
+
const allStaticRows = nativeStaticAllItems.flatMap((item) => item.rows);
|
|
441
|
+
const maxStaticRows = finalShellHeight > 0 ? finalShellHeight * 2 : allStaticRows.length;
|
|
442
|
+
const trimmedStaticRows = allStaticRows.slice(Math.max(0, allStaticRows.length - maxStaticRows));
|
|
443
|
+
|
|
444
|
+
const liveRows = showTimeline ? nativeTranscriptParts.liveRows : [];
|
|
445
|
+
|
|
446
|
+
if (nativePaused) {
|
|
447
|
+
return frozenNativeRowsRef.current;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const rows = [
|
|
451
|
+
...trimmedStaticRows,
|
|
452
|
+
...liveRows,
|
|
453
|
+
];
|
|
454
|
+
frozenLiveRowCountRef.current = liveRows.length;
|
|
455
|
+
frozenNativeRowsRef.current = rows;
|
|
456
|
+
return rows;
|
|
457
|
+
},
|
|
458
|
+
[mouseCapture, nativePaused, nativeStaticAllItems, nativeTranscriptParts.liveRows, showTimeline, finalShellHeight],
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
const nativeUnseenRows = nativePaused
|
|
462
|
+
? Math.max(0, (showTimeline ? nativeTranscriptParts.liveRows.length : 0) - frozenLiveRowCountRef.current)
|
|
463
|
+
: 0;
|
|
464
|
+
|
|
465
|
+
useEffect(() => {
|
|
466
|
+
previousMeasurements.current = {
|
|
467
|
+
timelineRows: resolvedTimelineRows,
|
|
468
|
+
composerRows: bottomChromeRows,
|
|
469
|
+
shellHeight: finalShellHeight,
|
|
470
|
+
shellWidth: finalShellWidth,
|
|
471
|
+
};
|
|
472
|
+
}, [resolvedTimelineRows, bottomChromeRows, finalShellHeight, finalShellWidth]);
|
|
473
|
+
|
|
474
|
+
const clonedComposer = React.isValidElement(composer)
|
|
475
|
+
? React.cloneElement(
|
|
476
|
+
composer as React.ReactElement<{ selectionProfile?: TerminalSelectionProfile }>,
|
|
477
|
+
{ selectionProfile },
|
|
478
|
+
)
|
|
479
|
+
: composer;
|
|
480
|
+
|
|
481
|
+
const contentWidth = getContentWidth(layout.cols);
|
|
482
|
+
const panelStagePaddingY = appLayoutBudget.panelStagePaddingY;
|
|
483
|
+
|
|
484
|
+
const panelAvailableRows = appLayoutBudget.panelRows;
|
|
485
|
+
|
|
486
|
+
const activePanelLayout = useMemo<ActivePanelLayout>(() => {
|
|
487
|
+
const panelBoxHeight = Math.max(3, resolvedTimelineRows - 2 * panelStagePaddingY);
|
|
488
|
+
const showBorder = panelBoxHeight >= 7;
|
|
489
|
+
const borderRows = showBorder ? 2 : 0;
|
|
490
|
+
const borderCols = showBorder ? 4 : 0;
|
|
491
|
+
const panelTitleRows = showBorder ? 1 : 0;
|
|
492
|
+
const panelHeaderRows = panelBoxHeight >= 9 ? 1 : 0;
|
|
493
|
+
const panelChromeRows = borderRows + panelTitleRows + panelHeaderRows;
|
|
494
|
+
|
|
495
|
+
const availableRows = Math.max(1, panelBoxHeight - panelChromeRows);
|
|
496
|
+
const availableCols = Math.max(20, contentWidth - borderCols);
|
|
497
|
+
|
|
498
|
+
return {
|
|
499
|
+
width: contentWidth,
|
|
500
|
+
height: panelBoxHeight,
|
|
501
|
+
availableRows,
|
|
502
|
+
availableCols,
|
|
503
|
+
};
|
|
504
|
+
}, [resolvedTimelineRows, panelStagePaddingY, contentWidth]);
|
|
505
|
+
|
|
506
|
+
const panelLayout = useMemo<PanelLayout>(() => {
|
|
507
|
+
return {
|
|
508
|
+
mode: appLayoutBudget.mode,
|
|
509
|
+
availableRows: appLayoutBudget.activePanelRows,
|
|
510
|
+
availableCols: appLayoutBudget.activePanelCols,
|
|
511
|
+
};
|
|
512
|
+
}, [appLayoutBudget.mode, appLayoutBudget.activePanelRows, appLayoutBudget.activePanelCols]);
|
|
513
|
+
|
|
514
|
+
const mainContent = (
|
|
515
|
+
<AppLayoutBudgetContext.Provider value={appLayoutBudget}>
|
|
516
|
+
<Box flexDirection="column" width={contentWidth} height="100%">
|
|
517
|
+
<MemoizedTopHeader
|
|
518
|
+
authState={authState}
|
|
519
|
+
workspaceLabel={workspaceLabel}
|
|
520
|
+
layout={layout}
|
|
521
|
+
runtimeSummary={runtimeSummary}
|
|
522
|
+
headerConfig={headerConfig}
|
|
523
|
+
updateAvailable={updateAvailable}
|
|
524
|
+
/>
|
|
525
|
+
|
|
526
|
+
{headerToContentGapRows > 0 && (
|
|
527
|
+
<Box height={headerToContentGapRows} />
|
|
528
|
+
)}
|
|
529
|
+
|
|
530
|
+
<Box
|
|
531
|
+
flexDirection="column"
|
|
532
|
+
height={resolvedTimelineRows}
|
|
533
|
+
overflow="hidden"
|
|
534
|
+
display={showTimeline ? "flex" : "none"}
|
|
535
|
+
>
|
|
536
|
+
<Timeline
|
|
537
|
+
key={`timeline-${clearCount}`}
|
|
538
|
+
staticEvents={staticEvents}
|
|
539
|
+
activeEvents={activeEvents}
|
|
540
|
+
layout={layout}
|
|
541
|
+
uiState={uiState}
|
|
542
|
+
viewportRows={resolvedTimelineRows}
|
|
543
|
+
verboseMode={verboseMode}
|
|
544
|
+
authState={authState}
|
|
545
|
+
workspaceLabel={workspaceLabel}
|
|
546
|
+
workspaceRoot={workspaceRoot}
|
|
547
|
+
mouseCapture={mouseCapture}
|
|
548
|
+
onMouseActivity={onMouseActivity}
|
|
549
|
+
contentSized
|
|
550
|
+
/>
|
|
551
|
+
</Box>
|
|
552
|
+
|
|
553
|
+
{showMainPanel && (
|
|
554
|
+
<Box flexDirection="column" height={resolvedTimelineRows} overflow="hidden" justifyContent="center">
|
|
555
|
+
{mainPanel}
|
|
556
|
+
</Box>
|
|
557
|
+
)}
|
|
558
|
+
|
|
559
|
+
{showPanelStage && (
|
|
560
|
+
<Box flexDirection="column" height={resolvedTimelineRows} overflow="hidden" paddingY={panelStagePaddingY}>
|
|
561
|
+
<PanelAvailableRowsContext.Provider value={panelAvailableRows}>
|
|
562
|
+
<ActivePanelLayoutContext.Provider value={activePanelLayout}>
|
|
563
|
+
<PanelLayoutContext.Provider value={panelLayout}>
|
|
564
|
+
{process.env.CODEXA_DEBUG_LAYOUT === "1" && (
|
|
565
|
+
<Box>
|
|
566
|
+
<Text color="red">
|
|
567
|
+
DEBUG layout: rows={layout.rows} cols={layout.cols} mode={layout.mode} headerRows={headerRows} panelRows={panelAvailableRows} bottomChromeRows={appLayoutBudget.bottomChromeBudget.totalRows}
|
|
568
|
+
</Text>
|
|
569
|
+
</Box>
|
|
570
|
+
)}
|
|
571
|
+
{injectPanelLayout(panel, panelAvailableRows, activePanelLayout, panelLayout)}
|
|
572
|
+
</PanelLayoutContext.Provider>
|
|
573
|
+
</ActivePanelLayoutContext.Provider>
|
|
574
|
+
</PanelAvailableRowsContext.Provider>
|
|
575
|
+
</Box>
|
|
576
|
+
)}
|
|
577
|
+
|
|
578
|
+
{showPanelStage && panelHint}
|
|
579
|
+
|
|
580
|
+
{effectiveShowComposer && (
|
|
581
|
+
<Box flexDirection="column" flexShrink={0}>
|
|
582
|
+
{nativePaused && (
|
|
583
|
+
<NativePauseBar unseenRows={nativeUnseenRows} />
|
|
584
|
+
)}
|
|
585
|
+
{clonedComposer}
|
|
586
|
+
</Box>
|
|
587
|
+
)}
|
|
588
|
+
</Box>
|
|
589
|
+
</AppLayoutBudgetContext.Provider>
|
|
590
|
+
);
|
|
591
|
+
|
|
592
|
+
if (showMainPanelFullOutput) {
|
|
593
|
+
const fullOutputContent = (
|
|
594
|
+
<Box flexDirection="column" width={contentWidth}>
|
|
595
|
+
<MemoizedTopHeader
|
|
596
|
+
authState={authState}
|
|
597
|
+
workspaceLabel={workspaceLabel}
|
|
598
|
+
layout={layout}
|
|
599
|
+
runtimeSummary={runtimeSummary}
|
|
600
|
+
headerConfig={headerConfig}
|
|
601
|
+
updateAvailable={updateAvailable}
|
|
602
|
+
/>
|
|
603
|
+
|
|
604
|
+
{headerToContentGapRows > 0 && (
|
|
605
|
+
<Box height={headerToContentGapRows} />
|
|
606
|
+
)}
|
|
607
|
+
|
|
608
|
+
{mainPanel}
|
|
609
|
+
|
|
610
|
+
{showComposer && (
|
|
611
|
+
<Box flexDirection="column" flexShrink={0}>
|
|
612
|
+
{composer}
|
|
613
|
+
</Box>
|
|
614
|
+
)}
|
|
615
|
+
</Box>
|
|
616
|
+
);
|
|
617
|
+
|
|
618
|
+
if (shellWidth > contentWidth) {
|
|
619
|
+
return (
|
|
620
|
+
<Box flexDirection="column" width="100%" alignItems="center">
|
|
621
|
+
{fullOutputContent}
|
|
622
|
+
</Box>
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
return fullOutputContent;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (shellWidth > contentWidth) {
|
|
629
|
+
return (
|
|
630
|
+
<Box flexDirection="column" width="100%" height={finalShellHeight} alignItems="center">
|
|
631
|
+
{mainContent}
|
|
632
|
+
</Box>
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return (
|
|
637
|
+
<Box flexDirection="column" width="100%" height={finalShellHeight}>
|
|
638
|
+
{mainContent}
|
|
639
|
+
</Box>
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export const AppShell = memo(AppShellInner, (prev, next) => {
|
|
644
|
+
const panelPropsEqual = next.screen === "main"
|
|
645
|
+
? prev.mainPanel === next.mainPanel
|
|
646
|
+
: (prev.panel === next.panel && prev.panelHint === next.panelHint);
|
|
647
|
+
|
|
648
|
+
return (
|
|
649
|
+
prev.layout.cols === next.layout.cols &&
|
|
650
|
+
prev.layout.rows === next.layout.rows &&
|
|
651
|
+
prev.layout.mode === next.layout.mode &&
|
|
652
|
+
prev.layout.layoutEpoch === next.layout.layoutEpoch &&
|
|
653
|
+
prev.screen === next.screen &&
|
|
654
|
+
prev.authState === next.authState &&
|
|
655
|
+
prev.workspaceLabel === next.workspaceLabel &&
|
|
656
|
+
prev.workspaceRoot === next.workspaceRoot &&
|
|
657
|
+
prev.runtimeSummary === next.runtimeSummary &&
|
|
658
|
+
prev.staticEvents === next.staticEvents &&
|
|
659
|
+
prev.activeEvents === next.activeEvents &&
|
|
660
|
+
prev.uiState === next.uiState &&
|
|
661
|
+
prev.composerRows === next.composerRows &&
|
|
662
|
+
prev.composer === next.composer &&
|
|
663
|
+
prev.mainPanel === next.mainPanel &&
|
|
664
|
+
prev.mainPanelMode === next.mainPanelMode &&
|
|
665
|
+
prev.verboseMode === next.verboseMode &&
|
|
666
|
+
prev.mouseCapture === next.mouseCapture &&
|
|
667
|
+
prev.onMouseActivity === next.onMouseActivity &&
|
|
668
|
+
prev.clearCount === next.clearCount &&
|
|
669
|
+
prev.updateAvailable === next.updateAvailable &&
|
|
670
|
+
panelPropsEqual
|
|
671
|
+
);
|
|
672
|
+
});
|