@aragon-agent/cli 0.6.48 → 0.6.50

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 (72) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -0
  3. package/dist/agent/controller.d.ts +21 -0
  4. package/dist/agent/controller.js +35 -8
  5. package/dist/agent/governance-wiring.d.ts +2 -0
  6. package/dist/agent/governance-wiring.js +4 -0
  7. package/dist/app/App.d.ts +2 -4
  8. package/dist/app/App.js +279 -522
  9. package/dist/cli.js +8 -150
  10. package/dist/commands/catalog.d.ts +17 -0
  11. package/dist/commands/catalog.js +52 -0
  12. package/dist/commands/create-registry.d.ts +13 -0
  13. package/dist/commands/create-registry.js +19 -0
  14. package/dist/commands/governance-command.js +5 -1
  15. package/dist/commands/skills.js +18 -67
  16. package/dist/config/env.d.ts +2 -0
  17. package/dist/config/env.js +11 -1
  18. package/dist/config/load.js +4 -0
  19. package/dist/fast/review-call.d.ts +6 -0
  20. package/dist/fast/review-call.js +10 -0
  21. package/dist/governance/engine/budget.d.ts +18 -6
  22. package/dist/governance/engine/budget.js +61 -19
  23. package/dist/governance/engine/engine-core.d.ts +10 -0
  24. package/dist/governance/engine/engine-core.js +56 -9
  25. package/dist/governance/engine/engine.d.ts +1 -0
  26. package/dist/governance/engine/engine.js +9 -10
  27. package/dist/governance/engine/inspector.js +4 -3
  28. package/dist/governance/engine/lifecycle.js +4 -2
  29. package/dist/governance/engine/report.js +7 -1
  30. package/dist/governance/engine/run-digest.js +2 -1
  31. package/dist/governance/engine/stage-runner.js +1 -1
  32. package/dist/governance/engine/submissions.d.ts +2 -0
  33. package/dist/governance/engine/submissions.js +22 -3
  34. package/dist/governance/engine/visibility.d.ts +10 -0
  35. package/dist/governance/engine/visibility.js +28 -0
  36. package/dist/governance/rules/settlement.d.ts +7 -0
  37. package/dist/governance/rules/settlement.js +24 -0
  38. package/dist/governance/tools/shared-tools.d.ts +2 -0
  39. package/dist/governance/tools/shared-tools.js +15 -1
  40. package/dist/governance/tools/submit-tools.js +14 -7
  41. package/dist/host/commands.d.ts +18 -0
  42. package/dist/host/commands.js +30 -0
  43. package/dist/host/controller-factory.d.ts +109 -0
  44. package/dist/host/controller-factory.js +159 -0
  45. package/dist/host/controller-feed.d.ts +122 -0
  46. package/dist/host/controller-feed.js +356 -0
  47. package/dist/host/index-build.d.ts +23 -0
  48. package/dist/host/index-build.js +35 -0
  49. package/dist/host/index.d.ts +21 -0
  50. package/dist/host/index.js +21 -0
  51. package/dist/host/interaction.d.ts +58 -0
  52. package/dist/host/interaction.js +165 -0
  53. package/dist/host/logging.d.ts +7 -0
  54. package/dist/host/logging.js +7 -0
  55. package/dist/host/prompts.d.ts +10 -0
  56. package/dist/host/prompts.js +9 -0
  57. package/dist/host/sessions.d.ts +87 -0
  58. package/dist/host/sessions.js +234 -0
  59. package/dist/host/settings.d.ts +104 -0
  60. package/dist/host/settings.js +235 -0
  61. package/dist/host/skills.d.ts +19 -0
  62. package/dist/host/skills.js +38 -0
  63. package/dist/skills/command-names.d.ts +19 -0
  64. package/dist/skills/command-names.js +28 -0
  65. package/dist/skills/invoke.d.ts +38 -0
  66. package/dist/skills/invoke.js +65 -0
  67. package/dist/team/overseer.d.ts +25 -1
  68. package/dist/team/overseer.js +38 -1
  69. package/dist/team/runtime.d.ts +2 -0
  70. package/dist/team/runtime.js +10 -7
  71. package/dist/team/subagent.js +6 -4
  72. package/package.json +3 -3
package/dist/app/App.js CHANGED
@@ -10,9 +10,8 @@ import { selectTranscriptEntries, mergePendingEntries } from '@aragon-agent/tui/
10
10
  import { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from 'react';
11
11
  import { Text, useApp, useInput, useStdout } from 'ink';
12
12
  import { advanceInterruptGesture, INTERRUPT_CONFIRM_MS, cancelInterruptConfirmation, } from '@aragon-agent/tui/input/interrupt-gesture';
13
- import { initialViewState, reduceEvent, viewReducer, } from '@aragon-agent/tui/model/agent/reducer';
14
- import { mergeDeltas } from '../agent/coalesce.js';
15
- import { computeCost } from '@aragon-agent/tui/model/agent/usage';
13
+ import { initialViewState, viewReducer, } from '@aragon-agent/tui/model/agent/reducer';
14
+ import { ActionCoalescer, attachAgentChannel, attachCompactionChannel, attachContextUsageChannel, attachFastChannel, attachGovernanceChannel, attachProcChannel, attachTeamChannel, attachTodosChannel, attachToolOutputChannel, attachWaitChannel, makePatchSource, } from '../host/controller-feed.js';
16
15
  import { parseMaxTokensInput, DEFAULT_TRANSCRIPT_RETAIN, DEFAULT_TRANSCRIPT_WINDOW, } from '@aragon-agent/tui/model/config/schema';
17
16
  import { updatePersistedConfig } from '../config/store.js';
18
17
  import { appendPrompt, loadPromptHistory } from '../config/prompt-history.js';
@@ -62,14 +61,15 @@ import { advanceBudget, decideFollowThrough, emptyBudget, } from '@aragon-agent/
62
61
  // no policy. Imported beside the todo decision it shares one timer with.
63
62
  import { decideForcedDispatch, FORCED_NUDGE_NOTICE } from '../team/dispatch-gate.js';
64
63
  import { FORCED_NUDGE_GRACE_MS } from '@aragon-agent/tui/model/team/limits';
65
- import { priceTeamUsage } from '@aragon-agent/tui/model/team/model';
66
64
  import { useTerminalSize } from '@aragon-agent/tui/ui/layout/useTerminalSize';
67
65
  import { useHeightStore } from '@aragon-agent/tui/ui/use-height-store';
66
+ import { createPersonaBook } from '@aragon-agent/tui/ui/persona-names';
67
+ import { bindVoiceScope } from '@aragon-agent/tui/ui/tool-voice';
68
68
  import { useRenderGovernor } from '@aragon-agent/tui/ui/use-render-governor';
69
69
  import { readScrollbarPerf, setPerfResetHook, setPerfSnapshotProvider, } from '../commands/perf.js';
70
70
  import { buildFrameBudget, POPUP_CAPACITY_SHARE } from '@aragon-agent/tui/ui/layout/budget';
71
71
  import { useWheelRouting } from '@aragon-agent/tui/ui/use-wheel-routing';
72
- import { INDEX_KEY_FRAME } from '@aragon-agent/tui/input/limits';
72
+ import { DEV_MODE_KEY_FRAME, INDEX_KEY_FRAME } from '@aragon-agent/tui/input/limits';
73
73
  import { INDEX_SKILL_NAME, buildIndexConfirmSummary, hasProjectIndex, indexBuildInvocationArgs, } from '../commands/index-build.js';
74
74
  import { installConsoleBridge } from '@aragon-agent/tui/ui/console-bridge';
75
75
  import { publishExitSnapshot } from '@aragon-agent/tui/ui/exit-snapshot';
@@ -92,10 +92,9 @@ import { SettingsScreen, compactionSettingsFrom, fastSettingsFrom, } from '@arag
92
92
  import { ConfirmDialog } from '@aragon-agent/tui/ui/overlays/ConfirmDialog';
93
93
  import { QuestionOverlay } from '@aragon-agent/tui/ui/overlays/QuestionOverlay';
94
94
  import { PlanReviewOverlay } from '@aragon-agent/tui/ui/overlays/PlanReviewOverlay';
95
- import { CommandRegistry, parseSlashInput, runSlashInput, } from '../commands/registry.js';
95
+ import { parseSlashInput, runSlashInput, } from '../commands/registry.js';
96
96
  import { buildInvocationCard, invocationCardsEnabled } from '@aragon-agent/tui/model/agent/invocation-card';
97
- import { registerBuiltinCommands } from '../commands/builtins.js';
98
- import { makeSkillsCommand, registerSkillCommands } from '../commands/skills.js';
97
+ import { createCommandRegistry } from '../commands/create-registry.js';
99
98
  import { MODE_TOGGLE_KEYS } from '@aragon-agent/tui/model/agent/agent-mode';
100
99
  import { createClipboardCoordinator } from '@aragon-agent/tui/ui/clipboard-task';
101
100
  import { QueuePanel } from '@aragon-agent/tui/ui/QueuePanel';
@@ -172,7 +171,10 @@ function liveServiceCount(services) {
172
171
  * across renders and React never re-runs it.
173
172
  */
174
173
  function seedViewState(seed) {
175
- const base = initialViewState({ thinkingVisible: seed.thinkingVisible });
174
+ const base = initialViewState({
175
+ thinkingVisible: seed.thinkingVisible,
176
+ ...(seed.developerMode !== undefined ? { developerMode: seed.developerMode } : {}),
177
+ });
176
178
  // THE REDUCER'S OWN ADOPTION LOGIC, NOT A COPY OF IT (3.12): `restoreEntries`
177
179
  // already lifts `seq` past the restored ids, trims to the retain ring and
178
180
  // clears the live-target pointers, and a second implementation of those thirty
@@ -301,11 +303,17 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
301
303
  });
302
304
  /** The transcript height cache, owned here and read by `TranscriptList` (L3). */
303
305
  const heights = useHeightStore();
306
+ // PERSONA NAMES live only in this session-scoped book (display nicknames: never
307
+ // stored, logged, prompted or addressable). A ref, so it survives re-renders without
308
+ // causing one; reset on `/clear` and `/resume` (see the `dispatch` wrapper below).
309
+ const personaBookRef = useRef(null);
310
+ if (personaBookRef.current === null)
311
+ personaBookRef.current = createPersonaBook();
304
312
  // SEEDED FROM CONFIG, not dispatched after mount (§3.1.1): a post-mount
305
313
  // `toggleThinking` would let `/resume` flash a restored thinking block on
306
314
  // frame 1. `seedViewState` is module-scope so the lazy initializer is a stable
307
315
  // function reference.
308
- const [state, dispatch] = useReducer(viewReducer, { thinkingVisible: cfg.showThinking, ...(initialEntries ? { entries: initialEntries } : {}) }, seedViewState);
316
+ const [state, dispatch] = useReducer(viewReducer, { thinkingVisible: cfg.showThinking, developerMode: cfg.developerMode, ...(initialEntries ? { entries: initialEntries } : {}) }, seedViewState);
309
317
  // THE IDENTITY, SEEDED FROM THE PROP AND REPLACED ON ROTATION (D-15). A ref
310
318
  // travels beside it because both readers -- the publish effect and the
311
319
  // `/session` port -- must see the CURRENT id, and a rotation can land between
@@ -370,6 +378,27 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
370
378
  const theme = useMemo(() => getTheme(cfg.theme, caps), [cfg.theme, caps]);
371
379
  const glyphs = useMemo(() => pickGlyphs(caps), [caps]);
372
380
  const reducedMotion = cfg.reducedMotion ?? false;
381
+ // THE VOICE: how tool names are worded and which persona names rows carry. Built from
382
+ // the RAW `reducedMotion` (not the widened `viewReducedMotion`, which is true for the
383
+ // whole run and would freeze the thinking words). Referentially stable per
384
+ // (mode, reducedMotion) because `EntryView`'s memo compares it by identity.
385
+ const voice = useMemo(() => {
386
+ const book = personaBookRef.current;
387
+ return {
388
+ mode: state.developerMode ? 'developer' : 'friendly',
389
+ reducedMotion,
390
+ nameOf: (label) => book.nameFor('', label),
391
+ nameIn: (scope, label) => book.nameFor(scope, label),
392
+ };
393
+ }, [state.developerMode, reducedMotion]);
394
+ // A GOVERNED DISPATCH is the governance run's team: alias its dispatch id to the run id
395
+ // so the roster, the Ctrl+B board and the settlement cards name the same child alike.
396
+ // Idempotent and cheap, so it is safe in render; the book ignores repeat calls.
397
+ if (state.team && state.governance
398
+ && liveRosterSurface(state.governance, true) === 'governance') {
399
+ personaBookRef.current.alias(state.team.dispatchId, state.governance.runId);
400
+ }
401
+ const teamVoice = state.team ? bindVoiceScope(voice, state.team.dispatchId) : voice;
373
402
  const stateRef = useRef(state);
374
403
  stateRef.current = state;
375
404
  // The first-seen-eliminated map for the legion panel (a replaced member shows for one
@@ -623,271 +652,213 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
623
652
  for (const entry of [...pendingHuman.current])
624
653
  settleHuman(entry, null);
625
654
  }, [settleHuman]);
626
- const registry = useMemo(() => {
627
- const r = new CommandRegistry();
628
- // Order matters: built-ins first, so `registerSkillCommands` sees them when
629
- // it probes for name conflicts and a skill can never displace `/exit` (D6).
630
- registerBuiltinCommands(r);
631
- const skills = controller.getSkillService();
632
- if (cfg.skills.enabled) {
633
- r.register(makeSkillsCommand(skills, version));
634
- registerSkillCommands(r, skills);
635
- }
636
- return r;
637
- // eslint-disable-next-line react-hooks/exhaustive-deps
638
- }, [controller, cfg.skills.enabled, version, skillsNonce]);
655
+ // The set is assembled by `createCommandRegistry`, which the desktop host shares, so the
656
+ // terminal's dispatcher and the desktop's `/` menu cannot drift apart.
657
+ const registry = useMemo(() => createCommandRegistry({
658
+ version, ...(cfg.skills.enabled ? { skills: controller.getSkillService() } : {}),
659
+ }),
660
+ // eslint-disable-next-line react-hooks/exhaustive-deps
661
+ [controller, cfg.skills.enabled, version, skillsNonce]);
639
662
  const commandOptions = useMemo(() => registry.all().map((c) => ({ name: c.name, description: c.description })), [registry]);
640
663
  // --- Streaming coalescer + controller subscription. --------------------
641
- const pending = useRef([]);
642
- const flushTimer = useRef(null);
643
- /** Alias so the subscription effect below reads one stable ref, not a hook. */
664
+ /** Alias so the subscription effects below read one stable ref, not a hook. */
644
665
  const governorInterval = governor.intervalMs;
645
- const flushPending = useCallback(() => {
646
- if (flushTimer.current) {
647
- clearTimeout(flushTimer.current);
648
- flushTimer.current = null;
649
- }
650
- if (pending.current.length === 0)
651
- return;
652
- const merged = mergeDeltas(pending.current);
653
- pending.current = [];
654
- for (const action of merged)
655
- dispatch(action);
656
- }, []);
666
+ // READ FROM THE REF AT ARM TIME (L4): the effects' dependency lists never change by
667
+ // construction, so a captured number would pin the ladder to the mount render.
668
+ const coalescer = useMemo(() => new ActionCoalescer(dispatch, () => governorInterval.current), [governorInterval]);
669
+ const flushPending = useCallback(() => coalescer.flush(), [coalescer]);
657
670
  /**
658
671
  * The CLI-local diff side channel (§3.3.7). Memoized once, beside the `cost`
659
672
  * lookup below, because `reduceEvent` TAKES a patch rather than reading one:
660
673
  * the store is consume-once, so this object must not be rebuilt per event.
661
674
  */
662
- const patchSource = useMemo(() => ({ take: (id) => controller.takeFilePatch(id) }), [controller]);
675
+ const patchSource = useMemo(() => makePatchSource(controller), [controller]);
663
676
  useEffect(() => {
664
- // CAPTURED AT SUBSCRIBE TIME AND COMPARED ON EVERY EVENT (I-7 / P1-7).
665
- //
666
- // `forceStop()` bumps the controller's generation, and everything the engine
667
- // emits while it unwinds - `turn_start`, `tool_call_start`, `turn_end`,
668
- // `agent_end` - belongs to the run the user just abandoned. `runStart` /
669
- // `turnStart` would set `status: 'running'` again, bouncing the view straight
670
- // back out of the `idle` force-stop just gave them, and stray entries would
671
- // append to a transcript they believe is finished.
672
- //
673
- // A LOCAL `let`, RE-READ RATHER THAN CAPTURED ONCE: the generation this
674
- // listener considers current advances with every submit, so a force-stop
675
- // makes stale events inert WITHOUT making the next run's events inert too.
676
- let generation = controller.runGeneration;
677
- const unsubscribe = controller.subscribe((event) => {
678
- // Receipts describe committed history even when force-stop invalidated the run.
679
- if (event.type === 'steering_accepted') {
680
- dispatch({ type: 'steeringAccepted', ids: event.ids });
681
- return;
682
- }
683
- if (controller.runGeneration !== generation) {
684
- // The engine is unwinding a force-stopped run. Adopt the new generation
685
- // only once it has finished doing so, so a late `agent_end` cannot be
686
- // mistaken for the next run's.
687
- if (event.type === 'agent_end')
688
- generation = controller.runGeneration;
689
- return;
690
- }
691
- metrics.current = updateRunMetrics(metrics.current, event, Date.now());
692
- if (event.type === 'agent_start') {
693
- interactionPhase.current = 'running';
694
- manualMetrics.current = createRunMetrics();
695
- // THE TWO PER-TURN COUNTERS ONLY (I-10). `nudgesRef` is deliberately
696
- // absent: a nudge continuation arrives here too, and clearing it would
697
- // delete the bound that keeps a disobedient model from looping.
698
- toolsUsedRef.current = 0;
699
- dispatchAttemptedRef.current = false;
700
- }
701
- if (event.type === 'agent_end') {
702
- interactionPhase.current = 'idle';
703
- resetInterrupt();
704
- }
705
- const cost = controller.getModelInfo().cost;
706
- for (const action of reduceEvent(event, cost, patchSource)) {
707
- // MUTATED HERE, ONE INSTANT BEFORE THE ACTION THAT SETS
708
- // `ViewState.errorNoticed`, rather than read back from the reducer one
709
- // commit later (C-11). This is the whole of the batching-independence
710
- // guarantee: `agent_end` can follow this action in the same tick with no
711
- // render in between, and AC-40 asserts exactly that sequence.
712
- if (action.type === 'notice' && action.level === 'error') {
713
- endReasonRef.current.errored = true;
714
- }
715
- // THE GATE'S TWO FACTS, counted where the reducer's own actions already
716
- // flow (no second subscription to keep in step). `toolExecStart` carries
717
- // the tool NAME, so a `task` call that was REFUSED - team off, dispatch
718
- // busy, no key - still counts as an attempt (P1-7): the upstream already
719
- // said no, and urging a re-dispatch would reproduce that refusal one
720
- // turn later.
721
- if (action.type === 'toolExecStart') {
722
- toolsUsedRef.current += 1;
723
- if (action.toolName === 'task')
724
- dispatchAttemptedRef.current = true;
725
- }
726
- if (action.type === 'textDelta' || action.type === 'thinkingDelta') {
727
- pending.current.push(action);
728
- if (!flushTimer.current) {
729
- // READ FROM THE REF AT ARM TIME (L4). This effect's dependency list
730
- // never changes by construction, so a captured number would be
731
- // pinned to the mount render and the ladder would move nothing.
732
- flushTimer.current = setTimeout(() => flushPending(), governorInterval.current);
677
+ // THE GENERATION GUARD LIVES IN `host/controller-feed.ts::attachAgentChannel` (I-7 / P1-7);
678
+ // what stays here is the TUI's interaction policy, reached through three hooks.
679
+ const detachAgent = attachAgentChannel(controller, {
680
+ dispatch,
681
+ coalescer,
682
+ patchSource,
683
+ hooks: {
684
+ beforeEvent(event) {
685
+ metrics.current = updateRunMetrics(metrics.current, event, Date.now());
686
+ if (event.type === 'agent_start') {
687
+ interactionPhase.current = 'running';
688
+ manualMetrics.current = createRunMetrics();
689
+ // THE TWO PER-TURN COUNTERS ONLY (I-10). `nudgesRef` is deliberately
690
+ // absent: a nudge continuation arrives here too, and clearing it would
691
+ // delete the bound that keeps a disobedient model from looping.
692
+ toolsUsedRef.current = 0;
693
+ dispatchAttemptedRef.current = false;
733
694
  }
734
- }
735
- else {
736
- flushPending();
737
- dispatch(action);
738
- }
739
- }
740
- if (event.type !== 'agent_end')
741
- return;
742
- // NO OVERLAY OUTLIVES ITS RUN (P1-4). `ctx.signal` already covers the
743
- // abort path, so this is DELIBERATE REDUNDANCY: it makes "the card cannot
744
- // survive the run that opened it" a property of the App's lifecycle
745
- // rather than a consequence of signal plumbing three modules away.
746
- // Without it, an aborted run leaves a plan card on screen whose `a` key
747
- // silently flips the session to build, with no visible cause.
748
- cancelPendingHuman();
749
- // --- Follow-through (todo-plan-followthrough §3.4). ------------------
750
- //
751
- // Round 1 printed one notice here and stopped, under a good argument
752
- // ("auto-continuation is an unbounded cost loop wearing a helpful hat").
753
- // That judgement is not overturned: the loop is BOUNDED first, by two
754
- // structural counters, and only then permitted — opt-in, and off by
755
- // default, so `followThrough: 'notify'` reproduces the old notice byte for
756
- // byte (AC-1).
757
- const todos = controller.getTodoSnapshot();
758
- budgetRef.current = advanceBudget(budgetRef.current, todos, autoContinuationRef.current);
759
- autoContinuationRef.current = false;
760
- // --- Forced-dispatch gate (team-command-forced-dispatch §3.7). --------
761
- //
762
- // THE THIRD LAYER, AND THE ONLY MECHANICAL ONE: if a whole turn went by
763
- // with tools used and nothing dispatched, ask ONCE for a dispatch. It is
764
- // computed BEFORE the todo decision and DOWN-GRADES that decision to
765
- // `none` rather than returning early (P0-3 / I-9): the two statements below
766
- // - the `endReasonRef` reset and `applyPendingMode()` - belong to EVERY
767
- // turn, and a `return` here would silently defer a pending `plan -> build`
768
- // by a whole turn and carry `errored` into the next one. It also keeps
769
- // `cancelFollowThrough()`'s callers at three: the gate reuses the timer
770
- // instead of adding a fourth canceller.
771
- const forced = controller.getForcedTeam();
772
- const gate = decideForcedDispatch({
773
- armed: forced !== null,
774
- count: forced?.count ?? 0,
775
- dispatchAttempted: dispatchAttemptedRef.current,
776
- toolsUsed: toolsUsedRef.current,
777
- nudgesUsed: nudgesRef.current,
778
- runEnd: { ...endReasonRef.current },
779
- });
780
- const gated = gate.kind === 'nudge' && forced !== null;
781
- const decision = gated
782
- ? { kind: 'none' }
783
- : decideFollowThrough({
784
- mode: controller.getTodoConfig().followThrough,
785
- snapshot: todos,
786
- runEnd: { ...endReasonRef.current },
787
- budget: budgetRef.current,
788
- interactive: true,
789
- });
790
- endReasonRef.current = { aborted: false, errored: false };
791
- if (decision.kind === 'notify') {
792
- dispatch({ type: 'notice', level: decision.level, text: decision.text });
793
- }
794
- else if (decision.kind === 'continue') {
795
- dispatch({ type: 'notice', level: 'info', text: decision.notice });
796
- // NO LIVE COUNTDOWN (D-10). The notice is written once and does not
797
- // tick: a 10 Hz re-render of the whole frame to animate a number is the
798
- // repaint cost this package refuses elsewhere, and Ink's two dedupe
799
- // gates mean the alternative is not free either.
800
- cancelFollowThrough(); // I-3: at most one armed continuation, ever
801
- followTimer.current = setTimeout(() => {
802
- followTimer.current = null;
803
- // TWO RE-CHECKS AT FIRE TIME, not only at decision time. The grace
804
- // window is 3 s and the user can type in it (C-6): without the first,
805
- // a fired continuation would either be swallowed into
806
- // `controller.steer()` (the quiet failure) or reach
807
- // `controller.prompt()`, which REJECTS while running.
808
- if (controller.isRunning() || controller.isCompactionBusy?.())
809
- return;
810
- const live = controller.getTodoSnapshot();
811
- // `planIsResolved`, NOT `doneCount >= total` (todo-acceptance-criteria
812
- // §6.7 / AC-20). With steps all done but criteria unchecked the old test
813
- // said "no work left" and returned silently - one second after the notice
814
- // promised "Continuing with 2 unchecked acceptance criteria in 3s". A
815
- // promise that cancels itself is the worst failure this design has.
816
- if (!live || planIsResolved(live.items, live.acceptance?.items ?? null))
817
- return;
818
- budgetRef.current = { ...budgetRef.current, used: budgetRef.current.used + 1 };
819
- autoContinuationRef.current = true;
820
- // COUNTS ONLY, NEVER ITEM TEXT (D-19), and only at the fire point —
821
- // the quiet paths must stay quiet.
822
- getLogger().debug('agent', 'todo_follow', {
823
- used: budgetRef.current.used,
824
- noProgressStreak: budgetRef.current.noProgressStreak,
825
- total: live.total,
826
- done: live.doneCount,
827
- accTotal: live.acceptance?.total ?? 0,
828
- accChecked: live.acceptance?.checkedCount ?? 0,
829
- mode: 'auto',
695
+ if (event.type === 'agent_end') {
696
+ interactionPhase.current = 'idle';
697
+ resetInterrupt();
698
+ }
699
+ },
700
+ onAction(action) {
701
+ // MUTATED HERE, ONE INSTANT BEFORE THE ACTION THAT SETS
702
+ // `ViewState.errorNoticed`, rather than read back from the reducer one
703
+ // commit later (C-11). This is the whole of the batching-independence
704
+ // guarantee: `agent_end` can follow this action in the same tick with no
705
+ // render in between, and AC-40 asserts exactly that sequence.
706
+ if (action.type === 'notice' && action.level === 'error') {
707
+ endReasonRef.current.errored = true;
708
+ }
709
+ // THE GATE'S TWO FACTS, counted where the reducer's own actions already
710
+ // flow (no second subscription to keep in step). `toolExecStart` carries
711
+ // the tool NAME, so a `task` call that was REFUSED - team off, dispatch
712
+ // busy, no key - still counts as an attempt (P1-7): the upstream already
713
+ // said no, and urging a re-dispatch would reproduce that refusal one
714
+ // turn later.
715
+ if (action.type === 'toolExecStart') {
716
+ toolsUsedRef.current += 1;
717
+ if (action.toolName === 'task')
718
+ dispatchAttemptedRef.current = true;
719
+ }
720
+ },
721
+ afterAgentEnd() {
722
+ // NO OVERLAY OUTLIVES ITS RUN (P1-4). `ctx.signal` already covers the
723
+ // abort path, so this is DELIBERATE REDUNDANCY: it makes "the card cannot
724
+ // survive the run that opened it" a property of the App's lifecycle
725
+ // rather than a consequence of signal plumbing three modules away.
726
+ // Without it, an aborted run leaves a plan card on screen whose `a` key
727
+ // silently flips the session to build, with no visible cause.
728
+ cancelPendingHuman();
729
+ // --- Follow-through (todo-plan-followthrough §3.4). ------------------
730
+ //
731
+ // Round 1 printed one notice here and stopped, under a good argument
732
+ // ("auto-continuation is an unbounded cost loop wearing a helpful hat").
733
+ // That judgement is not overturned: the loop is BOUNDED first, by two
734
+ // structural counters, and only then permitted — opt-in, and off by
735
+ // default, so `followThrough: 'notify'` reproduces the old notice byte for
736
+ // byte (AC-1).
737
+ const todos = controller.getTodoSnapshot();
738
+ budgetRef.current = advanceBudget(budgetRef.current, todos, autoContinuationRef.current);
739
+ autoContinuationRef.current = false;
740
+ // --- Forced-dispatch gate (team-command-forced-dispatch §3.7). --------
741
+ //
742
+ // THE THIRD LAYER, AND THE ONLY MECHANICAL ONE: if a whole turn went by
743
+ // with tools used and nothing dispatched, ask ONCE for a dispatch. It is
744
+ // computed BEFORE the todo decision and DOWN-GRADES that decision to
745
+ // `none` rather than returning early (P0-3 / I-9): the two statements below
746
+ // - the `endReasonRef` reset and `applyPendingMode()` - belong to EVERY
747
+ // turn, and a `return` here would silently defer a pending `plan -> build`
748
+ // by a whole turn and carry `errored` into the next one. It also keeps
749
+ // `cancelFollowThrough()`'s callers at three: the gate reuses the timer
750
+ // instead of adding a fourth canceller.
751
+ const forced = controller.getForcedTeam();
752
+ const gate = decideForcedDispatch({
753
+ armed: forced !== null,
754
+ count: forced?.count ?? 0,
755
+ dispatchAttempted: dispatchAttemptedRef.current,
756
+ toolsUsed: toolsUsedRef.current,
757
+ nudgesUsed: nudgesRef.current,
758
+ runEnd: { ...endReasonRef.current },
830
759
  });
831
- submitRef.current(decision.message, { userInitiated: false, todoPolicy: 'continue' });
832
- }, decision.graceMs);
833
- }
834
- // THE GATE'S OWN CONTINUATION: after the todo branch (which it has
835
- // already silenced) and BEFORE `applyPendingMode()`, on the SAME timer and
836
- // with the same re-checks. `level: 'warn'` and not `'error'` - the error
837
- // level sets `endReasonRef.errored`, which would make the next turn's gate
838
- // read "the run failed" and switch itself off for the rest of the session.
839
- if (gated && gate.kind === 'nudge') {
840
- nudgesRef.current += 1;
841
- dispatch({ type: 'notice', level: 'warn', text: FORCED_NUDGE_NOTICE });
842
- cancelFollowThrough(); // I-9 / I-3: at most one armed continuation, ever
843
- followTimer.current = setTimeout(() => {
844
- followTimer.current = null;
845
- if (controller.isRunning() || controller.isCompactionBusy?.())
846
- return;
847
- submitRef.current(gate.message, { userInitiated: false, todoPolicy: 'continue' });
848
- }, FORCED_NUDGE_GRACE_MS);
849
- }
850
- // A deferred `plan -> build` (or any posture change that waited for a governed
851
- // stage, governance-mode D-23) becomes real here and nowhere else (§3.2).
852
- const applied = controller.applyPendingPosture();
853
- if (applied) {
854
- const split = splitPosture(applied.effective);
855
- dispatch({
856
- type: 'setAgentMode',
857
- mode: split.mode,
858
- pending: null,
859
- posture: applied.effective,
860
- pendingPosture: applied.pending,
861
- });
862
- dispatch({
863
- type: 'pushToast',
864
- level: 'info',
865
- text: postureAppliedToast(applied.effective),
866
- });
867
- }
760
+ const gated = gate.kind === 'nudge' && forced !== null;
761
+ const decision = gated
762
+ ? { kind: 'none' }
763
+ : decideFollowThrough({
764
+ mode: controller.getTodoConfig().followThrough,
765
+ snapshot: todos,
766
+ runEnd: { ...endReasonRef.current },
767
+ budget: budgetRef.current,
768
+ interactive: true,
769
+ });
770
+ endReasonRef.current = { aborted: false, errored: false };
771
+ if (decision.kind === 'notify') {
772
+ dispatch({ type: 'notice', level: decision.level, text: decision.text });
773
+ }
774
+ else if (decision.kind === 'continue') {
775
+ dispatch({ type: 'notice', level: 'info', text: decision.notice });
776
+ // NO LIVE COUNTDOWN (D-10). The notice is written once and does not
777
+ // tick: a 10 Hz re-render of the whole frame to animate a number is the
778
+ // repaint cost this package refuses elsewhere, and Ink's two dedupe
779
+ // gates mean the alternative is not free either.
780
+ cancelFollowThrough(); // I-3: at most one armed continuation, ever
781
+ followTimer.current = setTimeout(() => {
782
+ followTimer.current = null;
783
+ // TWO RE-CHECKS AT FIRE TIME, not only at decision time. The grace
784
+ // window is 3 s and the user can type in it (C-6): without the first,
785
+ // a fired continuation would either be swallowed into
786
+ // `controller.steer()` (the quiet failure) or reach
787
+ // `controller.prompt()`, which REJECTS while running.
788
+ if (controller.isRunning() || controller.isCompactionBusy?.())
789
+ return;
790
+ const live = controller.getTodoSnapshot();
791
+ // `planIsResolved`, NOT `doneCount >= total` (todo-acceptance-criteria
792
+ // §6.7 / AC-20). With steps all done but criteria unchecked the old test
793
+ // said "no work left" and returned silently - one second after the notice
794
+ // promised "Continuing with 2 unchecked acceptance criteria in 3s". A
795
+ // promise that cancels itself is the worst failure this design has.
796
+ if (!live || planIsResolved(live.items, live.acceptance?.items ?? null))
797
+ return;
798
+ budgetRef.current = { ...budgetRef.current, used: budgetRef.current.used + 1 };
799
+ autoContinuationRef.current = true;
800
+ // COUNTS ONLY, NEVER ITEM TEXT (D-19), and only at the fire point —
801
+ // the quiet paths must stay quiet.
802
+ getLogger().debug('agent', 'todo_follow', {
803
+ used: budgetRef.current.used,
804
+ noProgressStreak: budgetRef.current.noProgressStreak,
805
+ total: live.total,
806
+ done: live.doneCount,
807
+ accTotal: live.acceptance?.total ?? 0,
808
+ accChecked: live.acceptance?.checkedCount ?? 0,
809
+ mode: 'auto',
810
+ });
811
+ submitRef.current(decision.message, { userInitiated: false, todoPolicy: 'continue' });
812
+ }, decision.graceMs);
813
+ }
814
+ // THE GATE'S OWN CONTINUATION: after the todo branch (which it has
815
+ // already silenced) and BEFORE `applyPendingMode()`, on the SAME timer and
816
+ // with the same re-checks. `level: 'warn'` and not `'error'` - the error
817
+ // level sets `endReasonRef.errored`, which would make the next turn's gate
818
+ // read "the run failed" and switch itself off for the rest of the session.
819
+ if (gated && gate.kind === 'nudge') {
820
+ nudgesRef.current += 1;
821
+ dispatch({ type: 'notice', level: 'warn', text: FORCED_NUDGE_NOTICE });
822
+ cancelFollowThrough(); // I-9 / I-3: at most one armed continuation, ever
823
+ followTimer.current = setTimeout(() => {
824
+ followTimer.current = null;
825
+ if (controller.isRunning() || controller.isCompactionBusy?.())
826
+ return;
827
+ submitRef.current(gate.message, { userInitiated: false, todoPolicy: 'continue' });
828
+ }, FORCED_NUDGE_GRACE_MS);
829
+ }
830
+ // A deferred `plan -> build` (or any posture change that waited for a governed
831
+ // stage, governance-mode D-23) becomes real here and nowhere else (§3.2).
832
+ const applied = controller.applyPendingPosture();
833
+ if (applied) {
834
+ const split = splitPosture(applied.effective);
835
+ dispatch({
836
+ type: 'setAgentMode',
837
+ mode: split.mode,
838
+ pending: null,
839
+ posture: applied.effective,
840
+ pendingPosture: applied.pending,
841
+ });
842
+ dispatch({
843
+ type: 'pushToast',
844
+ level: 'info',
845
+ text: postureAppliedToast(applied.effective),
846
+ });
847
+ }
848
+ },
849
+ },
868
850
  });
869
851
  return () => {
870
- flushPending();
871
852
  // An armed continuation must not outlive the tree that armed it (AC-21):
872
853
  // the timer would fire into an unmounted App and `submitRef.current` would
873
854
  // prompt a controller nobody is rendering.
874
855
  cancelFollowThrough();
875
- unsubscribe();
856
+ detachAgent();
876
857
  };
877
- }, [controller, patchSource, flushPending, cancelPendingHuman, cancelFollowThrough, resetInterrupt]);
858
+ }, [controller, patchSource, coalescer, cancelPendingHuman, cancelFollowThrough, resetInterrupt]);
878
859
  useEffect(() => {
879
- return controller.subscribeProc((event) => {
880
- const service = event.service;
860
+ return attachProcChannel(controller, dispatch, (service) => {
881
861
  setServices((prev) => ({ ...prev, [service.id]: service }));
882
- if (event.type === 'started') {
883
- dispatch({ type: 'serviceStart', service });
884
- return;
885
- }
886
- if (event.type === 'exited' || event.type === 'stopped') {
887
- dispatch({ type: 'serviceEnd', service });
888
- return;
889
- }
890
- dispatch({ type: 'serviceUpdate', service });
891
862
  });
892
863
  }, [controller]);
893
864
  // --- Team-mode event stream (team-subagents §5.2 / §3.9). --------------
@@ -901,94 +872,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
901
872
  // the source at 120 ms per child (§5.2), and pushing it through a second
902
873
  // buffer would only delay the roster.
903
874
  useEffect(() => {
904
- const unsubscribeTeam = controller.subscribeTeam((event) => {
905
- switch (event.type) {
906
- case 'dispatch_start':
907
- dispatch({
908
- type: 'teamStart',
909
- dispatchId: event.dispatchId,
910
- requested: event.requested,
911
- specs: event.specs,
912
- });
913
- break;
914
- case 'agent_update': {
915
- const snapshot = controller.getTeamSnapshot();
916
- if (snapshot)
917
- dispatch({ type: 'teamUpdate', snapshot });
918
- break;
919
- }
920
- case 'message': {
921
- const snapshot = controller.getTeamSnapshot();
922
- if (snapshot)
923
- dispatch({ type: 'teamUpdate', snapshot });
924
- break;
925
- }
926
- case 'overseer': {
927
- // A supervisor decision was applied (team-overseer). The roster
928
- // already refreshed through the agent_update the runtime publishes
929
- // with it; re-read the snapshot so the panel cannot miss the row.
930
- const snap = controller.getTeamSnapshot();
931
- if (snap)
932
- dispatch({ type: 'teamUpdate', snapshot: snap });
933
- // G-4 / AC-5 (subagent-overseer-v2): a TERMINAL verdict is the
934
- // one decision the user must not discover from the final report
935
- // - it removes work they watched running. wait and nudge stay
936
- // panel-only so the transcript gains no per-tick noise.
937
- if (event.decision.action === 'replace' || event.decision.action === 'abandon') {
938
- const verb = event.decision.action === 'replace' ? 'replaced' : 'abandoned';
939
- const level = event.decision.action === 'replace' ? 'info' : 'warn';
940
- const reason = event.decision.reason.slice(0, 120);
941
- dispatch({
942
- type: 'notice',
943
- level,
944
- text: `team supervisor ${verb} ${event.label} - ${reason}`,
945
- });
946
- }
947
- break;
948
- }
949
- case 'usage': {
950
- // Child spend is REAL SPEND and must reach the status bar, or the
951
- // session cost readout under-reports by however much the team consumed
952
- // — the single most misleading possible failure of this feature (R-5).
953
- //
954
- // THE COST TABLE IS SELECTED BY TIER (fast-model-tier §3.6 / R-7).
955
- // Always using the lead's would over-report a Haiku child under a
956
- // Sonnet lead by roughly an order of magnitude, which is a different
957
- // way of being wrong about the same number.
958
- // FROM THE CONTROLLER, NOT FROM `cfg` (the rule the `agent_end`
959
- // handler above records): this effect's dependency list never changes,
960
- // so it closes over the `cfg` object of the render it mounted in, and
961
- // `setModel` builds a NEW one.
962
- //
963
- // PRICED AT THE MODEL THE CHILDREN RAN (`team.model`), through the same
964
- // resolution the dispatch report prices with: under `fast` / `profile` the
965
- // lead's table would over-report by up to an order of magnitude, and an
966
- // unpriced child model must read as unknown (ZERO here), not as the lead's.
967
- const costDelta = priceTeamUsage(controller.subagentModelResolution(), event.usage, {
968
- mainCost: controller.getModelInfo().cost,
969
- isPriced: (ref) => controller.isPricedModel(ref),
970
- costFor: (ref) => controller.getModelInfoFor(ref).cost,
971
- });
972
- dispatch({ type: 'teamUsage', usage: event.usage, costDelta });
973
- break;
974
- }
975
- case 'dispatch_end': {
976
- // The supervisor's own calls never emit a usage event (they go through the fast
977
- // registry directly), so their spend reaches the readout HERE, once per
978
- // dispatch, at the fast tier's price - the same channel review spend uses.
979
- const spend = event.outcome.overseerUsage;
980
- if (spend !== undefined && (spend.inputTokens > 0 || spend.outputTokens > 0)) {
981
- const tier = controller.getFastStatus().tier;
982
- const costDelta = tier.ok && controller.isPricedModel(tier.ref)
983
- ? computeCost(spend, controller.getModelInfoFor(tier.ref).cost)
984
- : 0;
985
- dispatch({ type: 'fastUsage', usage: spend, costDelta });
986
- }
987
- dispatch({ type: 'teamEnd', outcome: event.outcome });
988
- break;
989
- }
990
- }
991
- });
875
+ const unsubscribeTeam = attachTeamChannel(controller, dispatch);
992
876
  return () => {
993
877
  unsubscribeTeam();
994
878
  controller.dispose();
@@ -1001,18 +885,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
1001
885
  // chatty updates; this effect only folds snapshots into the view, appends the four kinds
1002
886
  // of settlement card (charter, phase, escalation, final) and clears the live snapshot when
1003
887
  // the run ends. A no-op unsubscribe when governance was not registered.
1004
- useEffect(() => {
1005
- return controller.subscribeGovernance((event) => {
1006
- dispatch({ type: 'govSnapshot', snapshot: event.snapshot });
1007
- const card = event.type === 'run_started' || event.type === 'stage_ended' ? event.card
1008
- : event.type === 'escalation' || event.type === 'run_closed' ? event.card
1009
- : null;
1010
- if (card)
1011
- dispatch({ type: 'governanceCard', card });
1012
- if (event.type === 'run_closed')
1013
- dispatch({ type: 'govEnd' });
1014
- });
1015
- }, [controller]);
888
+ useEffect(() => attachGovernanceChannel(controller, dispatch), [controller]);
1016
889
  // --- Todo event stream (todo-plan-execution §3.8 / §5.2). --------------
1017
890
  //
1018
891
  // A THIRD SUBSCRIPTION, for the reason the team one records: `TodoEvent` is
@@ -1023,24 +896,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
1023
896
  // merge text/thinking deltas; a `todo_write` is one deliberate act per step,
1024
897
  // and delaying the one surface the user is watching a long task through would
1025
898
  // be exactly backwards.
1026
- useEffect(() => {
1027
- return controller.subscribeTodos((event) => {
1028
- switch (event.type) {
1029
- case 'updated':
1030
- dispatch({ type: 'todoUpdate', snapshot: event.snapshot });
1031
- break;
1032
- case 'cleared':
1033
- dispatch({ type: 'todoCleared' });
1034
- break;
1035
- case 'rejected':
1036
- // THE COMPENSATING PATH FOR SUPPRESSING THE TOOL CARD (§3.8). Without
1037
- // it, the one case where `todo_write` produces nothing visible would
1038
- // be the case that most needs to be visible.
1039
- dispatch({ type: 'notice', level: 'warn', text: event.reason });
1040
- break;
1041
- }
1042
- });
1043
- }, [controller]);
899
+ useEffect(() => attachTodosChannel(controller, dispatch), [controller]);
1044
900
  // --- Fast-tier event stream (fast-model-tier §5.3). --------------------
1045
901
  //
1046
902
  // A FOURTH SUBSCRIPTION, for the reason the team and todo ones record:
@@ -1050,43 +906,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
1050
906
  // `subscribeFast` returns a no-op unsubscribe when the tier was off at
1051
907
  // construction, so this can subscribe unconditionally and an ordinary session
1052
908
  // pays one closure for the whole run.
1053
- useEffect(() => {
1054
- // Seed the chip from the tier resolved at construction, so a fast-enabled
1055
- // session shows it on the first frame rather than after the first review.
1056
- const initial = controller.getFastStatus();
1057
- if (initial.registered)
1058
- dispatch({ type: 'fastTier', snapshot: initial.snapshot });
1059
- return controller.subscribeFast((event) => {
1060
- switch (event.type) {
1061
- case 'review_start':
1062
- dispatch({
1063
- type: 'fastStart',
1064
- index: event.index,
1065
- turn: event.turn,
1066
- model: controller.getFastStatus().snapshot.model,
1067
- });
1068
- break;
1069
- case 'review_end':
1070
- dispatch({ type: 'fastEnd', review: event.review });
1071
- // The card settled, so the chip's `inFlight` and the session totals
1072
- // both moved. One dispatch rather than two: `fastTier` carries them.
1073
- dispatch({ type: 'fastTier', snapshot: controller.getFastStatus().snapshot });
1074
- break;
1075
- case 'usage': {
1076
- // Review spend is REAL SPEND at the FAST model's price (§3.6 / AC-18).
1077
- const ref = controller.getFastStatus().tier;
1078
- const costDelta = ref.ok && controller.isPricedModel(ref.ref)
1079
- ? computeCost(event.usage, controller.getModelInfoFor(ref.ref).cost)
1080
- : 0;
1081
- dispatch({ type: 'fastUsage', usage: event.usage, costDelta });
1082
- break;
1083
- }
1084
- case 'tier_changed':
1085
- dispatch({ type: 'fastTier', snapshot: event.snapshot });
1086
- break;
1087
- }
1088
- });
1089
- }, [controller]);
909
+ useEffect(() => attachFastChannel(controller, dispatch), [controller]);
1090
910
  // --- Context occupancy (context-usage-gauge-accuracy §3.3 / I-1). --------
1091
911
  //
1092
912
  // A SEVENTH SUBSCRIPTION, AND THE SOLE DISPATCHER OF `contextUsage`. The gauge
@@ -1099,15 +919,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
1099
919
  // forwarder - the meter exists in every session, including one started with
1100
920
  // `--no-compaction`, which is precisely the session whose gauge previously had
1101
921
  // one sample per turn and read 0 % after a `/resume`.
1102
- useEffect(() => {
1103
- // SEED ON MOUNT so a resumed session shows a real occupancy on frame 1
1104
- // rather than after its first completed turn. `getContextUsage()` measures
1105
- // on demand, so this works before any event has ever arrived.
1106
- dispatch({ type: 'contextUsage', snapshot: controller.getContextUsage() });
1107
- return controller.subscribeContextUsage((snapshot) => {
1108
- dispatch({ type: 'contextUsage', snapshot });
1109
- });
1110
- }, [controller]);
922
+ useEffect(() => attachContextUsageChannel(controller, dispatch), [controller]);
1111
923
  // --- Compaction event stream (context-auto-compaction §5.2). -------------
1112
924
  //
1113
925
  // A SIXTH SUBSCRIPTION, for the reason the team, todo and fast ones record:
@@ -1127,74 +939,16 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
1127
939
  // `subscribeCompaction` returns a no-op unsubscribe when compaction was off at
1128
940
  // construction, so this can subscribe unconditionally and an ordinary session
1129
941
  // pays one closure for the whole run.
1130
- useEffect(() => {
1131
- // Seed the chip and the gauge marks from the snapshot resolved at
1132
- // construction, so a compaction-enabled session shows them on the FIRST
1133
- // frame rather than after the first turn.
1134
- if (controller.isCompactionRegistered()) {
1135
- dispatch({ type: 'compactionSnapshot', snapshot: controller.getCompactionSnapshot() });
1136
- }
1137
- return controller.subscribeCompaction((event) => {
1138
- switch (event.type) {
1139
- case 'compaction_start':
1140
- if (interactionPhase.current === 'idle') {
1141
- manualMetrics.current = updateRunMetrics(createRunMetrics(), { type: 'agent_start' }, Date.now());
1142
- }
1143
- dispatch({
1144
- type: 'compactionStart',
1145
- index: event.index,
1146
- trigger: event.trigger,
1147
- model: event.model,
1148
- });
1149
- break;
1150
- case 'compaction_end':
1151
- manualMetrics.current = freezeRunMetrics(manualMetrics.current, Date.now());
1152
- // THE CARD, AND NOTHING ELSE (context-usage-gauge-accuracy §3.3).
1153
- //
1154
- // A `contextTokensEstimated` dispatch used to live here, hand-building
1155
- // the post-compaction occupancy out of `record.tokensAfter` plus the
1156
- // snapshot's `estimateOffset`. It is gone because the gauge now has ONE
1157
- // writer: `ContextMeter` learns about the splice from
1158
- // `CompactionWiring.settlePending` itself and re-measures, so the bar
1159
- // falls in the same frame WITHOUT this branch and without the `snapshot`
1160
- // branch below racing it. Those two dispatches were the second and
1161
- // third writers of one number, and the loser of that race was the
1162
- // correct value (P0-1).
1163
- dispatch({ type: 'compactionEnd', record: event.record });
1164
- break;
1165
- case 'phase':
1166
- // THE STAGE LINE ON THE LIVE CARD (context-compaction-never-fires C).
1167
- // Dispatch is unconditional; the reducer is what ignores a phase that
1168
- // arrives for a card the settle has already closed.
1169
- dispatch({ type: 'compactionPhase', index: event.index, phase: event.phase });
1170
- break;
1171
- case 'usage': {
1172
- // Compaction spend is REAL SPEND at the SUMMARIZER's price (§6.4 /
1173
- // AC-15), which may be neither the lead's nor the fast tier's — so the
1174
- // ref is ASKED FOR rather than assumed. `getModelInfo()` here would
1175
- // price a Haiku summarization at the lead's Opus rates, which is the
1176
- // same class of lie as the `$0.00` `pricingUnknown` exists to prevent,
1177
- // just in the other direction.
1178
- const snapshot = controller.getCompactionSnapshot();
1179
- const ref = event.modelRef ?? controller.getCompactionSummarizerRef();
1180
- const costDelta = (event.pricingUnknown ?? snapshot.pricingUnknown)
1181
- ? 0
1182
- : event.costUsd ?? (ref
1183
- ? computeCost(event.usage, controller.getModelInfoFor(ref).cost) : 0);
1184
- dispatch({ type: 'compactionUsage', usage: event.usage, costDelta });
1185
- break;
1186
- }
1187
- case 'snapshot':
1188
- // THE CHIP, THE COUNTS AND THE SUMMARIZER (§3.3). The occupancy that
1189
- // rides along on `snapshot.pressure` is deliberately NOT dispatched
1190
- // here: the meter that produced it publishes it on its own channel, and
1191
- // a second dispatch of the same number is the second writer this
1192
- // feature removed.
1193
- dispatch({ type: 'compactionSnapshot', snapshot: event.snapshot });
1194
- break;
942
+ useEffect(() => attachCompactionChannel(controller, dispatch, {
943
+ onStart: () => {
944
+ if (interactionPhase.current === 'idle') {
945
+ manualMetrics.current = updateRunMetrics(createRunMetrics(), { type: 'agent_start' }, Date.now());
1195
946
  }
1196
- });
1197
- }, [controller]);
947
+ },
948
+ onEnd: () => {
949
+ manualMetrics.current = freezeRunMetrics(manualMetrics.current, Date.now());
950
+ },
951
+ }), [controller]);
1198
952
  // --- Live tool output (agent-activity-presentation-live §3.3.2). --------
1199
953
  //
1200
954
  // A FIFTH SUBSCRIPTION, and THE ONE THAT DOES GO THROUGH THE STREAMING
@@ -1214,18 +968,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
1214
968
  //
1215
969
  // `Date.now()` IS READ HERE, in the listener, not in the reducer, which is
1216
970
  // what keeps `viewReducer` pure.
1217
- useEffect(() => {
1218
- return controller.subscribeToolOutput(({ toolCallId, rows }) => {
1219
- pending.current.push({ type: 'toolOutputDelta', toolCallId, rows, at: Date.now() });
1220
- if (!flushTimer.current) {
1221
- // READ FROM THE REF AT ARM TIME, for the reason `App.tsx:439-441`
1222
- // records: this effect's dependency list never changes, so a captured
1223
- // number would be pinned to the mount render and the governor's ladder
1224
- // would move nothing.
1225
- flushTimer.current = setTimeout(() => flushPending(), governorInterval.current);
1226
- }
1227
- });
1228
- }, [controller, flushPending, governorInterval]);
971
+ useEffect(() => attachToolOutputChannel(controller, coalescer), [controller, coalescer]);
1229
972
  // --- The long wait's live view (extended-job-wait §3.8.1). --------------
1230
973
  //
1231
974
  // THROUGH THE COALESCER, like the tool tail above and for the same reason: a
@@ -1234,22 +977,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
1234
977
  // RUNNING matching entry); `end` needs no action of its own - `toolExecEnd` and
1235
978
  // every idle path clear the view (I-5 / RV-2), and a second clear here would be
1236
979
  // a third copy of that rule.
1237
- useEffect(() => {
1238
- // OPTIONAL CALL: a duck-typed controller (a test double, a headless shim) predates
1239
- // this channel and has nothing to subscribe to - exactly as `subscribeTeam?` is.
1240
- return controller.subscribeWait?.((event) => {
1241
- if (event.type === 'end')
1242
- return;
1243
- pending.current.push({
1244
- type: 'waitUpdate',
1245
- toolCallId: event.toolCallId,
1246
- view: event.view,
1247
- });
1248
- if (!flushTimer.current) {
1249
- flushTimer.current = setTimeout(() => flushPending(), governorInterval.current);
1250
- }
1251
- });
1252
- }, [controller, flushPending, governorInterval]);
980
+ useEffect(() => attachWaitChannel(controller, coalescer), [controller, coalescer]);
1253
981
  // Event boundaries own start/end; ticks only refresh the live projection.
1254
982
  useEffect(() => {
1255
983
  if (state.status !== 'running')
@@ -2006,6 +1734,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
2006
1734
  dispatch: (action) => {
2007
1735
  if (action.type === 'resetConversation' || action.type === 'restoreEntries') {
2008
1736
  scrollbackViewRef.current?.notifyReset(action.type === 'resetConversation' ? 'clear' : 'restore');
1737
+ personaBookRef.current?.reset();
2009
1738
  metrics.current = createRunMetrics();
2010
1739
  manualMetrics.current = createRunMetrics();
2011
1740
  setScrollResetKey((n) => n + 1);
@@ -2300,6 +2029,10 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
2300
2029
  && controller.getConfig().showThinking !== stateRef.current.thinkingVisible) {
2301
2030
  dispatch({ type: 'toggleThinking' });
2302
2031
  }
2032
+ if (draft.patch.developerMode !== undefined) {
2033
+ dispatch({ type: 'setDeveloperMode', value: controller.getConfig().developerMode });
2034
+ heights.clear();
2035
+ }
2303
2036
  dispatch({ type: 'setOverlay', overlay: null });
2304
2037
  toast(result.restartRequired ? 'warn' : 'success', modelSettingsResultMessage(result));
2305
2038
  return result;
@@ -2618,6 +2351,25 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
2618
2351
  dispatch({ type: 'setOverlay', overlay: open === 'shortcuts' ? null : 'shortcuts' });
2619
2352
  return;
2620
2353
  }
2354
+ // Display-only developer mode (hidden chord). Arrives as DEV_MODE_KEY_FRAME for the
2355
+ // same reason Ctrl+I does: legacy terminals encode it as 0x10, i.e. Ctrl+P. Not
2356
+ // gated on `tooSmall` (a pure display switch); ignored while an overlay owns the
2357
+ // keyboard so the Settings row never shows a stale session value. The toast is
2358
+ // dispatched directly because `toast()` takes no ttl.
2359
+ if (input.includes(DEV_MODE_KEY_FRAME)) {
2360
+ if (stateRef.current.overlay)
2361
+ return;
2362
+ const next = !stateRef.current.developerMode;
2363
+ dispatch({ type: 'setDeveloperMode', value: next });
2364
+ heights.clear();
2365
+ dispatch({
2366
+ type: 'pushToast',
2367
+ level: 'info',
2368
+ text: next ? 'Developer mode on' : 'Developer mode off',
2369
+ ttlMs: 1500,
2370
+ });
2371
+ return;
2372
+ }
2621
2373
  // Ctrl+B: the Agents board (tui-subagent-panel D-6 / §6.5).
2622
2374
  //
2623
2375
  // THE GUARD ORDER IS Ctrl+G's EXACTLY, plus one rung: pressing it again CLOSES the
@@ -3108,6 +2860,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
3108
2860
  ? buildGovernancePanelLayout({
3109
2861
  cols: native ? Math.max(1, cols - 1) : baseRail.contentCols, rows,
3110
2862
  snapshot: state.governance, glyphs, reducedMotion, now: Date.now(),
2863
+ voice: bindVoiceScope(voice, state.governance.runId),
3111
2864
  mode: governanceMode === 'panel' ? 'panel' : 'run-strip', eliminatedSince,
3112
2865
  availableRows: native
3113
2866
  ? Math.max(0, viewportBudget - 1)
@@ -3145,7 +2898,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
3145
2898
  const scrollbackView = useScrollbackView({
3146
2899
  enabled: native, bridge: scrollback, entries: state.entries, runActive: running,
3147
2900
  theme, caps, density: cfg.density, thinkingVisible: state.thinkingVisible,
3148
- reducedMotion, rows, cols,
2901
+ reducedMotion, voice, rows, cols,
3149
2902
  overlayOpen: overlay !== null, draftRows, popupRows: overlay ? 0 : popupRows,
3150
2903
  statusExpanded, forceInactive: native && guardTripped,
3151
2904
  // The band's inputs. `teamRowsNatural` is the roster layout computed above, so the
@@ -3229,6 +2982,10 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
3229
2982
  // and there is no setter), so the config IS the current value and
3230
2983
  // nothing can have toggled it since launch.
3231
2984
  liveToolOutput: cfg.liveToolOutput ? 'on' : 'off',
2985
+ // FROM `ViewState`, like `showThinking`: the hidden key chord edits the
2986
+ // session value and never the config, so seeding from `cfg` would show
2987
+ // the launch value and an untouched save would quietly flip it back.
2988
+ developerMode: state.developerMode ? 'on' : 'off',
3232
2989
  // `auto`, not an empty string: an empty field reads as "unset", which
3233
2990
  // is indistinguishable from AUTO and is not a state this can be in.
3234
2991
  maxTokens: cfg.maxTokens ? String(cfg.maxTokens) : 'auto',
@@ -3256,9 +3013,9 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
3256
3013
  // THE BRANCH AND THE `Overlay` MEMBER SHIP TOGETHER (R-11): a missing branch is not
3257
3014
  // a type error, it is a SILENT BLANK FRAME, because `active={overlay === null}` has
3258
3015
  // already disabled the transcript underneath.
3259
- _jsx(AgentsBoardOverlay, { team: state.team, entries: state.entries, cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, isActive: !tooSmall, native: native, theme: theme, caps: caps })) : overlay === 'governance' ? (
3016
+ _jsx(AgentsBoardOverlay, { voice: voice, team: state.team, entries: state.entries, cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, isActive: !tooSmall, native: native, theme: theme, caps: caps })) : overlay === 'governance' ? (
3260
3017
  // THE BRANCH AND THE `Overlay` MEMBER SHIP TOGETHER (R-11), like `agents` above.
3261
- _jsx(GovernanceBoardOverlay, { data: governanceBoardData(controller, state.governance), cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, isActive: !tooSmall, theme: theme, caps: caps, onCopyPath: (path) => { void copyCoordinator.requestCopy({ text: path, lines: 1 }); }, onNotice: toast })) : overlay === 'confirm' && confirmState ? (_jsx(ConfirmDialog, { isActive: !tooSmall, state: confirmState, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onClose: closeConfirm })) : overlay === 'question' && humanRequest?.kind === 'questions' ? (_jsx(QuestionOverlay, { isActive: !tooSmall, questions: humanRequest.questions, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onSubmit: (answers) => resolveHuman({ kind: 'answers', answers, cancelled: false }), ...interviewProps })) : overlay === 'plan' && humanRequest?.kind === 'plan' ? (_jsx(PlanReviewOverlay, { isActive: !tooSmall, plan: humanRequest.plan, maxRows: overlayMaxRows, cols: viewCols, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, onVerdict: handlePlanVerdict })) : null;
3018
+ _jsx(GovernanceBoardOverlay, { voice: voice, data: governanceBoardData(controller, state.governance), cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, isActive: !tooSmall, theme: theme, caps: caps, onCopyPath: (path) => { void copyCoordinator.requestCopy({ text: path, lines: 1 }); }, onNotice: toast })) : overlay === 'confirm' && confirmState ? (_jsx(ConfirmDialog, { isActive: !tooSmall, state: confirmState, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onClose: closeConfirm })) : overlay === 'question' && humanRequest?.kind === 'questions' ? (_jsx(QuestionOverlay, { isActive: !tooSmall, questions: humanRequest.questions, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onSubmit: (answers) => resolveHuman({ kind: 'answers', answers, cancelled: false }), ...interviewProps })) : overlay === 'plan' && humanRequest?.kind === 'plan' ? (_jsx(PlanReviewOverlay, { isActive: !tooSmall, plan: humanRequest.plan, maxRows: overlayMaxRows, cols: viewCols, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, onVerdict: handlePlanVerdict })) : null;
3262
3019
  const density = cfg.density;
3263
3020
  const transcriptWindow = cfg.transcriptWindow ?? DEFAULT_TRANSCRIPT_WINDOW;
3264
3021
  // The fixed status bar remains visible underneath every overlay and toast.
@@ -3404,7 +3161,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
3404
3161
  interruptPhase: interruptGesture.current.phase,
3405
3162
  updateAvailable: !!updateSnapshot && shouldRenderUpdateLine(updateSnapshot) } });
3406
3163
  const composer = (_jsx(Composer, { deleteDisambiguated: terminal?.deleteDisambiguated ?? false, onCompletionContextChange: setCompletion, cols: frameBudget.composerCols, terminalRows: rows, statusExpanded: statusExpanded, onInteraction: returnToComposer, reducedMotion: cfg.reducedMotion ?? false, onEscape: handleComposerEscape, onEscapeDismiss: cancelConfirmation, isActive: overlay === null && !tooSmall, running: state.status === 'running', history: promptHistory, commands: commandOptions, cwd: controller.getCwd(), showHint: false, submitCount: cfg.submitCount, hintsEnabled: cfg.hints, agentMode: state.agentMode, posture: state.posture, services: liveServices, modeToggleKey: modeToggleKey, popupMaxRows: popupMaxRows, popupMaxHeight: frameBudget.popupMaxHeight, onPopupRowsChange: onPopupRowsChange, onDraftRows: onDraftRows, onDraftPresence: onDraftPresence, draftClearNonce: draftClearNonce, ...(draftFill ? { draftFill } : {}), insertMode: cfg.prompts?.insertMode ?? 'insert', onNotice: notify, theme: theme, caps: caps, onSubmit: handleSubmit, onHelp: () => dispatch({ type: 'setOverlay', overlay: 'help' }) }));
3407
- const team = governanceLayout ? (_jsx(GovernancePanel, { layout: governanceLayout, theme: theme, caps: caps })) : state.team ? (_jsx(TeamPanel, { snapshot: state.team, layout: teamLayout, rows: rows, cols: contentCols, reducedMotion: viewReducedMotion, theme: theme, caps: caps })) : null;
3164
+ const team = governanceLayout ? (_jsx(GovernancePanel, { layout: governanceLayout, theme: theme, caps: caps })) : state.team ? (_jsx(TeamPanel, { snapshot: state.team, layout: teamLayout, rows: rows, cols: contentCols, reducedMotion: viewReducedMotion, voice: teamVoice, theme: theme, caps: caps })) : null;
3408
3165
  // --- Native panel band (release-gate-and-native-panels §6.3/§6.4) -------------
3409
3166
  //
3410
3167
  // SEPARATE NODES, NOT THE TWO ABOVE (RV-P1-7). Those carry `cols={contentCols}` for
@@ -3425,11 +3182,11 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
3425
3182
  // out against `previewCols` would stop its clock one rail short of the screen's edge.
3426
3183
  // `teamRowGeometry` is continuous in `cols`, so the number that decides whether the
3427
3184
  // panel mounts IS the number it lays out against.
3428
- const nativeTeam = governanceLayout && nativeBand ? (_jsx(GovernancePanel, { layout: governanceLayout, theme: theme, caps: caps })) : state.team && nativeBand ? (_jsx(TeamPanel, { snapshot: state.team, layout: teamLayout, rows: rows, cols: nativeBandCols, reducedMotion: viewReducedMotion, theme: theme, caps: caps })) : null;
3185
+ const nativeTeam = governanceLayout && nativeBand ? (_jsx(GovernancePanel, { layout: governanceLayout, theme: theme, caps: caps })) : state.team && nativeBand ? (_jsx(TeamPanel, { snapshot: state.team, layout: teamLayout, rows: rows, cols: nativeBandCols, reducedMotion: viewReducedMotion, voice: teamVoice, theme: theme, caps: caps })) : null;
3429
3186
  const rail = fullscreenRailVisible && state.todos ? (_jsx(TodoPanel, { snapshot: state.todos, width: railWidth, rows: railRows, running: running, reducedMotion: viewReducedMotion, theme: theme, caps: caps })) : null;
3430
- const viewport = (_jsxs(ScrollViewport, { active: overlay === null && !tooSmall, overlay: overlayNode, footer: _jsxs(_Fragment, { children: [team, _jsx(QueuePanel, { layout: queueLayout, theme: theme })] }), rail: rail, scrollbar: terminal?.scrollbar, resetKey: scrollResetKey, intent: scrollIntent, pinToBottomNonce: pinToBottomNonce, onScrolledLinesChange: setScrolledLines, onViewportShiftChange: onViewportShiftChange, onGeometryChange: onGeometryChange, geometryKey: `${rows}:${cols}:${viewportBudget}:${frameBudget.composerSlotRows}:${frameBudget.statusRows}:${contentCols}:${overlay}:${tooSmall}`, tailRowsRef: tailSink, hold: selectionHold, resumeMs: cfg.scrollResumeMs, showScrollIndicator: true, cols: contentCols, theme: theme, caps: caps, children: [opener, _jsx(TranscriptList, { entries: transcriptEntries, expandedToolIds: state.expandedToolIds, thinkingVisible: state.thinkingVisible, reducedMotion: viewReducedMotion, density: density, nowSec: nowSec, theme: theme, caps: caps, windowSize: transcriptWindow, cols: contentCols, heights: heights, mountedSink: mountedCount, tailSink: tailSink })] }));
3187
+ const viewport = (_jsxs(ScrollViewport, { active: overlay === null && !tooSmall, overlay: overlayNode, footer: _jsxs(_Fragment, { children: [team, _jsx(QueuePanel, { layout: queueLayout, theme: theme })] }), rail: rail, scrollbar: terminal?.scrollbar, resetKey: scrollResetKey, intent: scrollIntent, pinToBottomNonce: pinToBottomNonce, onScrolledLinesChange: setScrolledLines, onViewportShiftChange: onViewportShiftChange, onGeometryChange: onGeometryChange, geometryKey: `${rows}:${cols}:${viewportBudget}:${frameBudget.composerSlotRows}:${frameBudget.statusRows}:${contentCols}:${overlay}:${tooSmall}`, tailRowsRef: tailSink, hold: selectionHold, resumeMs: cfg.scrollResumeMs, showScrollIndicator: true, cols: contentCols, theme: theme, caps: caps, children: [opener, _jsx(TranscriptList, { entries: transcriptEntries, expandedToolIds: state.expandedToolIds, thinkingVisible: state.thinkingVisible, reducedMotion: viewReducedMotion, voice: voice, density: density, nowSec: nowSec, theme: theme, caps: caps, windowSize: transcriptWindow, cols: contentCols, heights: heights, mountedSink: mountedCount, tailSink: tailSink })] }));
3431
3188
  const detailsNode = _jsx(BottomStatusRow, { plan: details, columns: viewCols, theme: theme });
3432
- const statusNode = (_jsx(StatusBar, { columns: viewCols, speedKnown: speedKnown, ...feedbackProjection, interruptPhase: interruptGesture.current.phase, pendingSteering: state.pendingSteering, runPhase: state.runPhase, activeTool: state.activeTool, ...(wait ? { wait } : {}), runOutcome: state.runOutcome, reducedMotion: reducedMotion, ...(sessionId ? { sessionId } : {}), ...(kitChip ? { kit: kitChip } : {}), waitingForConfirmation: !!humanRequest || !!confirmState, stopping: interruptGesture.current.phase === 'stopping', interruptHint: interruptGesture.current.phase === 'stopping'
3189
+ const statusNode = (_jsx(StatusBar, { columns: viewCols, speedKnown: speedKnown, ...feedbackProjection, interruptPhase: interruptGesture.current.phase, pendingSteering: state.pendingSteering, runPhase: state.runPhase, activeTool: state.activeTool, ...(wait ? { wait } : {}), runOutcome: state.runOutcome, reducedMotion: reducedMotion, ...(sessionId ? { sessionId } : {}), developerMode: state.developerMode, ...(kitChip ? { kit: kitChip } : {}), waitingForConfirmation: !!humanRequest || !!confirmState, stopping: interruptGesture.current.phase === 'stopping', interruptHint: interruptGesture.current.phase === 'stopping'
3433
3190
  ? 'Esc force-stop' : 'Esc x2 interrupt', model: cfg.model, provider: cfg.provider, usageTotal: state.usageTotal,
3434
3191
  // ONE OBJECT INSTEAD OF FOUR PARALLEL PROPS (§4.3). The four were a
3435
3192
  // projection of "many sources of truth" into the props layer, and a
@@ -3487,7 +3244,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
3487
3244
  // fallback for a frame with no preview rows. The WHOLE list is passed: the window
3488
3245
  // belongs to `tail-window.ts`, and `prev` must come from the same list.
3489
3246
  tail: nativeBudget.band.previewRows > 0
3490
- ? (_jsx(LiveTail, { entries: state.entries, maxEntries: SCROLLBACK_LIMITS.liveTailMaxEntries, rows: nativeBudget.band.previewRows, cols: nativeBudget.previewCols, expandedToolIds: state.expandedToolIds, thinkingVisible: state.thinkingVisible, reducedMotion: viewReducedMotion, density: cfg.density, nowSec: nowSec, theme: theme, caps: caps, measuredRows: scrollbackView.measuredTailRows }))
3247
+ ? (_jsx(LiveTail, { entries: state.entries, maxEntries: SCROLLBACK_LIMITS.liveTailMaxEntries, rows: nativeBudget.band.previewRows, cols: nativeBudget.previewCols, expandedToolIds: state.expandedToolIds, thinkingVisible: state.thinkingVisible, reducedMotion: viewReducedMotion, voice: voice, density: cfg.density, nowSec: nowSec, theme: theme, caps: caps, measuredRows: scrollbackView.measuredTailRows }))
3491
3248
  : undefined, team: nativeTeam, rail: nativeRail, composer: composer, status: statusNode, details: detailsNode, placeholder: _jsxs(Text, { wrap: "truncate", color: theme.noticeWarn, children: [glyphs.warn, " Terminal too small - needs at least 40 columns and 12 rows."] }), theme: theme }));
3492
3249
  }
3493
3250
  return (_jsx(AppShell, { inactive: tooSmall, placeholder: _jsxs(Text, { wrap: "truncate", color: theme.noticeWarn, children: [glyphs.warn, " Terminal too small - needs at least 40 columns and 12 rows."] }), rows: rows, cols: cols, header: header, viewport: viewport, viewportRows: frameBudget.viewportRows, composer: composer, composerSlotRows: frameBudget.composerSlotRows, statusRows: frameBudget.statusRows, details: detailsNode, status: statusNode }));