tmux-ide 2.8.0 → 2.9.0-beta.6
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 +88 -125
- package/bin/cli.js +68983 -13250
- package/bin/cli.ts +412 -51
- package/package.json +63 -30
- package/packages/contracts/package.json +3 -2
- package/packages/contracts/src/__tests__/actions-contract.test.ts +119 -0
- package/packages/contracts/src/__tests__/agent-graph-overlay.test.ts +428 -0
- package/packages/contracts/src/__tests__/app-window-mutation.test.ts +51 -0
- package/packages/contracts/src/__tests__/app-window-state.test.ts +34 -0
- package/packages/contracts/src/__tests__/application-shell.test.ts +635 -0
- package/packages/contracts/src/__tests__/causal-cell.test.ts +47 -0
- package/packages/contracts/src/__tests__/client-view-state.test.ts +115 -0
- package/packages/contracts/src/__tests__/cohesion-fixture.test.ts +106 -0
- package/packages/contracts/src/__tests__/commands.test.ts +86 -0
- package/packages/contracts/src/__tests__/daemon-events.test.ts +400 -0
- package/packages/contracts/src/__tests__/daemon-resources.test.ts +143 -0
- package/packages/contracts/src/__tests__/daemon-wire.test.ts +117 -0
- package/packages/contracts/src/__tests__/desktop-host.test.ts +269 -0
- package/packages/contracts/src/__tests__/desktop-missions.test.ts +211 -0
- package/packages/contracts/src/__tests__/experience-conformance.test.ts +153 -0
- package/packages/contracts/src/__tests__/experience-kernel-boundary.test.ts +109 -0
- package/packages/contracts/src/__tests__/experience-shell.test.ts +65 -0
- package/packages/contracts/src/__tests__/fixtures/daemon-wire-v2.json +35 -0
- package/packages/contracts/src/__tests__/fleet-agent-graph.test.ts +231 -0
- package/packages/contracts/src/__tests__/fleet-catalog.test.ts +268 -0
- package/packages/contracts/src/__tests__/fleet-lifecycle.test.ts +62 -0
- package/packages/contracts/src/__tests__/focus-overlay.test.ts +110 -0
- package/packages/contracts/src/__tests__/ide-config.test.ts +18 -0
- package/packages/contracts/src/__tests__/issue-error.test.ts +78 -0
- package/packages/contracts/src/__tests__/mission-projections.test.ts +186 -0
- package/packages/contracts/src/__tests__/missions.test.ts +272 -0
- package/packages/contracts/src/__tests__/multiplexer-verbs.test.ts +240 -0
- package/packages/contracts/src/__tests__/pane-appearance.test.ts +146 -0
- package/packages/contracts/src/__tests__/pane-stream.test.ts +466 -0
- package/packages/contracts/src/__tests__/pane-widget-marker.test.ts +327 -0
- package/packages/contracts/src/__tests__/performance-metrics.test.ts +73 -0
- package/packages/contracts/src/__tests__/performance-qualification.test.ts +137 -0
- package/packages/contracts/src/__tests__/rich-card-widget.test.ts +29 -0
- package/packages/contracts/src/__tests__/session-runtime.test.ts +490 -0
- package/packages/contracts/src/__tests__/startup-readiness.test.ts +409 -0
- package/packages/contracts/src/__tests__/terminal-attachment-stream.test.ts +72 -0
- package/packages/contracts/src/__tests__/terminal-attachments.test.ts +329 -0
- package/packages/contracts/src/__tests__/terminal-delivery.test.ts +88 -0
- package/packages/contracts/src/__tests__/terminal-runtime-inventory.test.ts +68 -0
- package/packages/contracts/src/__tests__/visual-tokens.test.ts +224 -0
- package/packages/contracts/src/__tests__/workspace-changes-resource.test.ts +317 -0
- package/packages/contracts/src/__tests__/workspace-changes-view.test.ts +122 -0
- package/packages/contracts/src/__tests__/workspace-config.test.ts +294 -0
- package/packages/contracts/src/__tests__/workspace-files-resource.test.ts +261 -0
- package/packages/contracts/src/__tests__/workspace-files-tree.test.ts +147 -0
- package/packages/contracts/src/__tests__/workspace-pane-creation.test.ts +249 -0
- package/packages/contracts/src/__tests__/workspace-promotion.test.ts +94 -0
- package/packages/contracts/src/__tests__/workspace-resource-identity.test.ts +90 -0
- package/packages/contracts/src/actions-contract.ts +205 -0
- package/packages/contracts/src/actions-errors.ts +20 -0
- package/packages/contracts/src/agent-graph-overlay.ts +425 -0
- package/packages/contracts/src/app-window-mutation.ts +103 -0
- package/packages/contracts/src/app-window-state.ts +446 -0
- package/packages/contracts/src/application-shell-resource.ts +54 -0
- package/packages/contracts/src/application-shell.ts +1094 -0
- package/packages/contracts/src/causal-cell.ts +168 -0
- package/packages/contracts/src/client-view-state.ts +156 -0
- package/packages/contracts/src/cohesion-fixture.ts +647 -0
- package/packages/contracts/src/commands.ts +153 -0
- package/packages/contracts/src/daemon-events.ts +374 -0
- package/packages/contracts/src/daemon-resource-request.test.ts +192 -0
- package/packages/contracts/src/daemon-resource-request.ts +397 -0
- package/packages/contracts/src/daemon-resources.ts +108 -0
- package/packages/contracts/src/daemon-wire.ts +100 -0
- package/packages/contracts/src/desktop-daemon-issue.ts +83 -0
- package/packages/contracts/src/desktop-host.ts +746 -0
- package/packages/contracts/src/desktop-missions.ts +159 -0
- package/packages/contracts/src/desktop-update.ts +48 -0
- package/packages/contracts/src/desktop-workspace-name.ts +18 -0
- package/packages/contracts/src/domain.ts +493 -0
- package/packages/contracts/src/experience-identifiers.ts +53 -0
- package/packages/contracts/src/experience-shell.ts +249 -0
- package/packages/contracts/src/fleet-agent-graph.ts +171 -0
- package/packages/contracts/src/fleet-catalog.ts +190 -0
- package/packages/contracts/src/fleet-lifecycle.ts +136 -0
- package/packages/contracts/src/focus-overlay.ts +175 -0
- package/packages/contracts/src/ide-config.ts +40 -20
- package/packages/contracts/src/index.ts +59 -0
- package/packages/contracts/src/interaction-receipts.ts +438 -0
- package/packages/contracts/src/issue-error.ts +107 -0
- package/packages/contracts/src/mission-projections.ts +269 -0
- package/packages/contracts/src/multiplexer-verbs.ts +447 -0
- package/packages/contracts/src/pane-appearance.ts +248 -0
- package/packages/contracts/src/pane-stream.ts +709 -0
- package/packages/contracts/src/pane-widget-descriptor.ts +62 -0
- package/packages/contracts/src/pane-widget-marker.ts +301 -0
- package/packages/contracts/src/performance-metrics.ts +128 -0
- package/packages/contracts/src/performance-qualification.ts +276 -0
- package/packages/contracts/src/rich-card-widget.ts +72 -0
- package/packages/contracts/src/semantic-identity.ts +39 -0
- package/packages/contracts/src/session-runtime.ts +351 -0
- package/packages/contracts/src/shared-monotonic-clock.ts +18 -0
- package/packages/contracts/src/startup-readiness.ts +432 -0
- package/packages/contracts/src/terminal-attachment-stream.ts +119 -0
- package/packages/contracts/src/terminal-attachments.ts +347 -0
- package/packages/contracts/src/terminal-delivery.ts +245 -0
- package/packages/contracts/src/terminal-replica.ts +133 -0
- package/packages/contracts/src/terminal-runtime-inventory.ts +42 -0
- package/packages/contracts/src/visual-recipes.ts +126 -0
- package/packages/contracts/src/visual-tokens.ts +883 -0
- package/packages/contracts/src/widget-asset.ts +43 -0
- package/packages/contracts/src/workspace-catalog-resource.test.ts +146 -0
- package/packages/contracts/src/workspace-catalog-resource.ts +180 -0
- package/packages/contracts/src/workspace-changes-resource.ts +405 -0
- package/packages/contracts/src/workspace-changes-view.ts +195 -0
- package/packages/contracts/src/workspace-config.ts +303 -0
- package/packages/contracts/src/workspace-files-resource.ts +310 -0
- package/packages/contracts/src/workspace-files-tree.ts +167 -0
- package/packages/contracts/src/workspace-missions-resource.ts +32 -0
- package/packages/contracts/src/workspace-multiplexer.ts +373 -0
- package/packages/contracts/src/workspace-open-handoff.ts +99 -0
- package/packages/contracts/src/workspace-open.ts +64 -0
- package/packages/contracts/src/workspace-pane-creation.ts +223 -0
- package/packages/contracts/src/workspace-promotion.ts +109 -0
- package/packages/contracts/src/workspace-resource-identity.ts +81 -0
- package/packages/contracts/src/workspace-state.ts +530 -0
- package/packages/contracts/src/workspace.ts +14 -2
- package/packages/core/package.json +35 -0
- package/packages/core/src/agent-provisioning.test.ts +42 -0
- package/packages/core/src/agent-provisioning.ts +112 -0
- package/packages/core/src/app-window-identity.ts +33 -0
- package/packages/core/src/application-shell-session.test.ts +105 -0
- package/packages/core/src/application-shell-session.ts +195 -0
- package/packages/core/src/index.ts +15 -0
- package/packages/core/src/interaction-flow.test.ts +66 -0
- package/packages/core/src/interaction-flow.ts +159 -0
- package/packages/core/src/interaction-receipts.test.ts +361 -0
- package/packages/core/src/interaction-receipts.ts +335 -0
- package/packages/core/src/navigator.test.ts +34 -0
- package/packages/core/src/navigator.ts +74 -0
- package/packages/core/src/optimistic-projection-conformance.test.ts +75 -0
- package/packages/core/src/optimistic-projection-conformance.ts +61 -0
- package/packages/core/src/optimistic-projection-store.ts +71 -0
- package/packages/core/src/optimistic-projection.test.ts +118 -0
- package/packages/core/src/optimistic-projection.ts +194 -0
- package/packages/core/src/performance-metrics.test.ts +121 -0
- package/packages/core/src/performance-metrics.ts +241 -0
- package/packages/core/src/performance-qualification.test.ts +283 -0
- package/packages/core/src/performance-qualification.ts +360 -0
- package/packages/core/src/terminal-compact-capability.ts +31 -0
- package/packages/core/src/terminal-compact-cold.test.ts +87 -0
- package/packages/core/src/terminal-conformance.test.ts +48 -0
- package/packages/core/src/terminal-conformance.ts +405 -0
- package/packages/core/src/terminal-delivery.test.ts +1196 -0
- package/packages/core/src/terminal-delivery.ts +2918 -0
- package/packages/core/src/terminal-replica-cold.test.ts +31 -0
- package/packages/core/src/terminal-replica-hash-cache.test.ts +201 -0
- package/packages/core/src/terminal-replica-hash-cache.ts +367 -0
- package/packages/core/src/terminal-replica.test.ts +282 -0
- package/packages/core/src/terminal-replica.ts +943 -0
- package/packages/core/src/workspace-selection.test.ts +63 -0
- package/packages/core/src/workspace-selection.ts +97 -0
- package/packages/daemon/dist/attach.js +2 -2
- package/packages/daemon/dist/canonical.d.ts +2 -2
- package/packages/daemon/dist/canonical.js +1 -1
- package/packages/daemon/dist/cli.js +37 -36
- package/packages/daemon/dist/command-center/actions/command-definitions.d.ts +4 -0
- package/packages/daemon/dist/command-center/actions/command-definitions.js +70 -0
- package/packages/daemon/dist/command-center/actions/dispatcher.d.ts +29 -0
- package/packages/daemon/dist/command-center/actions/dispatcher.js +228 -10
- package/packages/daemon/dist/command-center/actions/errors.d.ts +1 -1
- package/packages/daemon/dist/command-center/actions/handlers/_project-context.d.ts +1 -1
- package/packages/daemon/dist/command-center/actions/handlers/_project-context.js +3 -4
- package/packages/daemon/dist/command-center/actions/handlers/app-window-mutate.d.ts +8 -0
- package/packages/daemon/dist/command-center/actions/handlers/app-window-mutate.js +39 -0
- package/packages/daemon/dist/command-center/actions/handlers/config-actions.d.ts +6 -6
- package/packages/daemon/dist/command-center/actions/handlers/config-actions.js +44 -20
- package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.d.ts +2 -1
- package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.js +11 -1
- package/packages/daemon/dist/command-center/actions/handlers/fleet-lifecycle.d.ts +10 -0
- package/packages/daemon/dist/command-center/actions/handlers/fleet-lifecycle.js +56 -0
- package/packages/daemon/dist/command-center/actions/handlers/project-launch.js +16 -4
- package/packages/daemon/dist/command-center/actions/handlers/workspace-multiplexer.d.ts +186 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-multiplexer.js +55 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-open.d.ts +16 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-open.js +89 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-pane-create.d.ts +8 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-pane-create.js +34 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-promote.d.ts +8 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-promote.js +34 -0
- package/packages/daemon/dist/command-center/actions/registry.d.ts +33 -2
- package/packages/daemon/dist/command-center/actions/registry.js +126 -0
- package/packages/daemon/dist/command-center/actions/semantic-multiplexer-actions.d.ts +3 -0
- package/packages/daemon/dist/command-center/actions/semantic-multiplexer-actions.js +16 -0
- package/packages/daemon/dist/command-center/agent-status-watch.d.ts +100 -0
- package/packages/daemon/dist/command-center/agent-status-watch.js +170 -0
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.d.ts +57 -0
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +395 -0
- package/packages/daemon/dist/command-center/discovery.d.ts +98 -1
- package/packages/daemon/dist/command-center/discovery.js +262 -3
- package/packages/daemon/dist/command-center/owner-authority.d.ts +71 -0
- package/packages/daemon/dist/command-center/owner-authority.js +46 -0
- package/packages/daemon/dist/command-center/pane-stream-issue.d.ts +26 -0
- package/packages/daemon/dist/command-center/pane-stream-issue.js +185 -0
- package/packages/daemon/dist/command-center/resources/agent-graph-overlay.d.ts +45 -0
- package/packages/daemon/dist/command-center/resources/agent-graph-overlay.js +234 -0
- package/packages/daemon/dist/command-center/resources/application-shell.d.ts +201 -0
- package/packages/daemon/dist/command-center/resources/application-shell.js +641 -0
- package/packages/daemon/dist/command-center/resources/desktop-missions.d.ts +10 -0
- package/packages/daemon/dist/command-center/resources/desktop-missions.js +132 -0
- package/packages/daemon/dist/command-center/resources/fleet-catalog.d.ts +25 -0
- package/packages/daemon/dist/command-center/resources/fleet-catalog.js +163 -0
- package/packages/daemon/dist/command-center/resources/fleet-resource-route.d.ts +25 -0
- package/packages/daemon/dist/command-center/resources/fleet-resource-route.js +46 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness-route.d.ts +38 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness-route.js +121 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness.d.ts +57 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness.js +183 -0
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.d.ts +5 -0
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +24 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-authority.d.ts +39 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-authority.js +451 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-git.d.ts +63 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-git.js +222 -0
- package/packages/daemon/dist/command-center/resources/workspace-files-authority.d.ts +44 -0
- package/packages/daemon/dist/command-center/resources/workspace-files-authority.js +493 -0
- package/packages/daemon/dist/command-center/resources/workspace-missions-route.d.ts +22 -0
- package/packages/daemon/dist/command-center/resources/workspace-missions-route.js +75 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-ids.d.ts +24 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-ids.js +69 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-routes.d.ts +17 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-routes.js +116 -0
- package/packages/daemon/dist/command-center/schemas.d.ts +1 -1
- package/packages/daemon/dist/command-center/server.d.ts +57 -1
- package/packages/daemon/dist/command-center/server.js +540 -51
- package/packages/daemon/dist/command-center/terminal-attachment-issue.d.ts +22 -0
- package/packages/daemon/dist/command-center/terminal-attachment-issue.js +191 -0
- package/packages/daemon/dist/command-center/workspace-resource-observer.d.ts +50 -0
- package/packages/daemon/dist/command-center/workspace-resource-observer.js +453 -0
- package/packages/daemon/dist/command-center/ws-events.d.ts +82 -7
- package/packages/daemon/dist/command-center/ws-events.js +681 -63
- package/packages/daemon/dist/config.js +31 -25
- package/packages/daemon/dist/control/lifecycle.js +12 -2
- package/packages/daemon/dist/control/server.js +3 -3
- package/packages/daemon/dist/detect.js +23 -20
- package/packages/daemon/dist/doctor.js +22 -6
- package/packages/daemon/dist/index.d.ts +21 -2
- package/packages/daemon/dist/index.js +20 -1
- package/packages/daemon/dist/init.js +24 -22
- package/packages/daemon/dist/inspect.d.ts +7 -1
- package/packages/daemon/dist/inspect.js +33 -8
- package/packages/daemon/dist/launch.d.ts +2 -0
- package/packages/daemon/dist/launch.js +38 -26
- package/packages/daemon/dist/lib/__tests__/fixtures/workspace-state-writer.js +58 -0
- package/packages/daemon/dist/lib/agent-kind.d.ts +7 -0
- package/packages/daemon/dist/lib/agent-kind.js +24 -0
- package/packages/daemon/dist/lib/app-config.d.ts +9 -4
- package/packages/daemon/dist/lib/app-config.js +27 -1
- package/packages/daemon/dist/lib/app-window-kernel.d.ts +64 -0
- package/packages/daemon/dist/lib/app-window-kernel.js +556 -0
- package/packages/daemon/dist/lib/app-window-mutation.d.ts +28 -0
- package/packages/daemon/dist/lib/app-window-mutation.js +139 -0
- package/packages/daemon/dist/lib/app-window-repository.d.ts +81 -0
- package/packages/daemon/dist/lib/app-window-repository.js +368 -0
- package/packages/daemon/dist/lib/app-window-state.d.ts +57 -0
- package/packages/daemon/dist/lib/app-window-state.js +415 -0
- package/packages/daemon/dist/lib/application-shell-app-windows.d.ts +16 -0
- package/packages/daemon/dist/lib/application-shell-app-windows.js +285 -0
- package/packages/daemon/dist/lib/auth/middleware.d.ts +1 -1
- package/packages/daemon/dist/lib/auth/middleware.js +7 -3
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.d.ts +25 -0
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +174 -0
- package/packages/daemon/dist/lib/canonical-daemon.d.ts +80 -14
- package/packages/daemon/dist/lib/canonical-daemon.js +507 -70
- package/packages/daemon/dist/lib/chrome-front-door.d.ts +7 -0
- package/packages/daemon/dist/lib/chrome-front-door.js +13 -0
- package/packages/daemon/dist/lib/cli-action-bridge.d.ts +8 -3
- package/packages/daemon/dist/lib/cli-action-bridge.js +112 -82
- package/packages/daemon/dist/lib/command-registry.d.ts +37 -0
- package/packages/daemon/dist/lib/command-registry.js +107 -0
- package/packages/daemon/dist/lib/config-context.d.ts +18 -0
- package/packages/daemon/dist/lib/config-context.js +34 -0
- package/packages/daemon/dist/lib/daemon-embed.d.ts +30 -0
- package/packages/daemon/dist/lib/daemon-embed.js +1060 -356
- package/packages/daemon/dist/lib/daemon-session-monitor.d.ts +50 -0
- package/packages/daemon/dist/lib/daemon-session-monitor.js +194 -0
- package/packages/daemon/dist/lib/daemon.js +3 -47
- package/packages/daemon/dist/lib/directory-watcher.d.ts +12 -0
- package/packages/daemon/dist/lib/directory-watcher.js +118 -0
- package/packages/daemon/dist/lib/environment-identity.d.ts +9 -0
- package/packages/daemon/dist/lib/environment-identity.js +79 -0
- package/packages/daemon/dist/lib/errors.d.ts +1 -1
- package/packages/daemon/dist/lib/fleet-agent-lifecycle.d.ts +8 -0
- package/packages/daemon/dist/lib/fleet-agent-lifecycle.js +65 -0
- package/packages/daemon/dist/lib/fleet-lifecycle-authority.d.ts +21 -0
- package/packages/daemon/dist/lib/fleet-lifecycle-authority.js +437 -0
- package/packages/daemon/dist/lib/headless-daemon.d.ts +33 -0
- package/packages/daemon/dist/lib/headless-daemon.js +306 -0
- package/packages/daemon/dist/lib/launch-plan.d.ts +20 -1
- package/packages/daemon/dist/lib/launch-plan.js +96 -1
- package/packages/daemon/dist/lib/legacy-config-adapter.d.ts +12 -0
- package/packages/daemon/dist/lib/legacy-config-adapter.js +19 -0
- package/packages/daemon/dist/lib/legacy-config-migration.d.ts +15 -0
- package/packages/daemon/dist/lib/legacy-config-migration.js +110 -0
- package/packages/daemon/dist/lib/legacy-theme-compat.d.ts +14 -0
- package/packages/daemon/dist/lib/legacy-theme-compat.js +25 -0
- package/packages/daemon/dist/lib/mission-projections.d.ts +24 -0
- package/packages/daemon/dist/lib/mission-projections.js +615 -0
- package/packages/daemon/dist/lib/mission-repository.d.ts +941 -0
- package/packages/daemon/dist/lib/mission-repository.js +775 -0
- package/packages/daemon/dist/lib/onboarding-marker.d.ts +13 -0
- package/packages/daemon/dist/lib/onboarding-marker.js +51 -0
- package/packages/daemon/dist/lib/pane-chrome.d.ts +12 -0
- package/packages/daemon/dist/lib/pane-chrome.js +12 -0
- package/packages/daemon/dist/lib/pane-source-credentials.d.ts +32 -0
- package/packages/daemon/dist/lib/pane-source-credentials.js +178 -0
- package/packages/daemon/dist/lib/pane-widget.d.ts +61 -0
- package/packages/daemon/dist/lib/pane-widget.js +126 -0
- package/packages/daemon/dist/lib/project-inspect.js +4 -0
- package/packages/daemon/dist/lib/project-onboard.d.ts +5 -5
- package/packages/daemon/dist/lib/project-onboard.js +17 -21
- package/packages/daemon/dist/lib/project-probe.d.ts +9 -3
- package/packages/daemon/dist/lib/project-probe.js +28 -22
- package/packages/daemon/dist/lib/project-readiness-probe.d.ts +60 -0
- package/packages/daemon/dist/lib/project-readiness-probe.js +425 -0
- package/packages/daemon/dist/lib/project-readiness.d.ts +157 -0
- package/packages/daemon/dist/lib/project-readiness.js +680 -0
- package/packages/daemon/dist/lib/project-registry.d.ts +8 -0
- package/packages/daemon/dist/lib/project-registry.js +42 -9
- package/packages/daemon/dist/lib/project-resolver.d.ts +77 -0
- package/packages/daemon/dist/lib/project-resolver.js +245 -0
- package/packages/daemon/dist/lib/project-runtime-errors.d.ts +13 -0
- package/packages/daemon/dist/lib/project-runtime-errors.js +21 -0
- package/packages/daemon/dist/lib/project-runtime-repository.d.ts +193 -0
- package/packages/daemon/dist/lib/project-runtime-repository.js +876 -0
- package/packages/daemon/dist/lib/resolved-config.d.ts +48 -0
- package/packages/daemon/dist/lib/resolved-config.js +318 -0
- package/packages/daemon/dist/lib/runtime-namespace.d.ts +34 -0
- package/packages/daemon/dist/lib/runtime-namespace.js +136 -0
- package/packages/daemon/dist/lib/semantic-resource-id.d.ts +7 -0
- package/packages/daemon/dist/lib/semantic-resource-id.js +14 -0
- package/packages/daemon/dist/lib/session-monitor.d.ts +2 -0
- package/packages/daemon/dist/lib/session-monitor.js +29 -23
- package/packages/daemon/dist/lib/session-options.js +3 -10
- package/packages/daemon/dist/lib/state-home.js +2 -3
- package/packages/daemon/dist/lib/theme-mode.d.ts +10 -0
- package/packages/daemon/dist/lib/theme-mode.js +9 -0
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.d.ts +88 -0
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +534 -0
- package/packages/daemon/dist/lib/tmux-interaction-options.d.ts +34 -0
- package/packages/daemon/dist/lib/tmux-interaction-options.js +126 -0
- package/packages/daemon/dist/lib/tmux-terminal-color.d.ts +18 -0
- package/packages/daemon/dist/lib/tmux-terminal-color.js +37 -0
- package/packages/daemon/dist/lib/tui-binary.d.ts +30 -5
- package/packages/daemon/dist/lib/tui-binary.js +291 -28
- package/packages/daemon/dist/lib/unix-socket-authority.d.ts +9 -0
- package/packages/daemon/dist/lib/unix-socket-authority.js +48 -0
- package/packages/daemon/dist/lib/widget-asset-policy.d.ts +3 -0
- package/packages/daemon/dist/lib/widget-asset-policy.js +3 -0
- package/packages/daemon/dist/lib/widget-asset-store.d.ts +22 -0
- package/packages/daemon/dist/lib/widget-asset-store.js +166 -0
- package/packages/daemon/dist/lib/workspace-config-loader.d.ts +68 -0
- package/packages/daemon/dist/lib/workspace-config-loader.js +280 -0
- package/packages/daemon/dist/lib/workspace-multiplexer-verbs.d.ts +109 -0
- package/packages/daemon/dist/lib/workspace-multiplexer-verbs.js +1138 -0
- package/packages/daemon/dist/lib/workspace-open-handoff.d.ts +41 -0
- package/packages/daemon/dist/lib/workspace-open-handoff.js +219 -0
- package/packages/daemon/dist/lib/workspace-open.d.ts +44 -0
- package/packages/daemon/dist/lib/workspace-open.js +740 -0
- package/packages/daemon/dist/lib/workspace-pane-creation.d.ts +64 -0
- package/packages/daemon/dist/lib/workspace-pane-creation.js +1107 -0
- package/packages/daemon/dist/lib/workspace-promotion.d.ts +41 -0
- package/packages/daemon/dist/lib/workspace-promotion.js +804 -0
- package/packages/daemon/dist/lib/workspace-registry.d.ts +49 -2
- package/packages/daemon/dist/lib/workspace-registry.js +150 -23
- package/packages/daemon/dist/lib/workspace-state-repository.d.ts +139 -0
- package/packages/daemon/dist/lib/workspace-state-repository.js +790 -0
- package/packages/daemon/dist/lib/workspace-state.d.ts +37 -0
- package/packages/daemon/dist/lib/workspace-state.js +765 -0
- package/packages/daemon/dist/lib/yaml-io.js +4 -18
- package/packages/daemon/dist/migrate.d.ts +11 -0
- package/packages/daemon/dist/migrate.js +105 -0
- package/packages/daemon/dist/restart.js +2 -2
- package/packages/daemon/dist/restore.d.ts +5 -5
- package/packages/daemon/dist/restore.js +10 -6
- package/packages/daemon/dist/schemas/inspect.d.ts +8 -0
- package/packages/daemon/dist/schemas/inspect.js +9 -1
- package/packages/daemon/dist/schemas/registry.d.ts +18 -4
- package/packages/daemon/dist/schemas/registry.js +5 -19
- package/packages/daemon/dist/schemas/ws-events.d.ts +5 -69
- package/packages/daemon/dist/schemas/ws-events.js +4 -107
- package/packages/daemon/dist/send.d.ts +8 -0
- package/packages/daemon/dist/send.js +106 -3
- package/packages/daemon/dist/server/pane-stream-upgrade.d.ts +12 -0
- package/packages/daemon/dist/server/pane-stream-upgrade.js +117 -0
- package/packages/daemon/dist/server/terminal-attachment-upgrade.d.ts +11 -0
- package/packages/daemon/dist/server/terminal-attachment-upgrade.js +121 -0
- package/packages/daemon/dist/status.js +11 -8
- package/packages/daemon/dist/stop.js +2 -2
- package/packages/daemon/dist/terminal/MonotonicPtyInput.d.ts +30 -0
- package/packages/daemon/dist/terminal/MonotonicPtyInput.js +130 -0
- package/packages/daemon/dist/terminal/NodePtyAdapter.d.ts +9 -3
- package/packages/daemon/dist/terminal/NodePtyAdapter.js +37 -10
- package/packages/daemon/dist/terminal/PtyAdapter.d.ts +93 -3
- package/packages/daemon/dist/terminal/PtyAdapter.js +18 -0
- package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.d.ts +14 -4
- package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.js +33 -6
- package/packages/daemon/dist/terminal/attachments/admission-util.d.ts +14 -0
- package/packages/daemon/dist/terminal/attachments/admission-util.js +87 -0
- package/packages/daemon/dist/terminal/attachments/agent-status-probe.d.ts +102 -0
- package/packages/daemon/dist/terminal/attachments/agent-status-probe.js +325 -0
- package/packages/daemon/dist/terminal/attachments/direct-websocket.d.ts +141 -0
- package/packages/daemon/dist/terminal/attachments/direct-websocket.js +1069 -0
- package/packages/daemon/dist/terminal/attachments/grouped-tmux.d.ts +106 -0
- package/packages/daemon/dist/terminal/attachments/grouped-tmux.js +213 -0
- package/packages/daemon/dist/terminal/attachments/lease-manager.d.ts +188 -0
- package/packages/daemon/dist/terminal/attachments/lease-manager.js +655 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.d.ts +196 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +1564 -0
- package/packages/daemon/dist/terminal/attachments/pty-tmux-attachment-launcher.d.ts +66 -0
- package/packages/daemon/dist/terminal/attachments/pty-tmux-attachment-launcher.js +607 -0
- package/packages/daemon/dist/terminal/attachments/semantic-pane-catalog.d.ts +81 -0
- package/packages/daemon/dist/terminal/attachments/semantic-pane-catalog.js +208 -0
- package/packages/daemon/dist/terminal/attachments/tmux-view-executor.d.ts +111 -0
- package/packages/daemon/dist/terminal/attachments/tmux-view-executor.js +825 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.d.ts +25 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.js +80 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.d.ts +66 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.js +133 -0
- package/packages/daemon/dist/terminal/mirror/control-channel.d.ts +188 -0
- package/packages/daemon/dist/terminal/mirror/control-channel.js +624 -0
- package/packages/daemon/dist/terminal/mirror/control-mode-ownership.d.ts +14 -0
- package/packages/daemon/dist/terminal/mirror/control-mode-ownership.js +30 -0
- package/packages/daemon/dist/terminal/mirror/events.d.ts +115 -0
- package/packages/daemon/dist/terminal/mirror/events.js +18 -0
- package/packages/daemon/dist/terminal/mirror/flow-ledger.d.ts +40 -0
- package/packages/daemon/dist/terminal/mirror/flow-ledger.js +56 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.d.ts +137 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +329 -0
- package/packages/daemon/dist/terminal/mirror/pane-feed.d.ts +90 -0
- package/packages/daemon/dist/terminal/mirror/pane-feed.js +140 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.d.ts +216 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +2301 -0
- package/packages/daemon/dist/terminal/mirror/trusted-inventory.d.ts +28 -0
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.d.ts +72 -0
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +245 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.d.ts +208 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +2058 -0
- package/packages/daemon/dist/terminal/pane-stream/runtime.d.ts +26 -0
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +53 -0
- package/packages/daemon/dist/terminal/pane-stream/wire-ledger.d.ts +59 -0
- package/packages/daemon/dist/terminal/pane-stream/wire-ledger.js +110 -0
- package/packages/daemon/dist/terminal/protocol/chunk-bytes.d.ts +3 -0
- package/packages/daemon/dist/terminal/protocol/chunk-bytes.js +21 -0
- package/packages/daemon/dist/terminal/protocol/control.d.ts +66 -0
- package/packages/daemon/dist/terminal/protocol/control.js +111 -0
- package/packages/daemon/dist/terminal/protocol/input-coalescer.d.ts +55 -0
- package/packages/daemon/dist/terminal/protocol/input-coalescer.js +111 -0
- package/packages/daemon/dist/terminal/protocol/layout-parse.d.ts +68 -0
- package/packages/daemon/dist/terminal/protocol/layout-parse.js +127 -0
- package/packages/daemon/dist/terminal/protocol/pane-display-name.d.ts +16 -0
- package/packages/daemon/dist/terminal/protocol/pane-display-name.js +153 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.d.ts +78 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +294 -0
- package/packages/daemon/dist/terminal/protocol/workspace-tmux-adapter.d.ts +90 -0
- package/packages/daemon/dist/terminal/protocol/workspace-tmux-adapter.js +213 -0
- package/packages/daemon/dist/terminal/session-runtime/authority-arbiter.d.ts +36 -0
- package/packages/daemon/dist/terminal/session-runtime/authority-arbiter.js +260 -0
- package/packages/daemon/dist/terminal/session-runtime/causal-cell-ledger.d.ts +29 -0
- package/packages/daemon/dist/terminal/session-runtime/causal-cell-ledger.js +278 -0
- package/packages/daemon/dist/terminal/session-runtime/interaction-receipt-facts.d.ts +12 -0
- package/packages/daemon/dist/terminal/session-runtime/interaction-receipt-facts.js +147 -0
- package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.d.ts +16 -0
- package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.js +116 -0
- package/packages/daemon/dist/terminal/session-runtime/registry.d.ts +148 -0
- package/packages/daemon/dist/terminal/session-runtime/registry.js +1368 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-observability.d.ts +118 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-observability.js +72 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-scheduler.d.ts +11 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-scheduler.js +10 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-trace-correlator.d.ts +18 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-trace-correlator.js +48 -0
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-executor.d.ts +69 -0
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-executor.js +353 -0
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-resource-changes.d.ts +8 -0
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-resource-changes.js +32 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.d.ts +91 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +1362 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-observation-identity.d.ts +3 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-observation-identity.js +9 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-interpreter-backend.d.ts +55 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.d.ts +91 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +528 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.d.ts +50 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +402 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-shadow-projections.d.ts +37 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-shadow-projections.js +21 -0
- package/packages/daemon/dist/terminal/session-runtime/transport-binding.d.ts +75 -0
- package/packages/daemon/dist/terminal/session-runtime/transport-binding.js +474 -0
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.d.ts +26 -0
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +276 -0
- package/packages/daemon/dist/tui/async-disposable-slot.d.ts +18 -0
- package/packages/daemon/dist/tui/async-disposable-slot.js +57 -0
- package/packages/daemon/dist/tui/chrome/cheatsheet.d.ts +59 -0
- package/packages/daemon/dist/tui/chrome/cheatsheet.js +211 -0
- package/packages/daemon/dist/tui/chrome/chip.d.ts +21 -0
- package/packages/daemon/dist/tui/chrome/chip.js +25 -0
- package/packages/daemon/dist/tui/chrome/events.d.ts +51 -0
- package/packages/daemon/dist/tui/chrome/events.js +94 -0
- package/packages/daemon/dist/tui/chrome/front-door.d.ts +16 -0
- package/packages/daemon/dist/tui/chrome/front-door.js +16 -0
- package/packages/daemon/dist/tui/chrome/kitty-keys.d.ts +41 -0
- package/packages/daemon/dist/tui/chrome/kitty-keys.js +54 -0
- package/packages/daemon/dist/tui/chrome/menu.d.ts +92 -0
- package/packages/daemon/dist/tui/chrome/menu.js +251 -0
- package/packages/daemon/dist/tui/chrome/notify-prefs.d.ts +47 -0
- package/packages/daemon/dist/tui/chrome/notify-prefs.js +13 -0
- package/packages/daemon/dist/tui/chrome/notify-state.d.ts +13 -0
- package/packages/daemon/dist/tui/chrome/notify-state.js +77 -0
- package/packages/daemon/dist/tui/chrome/notify.d.ts +361 -0
- package/packages/daemon/dist/tui/chrome/notify.js +711 -0
- package/packages/daemon/dist/tui/chrome/panels.d.ts +72 -0
- package/packages/daemon/dist/tui/chrome/panels.js +60 -0
- package/packages/daemon/dist/tui/chrome/sidebar.d.ts +77 -0
- package/packages/daemon/dist/tui/chrome/sidebar.js +183 -0
- package/packages/daemon/dist/tui/chrome/snapshot.d.ts +110 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +290 -0
- package/packages/daemon/dist/tui/chrome/statusline.d.ts +237 -0
- package/packages/daemon/dist/tui/chrome/statusline.js +552 -0
- package/packages/daemon/dist/tui/chrome/updater.d.ts +230 -0
- package/packages/daemon/dist/tui/chrome/updater.js +651 -0
- package/packages/daemon/dist/tui/chrome/welcome.d.ts +41 -0
- package/packages/daemon/dist/tui/chrome/welcome.js +117 -0
- package/packages/daemon/dist/tui/compiled.d.ts +86 -0
- package/packages/daemon/dist/tui/compiled.js +165 -0
- package/packages/daemon/dist/tui/detect/agent-resolution.d.ts +56 -0
- package/packages/daemon/dist/tui/detect/agent-resolution.js +60 -0
- package/packages/daemon/dist/tui/detect/classify.d.ts +107 -0
- package/packages/daemon/dist/tui/detect/classify.js +184 -0
- package/packages/daemon/dist/tui/detect/manifest-loader.d.ts +54 -0
- package/packages/daemon/dist/tui/detect/manifest-loader.js +242 -0
- package/packages/daemon/dist/tui/detect/manifest.d.ts +111 -0
- package/packages/daemon/dist/tui/detect/manifest.js +126 -0
- package/packages/daemon/dist/tui/detect/manifests.d.ts +40 -0
- package/packages/daemon/dist/tui/detect/manifests.js +535 -0
- package/packages/daemon/dist/tui/detect/process-tree.d.ts +96 -0
- package/packages/daemon/dist/tui/detect/process-tree.js +194 -0
- package/packages/daemon/dist/tui/detect/session-id.d.ts +110 -0
- package/packages/daemon/dist/tui/detect/session-id.js +414 -0
- package/packages/daemon/dist/tui/detect/snapshot.d.ts +27 -0
- package/packages/daemon/dist/tui/detect/snapshot.js +81 -0
- package/packages/daemon/dist/tui/integrations/claude.d.ts +65 -0
- package/packages/daemon/dist/tui/integrations/claude.js +151 -0
- package/packages/daemon/dist/tui/integrations/offer.d.ts +47 -0
- package/packages/daemon/dist/tui/integrations/offer.js +134 -0
- package/packages/daemon/dist/tui/integrations/opencode.d.ts +37 -0
- package/packages/daemon/dist/tui/integrations/opencode.js +117 -0
- package/packages/daemon/dist/tui/mirror/ack-writer.d.ts +36 -0
- package/packages/daemon/dist/tui/mirror/ack-writer.js +78 -0
- package/packages/daemon/dist/tui/mirror/activity-surface-view.d.ts +8 -0
- package/packages/daemon/dist/tui/mirror/activity-surface-view.jsx +69 -0
- package/packages/daemon/dist/tui/mirror/activity-surface.d.ts +103 -0
- package/packages/daemon/dist/tui/mirror/activity-surface.js +271 -0
- package/packages/daemon/dist/tui/mirror/agent-chip.d.ts +76 -0
- package/packages/daemon/dist/tui/mirror/agent-chip.js +84 -0
- package/packages/daemon/dist/tui/mirror/agent-lifecycle.d.ts +217 -0
- package/packages/daemon/dist/tui/mirror/agent-lifecycle.js +372 -0
- package/packages/daemon/dist/tui/mirror/agent-provisioning-executor.d.ts +42 -0
- package/packages/daemon/dist/tui/mirror/agent-provisioning-executor.js +86 -0
- package/packages/daemon/dist/tui/mirror/agent-rows.d.ts +119 -0
- package/packages/daemon/dist/tui/mirror/agent-rows.js +126 -0
- package/packages/daemon/dist/tui/mirror/ansi-palette.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/ansi-palette.js +3 -0
- package/packages/daemon/dist/tui/mirror/app-state.d.ts +114 -0
- package/packages/daemon/dist/tui/mirror/app-state.js +294 -0
- package/packages/daemon/dist/tui/mirror/application-keybindings.d.ts +18 -0
- package/packages/daemon/dist/tui/mirror/application-keybindings.js +33 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-connection.d.ts +53 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-connection.js +253 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-session.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-session.js +45 -0
- package/packages/daemon/dist/tui/mirror/attention.d.ts +63 -0
- package/packages/daemon/dist/tui/mirror/attention.js +59 -0
- package/packages/daemon/dist/tui/mirror/blit.d.ts +82 -0
- package/packages/daemon/dist/tui/mirror/blit.js +120 -0
- package/packages/daemon/dist/tui/mirror/canonical-workspace-routing.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/canonical-workspace-routing.js +45 -0
- package/packages/daemon/dist/tui/mirror/changes-surface-view.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/changes-surface-view.jsx +92 -0
- package/packages/daemon/dist/tui/mirror/changes-surface.d.ts +115 -0
- package/packages/daemon/dist/tui/mirror/changes-surface.js +210 -0
- package/packages/daemon/dist/tui/mirror/composite-layout.d.ts +91 -0
- package/packages/daemon/dist/tui/mirror/composite-layout.js +539 -0
- package/packages/daemon/dist/tui/mirror/configless-session-bootstrap.d.ts +39 -0
- package/packages/daemon/dist/tui/mirror/configless-session-bootstrap.js +133 -0
- package/packages/daemon/dist/tui/mirror/dialog-model.d.ts +154 -0
- package/packages/daemon/dist/tui/mirror/dialog-model.js +183 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack-core.d.ts +45 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack-core.js +232 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack.d.ts +2 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack.js +2 -0
- package/packages/daemon/dist/tui/mirror/diff-model.d.ts +169 -0
- package/packages/daemon/dist/tui/mirror/diff-model.js +332 -0
- package/packages/daemon/dist/tui/mirror/editor-buffer.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/editor-buffer.js +47 -0
- package/packages/daemon/dist/tui/mirror/editor-open-policy.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/editor-open-policy.js +9 -0
- package/packages/daemon/dist/tui/mirror/features/changes/contract.d.ts +75 -0
- package/packages/daemon/dist/tui/mirror/features/changes/controller.d.ts +10 -0
- package/packages/daemon/dist/tui/mirror/features/changes/controller.js +454 -0
- package/packages/daemon/dist/tui/mirror/features/changes/feature.d.ts +10 -0
- package/packages/daemon/dist/tui/mirror/features/changes/feature.jsx +9 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/contract.d.ts +47 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/feature.d.ts +12 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/feature.jsx +123 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/session.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/session.js +160 -0
- package/packages/daemon/dist/tui/mirror/features/files/feature.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/features/files/feature.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/features/files/session.d.ts +133 -0
- package/packages/daemon/dist/tui/mirror/features/files/session.js +617 -0
- package/packages/daemon/dist/tui/mirror/features/home/feature.d.ts +28 -0
- package/packages/daemon/dist/tui/mirror/features/home/feature.jsx +122 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/contract.d.ts +84 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/contract.js +3 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/feature.d.ts +6 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/feature.jsx +5 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/session.d.ts +5 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/session.js +377 -0
- package/packages/daemon/dist/tui/mirror/features/palette/contract.d.ts +116 -0
- package/packages/daemon/dist/tui/mirror/features/palette/contract.js +9 -0
- package/packages/daemon/dist/tui/mirror/features/palette/feature.d.ts +4 -0
- package/packages/daemon/dist/tui/mirror/features/palette/feature.js +3 -0
- package/packages/daemon/dist/tui/mirror/features/palette/session.d.ts +2 -0
- package/packages/daemon/dist/tui/mirror/features/palette/session.js +393 -0
- package/packages/daemon/dist/tui/mirror/features/palette/surface.d.ts +7 -0
- package/packages/daemon/dist/tui/mirror/features/palette/surface.jsx +48 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/contract.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/feature.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/feature.jsx +2 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/session.d.ts +8 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/session.js +148 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/surface.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/surface.jsx +64 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/asset-loader.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/asset-loader.js +125 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/contract.d.ts +71 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/feature.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/feature.jsx +103 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/session.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/session.js +310 -0
- package/packages/daemon/dist/tui/mirror/features/settings/catalog.d.ts +7 -0
- package/packages/daemon/dist/tui/mirror/features/settings/catalog.js +10 -0
- package/packages/daemon/dist/tui/mirror/features/settings/contract.d.ts +35 -0
- package/packages/daemon/dist/tui/mirror/features/settings/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/settings/feature.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/features/settings/feature.js +2 -0
- package/packages/daemon/dist/tui/mirror/features/settings/session.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/features/settings/session.js +309 -0
- package/packages/daemon/dist/tui/mirror/file-tree.d.ts +142 -0
- package/packages/daemon/dist/tui/mirror/file-tree.js +283 -0
- package/packages/daemon/dist/tui/mirror/files-surface-view.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/files-surface-view.jsx +92 -0
- package/packages/daemon/dist/tui/mirror/files-surface.d.ts +123 -0
- package/packages/daemon/dist/tui/mirror/files-surface.js +237 -0
- package/packages/daemon/dist/tui/mirror/focus-projection.d.ts +20 -0
- package/packages/daemon/dist/tui/mirror/focus-projection.js +80 -0
- package/packages/daemon/dist/tui/mirror/folder-picker.d.ts +38 -0
- package/packages/daemon/dist/tui/mirror/folder-picker.js +114 -0
- package/packages/daemon/dist/tui/mirror/frame-coalescer.d.ts +29 -0
- package/packages/daemon/dist/tui/mirror/frame-coalescer.js +74 -0
- package/packages/daemon/dist/tui/mirror/home-model.d.ts +81 -0
- package/packages/daemon/dist/tui/mirror/home-model.js +125 -0
- package/packages/daemon/dist/tui/mirror/home-surface-model.d.ts +113 -0
- package/packages/daemon/dist/tui/mirror/home-surface-model.js +297 -0
- package/packages/daemon/dist/tui/mirror/home-surface.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/home-surface.jsx +110 -0
- package/packages/daemon/dist/tui/mirror/host-terminal.d.ts +28 -0
- package/packages/daemon/dist/tui/mirror/host-terminal.js +33 -0
- package/packages/daemon/dist/tui/mirror/hosted.d.ts +179 -0
- package/packages/daemon/dist/tui/mirror/hosted.js +239 -0
- package/packages/daemon/dist/tui/mirror/input-lifecycle.d.ts +140 -0
- package/packages/daemon/dist/tui/mirror/input-lifecycle.js +147 -0
- package/packages/daemon/dist/tui/mirror/interaction-flow.d.ts +30 -0
- package/packages/daemon/dist/tui/mirror/interaction-flow.js +41 -0
- package/packages/daemon/dist/tui/mirror/legacy/missions-workspace-loader.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/legacy/missions-workspace-loader.js +84 -0
- package/packages/daemon/dist/tui/mirror/menu-model.d.ts +89 -0
- package/packages/daemon/dist/tui/mirror/menu-model.js +143 -0
- package/packages/daemon/dist/tui/mirror/missions-dashboard.d.ts +68 -0
- package/packages/daemon/dist/tui/mirror/missions-dashboard.js +261 -0
- package/packages/daemon/dist/tui/mirror/missions-render-fixtures.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/missions-render-fixtures.js +330 -0
- package/packages/daemon/dist/tui/mirror/missions-surface-controller.d.ts +84 -0
- package/packages/daemon/dist/tui/mirror/missions-surface-controller.js +314 -0
- package/packages/daemon/dist/tui/mirror/missions-surface.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/missions-surface.jsx +239 -0
- package/packages/daemon/dist/tui/mirror/missions-workspace.d.ts +341 -0
- package/packages/daemon/dist/tui/mirror/missions-workspace.js +1399 -0
- package/packages/daemon/dist/tui/mirror/multiplexer-action-executor.d.ts +71 -0
- package/packages/daemon/dist/tui/mirror/multiplexer-action-executor.js +233 -0
- package/packages/daemon/dist/tui/mirror/open-tui-pane-stream-socket.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/open-tui-pane-stream-socket.js +32 -0
- package/packages/daemon/dist/tui/mirror/open-tui-verified-routing.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/open-tui-verified-routing.js +45 -0
- package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.d.ts +36 -0
- package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +1084 -0
- package/packages/daemon/dist/tui/mirror/palette-surface-adapter.d.ts +58 -0
- package/packages/daemon/dist/tui/mirror/palette-surface-adapter.js +384 -0
- package/packages/daemon/dist/tui/mirror/palette.d.ts +315 -0
- package/packages/daemon/dist/tui/mirror/palette.js +522 -0
- package/packages/daemon/dist/tui/mirror/pane-frame-state.d.ts +68 -0
- package/packages/daemon/dist/tui/mirror/pane-frame-state.js +124 -0
- package/packages/daemon/dist/tui/mirror/pane-mirror.d.ts +205 -0
- package/packages/daemon/dist/tui/mirror/pane-mirror.js +584 -0
- package/packages/daemon/dist/tui/mirror/pane-surface.d.ts +257 -0
- package/packages/daemon/dist/tui/mirror/pane-surface.jsx +855 -0
- package/packages/daemon/dist/tui/mirror/panel-host-reactive.d.ts +7 -0
- package/packages/daemon/dist/tui/mirror/panel-host-reactive.js +13 -0
- package/packages/daemon/dist/tui/mirror/panel-host.d.ts +69 -0
- package/packages/daemon/dist/tui/mirror/panel-host.js +242 -0
- package/packages/daemon/dist/tui/mirror/perf-tap.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/perf-tap.js +32 -0
- package/packages/daemon/dist/tui/mirror/performance-events.d.ts +404 -0
- package/packages/daemon/dist/tui/mirror/performance-events.js +46 -0
- package/packages/daemon/dist/tui/mirror/recipe-components.d.ts +93 -0
- package/packages/daemon/dist/tui/mirror/recipe-components.jsx +135 -0
- package/packages/daemon/dist/tui/mirror/recipes.d.ts +90 -0
- package/packages/daemon/dist/tui/mirror/recipes.js +395 -0
- package/packages/daemon/dist/tui/mirror/reference-performance-trace.d.ts +80 -0
- package/packages/daemon/dist/tui/mirror/reference-performance-trace.js +597 -0
- package/packages/daemon/dist/tui/mirror/renderer-commands.d.ts +60 -0
- package/packages/daemon/dist/tui/mirror/renderer-commands.js +250 -0
- package/packages/daemon/dist/tui/mirror/resize-model.d.ts +76 -0
- package/packages/daemon/dist/tui/mirror/resize-model.js +105 -0
- package/packages/daemon/dist/tui/mirror/resize-transaction.d.ts +102 -0
- package/packages/daemon/dist/tui/mirror/resize-transaction.js +221 -0
- package/packages/daemon/dist/tui/mirror/rich-placement-projection.d.ts +64 -0
- package/packages/daemon/dist/tui/mirror/rich-placement-projection.js +80 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-appearance-owner.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-appearance-owner.js +79 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-bootstrap.d.ts +61 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-bootstrap.js +51 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-generation-starter.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-generation-starter.js +80 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog-owner.d.ts +21 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog-owner.js +88 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog.d.ts +60 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog.js +320 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-binding.d.ts +28 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-binding.js +111 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-capability.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-capability.js +25 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-presentation.d.ts +38 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-presentation.js +129 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-test-control.d.ts +43 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-test-control.js +242 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-input-readiness.d.ts +5 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-input-readiness.js +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-lifecycle.d.ts +72 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-lifecycle.js +297 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-optional-features.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-optional-features.js +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +61 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-input.d.ts +31 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-input.js +60 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-input.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-input.js +30 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-owner.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-owner.js +38 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pending-terminal-input.d.ts +53 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pending-terminal-input.js +74 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-performance-log.d.ts +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-performance-log.js +81 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-post-render-runtime.d.ts +37 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-post-render-runtime.js +117 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-configuration.d.ts +21 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-configuration.js +21 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-renderer.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-renderer.js +27 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-session-focus-owner.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-session-focus-owner.js +65 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-binding.d.ts +34 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-binding.js +307 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-viewport.d.ts +8 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-viewport.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-frame-readiness-owner.d.ts +6 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-frame-readiness-owner.js +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-host-focus-owner.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-host-focus-owner.js +25 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-input-ingress.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-input-ingress.js +96 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.d.ts +65 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +1326 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-palette-owner.d.ts +65 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-palette-owner.js +217 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-paste.d.ts +4 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-paste.js +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-renderer-sources.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-renderer-sources.js +31 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-selection-owner.d.ts +47 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-selection-owner.js +161 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace-policy.d.ts +44 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace-policy.js +177 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace.d.ts +103 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace.jsx +720 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-theme-repaint.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-theme-repaint.js +34 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-transient-note-owner.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-transient-note-owner.js +29 -0
- package/packages/daemon/dist/tui/mirror/runtime/bounded-performance-record-writer.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/bounded-performance-record-writer.js +67 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-client-ledger.d.ts +64 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-client-ledger.js +271 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-input-fixture.d.ts +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-input-fixture.js +43 -0
- package/packages/daemon/dist/tui/mirror/runtime/changes-deferred-identity.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/changes-deferred-identity.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/daemon-authority-rebind.d.ts +29 -0
- package/packages/daemon/dist/tui/mirror/runtime/daemon-authority-rebind.js +128 -0
- package/packages/daemon/dist/tui/mirror/runtime/deferred-intent-queue.d.ts +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/deferred-intent-queue.js +40 -0
- package/packages/daemon/dist/tui/mirror/runtime/editor-primitives.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/editor-primitives.js +39 -0
- package/packages/daemon/dist/tui/mirror/runtime/file-content-primitives.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/runtime/file-content-primitives.js +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/fleet-lifecycle-client.d.ts +4 -0
- package/packages/daemon/dist/tui/mirror/runtime/fleet-lifecycle-client.js +27 -0
- package/packages/daemon/dist/tui/mirror/runtime/focus-framebuffer-projection.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/runtime/focus-framebuffer-projection.js +53 -0
- package/packages/daemon/dist/tui/mirror/runtime/generation-bound-slot.d.ts +7 -0
- package/packages/daemon/dist/tui/mirror/runtime/generation-bound-slot.js +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/host-local-tmux-adapter.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/host-local-tmux-adapter.js +90 -0
- package/packages/daemon/dist/tui/mirror/runtime/hosted-tty-size-bridge.d.ts +55 -0
- package/packages/daemon/dist/tui/mirror/runtime/hosted-tty-size-bridge.js +166 -0
- package/packages/daemon/dist/tui/mirror/runtime/latest-intent-fence.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/runtime/latest-intent-fence.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/local-view-controller.d.ts +30 -0
- package/packages/daemon/dist/tui/mirror/runtime/local-view-controller.js +58 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-admission-coordinator.d.ts +44 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-admission-coordinator.js +118 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-pointer-capture.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-pointer-capture.js +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.d.ts +68 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.js +834 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-session-owner.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-session-owner.js +146 -0
- package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.d.ts +45 -0
- package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.js +178 -0
- package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.typecheck.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.typecheck.js +1 -0
- package/packages/daemon/dist/tui/mirror/runtime/palette-production-controller.d.ts +55 -0
- package/packages/daemon/dist/tui/mirror/runtime/palette-production-controller.js +126 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-resize-geometry.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-resize-geometry.js +13 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-scoped-terminal-surface.d.ts +42 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-scoped-terminal-surface.jsx +67 -0
- package/packages/daemon/dist/tui/mirror/runtime/product-surface-policy.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/runtime/product-surface-policy.js +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/renderer-cadence.d.ts +4 -0
- package/packages/daemon/dist/tui/mirror/runtime/renderer-cadence.js +4 -0
- package/packages/daemon/dist/tui/mirror/runtime/resize-terminal-pane.d.ts +35 -0
- package/packages/daemon/dist/tui/mirror/runtime/resize-terminal-pane.js +91 -0
- package/packages/daemon/dist/tui/mirror/runtime/rich-preview-demand.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/rich-preview-demand.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/runtime-layout-presentation.d.ts +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/runtime-layout-presentation.js +111 -0
- package/packages/daemon/dist/tui/mirror/runtime/select-terminal-pane.d.ts +25 -0
- package/packages/daemon/dist/tui/mirror/runtime/select-terminal-pane.js +90 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-pane-publication.d.ts +10 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-pane-publication.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-shell-viewport-resize.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-shell-viewport-resize.js +56 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-dimensions-owner.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-dimensions-owner.js +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.d.ts +52 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.js +610 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-frame-readiness.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-frame-readiness.js +84 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-host-focus.d.ts +41 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-host-focus.js +347 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-host-frame-diagnostics.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-host-frame-diagnostics.js +37 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-input-adapter.d.ts +10 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-input-adapter.js +50 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-layout-projection.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-layout-projection.js +28 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.js +82 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-selection.d.ts +66 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-selection.js +141 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-session-handoff.d.ts +50 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-session-handoff.js +89 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-tool-readiness.d.ts +31 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-tool-readiness.js +64 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-controller.d.ts +92 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-controller.js +636 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-projection.d.ts +59 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-projection.js +169 -0
- package/packages/daemon/dist/tui/mirror/runtime/viewport-fit-coordinator.d.ts +8 -0
- package/packages/daemon/dist/tui/mirror/runtime/viewport-fit-coordinator.js +7 -0
- package/packages/daemon/dist/tui/mirror/runtime/workspace-terminal-fast-lane.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/workspace-terminal-fast-lane.js +498 -0
- package/packages/daemon/dist/tui/mirror/scrollbar-model.d.ts +35 -0
- package/packages/daemon/dist/tui/mirror/scrollbar-model.js +64 -0
- package/packages/daemon/dist/tui/mirror/search-model.d.ts +41 -0
- package/packages/daemon/dist/tui/mirror/search-model.js +62 -0
- package/packages/daemon/dist/tui/mirror/selection.d.ts +175 -0
- package/packages/daemon/dist/tui/mirror/selection.js +264 -0
- package/packages/daemon/dist/tui/mirror/semantic-pane-render-source.d.ts +147 -0
- package/packages/daemon/dist/tui/mirror/semantic-pane-render-source.js +562 -0
- package/packages/daemon/dist/tui/mirror/semantic-session-view.d.ts +86 -0
- package/packages/daemon/dist/tui/mirror/semantic-session-view.js +269 -0
- package/packages/daemon/dist/tui/mirror/settings-model.d.ts +108 -0
- package/packages/daemon/dist/tui/mirror/settings-model.js +304 -0
- package/packages/daemon/dist/tui/mirror/shell-chrome.d.ts +151 -0
- package/packages/daemon/dist/tui/mirror/shell-chrome.js +313 -0
- package/packages/daemon/dist/tui/mirror/size-truth.d.ts +92 -0
- package/packages/daemon/dist/tui/mirror/size-truth.js +104 -0
- package/packages/daemon/dist/tui/mirror/spans.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/spans.js +31 -0
- package/packages/daemon/dist/tui/mirror/status-grammar.d.ts +18 -0
- package/packages/daemon/dist/tui/mirror/status-grammar.js +29 -0
- package/packages/daemon/dist/tui/mirror/terminal-surface.d.ts +55 -0
- package/packages/daemon/dist/tui/mirror/terminal-surface.js +92 -0
- package/packages/daemon/dist/tui/mirror/terminal-text.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/terminal-text.js +38 -0
- package/packages/daemon/dist/tui/mirror/theme.d.ts +207 -0
- package/packages/daemon/dist/tui/mirror/theme.js +744 -0
- package/packages/daemon/dist/tui/mirror/ui/agent-badge.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/ui/agent-badge.jsx +14 -0
- package/packages/daemon/dist/tui/mirror/ui/badge.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/ui/badge.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/ui/button.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/ui/button.jsx +66 -0
- package/packages/daemon/dist/tui/mirror/ui/dialog.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/ui/dialog.jsx +8 -0
- package/packages/daemon/dist/tui/mirror/ui/index.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/ui/index.js +16 -0
- package/packages/daemon/dist/tui/mirror/ui/key-hint.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/ui/key-hint.jsx +39 -0
- package/packages/daemon/dist/tui/mirror/ui/keyboard-router.d.ts +25 -0
- package/packages/daemon/dist/tui/mirror/ui/keyboard-router.jsx +46 -0
- package/packages/daemon/dist/tui/mirror/ui/menu.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/ui/menu.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/ui/navigation-row.d.ts +21 -0
- package/packages/daemon/dist/tui/mirror/ui/navigation-row.jsx +62 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-frame.d.ts +25 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-frame.jsx +52 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-host.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-host.jsx +33 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-list-row.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-list-row.jsx +23 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-model.d.ts +29 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-model.js +45 -0
- package/packages/daemon/dist/tui/mirror/ui/state.d.ts +27 -0
- package/packages/daemon/dist/tui/mirror/ui/state.js +171 -0
- package/packages/daemon/dist/tui/mirror/ui/status-bar.d.ts +43 -0
- package/packages/daemon/dist/tui/mirror/ui/status-bar.jsx +102 -0
- package/packages/daemon/dist/tui/mirror/ui/surface.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/ui/surface.jsx +45 -0
- package/packages/daemon/dist/tui/mirror/ui/tabs.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/ui/tabs.jsx +88 -0
- package/packages/daemon/dist/tui/mirror/widget-fallback.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/widget-fallback.js +52 -0
- package/packages/daemon/dist/tui/mirror/widget-surface-model.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/widget-surface-model.js +145 -0
- package/packages/daemon/dist/tui/mirror/widget-surface.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/widget-surface.jsx +31 -0
- package/packages/daemon/dist/tui/mirror/workspace/agent-terminal-canvas.d.ts +53 -0
- package/packages/daemon/dist/tui/mirror/workspace/agent-terminal-canvas.js +77 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-root-controller.d.ts +266 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-root-controller.js +99 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-controller.d.ts +83 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-controller.js +292 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-surface-commands.d.ts +5 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-surface-commands.js +28 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell.d.ts +49 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell.js +97 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface-view.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface-view.jsx +158 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface.d.ts +128 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface.js +342 -0
- package/packages/daemon/dist/tui/mirror/workspace/icons.d.ts +154 -0
- package/packages/daemon/dist/tui/mirror/workspace/icons.js +43 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu.jsx +20 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-frame.d.ts +143 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-frame.js +452 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-chrome.d.ts +152 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-chrome.js +555 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-header.d.ts +58 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-header.jsx +93 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-window-strip.d.ts +75 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-window-strip.jsx +253 -0
- package/packages/daemon/dist/tui/mirror/workspace/text.d.ts +2 -0
- package/packages/daemon/dist/tui/mirror/workspace/text.js +27 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-controller.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-controller.js +34 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-shell.d.ts +123 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-shell.js +286 -0
- package/packages/daemon/dist/tui/mirror/workspace-ui-state.d.ts +174 -0
- package/packages/daemon/dist/tui/mirror/workspace-ui-state.js +885 -0
- package/packages/daemon/dist/tui/readiness.d.ts +22 -0
- package/packages/daemon/dist/tui/readiness.js +34 -0
- package/packages/daemon/dist/tui/team/entry.d.ts +37 -0
- package/packages/daemon/dist/tui/team/entry.js +20 -0
- package/packages/daemon/dist/tui/team/fuzzy.d.ts +38 -0
- package/packages/daemon/dist/tui/team/fuzzy.js +141 -0
- package/packages/daemon/dist/tui/team/home.d.ts +94 -0
- package/packages/daemon/dist/tui/team/home.js +115 -0
- package/packages/daemon/dist/tui/team/input.d.ts +22 -0
- package/packages/daemon/dist/tui/team/input.js +21 -0
- package/packages/daemon/dist/tui/team/keymap.d.ts +33 -0
- package/packages/daemon/dist/tui/team/keymap.js +99 -0
- package/packages/daemon/dist/tui/team/mouse.d.ts +18 -0
- package/packages/daemon/dist/tui/team/mouse.js +17 -0
- package/packages/daemon/dist/tui/team/nav.d.ts +21 -0
- package/packages/daemon/dist/tui/team/nav.js +33 -0
- package/packages/daemon/dist/tui/team/preview.d.ts +19 -0
- package/packages/daemon/dist/tui/team/preview.js +35 -0
- package/packages/daemon/dist/tui/team/projects.d.ts +52 -0
- package/packages/daemon/dist/tui/team/projects.js +159 -0
- package/packages/daemon/dist/tui/team/report.d.ts +51 -0
- package/packages/daemon/dist/tui/team/report.js +37 -0
- package/packages/daemon/dist/tui/team/sessions.d.ts +235 -0
- package/packages/daemon/dist/tui/team/sessions.js +292 -0
- package/packages/daemon/dist/tui/team/tree.d.ts +41 -0
- package/packages/daemon/dist/tui/team/tree.js +42 -0
- package/packages/daemon/dist/tui/team/wait-receipts.d.ts +60 -0
- package/packages/daemon/dist/tui/team/wait-receipts.js +153 -0
- package/packages/daemon/dist/tui/team/wait.d.ts +62 -0
- package/packages/daemon/dist/tui/team/wait.js +90 -0
- package/packages/daemon/dist/validate.js +16 -10
- package/packages/daemon/dist/widgets/lib/watcher.d.ts +5 -9
- package/packages/daemon/dist/widgets/lib/watcher.js +5 -92
- package/packages/daemon/dist/widgets/resolve.js +10 -7
- package/packages/daemon/dist/widgets/setup/setup-model.js +7 -9
- package/packages/daemon/src/attach.ts +2 -2
- package/packages/daemon/src/canonical.ts +19 -2
- package/packages/daemon/src/cli.ts +38 -36
- package/packages/daemon/src/command-center/actions/command-definitions.ts +91 -0
- package/packages/daemon/src/command-center/actions/dispatcher.ts +291 -10
- package/packages/daemon/src/command-center/actions/errors.ts +40 -0
- package/packages/daemon/src/command-center/actions/handlers/_project-context.ts +4 -5
- package/packages/daemon/src/command-center/actions/handlers/app-window-mutate.ts +54 -0
- package/packages/daemon/src/command-center/actions/handlers/config-actions.ts +59 -29
- package/packages/daemon/src/command-center/actions/handlers/daemon-shutdown.ts +12 -0
- package/packages/daemon/src/command-center/actions/handlers/fleet-lifecycle.ts +104 -0
- package/packages/daemon/src/command-center/actions/handlers/project-launch.ts +20 -4
- package/packages/daemon/src/command-center/actions/handlers/workspace-multiplexer.ts +96 -0
- package/packages/daemon/src/command-center/actions/handlers/workspace-open.ts +141 -0
- package/packages/daemon/src/command-center/actions/handlers/workspace-pane-create.ts +48 -0
- package/packages/daemon/src/command-center/actions/handlers/workspace-promote.ts +48 -0
- package/packages/daemon/src/command-center/actions/registry.ts +200 -1
- package/packages/daemon/src/command-center/actions/semantic-multiplexer-actions.ts +26 -0
- package/packages/daemon/src/command-center/agent-status-watch.ts +222 -0
- package/packages/daemon/src/command-center/daemon-fleet-facts-observer.ts +465 -0
- package/packages/daemon/src/command-center/discovery.ts +310 -5
- package/packages/daemon/src/command-center/owner-authority.ts +118 -0
- package/packages/daemon/src/command-center/pane-stream-issue.ts +247 -0
- package/packages/daemon/src/command-center/resources/agent-graph-overlay.ts +270 -0
- package/packages/daemon/src/command-center/resources/application-shell.ts +909 -0
- package/packages/daemon/src/command-center/resources/desktop-missions.ts +171 -0
- package/packages/daemon/src/command-center/resources/fleet-catalog.ts +200 -0
- package/packages/daemon/src/command-center/resources/fleet-resource-route.ts +61 -0
- package/packages/daemon/src/command-center/resources/startup-readiness-route.ts +172 -0
- package/packages/daemon/src/command-center/resources/startup-readiness.ts +250 -0
- package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +45 -0
- package/packages/daemon/src/command-center/resources/workspace-changes-authority.ts +594 -0
- package/packages/daemon/src/command-center/resources/workspace-changes-git.ts +278 -0
- package/packages/daemon/src/command-center/resources/workspace-files-authority.ts +583 -0
- package/packages/daemon/src/command-center/resources/workspace-missions-route.ts +125 -0
- package/packages/daemon/src/command-center/resources/workspace-resource-ids.ts +81 -0
- package/packages/daemon/src/command-center/resources/workspace-resource-routes.ts +147 -0
- package/packages/daemon/src/command-center/server.ts +732 -59
- package/packages/daemon/src/command-center/terminal-attachment-issue.ts +257 -0
- package/packages/daemon/src/command-center/workspace-resource-observer.ts +560 -0
- package/packages/daemon/src/command-center/ws-events.ts +853 -66
- package/packages/daemon/src/config.ts +35 -25
- package/packages/daemon/src/control/lifecycle.ts +14 -2
- package/packages/daemon/src/control/server.ts +3 -3
- package/packages/daemon/src/detect.ts +25 -20
- package/packages/daemon/src/doctor.ts +20 -5
- package/packages/daemon/src/index.ts +244 -2
- package/packages/daemon/src/init.ts +23 -22
- package/packages/daemon/src/inspect.ts +41 -8
- package/packages/daemon/src/launch.ts +56 -28
- package/packages/daemon/src/lib/agent-kind.ts +23 -0
- package/packages/daemon/src/lib/app-config.ts +41 -5
- package/packages/daemon/src/lib/app-window-kernel.ts +777 -0
- package/packages/daemon/src/lib/app-window-mutation.ts +178 -0
- package/packages/daemon/src/lib/app-window-repository.ts +650 -0
- package/packages/daemon/src/lib/app-window-state.ts +599 -0
- package/packages/daemon/src/lib/application-shell-app-windows.ts +357 -0
- package/packages/daemon/src/lib/auth/middleware.ts +9 -3
- package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +266 -0
- package/packages/daemon/src/lib/canonical-daemon.ts +695 -73
- package/packages/daemon/src/lib/chrome-front-door.ts +17 -0
- package/packages/daemon/src/lib/cli-action-bridge.ts +127 -91
- package/packages/daemon/src/lib/command-registry.ts +152 -0
- package/packages/daemon/src/lib/config-context.ts +61 -0
- package/packages/daemon/src/lib/daemon-embed.ts +1347 -387
- package/packages/daemon/src/lib/daemon-session-monitor.ts +274 -0
- package/packages/daemon/src/lib/daemon.ts +3 -46
- package/packages/daemon/src/lib/directory-watcher.ts +166 -0
- package/packages/daemon/src/lib/environment-identity.ts +82 -0
- package/packages/daemon/src/lib/errors.ts +7 -1
- package/packages/daemon/src/lib/fleet-agent-lifecycle.ts +74 -0
- package/packages/daemon/src/lib/fleet-lifecycle-authority.ts +535 -0
- package/packages/daemon/src/lib/headless-daemon.ts +406 -0
- package/packages/daemon/src/lib/launch-plan.ts +123 -4
- package/packages/daemon/src/lib/legacy-config-adapter.ts +28 -0
- package/packages/daemon/src/lib/legacy-config-migration.ts +145 -0
- package/packages/daemon/src/lib/legacy-theme-compat.ts +40 -0
- package/packages/daemon/src/lib/mission-projections.ts +775 -0
- package/packages/daemon/src/lib/mission-repository.ts +1311 -0
- package/packages/daemon/src/lib/onboarding-marker.ts +51 -0
- package/packages/daemon/src/lib/pane-chrome.ts +14 -0
- package/packages/daemon/src/lib/pane-source-credentials.ts +200 -0
- package/packages/daemon/src/lib/pane-widget.ts +182 -0
- package/packages/daemon/src/lib/project-inspect.ts +4 -0
- package/packages/daemon/src/lib/project-onboard.ts +19 -24
- package/packages/daemon/src/lib/project-probe.ts +38 -30
- package/packages/daemon/src/lib/project-readiness-probe.ts +578 -0
- package/packages/daemon/src/lib/project-readiness.ts +1034 -0
- package/packages/daemon/src/lib/project-registry.ts +45 -9
- package/packages/daemon/src/lib/project-resolver.ts +350 -0
- package/packages/daemon/src/lib/project-runtime-errors.ts +41 -0
- package/packages/daemon/src/lib/project-runtime-repository.ts +1194 -0
- package/packages/daemon/src/lib/resolved-config.ts +425 -0
- package/packages/daemon/src/lib/runtime-namespace.ts +186 -0
- package/packages/daemon/src/lib/semantic-resource-id.ts +17 -0
- package/packages/daemon/src/lib/session-monitor.ts +28 -20
- package/packages/daemon/src/lib/session-options.ts +3 -10
- package/packages/daemon/src/lib/state-home.ts +2 -3
- package/packages/daemon/src/lib/theme-mode.ts +11 -0
- package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +632 -0
- package/packages/daemon/src/lib/tmux-interaction-options.ts +171 -0
- package/packages/daemon/src/lib/tmux-terminal-color.ts +44 -0
- package/packages/daemon/src/lib/tui-binary.ts +354 -34
- package/packages/daemon/src/lib/unix-socket-authority.ts +65 -0
- package/packages/daemon/src/lib/widget-asset-policy.ts +3 -0
- package/packages/daemon/src/lib/widget-asset-store.ts +218 -0
- package/packages/daemon/src/lib/workspace-config-loader.ts +378 -0
- package/packages/daemon/src/lib/workspace-multiplexer-verbs.ts +1362 -0
- package/packages/daemon/src/lib/workspace-open-handoff.ts +340 -0
- package/packages/daemon/src/lib/workspace-open.ts +983 -0
- package/packages/daemon/src/lib/workspace-pane-creation.ts +1406 -0
- package/packages/daemon/src/lib/workspace-promotion.ts +1031 -0
- package/packages/daemon/src/lib/workspace-registry.ts +193 -25
- package/packages/daemon/src/lib/workspace-state-repository.ts +1204 -0
- package/packages/daemon/src/lib/workspace-state.ts +960 -0
- package/packages/daemon/src/lib/yaml-io.ts +8 -17
- package/packages/daemon/src/migrate.ts +134 -0
- package/packages/daemon/src/restart.ts +2 -2
- package/packages/daemon/src/restore.ts +14 -9
- package/packages/daemon/src/schemas/inspect.ts +9 -1
- package/packages/daemon/src/schemas/registry.ts +12 -22
- package/packages/daemon/src/schemas/ws-events.ts +14 -131
- package/packages/daemon/src/send.ts +138 -3
- package/packages/daemon/src/server/pane-stream-upgrade.ts +141 -0
- package/packages/daemon/src/server/terminal-attachment-upgrade.ts +153 -0
- package/packages/daemon/src/status.ts +13 -8
- package/packages/daemon/src/stop.ts +2 -2
- package/packages/daemon/src/terminal/MonotonicPtyInput.ts +153 -0
- package/packages/daemon/src/terminal/NodePtyAdapter.ts +53 -11
- package/packages/daemon/src/terminal/PtyAdapter.ts +111 -3
- package/packages/daemon/src/terminal/README.md +34 -16
- package/packages/daemon/src/terminal/attachments/admission-util.ts +97 -0
- package/packages/daemon/src/terminal/attachments/agent-status-probe.ts +474 -0
- package/packages/daemon/src/terminal/attachments/direct-websocket.ts +1482 -0
- package/packages/daemon/src/terminal/attachments/grouped-tmux.ts +293 -0
- package/packages/daemon/src/terminal/attachments/lease-manager.ts +1042 -0
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +2206 -0
- package/packages/daemon/src/terminal/attachments/pty-tmux-attachment-launcher.ts +750 -0
- package/packages/daemon/src/terminal/attachments/semantic-pane-catalog.ts +365 -0
- package/packages/daemon/src/terminal/attachments/tmux-view-executor.ts +1095 -0
- package/packages/daemon/src/terminal/mirror/control-channel.ts +827 -0
- package/packages/daemon/src/terminal/mirror/control-mode-ownership.ts +34 -0
- package/packages/daemon/src/terminal/mirror/events.ts +128 -0
- package/packages/daemon/src/terminal/mirror/flow-ledger.ts +65 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +480 -0
- package/packages/daemon/src/terminal/mirror/pane-feed.ts +193 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +2820 -0
- package/packages/daemon/src/terminal/mirror/trusted-inventory.ts +29 -0
- package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +375 -0
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +2612 -0
- package/packages/daemon/src/terminal/pane-stream/runtime.ts +78 -0
- package/packages/daemon/src/terminal/pane-stream/wire-ledger.ts +155 -0
- package/packages/daemon/src/terminal/protocol/README.md +14 -0
- package/packages/daemon/src/terminal/protocol/chunk-bytes.ts +20 -0
- package/packages/daemon/src/{tui/mirror → terminal/protocol}/control.ts +39 -6
- package/packages/daemon/src/{tui/mirror → terminal/protocol}/input-coalescer.ts +18 -7
- package/packages/daemon/src/terminal/protocol/pane-display-name.ts +185 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +382 -0
- package/packages/daemon/src/terminal/protocol/workspace-tmux-adapter.ts +470 -0
- package/packages/daemon/src/terminal/session-runtime/authority-arbiter.ts +312 -0
- package/packages/daemon/src/terminal/session-runtime/causal-cell-ledger.ts +359 -0
- package/packages/daemon/src/terminal/session-runtime/interaction-receipt-facts.ts +173 -0
- package/packages/daemon/src/terminal/session-runtime/multiplexer-backend.ts +194 -0
- package/packages/daemon/src/terminal/session-runtime/registry.ts +2047 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +267 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-scheduler.ts +22 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-trace-correlator.ts +58 -0
- package/packages/daemon/src/terminal/session-runtime/semantic-mutation-executor.ts +555 -0
- package/packages/daemon/src/terminal/session-runtime/semantic-mutation-resource-changes.ts +48 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +1806 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-delivery-observation-identity.ts +18 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +64 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +690 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +514 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-shadow-projections.ts +36 -0
- package/packages/daemon/src/terminal/session-runtime/transport-binding.ts +682 -0
- package/packages/daemon/src/terminal/session-runtime/xterm-headless-provenance.json +25 -0
- package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +379 -0
- package/packages/daemon/src/tui/async-disposable-slot.ts +60 -0
- package/packages/daemon/src/tui/chrome/front-door.ts +11 -23
- package/packages/daemon/src/tui/chrome/sidebar.ts +9 -4
- package/packages/daemon/src/tui/chrome/statusline.ts +15 -6
- package/packages/daemon/src/tui/chrome/updater.ts +100 -3
- package/packages/daemon/src/tui/compiled.ts +102 -6
- package/packages/daemon/src/tui/detect/agent-resolution.ts +85 -0
- package/packages/daemon/src/tui/detect/process-tree.ts +17 -1
- package/packages/daemon/src/tui/detect/snapshot.ts +38 -3
- package/packages/daemon/src/tui/integrations/claude.ts +1 -0
- package/packages/daemon/src/tui/main.ts +53 -0
- package/packages/daemon/src/tui/mirror/RECIPES.md +59 -0
- package/packages/daemon/src/tui/mirror/SHELL_CHROME.md +39 -0
- package/packages/daemon/src/tui/mirror/THEME.md +48 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/activity-surface-renderer.test.tsx.snap +42 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/changes-terminal-surface-renderer.test.tsx.snap +267 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/home-files-surface-renderer.test.tsx.snap +267 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/missions-surface-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/recipes-gallery-renderer.test.tsx.snap +141 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/shell-chrome-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/activity-surface-view.tsx +169 -0
- package/packages/daemon/src/tui/mirror/activity-surface.ts +430 -0
- package/packages/daemon/src/tui/mirror/agent-lifecycle.ts +36 -5
- package/packages/daemon/src/tui/mirror/agent-provisioning-executor.ts +151 -0
- package/packages/daemon/src/tui/mirror/agent-rows.ts +34 -0
- package/packages/daemon/src/tui/mirror/ansi-palette.ts +3 -0
- package/packages/daemon/src/tui/mirror/app-state.ts +14 -1
- package/packages/daemon/src/tui/mirror/app.tsx +2 -7047
- package/packages/daemon/src/tui/mirror/application-keybindings.ts +54 -0
- package/packages/daemon/src/tui/mirror/application-shell-daemon-connection.ts +344 -0
- package/packages/daemon/src/tui/mirror/application-shell-daemon-session.ts +74 -0
- package/packages/daemon/src/tui/mirror/canonical-workspace-routing.ts +63 -0
- package/packages/daemon/src/tui/mirror/changes-surface-view.tsx +263 -0
- package/packages/daemon/src/tui/mirror/changes-surface.ts +338 -0
- package/packages/daemon/src/tui/mirror/composite-layout.ts +710 -0
- package/packages/daemon/src/tui/mirror/configless-session-bootstrap.ts +192 -0
- package/packages/daemon/src/tui/mirror/dialog-model.ts +2 -2
- package/packages/daemon/src/tui/mirror/dialog-stack-core.ts +264 -0
- package/packages/daemon/src/tui/mirror/dialog-stack.ts +2 -367
- package/packages/daemon/src/tui/mirror/editor-buffer.ts +9 -70
- package/packages/daemon/src/tui/mirror/editor-open-policy.ts +16 -0
- package/packages/daemon/src/tui/mirror/features/changes/contract.ts +84 -0
- package/packages/daemon/src/tui/mirror/features/changes/controller.ts +470 -0
- package/packages/daemon/src/tui/mirror/features/changes/feature.tsx +19 -0
- package/packages/daemon/src/tui/mirror/features/dialogs/contract.ts +64 -0
- package/packages/daemon/src/tui/mirror/features/dialogs/feature.tsx +227 -0
- package/packages/daemon/src/tui/mirror/features/dialogs/session.ts +186 -0
- package/packages/daemon/src/tui/mirror/features/files/feature.tsx +54 -0
- package/packages/daemon/src/tui/mirror/features/files/session.ts +694 -0
- package/packages/daemon/src/tui/mirror/features/home/feature.tsx +172 -0
- package/packages/daemon/src/tui/mirror/features/missions-activity/contract.ts +106 -0
- package/packages/daemon/src/tui/mirror/features/missions-activity/feature.tsx +19 -0
- package/packages/daemon/src/tui/mirror/features/missions-activity/session.ts +470 -0
- package/packages/daemon/src/tui/mirror/features/palette/contract.ts +121 -0
- package/packages/daemon/src/tui/mirror/features/palette/feature.ts +14 -0
- package/packages/daemon/src/tui/mirror/features/palette/session.ts +427 -0
- package/packages/daemon/src/tui/mirror/features/palette/surface.tsx +92 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/contract.ts +20 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/feature.tsx +8 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/session.ts +152 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/surface.tsx +137 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/asset-loader.ts +153 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/contract.ts +94 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/feature.tsx +141 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/session.ts +387 -0
- package/packages/daemon/src/tui/mirror/features/settings/catalog.ts +26 -0
- package/packages/daemon/src/tui/mirror/features/settings/contract.ts +41 -0
- package/packages/daemon/src/tui/mirror/features/settings/feature.ts +3 -0
- package/packages/daemon/src/tui/mirror/features/settings/session.ts +375 -0
- package/packages/daemon/src/tui/mirror/files-surface-view.tsx +242 -0
- package/packages/daemon/src/tui/mirror/files-surface.ts +371 -0
- package/packages/daemon/src/tui/mirror/focus-projection.ts +113 -0
- package/packages/daemon/src/tui/mirror/frame-coalescer.ts +87 -0
- package/packages/daemon/src/tui/mirror/home-model.ts +1 -1
- package/packages/daemon/src/tui/mirror/home-surface-model.ts +440 -0
- package/packages/daemon/src/tui/mirror/home-surface.tsx +254 -0
- package/packages/daemon/src/tui/mirror/hosted.ts +87 -6
- package/packages/daemon/src/tui/mirror/input-lifecycle.ts +248 -0
- package/packages/daemon/src/tui/mirror/interaction-flow.ts +83 -0
- package/packages/daemon/src/tui/mirror/legacy/missions-workspace-loader.ts +117 -0
- package/packages/daemon/src/tui/mirror/menu-model.ts +1 -14
- package/packages/daemon/src/tui/mirror/missions-dashboard.ts +451 -0
- package/packages/daemon/src/tui/mirror/missions-render-fixtures.ts +371 -0
- package/packages/daemon/src/tui/mirror/missions-surface-controller.ts +530 -0
- package/packages/daemon/src/tui/mirror/missions-surface.tsx +434 -0
- package/packages/daemon/src/tui/mirror/missions-workspace.ts +1996 -0
- package/packages/daemon/src/tui/mirror/multiplexer-action-executor.ts +379 -0
- package/packages/daemon/src/tui/mirror/open-tui-pane-stream-socket.ts +47 -0
- package/packages/daemon/src/tui/mirror/open-tui-verified-routing.ts +83 -0
- package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +1335 -0
- package/packages/daemon/src/tui/mirror/palette-surface-adapter.ts +465 -0
- package/packages/daemon/src/tui/mirror/palette.ts +189 -28
- package/packages/daemon/src/tui/mirror/pane-frame-state.ts +209 -0
- package/packages/daemon/src/tui/mirror/pane-mirror.ts +133 -46
- package/packages/daemon/src/tui/mirror/pane-surface.tsx +702 -40
- package/packages/daemon/src/tui/mirror/panel-host-reactive.ts +17 -0
- package/packages/daemon/src/tui/mirror/panel-host.ts +384 -0
- package/packages/daemon/src/tui/mirror/perf-tap.ts +1 -148
- package/packages/daemon/src/tui/mirror/performance-events.ts +488 -0
- package/packages/daemon/src/tui/mirror/recipe-components.tsx +310 -0
- package/packages/daemon/src/tui/mirror/recipes-gallery.tsx +256 -0
- package/packages/daemon/src/tui/mirror/recipes.ts +543 -0
- package/packages/daemon/src/tui/mirror/reference-performance-trace.ts +726 -0
- package/packages/daemon/src/tui/mirror/renderer-commands.ts +344 -0
- package/packages/daemon/src/tui/mirror/resize-model.ts +74 -9
- package/packages/daemon/src/tui/mirror/resize-transaction.ts +342 -0
- package/packages/daemon/src/tui/mirror/rich-placement-projection.ts +173 -0
- package/packages/daemon/src/tui/mirror/runtime/__snapshots__/application-shell-view-renderer.test.tsx.snap +87 -0
- package/packages/daemon/src/tui/mirror/runtime/application-appearance-owner.ts +121 -0
- package/packages/daemon/src/tui/mirror/runtime/application-bootstrap.ts +118 -0
- package/packages/daemon/src/tui/mirror/runtime/application-entry.ts +194 -0
- package/packages/daemon/src/tui/mirror/runtime/application-generation-starter.ts +116 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-catalog-owner.ts +112 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-catalog.ts +440 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-control-binding.ts +143 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-control-capability.ts +46 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-presentation.ts +176 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-test-control.ts +313 -0
- package/packages/daemon/src/tui/mirror/runtime/application-input-readiness.ts +28 -0
- package/packages/daemon/src/tui/mirror/runtime/application-lifecycle.ts +374 -0
- package/packages/daemon/src/tui/mirror/runtime/application-optional-features.ts +25 -0
- package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +87 -0
- package/packages/daemon/src/tui/mirror/runtime/application-palette-input.ts +105 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-input.ts +43 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-owner.ts +43 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pending-terminal-input.ts +117 -0
- package/packages/daemon/src/tui/mirror/runtime/application-performance-log.ts +110 -0
- package/packages/daemon/src/tui/mirror/runtime/application-post-render-runtime.ts +163 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-configuration.ts +47 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-renderer.ts +32 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +506 -0
- package/packages/daemon/src/tui/mirror/runtime/application-session-focus-owner.ts +80 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-binding.ts +365 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-catalog.tsx +372 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-home.tsx +161 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-overlay-stack.tsx +42 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-overlays.tsx +154 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-sidebar.tsx +140 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-view.tsx +425 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-viewport.ts +18 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-frame-readiness-owner.ts +33 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-host-focus-owner.ts +36 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-input-ingress.ts +133 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +1630 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-palette-owner.ts +302 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-paste.ts +33 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-renderer-sources.ts +33 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-selection-owner.ts +218 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace-policy.ts +285 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace.tsx +1150 -0
- package/packages/daemon/src/tui/mirror/runtime/application-theme-repaint.ts +45 -0
- package/packages/daemon/src/tui/mirror/runtime/application-transient-note-owner.ts +42 -0
- package/packages/daemon/src/tui/mirror/runtime/bounded-performance-record-writer.ts +75 -0
- package/packages/daemon/src/tui/mirror/runtime/causal-cell-client-ledger.ts +394 -0
- package/packages/daemon/src/tui/mirror/runtime/causal-cell-input-fixture.ts +55 -0
- package/packages/daemon/src/tui/mirror/runtime/changes-deferred-identity.ts +34 -0
- package/packages/daemon/src/tui/mirror/runtime/daemon-authority-rebind.ts +163 -0
- package/packages/daemon/src/tui/mirror/runtime/deferred-intent-queue.ts +45 -0
- package/packages/daemon/src/tui/mirror/runtime/editor-primitives.ts +56 -0
- package/packages/daemon/src/tui/mirror/runtime/file-content-primitives.ts +8 -0
- package/packages/daemon/src/tui/mirror/runtime/fleet-lifecycle-client.ts +61 -0
- package/packages/daemon/src/tui/mirror/runtime/focus-framebuffer-projection.ts +71 -0
- package/packages/daemon/src/tui/mirror/runtime/generation-bound-slot.ts +23 -0
- package/packages/daemon/src/tui/mirror/runtime/host-local-tmux-adapter.ts +105 -0
- package/packages/daemon/src/tui/mirror/runtime/hosted-tty-size-bridge.ts +213 -0
- package/packages/daemon/src/tui/mirror/runtime/latest-intent-fence.ts +22 -0
- package/packages/daemon/src/tui/mirror/runtime/local-view-controller.ts +95 -0
- package/packages/daemon/src/tui/mirror/runtime/modal-admission-coordinator.ts +158 -0
- package/packages/daemon/src/tui/mirror/runtime/modal-pointer-capture.ts +23 -0
- package/packages/daemon/src/tui/mirror/runtime/open-tui-generation-host.ts +996 -0
- package/packages/daemon/src/tui/mirror/runtime/open-tui-session-owner.ts +195 -0
- package/packages/daemon/src/tui/mirror/runtime/optional-feature-registry.ts +234 -0
- package/packages/daemon/src/tui/mirror/runtime/optional-feature-registry.typecheck.ts +14 -0
- package/packages/daemon/src/tui/mirror/runtime/palette-production-controller.ts +170 -0
- package/packages/daemon/src/tui/mirror/runtime/palette-production-overlay.tsx +65 -0
- package/packages/daemon/src/tui/mirror/runtime/pane-resize-geometry.ts +22 -0
- package/packages/daemon/src/tui/mirror/runtime/pane-scoped-terminal-surface.tsx +146 -0
- package/packages/daemon/src/tui/mirror/runtime/product-surface-policy.ts +16 -0
- package/packages/daemon/src/tui/mirror/runtime/renderer-cadence.ts +4 -0
- package/packages/daemon/src/tui/mirror/runtime/resize-terminal-pane.ts +134 -0
- package/packages/daemon/src/tui/mirror/runtime/rich-preview-demand.ts +26 -0
- package/packages/daemon/src/tui/mirror/runtime/rich-preview-overlay.tsx +54 -0
- package/packages/daemon/src/tui/mirror/runtime/runtime-layout-presentation.ts +119 -0
- package/packages/daemon/src/tui/mirror/runtime/select-terminal-pane.ts +127 -0
- package/packages/daemon/src/tui/mirror/runtime/semantic-pane-publication.ts +26 -0
- package/packages/daemon/src/tui/mirror/runtime/semantic-shell-viewport-resize.ts +78 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-dimensions-owner.ts +20 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.ts +719 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-frame-readiness.ts +100 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-host-focus.ts +519 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-host-frame-diagnostics.ts +47 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-input-adapter.ts +69 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-layout-projection.ts +45 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-pane-input-router.ts +94 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-selection.ts +218 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-session-handoff.ts +143 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-tool-readiness.ts +72 -0
- package/packages/daemon/src/tui/mirror/runtime/tool-resource-controller.ts +799 -0
- package/packages/daemon/src/tui/mirror/runtime/tool-resource-projection.ts +223 -0
- package/packages/daemon/src/tui/mirror/runtime/viewport-fit-coordinator.ts +12 -0
- package/packages/daemon/src/tui/mirror/runtime/workspace-terminal-fast-lane.ts +597 -0
- package/packages/daemon/src/tui/mirror/selection.ts +0 -21
- package/packages/daemon/src/tui/mirror/semantic-pane-render-source.ts +767 -0
- package/packages/daemon/src/tui/mirror/semantic-session-view.ts +366 -0
- package/packages/daemon/src/tui/mirror/settings-model.ts +24 -66
- package/packages/daemon/src/tui/mirror/shell-chrome-view.tsx +346 -0
- package/packages/daemon/src/tui/mirror/shell-chrome.ts +508 -0
- package/packages/daemon/src/tui/mirror/sidebar.tsx +138 -35
- package/packages/daemon/src/tui/mirror/size-truth.ts +1 -1
- package/packages/daemon/src/tui/mirror/terminal-surface.ts +157 -0
- package/packages/daemon/src/tui/mirror/terminal-surface.tsx +84 -0
- package/packages/daemon/src/tui/mirror/terminal-text.ts +42 -0
- package/packages/daemon/src/tui/mirror/theme.ts +1047 -33
- package/packages/daemon/src/tui/mirror/ui/agent-badge.tsx +41 -0
- package/packages/daemon/src/tui/mirror/ui/badge.tsx +42 -0
- package/packages/daemon/src/tui/mirror/ui/button.tsx +127 -0
- package/packages/daemon/src/tui/mirror/ui/dialog.tsx +45 -0
- package/packages/daemon/src/tui/mirror/ui/index.ts +59 -0
- package/packages/daemon/src/tui/mirror/ui/key-hint.tsx +63 -0
- package/packages/daemon/src/tui/mirror/ui/keyboard-router.tsx +72 -0
- package/packages/daemon/src/tui/mirror/ui/menu.tsx +68 -0
- package/packages/daemon/src/tui/mirror/ui/navigation-row.tsx +114 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-frame.tsx +115 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-host.tsx +71 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-list-row.tsx +59 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-model.ts +75 -0
- package/packages/daemon/src/tui/mirror/ui/state.ts +218 -0
- package/packages/daemon/src/tui/mirror/ui/status-bar.tsx +208 -0
- package/packages/daemon/src/tui/mirror/ui/surface.tsx +71 -0
- package/packages/daemon/src/tui/mirror/ui/tabs.tsx +168 -0
- package/packages/daemon/src/tui/mirror/widget-fallback.ts +66 -0
- package/packages/daemon/src/tui/mirror/widget-surface-model.ts +170 -0
- package/packages/daemon/src/tui/mirror/widget-surface.tsx +79 -0
- package/packages/daemon/src/tui/mirror/workspace/README.md +79 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/agent-terminal-canvas-renderer.test.tsx.snap +348 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/application-shell-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/command-palette-surface-renderer.test.tsx.snap +255 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/pane-frame-renderer.test.tsx.snap +525 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/workbench-shell-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas-view.tsx +61 -0
- package/packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas.ts +131 -0
- package/packages/daemon/src/tui/mirror/workspace/application-root-controller.ts +169 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell-controller.ts +430 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell-surface-commands.ts +64 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell-view.tsx +169 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell.ts +179 -0
- package/packages/daemon/src/tui/mirror/workspace/command-palette-surface-view.tsx +356 -0
- package/packages/daemon/src/tui/mirror/workspace/command-palette-surface.ts +544 -0
- package/packages/daemon/src/tui/mirror/workspace/icons.ts +56 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-action-menu.tsx +68 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-frame.ts +675 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-frame.tsx +490 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome-view.tsx +125 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome.ts +833 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-pane-header.tsx +225 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-window-strip.tsx +466 -0
- package/packages/daemon/src/tui/mirror/workspace/text.ts +28 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-controller.ts +75 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-dock-opentui.tsx +224 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-shell.ts +486 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-shell.tsx +95 -0
- package/packages/daemon/src/tui/mirror/workspace-ui-state.ts +1278 -0
- package/packages/daemon/src/tui/readiness.ts +52 -0
- package/packages/daemon/src/tui/team/entry.ts +23 -13
- package/packages/daemon/src/tui/team/home.ts +1 -1
- package/packages/daemon/src/tui/team/index.tsx +27 -8
- package/packages/daemon/src/tui/team/projects.ts +12 -0
- package/packages/daemon/src/tui/team/sessions.ts +43 -48
- package/packages/daemon/src/tui/team/wait-receipts.ts +192 -0
- package/packages/daemon/src/ui/pane-frame/fixture.ts +43 -0
- package/packages/daemon/src/ui/workbench-dock/fixture.ts +61 -0
- package/packages/daemon/src/validate.ts +21 -9
- package/packages/daemon/src/widgets/config/README.md +1 -1
- package/packages/daemon/src/widgets/config/index.tsx +15 -115
- package/packages/daemon/src/widgets/lib/watcher.ts +3 -130
- package/packages/daemon/src/widgets/resolve.ts +15 -7
- package/packages/daemon/src/widgets/setup/footer.tsx +0 -7
- package/packages/daemon/src/widgets/setup/index.tsx +18 -20
- package/packages/daemon/src/widgets/setup/review-panel.tsx +15 -10
- package/packages/daemon/src/widgets/setup/setup-model.ts +7 -10
- package/packages/daemon-client/package.json +42 -0
- package/packages/daemon-client/src/application-shell-session.test.ts +196 -0
- package/packages/daemon-client/src/application-shell-session.ts +450 -0
- package/packages/daemon-client/src/bootstrap-coordinator.test.ts +122 -0
- package/packages/daemon-client/src/bootstrap-coordinator.ts +293 -0
- package/packages/daemon-client/src/connection-supervisor.test.ts +109 -0
- package/packages/daemon-client/src/connection-supervisor.ts +216 -0
- package/packages/daemon-client/src/direct-application-shell-transport.test.ts +939 -0
- package/packages/daemon-client/src/direct-application-shell-transport.ts +1144 -0
- package/packages/daemon-client/src/first-latest-coordinator.test.ts +175 -0
- package/packages/daemon-client/src/first-latest-coordinator.ts +82 -0
- package/packages/daemon-client/src/generation-bound-store-timers.test.ts +74 -0
- package/packages/daemon-client/src/generation-bound-store.ts +908 -0
- package/packages/daemon-client/src/index.ts +25 -0
- package/packages/daemon-client/src/owner-action-client.test.ts +180 -0
- package/packages/daemon-client/src/owner-action-client.ts +113 -0
- package/packages/daemon-client/src/pane-stream-client.test.ts +2754 -0
- package/packages/daemon-client/src/pane-stream-client.ts +1665 -0
- package/packages/daemon-client/src/pane-stream-clock-calibration.test.ts +207 -0
- package/packages/daemon-client/src/pane-stream-clock-calibration.ts +161 -0
- package/packages/daemon-client/src/pane-stream-loopback-benchmark.test.ts +51 -0
- package/packages/daemon-client/src/push-resource-session.test.ts +509 -0
- package/packages/daemon-client/src/push-resource-session.ts +797 -0
- package/packages/daemon-client/src/resource-replica.test.ts +186 -0
- package/packages/daemon-client/src/resource-replica.ts +280 -0
- package/packages/daemon-client/src/runtime-resource-ledger.test.ts +18 -0
- package/packages/daemon-client/src/runtime-resource-ledger.ts +69 -0
- package/packages/daemon-client/src/terminal-fast-lane.test.ts +817 -0
- package/packages/daemon-client/src/terminal-fast-lane.ts +817 -0
- package/packages/daemon-client/src/terminal-fast-lane.typecheck.ts +16 -0
- package/packages/daemon-client/src/workspace-catalog-v2.test.ts +109 -0
- package/packages/daemon-client/src/workspace-catalog-v2.ts +66 -0
- package/packages/daemon-client/src/workspace-client-boundaries.test.ts +59 -0
- package/packages/daemon-client/src/workspace-client-conformance.ts +67 -0
- package/packages/daemon-client/src/workspace-client-operations.ts +203 -0
- package/packages/daemon-client/src/workspace-client-types.ts +302 -0
- package/packages/daemon-client/src/workspace-client.test.ts +2682 -0
- package/packages/daemon-client/src/workspace-client.ts +1432 -0
- package/packages/daemon-client/src/workspace-event-supervisor.test.ts +1086 -0
- package/packages/daemon-client/src/workspace-event-supervisor.ts +719 -0
- package/packages/daemon-client/src/workspace-pane-client.test.ts +80 -0
- package/packages/daemon-client/src/workspace-pane-client.ts +63 -0
- package/packages/presentation/package.json +28 -0
- package/packages/presentation/src/index.ts +2 -0
- package/packages/presentation/src/pane-frame/action-state.ts +72 -0
- package/packages/presentation/src/pane-frame/index.ts +3 -0
- package/packages/presentation/src/pane-frame/model.ts +517 -0
- package/packages/presentation/src/pane-frame/presenter.tsx +335 -0
- package/packages/presentation/src/pane-frame/web-entry.tsx +22 -0
- package/packages/presentation/src/pane-frame/web-host-unstyled.tsx +280 -0
- package/packages/presentation/src/pane-frame/web-host.css +388 -0
- package/packages/presentation/src/pane-frame/web-host.tsx +3 -0
- package/packages/presentation/src/presentation-contract.test.ts +63 -0
- package/packages/presentation/src/workbench-dock/index.ts +2 -0
- package/packages/presentation/src/workbench-dock/navigation.ts +54 -0
- package/packages/presentation/src/workbench-dock/presenter.tsx +252 -0
- package/packages/presentation/src/workbench-dock/web-entry.tsx +19 -0
- package/packages/presentation/src/workbench-dock/web-host-unstyled.tsx +198 -0
- package/packages/presentation/src/workbench-dock/web-host.css +204 -0
- package/packages/presentation/src/workbench-dock/web-host.tsx +3 -0
- package/packages/tmux-bridge/src/index.ts +9 -1
- package/packages/tmux-bridge/src/panes.ts +4 -0
- package/packages/tmux-bridge/src/runner.test.ts +72 -0
- package/packages/tmux-bridge/src/runner.ts +43 -2
- package/packages/tmux-bridge/src/sessions.ts +8 -1
- package/scripts/architecture-debt-budget.json +10 -0
- package/scripts/architecture-debt-inventory.mjs +98 -0
- package/scripts/build-cli.mjs +22 -1
- package/scripts/build-tui.mjs +59 -3
- package/scripts/check-control-bytes.mjs +70 -0
- package/scripts/dev-web.mjs +66 -0
- package/scripts/lib/bounded-child-command.mjs +59 -0
- package/scripts/lib/bounded-child-command.test.mjs +148 -0
- package/scripts/lib/bounded-diagnostic-tail.mjs +82 -0
- package/scripts/lib/bounded-diagnostic-tail.test.mjs +97 -0
- package/scripts/lib/npm-release-tag.mjs +27 -0
- package/scripts/lib/npm-release-tag.test.mjs +116 -0
- package/scripts/lib/packed-opentui-frame.mjs +18 -0
- package/scripts/lib/packed-opentui-frame.test.mjs +40 -0
- package/scripts/lib/performance-reference-budgets.mjs +36 -0
- package/scripts/lib/performance-reference-report.mjs +157 -0
- package/scripts/lib/performance-reference-report.test.mjs +62 -0
- package/scripts/lib/portable-performance-evidence.mjs +210 -0
- package/scripts/lib/portable-performance-evidence.test.mjs +208 -0
- package/scripts/lib/product-ansi-cursor-alt-screen-fixture.mjs +132 -0
- package/scripts/lib/product-ansi-cursor-alt-screen.mjs +4618 -0
- package/scripts/lib/product-ansi-cursor-alt-screen.test.mjs +4120 -0
- package/scripts/lib/product-ansi-tmux-precondition.mjs +159 -0
- package/scripts/lib/product-ansi-tmux-precondition.test.mjs +147 -0
- package/scripts/lib/product-card5-host-topology.mjs +873 -0
- package/scripts/lib/product-card5-host-topology.test.mjs +1070 -0
- package/scripts/lib/product-card5-production-host-owner.mjs +4864 -0
- package/scripts/lib/product-card5-production-host-owner.test.mjs +5051 -0
- package/scripts/lib/product-configless-owner.mjs +1578 -0
- package/scripts/lib/product-configless-owner.test.mjs +2169 -0
- package/scripts/lib/product-cross-client-handoff.mjs +1165 -0
- package/scripts/lib/product-cross-client-handoff.test.mjs +1062 -0
- package/scripts/lib/product-cross-client-host-evidence.mjs +4780 -0
- package/scripts/lib/product-cross-client-host-evidence.test.mjs +3897 -0
- package/scripts/lib/product-first-input.mjs +1546 -0
- package/scripts/lib/product-first-input.test.mjs +1731 -0
- package/scripts/lib/product-focus-tmux.mjs +46 -0
- package/scripts/lib/product-focus.mjs +1198 -0
- package/scripts/lib/product-focus.test.mjs +1504 -0
- package/scripts/lib/product-idle-process-proof.mjs +270 -0
- package/scripts/lib/product-idle-process-proof.test.mjs +210 -0
- package/scripts/lib/product-keyboard-pointer-resize.mjs +471 -0
- package/scripts/lib/product-keyboard-pointer-resize.test.mjs +363 -0
- package/scripts/lib/product-rig-causal-cell-fixture.mjs +91 -0
- package/scripts/lib/product-rig-causal-fixture-geometry.mjs +27 -0
- package/scripts/lib/product-rig-causal-fixture-geometry.test.mjs +45 -0
- package/scripts/lib/product-rig-sleep-assertion.mjs +179 -0
- package/scripts/lib/product-selection-copy-app-mouse.mjs +1585 -0
- package/scripts/lib/product-selection-copy-app-mouse.test.mjs +1602 -0
- package/scripts/lib/product-tui-host-readiness.mjs +133 -0
- package/scripts/lib/product-tui-host-readiness.test.mjs +258 -0
- package/scripts/lib/product-window-lifecycle.mjs +1351 -0
- package/scripts/lib/product-window-lifecycle.test.mjs +1305 -0
- package/scripts/lib/release-source-state.mjs +28 -0
- package/scripts/lib/release-source-state.test.mjs +26 -0
- package/scripts/lib/tui-diagnostics.mjs +159 -0
- package/scripts/lib/tui-host-publication.mjs +38 -0
- package/scripts/lib/tui-testdrive-clipboard-hook.mjs +543 -0
- package/scripts/lib/tui-testdrive-clipboard-hook.test.mjs +626 -0
- package/scripts/lib/tui-testdrive-input.mjs +1940 -0
- package/scripts/lib/tui-testdrive-input.test.mjs +3434 -0
- package/scripts/lib/tui-testdrive-launch.mjs +180 -0
- package/scripts/lib/tui-testdrive-launch.test.mjs +294 -0
- package/scripts/opentui-release-check.mjs +209 -0
- package/scripts/pack-check-run.mjs +1779 -30
- package/scripts/pack-tui-check.mjs +73 -0
- package/scripts/pack-web-check.mjs +19 -0
- package/scripts/performance-portable-evidence.mjs +419 -0
- package/scripts/performance-qualification.mjs +456 -0
- package/scripts/performance-reference-memory.ts +177 -0
- package/scripts/performance-reference-pane-stream.ts +74 -0
- package/scripts/performance-reference.mjs +681 -0
- package/scripts/postinstall.js +6 -5
- package/scripts/prepublish-opentui-check.mjs +24 -0
- package/scripts/product-test-rig-journeys.mjs +2700 -0
- package/scripts/product-test-rig-journeys.test.mjs +3959 -0
- package/scripts/product-test-rig-lib.mjs +2359 -0
- package/scripts/product-test-rig-multiclient.ts +434 -0
- package/scripts/product-test-rig-native-client.mjs +45 -0
- package/scripts/product-test-rig.mjs +20260 -0
- package/scripts/product-test-rig.test.mjs +3634 -0
- package/scripts/smoke-tui-missions.mjs +329 -0
- package/scripts/tui-diagnose.mjs +258 -0
- package/scripts/tui-diagnose.test.mjs +200 -0
- package/scripts/tui-testdrive-capture.test.mjs +161 -0
- package/scripts/tui-testdrive.mjs +1955 -0
- package/skill/SKILL.md +27 -28
- package/templates/agent-team-monorepo.yml +28 -30
- package/templates/agent-team-nextjs.yml +24 -26
- package/templates/agent-team.yml +24 -24
- package/templates/convex.yml +24 -16
- package/templates/default.yml +26 -21
- package/templates/go.yml +21 -14
- package/templates/missions.yml +25 -40
- package/templates/nextjs.yml +24 -16
- package/templates/python.yml +21 -14
- package/templates/vite.yml +21 -14
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +0 -34
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/PkgInfo +0 -1
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/AppIcon.icns +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +0 -139
- package/packages/daemon/dist/widgets/changes/index.jsx +0 -575
- package/packages/daemon/dist/widgets/config/index.d.ts +0 -1
- package/packages/daemon/dist/widgets/config/index.jsx +0 -395
- package/packages/daemon/dist/widgets/explorer/breadcrumbs.d.ts +0 -10
- package/packages/daemon/dist/widgets/explorer/breadcrumbs.jsx +0 -51
- package/packages/daemon/dist/widgets/explorer/footer.d.ts +0 -6
- package/packages/daemon/dist/widgets/explorer/footer.jsx +0 -11
- package/packages/daemon/dist/widgets/explorer/index.jsx +0 -393
- package/packages/daemon/dist/widgets/explorer/tree.d.ts +0 -13
- package/packages/daemon/dist/widgets/explorer/tree.jsx +0 -108
- package/packages/daemon/dist/widgets/lib/help-overlay.d.ts +0 -19
- package/packages/daemon/dist/widgets/lib/help-overlay.jsx +0 -69
- package/packages/daemon/dist/widgets/preview/index.jsx +0 -371
- package/packages/daemon/dist/widgets/setup/agent-naming.d.ts +0 -9
- package/packages/daemon/dist/widgets/setup/agent-naming.jsx +0 -81
- package/packages/daemon/dist/widgets/setup/config-tree.d.ts +0 -13
- package/packages/daemon/dist/widgets/setup/config-tree.jsx +0 -203
- package/packages/daemon/dist/widgets/setup/detect-panel.d.ts +0 -14
- package/packages/daemon/dist/widgets/setup/detect-panel.jsx +0 -48
- package/packages/daemon/dist/widgets/setup/field-editor.d.ts +0 -12
- package/packages/daemon/dist/widgets/setup/field-editor.jsx +0 -163
- package/packages/daemon/dist/widgets/setup/footer.d.ts +0 -17
- package/packages/daemon/dist/widgets/setup/footer.jsx +0 -64
- package/packages/daemon/dist/widgets/setup/index.d.ts +0 -1
- package/packages/daemon/dist/widgets/setup/index.jsx +0 -261
- package/packages/daemon/dist/widgets/setup/layout-picker.d.ts +0 -9
- package/packages/daemon/dist/widgets/setup/layout-picker.jsx +0 -69
- package/packages/daemon/dist/widgets/sidebar/index.jsx +0 -462
- package/packages/daemon/src/tui/mirror/control-client.ts +0 -214
- package/packages/daemon/src/tui/mirror/focus-border.ts +0 -57
- package/packages/daemon/src/tui/mirror/session-mirror.ts +0 -724
- package/packages/daemon/src/widgets/setup/orchestrator-panel.tsx +0 -200
- package/scripts/perf-mirror.mjs +0 -313
- package/scripts/verify-endpoints.sh +0 -90
- /package/packages/daemon/dist/{widgets/changes/index.d.ts → lib/__tests__/fixtures/workspace-state-writer.d.ts} +0 -0
- /package/packages/daemon/dist/{widgets/explorer/index.d.ts → terminal/mirror/trusted-inventory.js} +0 -0
- /package/packages/daemon/dist/{widgets/preview/index.d.ts → terminal/session-runtime/terminal-interpreter-backend.js} +0 -0
- /package/packages/daemon/dist/{widgets/sidebar/index.d.ts → tui/mirror/features/changes/contract.js} +0 -0
- /package/packages/daemon/src/{tui/mirror → terminal/protocol}/layout-parse.ts +0 -0
|
@@ -0,0 +1,2820 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionChannel — one control-mode channel serving every pane subscription
|
|
3
|
+
* of one tmux session (m43 card 1).
|
|
4
|
+
*
|
|
5
|
+
* Responsibilities, in the order the bytes see them:
|
|
6
|
+
*
|
|
7
|
+
* - ROUTING: `%output`/`%extended-output` bytes are keyed by runtime `%N`
|
|
8
|
+
* and fanned out to that pane's subscribers through their {@link PaneFeed}
|
|
9
|
+
* gates. Runtime ids never leave this module — the public surface
|
|
10
|
+
* (subscribe, describe, layout events) speaks semantic ids only.
|
|
11
|
+
* - IDENTITY: the descriptor discovery ({@link SessionDescriptorDiscovery})
|
|
12
|
+
* feeds the workspace-tmux-adapter reconciliation; stamps are untrusted
|
|
13
|
+
* until verified, generated ids become real only after their pane-local
|
|
14
|
+
* stamp-back succeeds, and duplicate stamps are ALL restamped.
|
|
15
|
+
* - SEED/RESEED: the atomic recipe (capture + cursor probe back-to-back on
|
|
16
|
+
* the control channel, discard-until-reply) via `commandInline`, whose
|
|
17
|
+
* callbacks fire synchronously in channel read order.
|
|
18
|
+
* - FLOW: `%pause` bookkeeping in the {@link FlowLedger}; sticky-pause
|
|
19
|
+
* recovery continues+reseeds EVERY backpressure-paused pane that still has
|
|
20
|
+
* an unfrozen subscriber; explicit freeze/thaw parks one pane without
|
|
21
|
+
* touching siblings.
|
|
22
|
+
* - LAYOUT: `%layout-change`/`%window-pane-changed`/`%session-window-changed`
|
|
23
|
+
* are applied synchronously in notification order (ahead of any output the
|
|
24
|
+
* server emitted after the layout), joined to semantic window/pane ids.
|
|
25
|
+
* - INPUT: literals coalesce per pane (measured 256-byte chunks) and named
|
|
26
|
+
* keys flush pending literals first — the shared {@link InputCoalescer}
|
|
27
|
+
* discipline — leaving fire-and-forget via the channel.
|
|
28
|
+
*/
|
|
29
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
30
|
+
import {
|
|
31
|
+
WORKSPACE_SEMANTIC_PANE_OPTION,
|
|
32
|
+
WORKSPACE_SEMANTIC_WINDOW_OPTION,
|
|
33
|
+
WorkspaceIdSchemaZ,
|
|
34
|
+
type WorkspacePaneRect,
|
|
35
|
+
} from "@tmux-ide/contracts";
|
|
36
|
+
import { textToHexKeys } from "../protocol/control.ts";
|
|
37
|
+
import { InputCoalescer } from "../protocol/input-coalescer.ts";
|
|
38
|
+
import type { InputAction } from "../protocol/input-coalescer.ts";
|
|
39
|
+
import {
|
|
40
|
+
parseLayout,
|
|
41
|
+
parseLayoutChange,
|
|
42
|
+
parseSessionWindowChanged,
|
|
43
|
+
parseWindowPaneChanged,
|
|
44
|
+
type ParsedLayout,
|
|
45
|
+
} from "../protocol/layout-parse.ts";
|
|
46
|
+
import {
|
|
47
|
+
SESSION_PANE_DESCRIPTOR_FORMAT,
|
|
48
|
+
SessionDescriptorDiscovery,
|
|
49
|
+
decodeControlReplyUtf8,
|
|
50
|
+
decodeTmuxArgument,
|
|
51
|
+
parseSessionPaneDescriptorReply,
|
|
52
|
+
type SessionPaneDescriptor,
|
|
53
|
+
} from "../protocol/session-descriptor-discovery.ts";
|
|
54
|
+
import { resolvePaneDisplayName } from "../protocol/pane-display-name.ts";
|
|
55
|
+
import {
|
|
56
|
+
finalizeWorkspaceTmuxReconciliation,
|
|
57
|
+
planWorkspaceTmuxReconciliation,
|
|
58
|
+
type WorkspaceTmuxPaneSnapshot,
|
|
59
|
+
type WorkspaceTmuxStampOutcome,
|
|
60
|
+
} from "../protocol/workspace-tmux-adapter.ts";
|
|
61
|
+
import type {
|
|
62
|
+
AtomicPaneSnapshotFailureReason,
|
|
63
|
+
AtomicPaneSnapshotProgress,
|
|
64
|
+
AtomicPaneSnapshotResult,
|
|
65
|
+
MirrorChannelHandlers,
|
|
66
|
+
MirrorChannelIo,
|
|
67
|
+
MirrorOutputTiming,
|
|
68
|
+
} from "./control-channel.ts";
|
|
69
|
+
import type {
|
|
70
|
+
MirrorDiagnostic,
|
|
71
|
+
MirrorLayoutAuthoritySnapshot,
|
|
72
|
+
MirrorLayoutEvent,
|
|
73
|
+
MirrorPaneEvent,
|
|
74
|
+
MirrorSessionDescription,
|
|
75
|
+
} from "./events.ts";
|
|
76
|
+
import { FlowLedger } from "./flow-ledger.ts";
|
|
77
|
+
import { PaneFeed } from "./pane-feed.ts";
|
|
78
|
+
import type {
|
|
79
|
+
TrustedMirrorPaneInventory,
|
|
80
|
+
TrustedMirrorSessionInventory,
|
|
81
|
+
} from "./trusted-inventory.ts";
|
|
82
|
+
import {
|
|
83
|
+
INTERNAL_READ_OPERATION_OPTION,
|
|
84
|
+
registerInternalReadOperation,
|
|
85
|
+
retireInternalReadOperation,
|
|
86
|
+
} from "../../lib/tmux-interaction-options.ts";
|
|
87
|
+
|
|
88
|
+
/** Notifications whose payload cannot be applied directly — fall back to the
|
|
89
|
+
* debounced truth sync (shared by all semantic terminal clients). */
|
|
90
|
+
const STRUCTURAL_NOTIFICATIONS = new Set([
|
|
91
|
+
"window-add",
|
|
92
|
+
"window-close",
|
|
93
|
+
"window-renamed",
|
|
94
|
+
"unlinked-window-close",
|
|
95
|
+
]);
|
|
96
|
+
const NATIVE_CLIENT_NOTIFICATIONS = new Set([
|
|
97
|
+
"client-attached",
|
|
98
|
+
"client-detached",
|
|
99
|
+
"client-resized",
|
|
100
|
+
"client-session-changed",
|
|
101
|
+
"subscription-changed",
|
|
102
|
+
]);
|
|
103
|
+
const NATIVE_CLIENT_SUBSCRIPTION = "tmux-ide-native-clients";
|
|
104
|
+
|
|
105
|
+
const DEFAULT_HISTORY_LINES = 2000;
|
|
106
|
+
const SYNC_DEBOUNCE_MS = 40;
|
|
107
|
+
/** Foreground-command labels follow output, but never turn a busy pane into a probe loop. */
|
|
108
|
+
const DISPLAY_NAME_SYNC_INTERVAL_MS = 750;
|
|
109
|
+
const RECOVERY_QUIET_MS = 40;
|
|
110
|
+
const RECOVERY_COMMAND_DEADLINE_MS = 500;
|
|
111
|
+
const RECOVERY_NO_PROGRESS_DEADLINE_MS = 3_000;
|
|
112
|
+
const RECOVERY_ABSOLUTE_DEADLINE_MS = 5_000;
|
|
113
|
+
const RECOVERY_MAX_ATTEMPTS = 4;
|
|
114
|
+
const RECOVERY_CAPTURE_MAX_BYTES = 16 * 1024 * 1024;
|
|
115
|
+
const RECOVERY_CAPTURE_MAX_LINES = 8_192;
|
|
116
|
+
const RECOVERY_CURSOR_MAX_BYTES = 1_024;
|
|
117
|
+
const MAX_CONTINUE_NOTIFICATION_QUEUE = 32;
|
|
118
|
+
const MAX_CONTINUE_NOTIFICATION_DEBT = 65_536;
|
|
119
|
+
const RECOVERY_CURSOR_PROBE_FORMAT = [
|
|
120
|
+
"#{cursor_x}",
|
|
121
|
+
"#{cursor_y}",
|
|
122
|
+
"#{pane_width}",
|
|
123
|
+
"#{pane_height}",
|
|
124
|
+
"#{alternate_on}",
|
|
125
|
+
"#{cursor_flag}",
|
|
126
|
+
"#{insert_flag}",
|
|
127
|
+
"#{keypad_cursor_flag}",
|
|
128
|
+
"#{keypad_flag}",
|
|
129
|
+
"#{mouse_any_flag}",
|
|
130
|
+
"#{mouse_button_flag}",
|
|
131
|
+
"#{mouse_standard_flag}",
|
|
132
|
+
"#{origin_flag}",
|
|
133
|
+
"#{wrap_flag}",
|
|
134
|
+
].join(" ");
|
|
135
|
+
|
|
136
|
+
export type MirrorFlowRecoveryPhase =
|
|
137
|
+
| "pause"
|
|
138
|
+
| "continue-request"
|
|
139
|
+
| "continue-reply"
|
|
140
|
+
| "continue-notify"
|
|
141
|
+
| "provisional-reseed"
|
|
142
|
+
| "final-continue-request"
|
|
143
|
+
| "final-continue-reply"
|
|
144
|
+
| "final-reseed"
|
|
145
|
+
| "confirmation-reseed"
|
|
146
|
+
| "converged"
|
|
147
|
+
| "nonconverged";
|
|
148
|
+
|
|
149
|
+
export type MirrorFlowRecoveryFailureReason =
|
|
150
|
+
| "command-error"
|
|
151
|
+
| "command-timeout"
|
|
152
|
+
| "notification-queue-overflow"
|
|
153
|
+
| "no-progress"
|
|
154
|
+
| "absolute-deadline"
|
|
155
|
+
| "attempts-exhausted";
|
|
156
|
+
|
|
157
|
+
export interface MirrorFlowRecoveryObservation {
|
|
158
|
+
readonly semanticPaneId: string;
|
|
159
|
+
readonly phase: MirrorFlowRecoveryPhase;
|
|
160
|
+
readonly recoveryOrdinal: number;
|
|
161
|
+
readonly paneIncarnation: number;
|
|
162
|
+
readonly outputOrdinal: number;
|
|
163
|
+
readonly failureReason: MirrorFlowRecoveryFailureReason | null;
|
|
164
|
+
/** Monotonic time from this recovery's start, bounded by its absolute lease. */
|
|
165
|
+
readonly elapsedMicros: number;
|
|
166
|
+
/** Private full-snapshot fingerprints never leave this module. */
|
|
167
|
+
readonly fingerprintExact: boolean | null;
|
|
168
|
+
readonly confirmationOrdinal: number;
|
|
169
|
+
readonly collectorStarted: boolean;
|
|
170
|
+
readonly collectorLastCompletedOrdinal: number;
|
|
171
|
+
readonly collectorCaptureLineCount: number;
|
|
172
|
+
readonly collectorCaptureByteCount: number;
|
|
173
|
+
readonly collectorContinueObserved: boolean;
|
|
174
|
+
readonly collectorStatusObserved: boolean;
|
|
175
|
+
readonly collectorObserverEmissionObserved: boolean;
|
|
176
|
+
readonly collectorFailureReason: AtomicPaneSnapshotFailureReason | null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface SessionChannelOptions {
|
|
180
|
+
session: string;
|
|
181
|
+
createIo: (handlers: MirrorChannelHandlers) => MirrorChannelIo;
|
|
182
|
+
historyLines?: number;
|
|
183
|
+
generatePaneId?: () => string;
|
|
184
|
+
generateWindowId?: () => string;
|
|
185
|
+
/** Debounce scheduler for the truth sync — injectable for tests. Returns a
|
|
186
|
+
* cancel function. */
|
|
187
|
+
scheduleSync?: (callback: () => void, delayMs: number) => () => void;
|
|
188
|
+
scheduleRecovery?: (callback: () => void, delayMs: number) => () => void;
|
|
189
|
+
recoveryNowMs?: () => number;
|
|
190
|
+
generateAtomicHookNonce?: () => string;
|
|
191
|
+
internalReadHookEmission?: (
|
|
192
|
+
runtimePaneId: string,
|
|
193
|
+
marker: string,
|
|
194
|
+
) => { readonly bufferName: string; readonly signalChannel: string; readonly record: string };
|
|
195
|
+
/** The channel died underneath us (tmux exited or detached the client). */
|
|
196
|
+
onExit?: () => void;
|
|
197
|
+
/** Event-driven proof that a non-control tmux client is actively attached. */
|
|
198
|
+
onNativeClientActivity?: () => void;
|
|
199
|
+
onInputWrite?: (
|
|
200
|
+
action: InputAction,
|
|
201
|
+
startedAtMicros: number,
|
|
202
|
+
endedAtMicros: number,
|
|
203
|
+
pendingBeforeSend: number,
|
|
204
|
+
) => void;
|
|
205
|
+
onInputAccepted?: (action: InputAction, acceptedAtMicros: number, ok: boolean) => void;
|
|
206
|
+
onOutputObserved?: (
|
|
207
|
+
semanticPaneId: string,
|
|
208
|
+
ageMs: number | null,
|
|
209
|
+
timing?: MirrorOutputTiming,
|
|
210
|
+
) => void;
|
|
211
|
+
onFlowRecoveryObserved?: (observation: MirrorFlowRecoveryObservation) => void;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface PaneSubscriptionHandle {
|
|
215
|
+
readonly semanticPaneId: string;
|
|
216
|
+
freeze(): void;
|
|
217
|
+
thaw(): void;
|
|
218
|
+
reseed(): void;
|
|
219
|
+
sendText(text: string): void;
|
|
220
|
+
sendKey(key: string): void;
|
|
221
|
+
close(): void;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface LayoutSubscriptionHandle {
|
|
225
|
+
close(): void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
interface SubRecord {
|
|
229
|
+
readonly feed: PaneFeed;
|
|
230
|
+
readonly onEvent: (event: MirrorPaneEvent) => void;
|
|
231
|
+
readonly onLayout: ((event: MirrorLayoutEvent) => void) | null;
|
|
232
|
+
pane: PaneRecord;
|
|
233
|
+
frozen: boolean;
|
|
234
|
+
closed: boolean;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
interface PaneRecord {
|
|
238
|
+
runtimeId: string;
|
|
239
|
+
semanticId: string;
|
|
240
|
+
descriptor: SessionPaneDescriptor | null;
|
|
241
|
+
active: boolean;
|
|
242
|
+
windowRuntimeId: string | null;
|
|
243
|
+
readonly subs: Set<SubRecord>;
|
|
244
|
+
incarnation: number;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface RecoveryRecord {
|
|
248
|
+
readonly ordinal: number;
|
|
249
|
+
readonly runtimeId: string;
|
|
250
|
+
readonly paneIncarnation: number;
|
|
251
|
+
readonly reason: "backpressure" | "requested";
|
|
252
|
+
readonly startedAtMs: number;
|
|
253
|
+
retired: boolean;
|
|
254
|
+
continueReply: boolean;
|
|
255
|
+
continueNotify: boolean;
|
|
256
|
+
stage: "continue" | "provisional" | "final-continue" | "quiet" | "final" | "confirm";
|
|
257
|
+
attempts: number;
|
|
258
|
+
reseedOrdinal: number;
|
|
259
|
+
outputOrdinal: number;
|
|
260
|
+
candidateFingerprint: string | null;
|
|
261
|
+
confirmationFingerprint: string | null;
|
|
262
|
+
confirmationOrdinal: number;
|
|
263
|
+
atomicCollectorNonce: string | null;
|
|
264
|
+
collectorStarted: boolean;
|
|
265
|
+
collectorLastCompletedOrdinal: number;
|
|
266
|
+
collectorCaptureLineCount: number;
|
|
267
|
+
collectorCaptureByteCount: number;
|
|
268
|
+
collectorContinueObserved: boolean;
|
|
269
|
+
collectorStatusObserved: boolean;
|
|
270
|
+
collectorObserverEmissionObserved: boolean;
|
|
271
|
+
collectorFailureReason: AtomicPaneSnapshotFailureReason | null;
|
|
272
|
+
cancelQuiet: (() => void) | null;
|
|
273
|
+
cancelCommandDeadline: (() => void) | null;
|
|
274
|
+
cancelNoProgressDeadline: (() => void) | null;
|
|
275
|
+
cancelAbsoluteDeadline: (() => void) | null;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface ReseedResult {
|
|
279
|
+
readonly ok: boolean;
|
|
280
|
+
readonly fingerprint: string | null;
|
|
281
|
+
readonly publish: () => boolean;
|
|
282
|
+
readonly hold: () => void;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const FAILED_RESEED_RESULT: ReseedResult = Object.freeze({
|
|
286
|
+
ok: false,
|
|
287
|
+
fingerprint: null,
|
|
288
|
+
publish: () => false,
|
|
289
|
+
hold: () => {},
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
function snapshotFingerprint(
|
|
293
|
+
captureLines: readonly string[],
|
|
294
|
+
cursorLine: string,
|
|
295
|
+
fallbackSize: { cols: number; rows: number } | null,
|
|
296
|
+
): string {
|
|
297
|
+
const hash = createHash("sha256");
|
|
298
|
+
const append = (bytes: Uint8Array): void => {
|
|
299
|
+
const length = Buffer.allocUnsafe(4);
|
|
300
|
+
length.writeUInt32BE(bytes.byteLength);
|
|
301
|
+
hash.update(length);
|
|
302
|
+
hash.update(bytes);
|
|
303
|
+
};
|
|
304
|
+
hash.update("tmux-ide/recovery-snapshot/v1\0");
|
|
305
|
+
const count = Buffer.allocUnsafe(4);
|
|
306
|
+
count.writeUInt32BE(captureLines.length);
|
|
307
|
+
hash.update(count);
|
|
308
|
+
for (const line of captureLines) append(Buffer.from(line, "latin1"));
|
|
309
|
+
append(Buffer.from(cursorLine, "utf8"));
|
|
310
|
+
append(
|
|
311
|
+
Buffer.from(
|
|
312
|
+
fallbackSize ? `${fallbackSize.cols}x${fallbackSize.rows}` : "no-layout-fallback",
|
|
313
|
+
"ascii",
|
|
314
|
+
),
|
|
315
|
+
);
|
|
316
|
+
return hash.digest("hex");
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function tmuxSingleQuote(value: string): string {
|
|
320
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
interface ContinueNotificationOwner {
|
|
324
|
+
readonly kind: "owner";
|
|
325
|
+
readonly recovery: RecoveryRecord;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
interface ContinueNotificationDebt {
|
|
329
|
+
readonly kind: "debt";
|
|
330
|
+
count: number;
|
|
331
|
+
saturated: boolean;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
type ContinueNotificationEntry = ContinueNotificationOwner | ContinueNotificationDebt;
|
|
335
|
+
|
|
336
|
+
interface WindowRecord {
|
|
337
|
+
runtimeId: string;
|
|
338
|
+
semanticId: string | null;
|
|
339
|
+
name: string | null;
|
|
340
|
+
paneBorderStatus: "top" | "bottom" | "off";
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
interface WindowSyncStage {
|
|
344
|
+
readonly windows: Map<string, WindowRecord>;
|
|
345
|
+
readonly layouts: Map<string, ParsedLayout & { zoomed: boolean }>;
|
|
346
|
+
readonly currentWindow: string;
|
|
347
|
+
readonly repairedIdentity: boolean;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function defaultMirrorPaneId(): string {
|
|
351
|
+
return `pane.mirror.${randomBytes(8).toString("hex")}`;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export function defaultMirrorWindowId(): string {
|
|
355
|
+
return `window.mirror.${randomBytes(8).toString("hex")}`;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export class SessionChannel {
|
|
359
|
+
private readonly opts: SessionChannelOptions;
|
|
360
|
+
private readonly io: MirrorChannelIo;
|
|
361
|
+
private readonly ledger = new FlowLedger();
|
|
362
|
+
private readonly discovery: SessionDescriptorDiscovery;
|
|
363
|
+
private readonly panesByRuntime = new Map<string, PaneRecord>();
|
|
364
|
+
private readonly panesBySemantic = new Map<string, PaneRecord>();
|
|
365
|
+
private readonly windowsByRuntime = new Map<string, WindowRecord>();
|
|
366
|
+
private readonly layoutByWindow = new Map<string, ParsedLayout & { zoomed: boolean }>();
|
|
367
|
+
private readonly activePaneByWindow = new Map<string, string>();
|
|
368
|
+
private readonly layoutSubscribers = new Set<(event: MirrorLayoutEvent) => void>();
|
|
369
|
+
private readonly layoutAuthoritySubscribers = new Set<
|
|
370
|
+
(snapshot: MirrorLayoutAuthoritySnapshot) => void
|
|
371
|
+
>();
|
|
372
|
+
private layoutTopologyEpoch = 0;
|
|
373
|
+
private readonly truthActive = new Map<string, boolean>();
|
|
374
|
+
private readonly truthWindow = new Map<string, string>();
|
|
375
|
+
private currentWindow = "";
|
|
376
|
+
private diagnostics: MirrorDiagnostic[] = [];
|
|
377
|
+
private degraded = false;
|
|
378
|
+
private readonly ageByRuntime = new Map<string, number>();
|
|
379
|
+
private maxAgeMs = 0;
|
|
380
|
+
private geometryParticipating = false;
|
|
381
|
+
private cancelSync: (() => void) | null = null;
|
|
382
|
+
private lastDisplayNameSyncAtMs = 0;
|
|
383
|
+
private disposed = false;
|
|
384
|
+
private nativeClientProbePending = false;
|
|
385
|
+
private windowAuthorityOrdinal = 0;
|
|
386
|
+
private paneIncarnation = 0;
|
|
387
|
+
private recoveryOrdinal = 0;
|
|
388
|
+
private readonly outputOrdinals = new Map<string, number>();
|
|
389
|
+
private readonly recoveries = new Map<string, RecoveryRecord>();
|
|
390
|
+
private readonly continueNotificationQueues = new Map<string, ContinueNotificationEntry[]>();
|
|
391
|
+
private trustedInventoryFlight: Promise<TrustedMirrorSessionInventory> | null = null;
|
|
392
|
+
private trustedInventoryFlightSessionId: string | null = null;
|
|
393
|
+
private attachedIdentity: { sessionName: string; runtimeSessionId: string } | null = null;
|
|
394
|
+
/** Settles once the FIRST identity join lands (or is proven impossible), so
|
|
395
|
+
* `start()` returns a channel whose semantic ids are subscribable. */
|
|
396
|
+
private resolveFirstJoin: (() => void) | null = null;
|
|
397
|
+
private readonly firstJoin = new Promise<void>((resolve) => {
|
|
398
|
+
this.resolveFirstJoin = resolve;
|
|
399
|
+
});
|
|
400
|
+
private readonly input = new InputCoalescer(
|
|
401
|
+
(action) => {
|
|
402
|
+
const startedAtMicros = action.traceIds?.length ? Math.floor(performance.now() * 1_000) : 0;
|
|
403
|
+
const pendingBeforeSend = action.traceIds?.length ? (this.io.pendingCount ?? 0) : 0;
|
|
404
|
+
const onReply = action.traceIds?.length
|
|
405
|
+
? (reply: { ok: boolean }) =>
|
|
406
|
+
this.opts.onInputAccepted?.(action, Math.floor(performance.now() * 1_000), reply.ok)
|
|
407
|
+
: undefined;
|
|
408
|
+
if (action.kind === "literal") {
|
|
409
|
+
this.io.send(
|
|
410
|
+
`send-keys -t ${action.pane} -H ${textToHexKeys(action.text).join(" ")}`,
|
|
411
|
+
onReply,
|
|
412
|
+
);
|
|
413
|
+
} else {
|
|
414
|
+
this.io.send(`send-keys -t ${action.pane} ${action.key}`, onReply);
|
|
415
|
+
}
|
|
416
|
+
if (action.traceIds?.length)
|
|
417
|
+
this.opts.onInputWrite?.(
|
|
418
|
+
action,
|
|
419
|
+
startedAtMicros,
|
|
420
|
+
Math.floor(performance.now() * 1_000),
|
|
421
|
+
pendingBeforeSend,
|
|
422
|
+
);
|
|
423
|
+
},
|
|
424
|
+
(flush) => queueMicrotask(flush),
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
constructor(opts: SessionChannelOptions) {
|
|
428
|
+
this.opts = opts;
|
|
429
|
+
this.io = opts.createIo({
|
|
430
|
+
onOutput: (pane, data, ageMs, timing) => this.onOutput(pane, data, ageMs, timing),
|
|
431
|
+
onNotify: (name, rest) => this.onNotify(name, rest),
|
|
432
|
+
onExit: () => this.onChannelExit(),
|
|
433
|
+
});
|
|
434
|
+
this.discovery = new SessionDescriptorDiscovery({
|
|
435
|
+
query: () =>
|
|
436
|
+
this.io.request(
|
|
437
|
+
`list-panes -s -t "${this.opts.session}" -F "${SESSION_PANE_DESCRIPTOR_FORMAT}"`,
|
|
438
|
+
),
|
|
439
|
+
onDescriptors: (descriptors, listed) => {
|
|
440
|
+
void this.reconcileIdentity(descriptors, listed).catch(() => {});
|
|
441
|
+
},
|
|
442
|
+
onStatus: (status) => {
|
|
443
|
+
if (status) {
|
|
444
|
+
this.pushDiagnostic({
|
|
445
|
+
code: `DESCRIPTOR_${status.status.toUpperCase()}`,
|
|
446
|
+
message: status.message,
|
|
447
|
+
degraded: status.degraded,
|
|
448
|
+
});
|
|
449
|
+
// Discovery gave up: identity will not improve on its own — let
|
|
450
|
+
// start() return the (degraded) channel rather than hang.
|
|
451
|
+
if (status.status === "failed") this.settleFirstJoin();
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
async start(): Promise<void> {
|
|
458
|
+
await this.io.start();
|
|
459
|
+
await this.captureAttachedSessionIdentity();
|
|
460
|
+
if (this.opts.onNativeClientActivity) {
|
|
461
|
+
// tmux does not guarantee `%client-attached` is broadcast to an
|
|
462
|
+
// existing control client. A format subscription is the documented,
|
|
463
|
+
// event-driven observation seam; its notification only schedules the
|
|
464
|
+
// coalesced list-clients proof below.
|
|
465
|
+
this.io.send(`refresh-client -B '${NATIVE_CLIENT_SUBSCRIPTION}::#{session_attached}'`);
|
|
466
|
+
}
|
|
467
|
+
await this.syncNow();
|
|
468
|
+
await this.firstJoin;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// ── Public surface (semantic ids only) ──────────────────────────────────
|
|
472
|
+
|
|
473
|
+
describe(): MirrorSessionDescription {
|
|
474
|
+
const panes = [...this.panesBySemantic.values()].map((pane) => {
|
|
475
|
+
const display = resolvePaneDisplayName({
|
|
476
|
+
semanticPaneId: pane.semanticId,
|
|
477
|
+
configuredName: pane.descriptor?.name,
|
|
478
|
+
configuredNameSource: pane.descriptor?.nameSource,
|
|
479
|
+
currentCommand: pane.descriptor?.currentCommand,
|
|
480
|
+
title: pane.descriptor?.title,
|
|
481
|
+
paneType: pane.descriptor?.type,
|
|
482
|
+
});
|
|
483
|
+
return {
|
|
484
|
+
semanticPaneId: pane.semanticId,
|
|
485
|
+
semanticWindowId: pane.windowRuntimeId
|
|
486
|
+
? (this.windowsByRuntime.get(pane.windowRuntimeId)?.semanticId ?? null)
|
|
487
|
+
: null,
|
|
488
|
+
role: pane.descriptor?.role ?? null,
|
|
489
|
+
paneType: pane.descriptor?.type ?? null,
|
|
490
|
+
currentCommand: pane.descriptor?.currentCommand ?? null,
|
|
491
|
+
cwd: pane.descriptor?.cwd ?? null,
|
|
492
|
+
title: pane.descriptor?.title ?? null,
|
|
493
|
+
displayName: display.name,
|
|
494
|
+
displayNameSource: display.source,
|
|
495
|
+
windowName: pane.descriptor?.windowName ?? null,
|
|
496
|
+
active: pane.active,
|
|
497
|
+
};
|
|
498
|
+
});
|
|
499
|
+
return {
|
|
500
|
+
session: this.opts.session,
|
|
501
|
+
panes,
|
|
502
|
+
diagnostics: [...this.diagnostics],
|
|
503
|
+
degraded: this.degraded,
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Strict daemon-internal inventory from this channel's current tmux truth.
|
|
509
|
+
* Unlike the background discovery path, this query awaits descriptor
|
|
510
|
+
* reconciliation before projecting and rejects incomplete identity rather
|
|
511
|
+
* than returning the previous descriptor snapshot.
|
|
512
|
+
*/
|
|
513
|
+
describeTrustedInventory(
|
|
514
|
+
expectedRuntimeSessionId: string,
|
|
515
|
+
): Promise<TrustedMirrorSessionInventory> {
|
|
516
|
+
if (this.disposed) {
|
|
517
|
+
return Promise.reject(new Error(`mirror session ${this.opts.session} is disposed`));
|
|
518
|
+
}
|
|
519
|
+
if (this.trustedInventoryFlight) {
|
|
520
|
+
return this.trustedInventoryFlightSessionId === expectedRuntimeSessionId
|
|
521
|
+
? this.trustedInventoryFlight
|
|
522
|
+
: Promise.reject(new Error(`trusted inventory identity changed for ${this.opts.session}`));
|
|
523
|
+
}
|
|
524
|
+
const flight = this.refreshTrustedInventory(expectedRuntimeSessionId).finally(() => {
|
|
525
|
+
if (this.trustedInventoryFlight === flight) {
|
|
526
|
+
this.trustedInventoryFlight = null;
|
|
527
|
+
this.trustedInventoryFlightSessionId = null;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
this.trustedInventoryFlight = flight;
|
|
531
|
+
this.trustedInventoryFlightSessionId = expectedRuntimeSessionId;
|
|
532
|
+
return flight;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/** Read-only proof of the session this control client is actually attached to. */
|
|
536
|
+
async attachedSessionIdentity(): Promise<{ sessionName: string; runtimeSessionId: string }> {
|
|
537
|
+
if (this.disposed) throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
538
|
+
if (!this.attachedIdentity)
|
|
539
|
+
throw new Error(`mirror session ${this.opts.session} identity is absent`);
|
|
540
|
+
return this.attachedIdentity;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
private async captureAttachedSessionIdentity(): Promise<void> {
|
|
544
|
+
const lines = await this.io.request(`display-message -p "#{qa:session_name}\t#{session_id}"`);
|
|
545
|
+
if (lines.length !== 1)
|
|
546
|
+
throw new Error(`mirror session ${this.opts.session} identity is absent`);
|
|
547
|
+
const decodedLine = decodeControlReplyUtf8(lines[0]!);
|
|
548
|
+
if (decodedLine === null)
|
|
549
|
+
throw new Error(`mirror session ${this.opts.session} identity is malformed`);
|
|
550
|
+
const [encodedName = "", runtimeSessionId = ""] = decodedLine.split("\t");
|
|
551
|
+
const sessionName = decodeTmuxArgument(encodedName);
|
|
552
|
+
if (
|
|
553
|
+
sessionName.length === 0 ||
|
|
554
|
+
sessionName.length > 160 ||
|
|
555
|
+
!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) ||
|
|
556
|
+
runtimeSessionId.length > 32
|
|
557
|
+
) {
|
|
558
|
+
throw new Error(`mirror session ${this.opts.session} identity is malformed`);
|
|
559
|
+
}
|
|
560
|
+
this.attachedIdentity = Object.freeze({ sessionName, runtimeSessionId });
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
subscribePane(
|
|
564
|
+
semanticPaneId: string,
|
|
565
|
+
onEvent: (event: MirrorPaneEvent) => void,
|
|
566
|
+
onLayout?: (event: MirrorLayoutEvent) => void,
|
|
567
|
+
): PaneSubscriptionHandle {
|
|
568
|
+
const pane = this.panesBySemantic.get(semanticPaneId);
|
|
569
|
+
if (!pane) {
|
|
570
|
+
throw new Error(`unknown semantic pane ${semanticPaneId} in session ${this.opts.session}`);
|
|
571
|
+
}
|
|
572
|
+
const sub: SubRecord = {
|
|
573
|
+
feed: new PaneFeed(),
|
|
574
|
+
onEvent,
|
|
575
|
+
onLayout: onLayout ?? null,
|
|
576
|
+
pane,
|
|
577
|
+
frozen: false,
|
|
578
|
+
closed: false,
|
|
579
|
+
};
|
|
580
|
+
pane.subs.add(sub);
|
|
581
|
+
// A paused pane gains an unfrozen watcher: release the park before the
|
|
582
|
+
// seed so the capture reflects a flowing pane.
|
|
583
|
+
const recoveryReason = this.ledger.isRequested(pane.runtimeId)
|
|
584
|
+
? "requested"
|
|
585
|
+
: this.ledger.isBackpressured(pane.runtimeId)
|
|
586
|
+
? "backpressure"
|
|
587
|
+
: null;
|
|
588
|
+
if (recoveryReason) this.beginRecovery(pane, recoveryReason);
|
|
589
|
+
else this.reseedPlain(sub);
|
|
590
|
+
this.emitLayoutSnapshot(sub);
|
|
591
|
+
return {
|
|
592
|
+
semanticPaneId,
|
|
593
|
+
freeze: () => this.freeze(sub),
|
|
594
|
+
thaw: () => this.thaw(sub),
|
|
595
|
+
reseed: () => this.reseedPlain(sub),
|
|
596
|
+
sendText: (text) => {
|
|
597
|
+
if (!sub.closed) this.input.literal(sub.pane.runtimeId, text);
|
|
598
|
+
},
|
|
599
|
+
sendKey: (key) => {
|
|
600
|
+
if (!sub.closed) this.input.key(sub.pane.runtimeId, key);
|
|
601
|
+
},
|
|
602
|
+
close: () => this.closeSub(sub),
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** Session geometry without a dummy pane feed or terminal-content seed. */
|
|
607
|
+
subscribeLayout(onLayout: (event: MirrorLayoutEvent) => void): LayoutSubscriptionHandle {
|
|
608
|
+
if (this.disposed) throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
609
|
+
this.layoutSubscribers.add(onLayout);
|
|
610
|
+
for (const windowRuntimeId of this.layoutByWindow.keys()) {
|
|
611
|
+
const event = this.layoutEventFor(windowRuntimeId);
|
|
612
|
+
if (event) onLayout(event);
|
|
613
|
+
}
|
|
614
|
+
let closed = false;
|
|
615
|
+
return {
|
|
616
|
+
close: () => {
|
|
617
|
+
if (closed) return;
|
|
618
|
+
closed = true;
|
|
619
|
+
this.layoutSubscribers.delete(onLayout);
|
|
620
|
+
},
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Refresh all session/window authority before exposing a global layout
|
|
626
|
+
* subscription. A cached control-mode channel may have been retained while
|
|
627
|
+
* only the current window had emitted geometry; replaying that cache would
|
|
628
|
+
* strand a multi-window renderer behind its exact inventory-coverage gate.
|
|
629
|
+
*/
|
|
630
|
+
async subscribeAuthoritativeLayout(
|
|
631
|
+
onLayout: (event: MirrorLayoutEvent) => void,
|
|
632
|
+
expectedSemanticPaneIds?: readonly string[],
|
|
633
|
+
onAuthority?: (snapshot: MirrorLayoutAuthoritySnapshot) => void,
|
|
634
|
+
): Promise<LayoutSubscriptionHandle> {
|
|
635
|
+
if (this.disposed) throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
636
|
+
const identity = await this.attachedSessionIdentity();
|
|
637
|
+
const inventory = await this.describeTrustedInventory(identity.runtimeSessionId);
|
|
638
|
+
if (this.disposed) throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
639
|
+
|
|
640
|
+
const expectedByWindow = new Map<string, Set<string>>();
|
|
641
|
+
for (const pane of inventory.panes) {
|
|
642
|
+
const expected = expectedByWindow.get(pane.runtimeWindowId) ?? new Set<string>();
|
|
643
|
+
expected.add(pane.semanticPaneId);
|
|
644
|
+
expectedByWindow.set(pane.runtimeWindowId, expected);
|
|
645
|
+
}
|
|
646
|
+
if (expectedSemanticPaneIds) {
|
|
647
|
+
const requested = [...expectedSemanticPaneIds].sort();
|
|
648
|
+
const authoritative = inventory.panes.map(({ semanticPaneId }) => semanticPaneId).sort();
|
|
649
|
+
if (
|
|
650
|
+
requested.length === 0 ||
|
|
651
|
+
new Set(requested).size !== requested.length ||
|
|
652
|
+
requested.length !== authoritative.length ||
|
|
653
|
+
requested.some((pane, index) => pane !== authoritative[index])
|
|
654
|
+
) {
|
|
655
|
+
const error = new Error(`authoritative layout for ${this.opts.session} changed topology`);
|
|
656
|
+
error.name = "MirrorTopologyChangedError";
|
|
657
|
+
throw error;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
if (
|
|
661
|
+
expectedByWindow.size !== inventory.panes[0]!.sessionWindowCount ||
|
|
662
|
+
expectedByWindow.size !== this.windowsByRuntime.size
|
|
663
|
+
) {
|
|
664
|
+
throw new Error(`authoritative layout for ${this.opts.session} has incomplete windows`);
|
|
665
|
+
}
|
|
666
|
+
for (const [runtimeWindowId, expectedPanes] of expectedByWindow) {
|
|
667
|
+
const event = this.layoutEventFor(runtimeWindowId);
|
|
668
|
+
if (!event)
|
|
669
|
+
throw new Error(`authoritative layout for ${this.opts.session} has incomplete panes`);
|
|
670
|
+
const observed = event.panes.flatMap(({ semanticPaneId }) =>
|
|
671
|
+
typeof semanticPaneId === "string" ? [semanticPaneId] : [],
|
|
672
|
+
);
|
|
673
|
+
if (
|
|
674
|
+
observed.length !== event.panes.length ||
|
|
675
|
+
observed.length !== expectedPanes.size ||
|
|
676
|
+
new Set(observed).size !== observed.length ||
|
|
677
|
+
observed.some((pane) => !expectedPanes.has(pane))
|
|
678
|
+
) {
|
|
679
|
+
throw new Error(`authoritative layout for ${this.opts.session} has incomplete panes`);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
const handle = this.subscribeLayout(onLayout);
|
|
683
|
+
if (onAuthority) {
|
|
684
|
+
this.layoutAuthoritySubscribers.add(onAuthority);
|
|
685
|
+
this.emitLayoutAuthorityTo(onAuthority, identity.runtimeSessionId);
|
|
686
|
+
}
|
|
687
|
+
return {
|
|
688
|
+
close: () => {
|
|
689
|
+
handle.close();
|
|
690
|
+
if (onAuthority) this.layoutAuthoritySubscribers.delete(onAuthority);
|
|
691
|
+
},
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** Controller-authorized input fast path. It deliberately reuses the one
|
|
696
|
+
* session InputCoalescer, so literal/key ordering and tmux application-mode
|
|
697
|
+
* named-key semantics are identical for GUI, TUI and direct subscribers. */
|
|
698
|
+
sendText(
|
|
699
|
+
semanticPaneId: string,
|
|
700
|
+
text: string,
|
|
701
|
+
performanceTraceId?: string,
|
|
702
|
+
isolated = false,
|
|
703
|
+
): void {
|
|
704
|
+
const pane = this.panesBySemantic.get(semanticPaneId);
|
|
705
|
+
if (!pane)
|
|
706
|
+
throw new Error(`unknown semantic pane ${semanticPaneId} in session ${this.opts.session}`);
|
|
707
|
+
if (isolated) this.input.flush();
|
|
708
|
+
this.input.literal(pane.runtimeId, text, performanceTraceId);
|
|
709
|
+
if (isolated) this.input.flush();
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
sendKey(semanticPaneId: string, key: string, performanceTraceId?: string): void {
|
|
713
|
+
const pane = this.panesBySemantic.get(semanticPaneId);
|
|
714
|
+
if (!pane)
|
|
715
|
+
throw new Error(`unknown semantic pane ${semanticPaneId} in session ${this.opts.session}`);
|
|
716
|
+
this.input.key(pane.runtimeId, key, performanceTraceId);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
fitViewport(cols: number, rows: number): void {
|
|
720
|
+
if (!Number.isSafeInteger(cols) || !Number.isSafeInteger(rows) || cols < 2 || rows < 2) {
|
|
721
|
+
throw new RangeError("viewport must contain positive bounded terminal cells");
|
|
722
|
+
}
|
|
723
|
+
this.input.flush();
|
|
724
|
+
this.io.send(`refresh-client -C ${cols}x${rows}`);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/** Toggle whether the retained control client participates in tmux sizing. */
|
|
728
|
+
setGeometryParticipation(active: boolean): void {
|
|
729
|
+
if (this.geometryParticipating === active) return;
|
|
730
|
+
this.geometryParticipating = active;
|
|
731
|
+
this.input.flush();
|
|
732
|
+
this.io.send(`refresh-client -f ${active ? "!ignore-size" : "ignore-size"}`);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
subscriberCount(): number {
|
|
736
|
+
let count = 0;
|
|
737
|
+
for (const pane of this.panesByRuntime.values()) count += pane.subs.size;
|
|
738
|
+
return count;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/** Fall-behind telemetry from the `%extended-output` age field. */
|
|
742
|
+
ageTelemetry(): { maxAgeMs: number; byPane: Record<string, number> } {
|
|
743
|
+
const byPane: Record<string, number> = {};
|
|
744
|
+
for (const [runtime, age] of this.ageByRuntime) {
|
|
745
|
+
const semantic = this.panesByRuntime.get(runtime)?.semanticId;
|
|
746
|
+
if (semantic) byPane[semantic] = age;
|
|
747
|
+
}
|
|
748
|
+
return { maxAgeMs: this.maxAgeMs, byPane };
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
flowSnapshot(): { backpressured: string[]; requested: string[] } {
|
|
752
|
+
const toSemantic = (runtime: string): string =>
|
|
753
|
+
this.panesByRuntime.get(runtime)?.semanticId ?? "(unidentified)";
|
|
754
|
+
const snapshot = this.ledger.snapshot();
|
|
755
|
+
return {
|
|
756
|
+
backpressured: snapshot.backpressured.map(toSemantic),
|
|
757
|
+
requested: snapshot.requested.map(toSemantic),
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
async dispose(): Promise<void> {
|
|
762
|
+
if (this.disposed) return;
|
|
763
|
+
this.disposed = true;
|
|
764
|
+
this.settleFirstJoin();
|
|
765
|
+
this.cancelSync?.();
|
|
766
|
+
this.cancelSync = null;
|
|
767
|
+
for (const runtime of [...this.recoveries.keys()]) this.cancelRecovery(runtime);
|
|
768
|
+
this.continueNotificationQueues.clear();
|
|
769
|
+
this.discovery.dispose();
|
|
770
|
+
this.input.flush();
|
|
771
|
+
for (const pane of this.panesByRuntime.values()) {
|
|
772
|
+
for (const sub of pane.subs) {
|
|
773
|
+
if (!sub.closed) {
|
|
774
|
+
sub.closed = true;
|
|
775
|
+
sub.onEvent({ type: "closed" });
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
pane.subs.clear();
|
|
779
|
+
}
|
|
780
|
+
this.layoutSubscribers.clear();
|
|
781
|
+
this.layoutAuthoritySubscribers.clear();
|
|
782
|
+
await this.io.dispose();
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// ── Byte routing ─────────────────────────────────────────────────────────
|
|
786
|
+
|
|
787
|
+
private onOutput(
|
|
788
|
+
runtimePane: string,
|
|
789
|
+
data: Uint8Array,
|
|
790
|
+
ageMs: number | null,
|
|
791
|
+
timing?: MirrorOutputTiming,
|
|
792
|
+
): void {
|
|
793
|
+
const now = Date.now();
|
|
794
|
+
if (now - this.lastDisplayNameSyncAtMs >= DISPLAY_NAME_SYNC_INTERVAL_MS) {
|
|
795
|
+
this.lastDisplayNameSyncAtMs = now;
|
|
796
|
+
this.scheduleSync();
|
|
797
|
+
}
|
|
798
|
+
if (ageMs !== null) {
|
|
799
|
+
this.ageByRuntime.set(runtimePane, ageMs);
|
|
800
|
+
if (ageMs > this.maxAgeMs) this.maxAgeMs = ageMs;
|
|
801
|
+
}
|
|
802
|
+
const pane = this.panesByRuntime.get(runtimePane);
|
|
803
|
+
if (!pane) return;
|
|
804
|
+
const outputOrdinal = (this.outputOrdinals.get(runtimePane) ?? 0) + 1;
|
|
805
|
+
this.outputOrdinals.set(runtimePane, outputOrdinal);
|
|
806
|
+
this.opts.onOutputObserved?.(pane.semanticId, ageMs, timing);
|
|
807
|
+
let overflowed = false;
|
|
808
|
+
for (const sub of pane.subs) {
|
|
809
|
+
if (sub.frozen || sub.closed) continue;
|
|
810
|
+
for (const event of sub.feed.delta(data)) sub.onEvent(event);
|
|
811
|
+
if (sub.feed.takeOverflowed()) overflowed = true;
|
|
812
|
+
}
|
|
813
|
+
if (overflowed) this.restartRecoveryAfterOutputOverflow(pane);
|
|
814
|
+
this.noteRecoveryOutput(pane, outputOrdinal);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// ── Seed / reseed (the atomic recipe) ────────────────────────────────────
|
|
818
|
+
|
|
819
|
+
private reseed(
|
|
820
|
+
sub: SubRecord,
|
|
821
|
+
onSettled?: (result: ReseedResult) => void,
|
|
822
|
+
deferPublish = false,
|
|
823
|
+
): void {
|
|
824
|
+
if (sub.closed || sub.frozen || this.disposed) {
|
|
825
|
+
onSettled?.(FAILED_RESEED_RESULT);
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
const runtime = sub.pane.runtimeId;
|
|
829
|
+
const epoch = sub.feed.beginReseed();
|
|
830
|
+
let settled = false;
|
|
831
|
+
let captureSucceeded = false;
|
|
832
|
+
let markerRetired = false;
|
|
833
|
+
let captureLines: readonly string[] | null = null;
|
|
834
|
+
const settle = (result: ReseedResult) => {
|
|
835
|
+
if (settled) return;
|
|
836
|
+
settled = true;
|
|
837
|
+
onSettled?.(result);
|
|
838
|
+
};
|
|
839
|
+
// Keystroke ordering: pending coalesced input leaves before the probes.
|
|
840
|
+
this.input.flush();
|
|
841
|
+
const history = this.opts.historyLines ?? DEFAULT_HISTORY_LINES;
|
|
842
|
+
const internalReadMarker = registerInternalReadOperation(runtime);
|
|
843
|
+
const retireMarker = (): void => {
|
|
844
|
+
if (markerRetired) return;
|
|
845
|
+
markerRetired = true;
|
|
846
|
+
this.retireInternalReadMarker(runtime, internalReadMarker);
|
|
847
|
+
};
|
|
848
|
+
// Both probes ride one write burst; the FIFO reply order is the seam.
|
|
849
|
+
this.io.commandListInline(
|
|
850
|
+
`set-option -p -t ${runtime} ${INTERNAL_READ_OPERATION_OPTION} ${internalReadMarker} ; capture-pane -p -e -J -S -${history} -t ${runtime}`,
|
|
851
|
+
2,
|
|
852
|
+
1,
|
|
853
|
+
(reply) => {
|
|
854
|
+
if (!reply.ok) {
|
|
855
|
+
// Successful captures consume the marker atomically inside the tmux
|
|
856
|
+
// after-capture-pane hook. The command-list also prevents a concurrent
|
|
857
|
+
// mirror from stealing the marker. Only failures need cleanup.
|
|
858
|
+
retireMarker();
|
|
859
|
+
sub.feed.abort(epoch);
|
|
860
|
+
settle(FAILED_RESEED_RESULT);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
captureSucceeded = true;
|
|
864
|
+
if (sub.closed || sub.frozen || this.disposed) {
|
|
865
|
+
sub.feed.abort(epoch);
|
|
866
|
+
settle(FAILED_RESEED_RESULT);
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
captureLines = [...reply.lines];
|
|
870
|
+
sub.feed.captureReply(epoch, reply.lines);
|
|
871
|
+
},
|
|
872
|
+
);
|
|
873
|
+
this.io.commandInline(
|
|
874
|
+
`display-message -p -t ${runtime} "${RECOVERY_CURSOR_PROBE_FORMAT}"`,
|
|
875
|
+
(reply) => {
|
|
876
|
+
if (sub.closed || sub.frozen || this.disposed) {
|
|
877
|
+
sub.feed.abort(epoch);
|
|
878
|
+
settle(FAILED_RESEED_RESULT);
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
if (!reply.ok) {
|
|
882
|
+
if (!captureSucceeded) retireMarker();
|
|
883
|
+
sub.feed.abort(epoch);
|
|
884
|
+
settle(FAILED_RESEED_RESULT);
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
const cursorLine = reply.lines[0] ?? "";
|
|
888
|
+
const fallbackSize = this.layoutSizeFor(runtime);
|
|
889
|
+
const events = sub.feed.cursorReply(epoch, cursorLine, fallbackSize);
|
|
890
|
+
let published = false;
|
|
891
|
+
const publish = (): boolean => {
|
|
892
|
+
if (published) return true;
|
|
893
|
+
if (sub.closed || sub.frozen || this.disposed) return false;
|
|
894
|
+
published = true;
|
|
895
|
+
for (const event of events) sub.onEvent(event);
|
|
896
|
+
return true;
|
|
897
|
+
};
|
|
898
|
+
const ok = events.length > 0 && !sub.closed && captureLines !== null;
|
|
899
|
+
const result = {
|
|
900
|
+
ok,
|
|
901
|
+
fingerprint: ok ? snapshotFingerprint(captureLines!, cursorLine, fallbackSize) : null,
|
|
902
|
+
publish,
|
|
903
|
+
hold: () => sub.feed.quarantine(epoch),
|
|
904
|
+
} satisfies ReseedResult;
|
|
905
|
+
if (!deferPublish) publish();
|
|
906
|
+
settle(result);
|
|
907
|
+
},
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
private reseedPlain(sub: SubRecord, resumeReason: "requested" | null = null): void {
|
|
912
|
+
this.reseed(sub, ({ ok }) => {
|
|
913
|
+
if (ok) {
|
|
914
|
+
if (resumeReason && !sub.closed && !sub.frozen)
|
|
915
|
+
sub.onEvent({ type: "flow", state: "resumed", reason: resumeReason });
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (
|
|
919
|
+
sub.closed ||
|
|
920
|
+
sub.frozen ||
|
|
921
|
+
this.disposed ||
|
|
922
|
+
this.recoveries.has(sub.pane.runtimeId) ||
|
|
923
|
+
this.panesByRuntime.get(sub.pane.runtimeId) !== sub.pane
|
|
924
|
+
)
|
|
925
|
+
return;
|
|
926
|
+
this.beginLocalOverflowRecovery(sub.pane);
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
private retireInternalReadMarker(runtime: string, marker: string): void {
|
|
931
|
+
if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtime))
|
|
932
|
+
throw new TypeError("internal read cleanup requires a runtime pane id");
|
|
933
|
+
retireInternalReadOperation(marker, runtime);
|
|
934
|
+
// Pane capture phases overlap under cancellation. Clear only the exact
|
|
935
|
+
// failed marker so a late A callback cannot erase the newer B authority.
|
|
936
|
+
this.io.send(
|
|
937
|
+
`if-shell -t ${runtime} -F "#{==:#{${INTERNAL_READ_OPERATION_OPTION}},${marker}}" ` +
|
|
938
|
+
`"set-option -pu -t ${runtime} ${INTERNAL_READ_OPERATION_OPTION}" ""`,
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
private layoutSizeFor(runtime: string): { cols: number; rows: number } | null {
|
|
943
|
+
for (const layout of this.layoutByWindow.values()) {
|
|
944
|
+
const leaf = layout.leaves.find((candidate) => candidate.id === runtime);
|
|
945
|
+
if (leaf) return { cols: leaf.width, rows: leaf.height };
|
|
946
|
+
}
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// ── Flow control ─────────────────────────────────────────────────────────
|
|
951
|
+
|
|
952
|
+
private freeze(sub: SubRecord): void {
|
|
953
|
+
if (sub.frozen || sub.closed) return;
|
|
954
|
+
sub.frozen = true;
|
|
955
|
+
sub.onEvent({ type: "flow", state: "paused", reason: "requested" });
|
|
956
|
+
const pane = sub.pane;
|
|
957
|
+
const allFrozen = [...pane.subs].every((candidate) => candidate.frozen || candidate.closed);
|
|
958
|
+
if (allFrozen) {
|
|
959
|
+
this.cancelRecovery(pane.runtimeId);
|
|
960
|
+
this.ledger.requestPause(pane.runtimeId);
|
|
961
|
+
this.io.send(`refresh-client -A '${pane.runtimeId}:pause'`);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
private thaw(sub: SubRecord): void {
|
|
966
|
+
if (!sub.frozen || sub.closed) return;
|
|
967
|
+
sub.frozen = false;
|
|
968
|
+
const runtime = sub.pane.runtimeId;
|
|
969
|
+
if (this.ledger.isRequested(runtime) || this.ledger.isBackpressured(runtime))
|
|
970
|
+
this.beginRecovery(sub.pane, "requested");
|
|
971
|
+
else this.reseedPlain(sub, "requested");
|
|
972
|
+
this.recoverSticky();
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
private continuePane(runtime: string): void {
|
|
976
|
+
this.io.send(`refresh-client -A '${runtime}:continue'`);
|
|
977
|
+
this.ledger.noteContinued(runtime);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
private scheduleRecovery(callback: () => void, delayMs: number): () => void {
|
|
981
|
+
if (this.opts.scheduleRecovery) return this.opts.scheduleRecovery(callback, delayMs);
|
|
982
|
+
const timer = setTimeout(callback, delayMs);
|
|
983
|
+
return () => clearTimeout(timer);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
private observeRecovery(
|
|
987
|
+
pane: PaneRecord,
|
|
988
|
+
recovery: RecoveryRecord,
|
|
989
|
+
phase: MirrorFlowRecoveryPhase,
|
|
990
|
+
failureReason: MirrorFlowRecoveryFailureReason | null = null,
|
|
991
|
+
fingerprintExact: boolean | null = null,
|
|
992
|
+
): void {
|
|
993
|
+
const elapsedMicros = Math.min(
|
|
994
|
+
RECOVERY_ABSOLUTE_DEADLINE_MS * 1_000,
|
|
995
|
+
Math.max(0, Math.floor((this.recoveryNowMs() - recovery.startedAtMs) * 1_000)),
|
|
996
|
+
);
|
|
997
|
+
this.opts.onFlowRecoveryObserved?.(
|
|
998
|
+
Object.freeze({
|
|
999
|
+
semanticPaneId: pane.semanticId,
|
|
1000
|
+
phase,
|
|
1001
|
+
recoveryOrdinal: recovery.ordinal,
|
|
1002
|
+
paneIncarnation: recovery.paneIncarnation,
|
|
1003
|
+
outputOrdinal: this.outputOrdinals.get(recovery.runtimeId) ?? 0,
|
|
1004
|
+
failureReason,
|
|
1005
|
+
elapsedMicros,
|
|
1006
|
+
fingerprintExact,
|
|
1007
|
+
confirmationOrdinal: recovery.confirmationOrdinal,
|
|
1008
|
+
collectorStarted: recovery.collectorStarted,
|
|
1009
|
+
collectorLastCompletedOrdinal: recovery.collectorLastCompletedOrdinal,
|
|
1010
|
+
collectorCaptureLineCount: recovery.collectorCaptureLineCount,
|
|
1011
|
+
collectorCaptureByteCount: recovery.collectorCaptureByteCount,
|
|
1012
|
+
collectorContinueObserved: recovery.collectorContinueObserved,
|
|
1013
|
+
collectorStatusObserved: recovery.collectorStatusObserved,
|
|
1014
|
+
collectorObserverEmissionObserved: recovery.collectorObserverEmissionObserved,
|
|
1015
|
+
collectorFailureReason: recovery.collectorFailureReason,
|
|
1016
|
+
}),
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
private recoveryNowMs(): number {
|
|
1021
|
+
return this.opts.recoveryNowMs?.() ?? performance.now();
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
private recoveryPane(recovery: RecoveryRecord): PaneRecord | null {
|
|
1025
|
+
const pane = this.panesByRuntime.get(recovery.runtimeId);
|
|
1026
|
+
return !this.disposed &&
|
|
1027
|
+
this.recoveries.get(recovery.runtimeId) === recovery &&
|
|
1028
|
+
pane?.incarnation === recovery.paneIncarnation
|
|
1029
|
+
? !recovery.retired
|
|
1030
|
+
? pane
|
|
1031
|
+
: null
|
|
1032
|
+
: null;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
private cancelRecovery(runtime: string): void {
|
|
1036
|
+
const recovery = this.recoveries.get(runtime);
|
|
1037
|
+
if (!recovery) return;
|
|
1038
|
+
recovery.retired = true;
|
|
1039
|
+
recovery.cancelQuiet?.();
|
|
1040
|
+
recovery.cancelCommandDeadline?.();
|
|
1041
|
+
recovery.cancelNoProgressDeadline?.();
|
|
1042
|
+
recovery.cancelAbsoluteDeadline?.();
|
|
1043
|
+
if (recovery.atomicCollectorNonce)
|
|
1044
|
+
this.io.retireAtomicPaneSnapshotCollector?.(recovery.atomicCollectorNonce, "retired");
|
|
1045
|
+
recovery.atomicCollectorNonce = null;
|
|
1046
|
+
this.recoveries.delete(runtime);
|
|
1047
|
+
this.retireContinueNotificationOwner(recovery);
|
|
1048
|
+
const pane = this.panesByRuntime.get(runtime);
|
|
1049
|
+
if (pane?.incarnation === recovery.paneIncarnation)
|
|
1050
|
+
for (const sub of pane.subs) sub.feed.abortCurrent();
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
private beginRecovery(pane: PaneRecord, reason: "backpressure" | "requested"): void {
|
|
1054
|
+
const runtime = pane.runtimeId;
|
|
1055
|
+
this.cancelRecovery(runtime);
|
|
1056
|
+
const recovery: RecoveryRecord = {
|
|
1057
|
+
ordinal: ++this.recoveryOrdinal,
|
|
1058
|
+
runtimeId: runtime,
|
|
1059
|
+
paneIncarnation: pane.incarnation,
|
|
1060
|
+
reason,
|
|
1061
|
+
startedAtMs: this.recoveryNowMs(),
|
|
1062
|
+
retired: false,
|
|
1063
|
+
continueReply: false,
|
|
1064
|
+
continueNotify: false,
|
|
1065
|
+
stage: "continue",
|
|
1066
|
+
attempts: 0,
|
|
1067
|
+
reseedOrdinal: 0,
|
|
1068
|
+
outputOrdinal: this.outputOrdinals.get(runtime) ?? 0,
|
|
1069
|
+
candidateFingerprint: null,
|
|
1070
|
+
confirmationFingerprint: null,
|
|
1071
|
+
confirmationOrdinal: 0,
|
|
1072
|
+
atomicCollectorNonce: null,
|
|
1073
|
+
collectorStarted: false,
|
|
1074
|
+
collectorLastCompletedOrdinal: -1,
|
|
1075
|
+
collectorCaptureLineCount: 0,
|
|
1076
|
+
collectorCaptureByteCount: 0,
|
|
1077
|
+
collectorContinueObserved: false,
|
|
1078
|
+
collectorStatusObserved: false,
|
|
1079
|
+
collectorObserverEmissionObserved: false,
|
|
1080
|
+
collectorFailureReason: null,
|
|
1081
|
+
cancelQuiet: null,
|
|
1082
|
+
cancelCommandDeadline: null,
|
|
1083
|
+
cancelNoProgressDeadline: null,
|
|
1084
|
+
cancelAbsoluteDeadline: null,
|
|
1085
|
+
};
|
|
1086
|
+
this.recoveries.set(runtime, recovery);
|
|
1087
|
+
for (const sub of pane.subs) {
|
|
1088
|
+
if (!sub.frozen && !sub.closed) sub.feed.abortCurrent();
|
|
1089
|
+
}
|
|
1090
|
+
this.observeRecovery(pane, recovery, "pause");
|
|
1091
|
+
this.observeRecovery(pane, recovery, "continue-request");
|
|
1092
|
+
recovery.cancelCommandDeadline = this.scheduleRecovery(() => {
|
|
1093
|
+
if (this.recoveryPane(recovery) && !recovery.continueReply)
|
|
1094
|
+
this.failRecovery(recovery, "command-timeout");
|
|
1095
|
+
}, RECOVERY_COMMAND_DEADLINE_MS);
|
|
1096
|
+
const queue = this.continueNotificationQueues.get(runtime) ?? [];
|
|
1097
|
+
if (queue.length >= MAX_CONTINUE_NOTIFICATION_QUEUE) {
|
|
1098
|
+
this.failRecovery(recovery, "notification-queue-overflow");
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
queue.push({ kind: "owner", recovery });
|
|
1102
|
+
this.continueNotificationQueues.set(runtime, queue);
|
|
1103
|
+
this.io.send(`refresh-client -A '${runtime}:continue'`, (reply) => {
|
|
1104
|
+
const current = this.recoveryPane(recovery);
|
|
1105
|
+
if (!reply.ok) {
|
|
1106
|
+
this.removeContinueNotificationOwner(recovery);
|
|
1107
|
+
if (current) this.failRecovery(recovery, "command-error");
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
recovery.continueReply = true;
|
|
1111
|
+
if (!current) {
|
|
1112
|
+
this.retireContinueNotificationOwner(recovery);
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
recovery.cancelCommandDeadline?.();
|
|
1116
|
+
recovery.cancelCommandDeadline = null;
|
|
1117
|
+
this.beginRecoveryConvergence(recovery);
|
|
1118
|
+
this.observeRecovery(current, recovery, "continue-reply");
|
|
1119
|
+
this.noteRecoveryProgress(recovery);
|
|
1120
|
+
this.beginFinalRecovery(recovery);
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
private beginLocalOverflowRecovery(pane: PaneRecord): void {
|
|
1125
|
+
const runtime = pane.runtimeId;
|
|
1126
|
+
this.cancelRecovery(runtime);
|
|
1127
|
+
const recovery: RecoveryRecord = {
|
|
1128
|
+
ordinal: ++this.recoveryOrdinal,
|
|
1129
|
+
runtimeId: runtime,
|
|
1130
|
+
paneIncarnation: pane.incarnation,
|
|
1131
|
+
reason: "backpressure",
|
|
1132
|
+
startedAtMs: this.recoveryNowMs(),
|
|
1133
|
+
retired: false,
|
|
1134
|
+
continueReply: true,
|
|
1135
|
+
continueNotify: true,
|
|
1136
|
+
stage: "continue",
|
|
1137
|
+
attempts: 0,
|
|
1138
|
+
reseedOrdinal: 0,
|
|
1139
|
+
outputOrdinal: this.outputOrdinals.get(runtime) ?? 0,
|
|
1140
|
+
candidateFingerprint: null,
|
|
1141
|
+
confirmationFingerprint: null,
|
|
1142
|
+
confirmationOrdinal: 0,
|
|
1143
|
+
atomicCollectorNonce: null,
|
|
1144
|
+
collectorStarted: false,
|
|
1145
|
+
collectorLastCompletedOrdinal: -1,
|
|
1146
|
+
collectorCaptureLineCount: 0,
|
|
1147
|
+
collectorCaptureByteCount: 0,
|
|
1148
|
+
collectorContinueObserved: false,
|
|
1149
|
+
collectorStatusObserved: false,
|
|
1150
|
+
collectorObserverEmissionObserved: false,
|
|
1151
|
+
collectorFailureReason: null,
|
|
1152
|
+
cancelQuiet: null,
|
|
1153
|
+
cancelCommandDeadline: null,
|
|
1154
|
+
cancelNoProgressDeadline: null,
|
|
1155
|
+
cancelAbsoluteDeadline: null,
|
|
1156
|
+
};
|
|
1157
|
+
this.recoveries.set(runtime, recovery);
|
|
1158
|
+
for (const sub of pane.subs) {
|
|
1159
|
+
if (!sub.frozen && !sub.closed)
|
|
1160
|
+
sub.onEvent({ type: "flow", state: "paused", reason: "backpressure" });
|
|
1161
|
+
}
|
|
1162
|
+
this.observeRecovery(pane, recovery, "pause");
|
|
1163
|
+
this.beginRecoveryConvergence(recovery);
|
|
1164
|
+
this.beginFinalRecovery(recovery);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
private beginRecoveryConvergence(recovery: RecoveryRecord): void {
|
|
1168
|
+
if (recovery.cancelAbsoluteDeadline) return;
|
|
1169
|
+
recovery.cancelAbsoluteDeadline = this.scheduleRecovery(() => {
|
|
1170
|
+
if (this.recoveryPane(recovery)) this.failRecovery(recovery, "absolute-deadline");
|
|
1171
|
+
}, RECOVERY_ABSOLUTE_DEADLINE_MS);
|
|
1172
|
+
this.noteRecoveryProgress(recovery);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
private noteRecoveryProgress(recovery: RecoveryRecord): void {
|
|
1176
|
+
if (!this.recoveryPane(recovery) || !recovery.cancelAbsoluteDeadline) return;
|
|
1177
|
+
recovery.cancelNoProgressDeadline?.();
|
|
1178
|
+
recovery.cancelNoProgressDeadline = this.scheduleRecovery(() => {
|
|
1179
|
+
if (this.recoveryPane(recovery)) this.failRecovery(recovery, "no-progress");
|
|
1180
|
+
}, RECOVERY_NO_PROGRESS_DEADLINE_MS);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
private noteAtomicCollectorProgress(
|
|
1184
|
+
recovery: RecoveryRecord,
|
|
1185
|
+
nonce: string,
|
|
1186
|
+
progress: AtomicPaneSnapshotProgress,
|
|
1187
|
+
): void {
|
|
1188
|
+
if (
|
|
1189
|
+
this.recoveryPane(recovery) === null ||
|
|
1190
|
+
recovery.atomicCollectorNonce !== nonce ||
|
|
1191
|
+
!progress.started
|
|
1192
|
+
)
|
|
1193
|
+
return;
|
|
1194
|
+
recovery.collectorStarted = true;
|
|
1195
|
+
recovery.collectorLastCompletedOrdinal = Math.max(
|
|
1196
|
+
recovery.collectorLastCompletedOrdinal,
|
|
1197
|
+
progress.lastCompletedOrdinal,
|
|
1198
|
+
);
|
|
1199
|
+
recovery.collectorCaptureLineCount = Math.max(
|
|
1200
|
+
recovery.collectorCaptureLineCount,
|
|
1201
|
+
progress.captureLineCount,
|
|
1202
|
+
);
|
|
1203
|
+
recovery.collectorCaptureByteCount = Math.max(
|
|
1204
|
+
recovery.collectorCaptureByteCount,
|
|
1205
|
+
progress.captureByteCount,
|
|
1206
|
+
);
|
|
1207
|
+
recovery.collectorContinueObserved ||= progress.continueObserved;
|
|
1208
|
+
recovery.collectorStatusObserved ||= progress.statusObserved;
|
|
1209
|
+
recovery.collectorObserverEmissionObserved ||= progress.observerEmissionObserved;
|
|
1210
|
+
this.noteRecoveryProgress(recovery);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
private reseedRecoverySubscribers(
|
|
1214
|
+
pane: PaneRecord,
|
|
1215
|
+
recovery: RecoveryRecord,
|
|
1216
|
+
done: (result: ReseedResult) => void,
|
|
1217
|
+
deferPublish = false,
|
|
1218
|
+
): void {
|
|
1219
|
+
if (this.io.armAtomicPaneSnapshotCollector && this.io.retireAtomicPaneSnapshotCollector) {
|
|
1220
|
+
this.reseedRecoverySubscribersAtomic(pane, recovery, done, deferPublish);
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
const live = [...pane.subs].filter((sub) => !sub.frozen && !sub.closed);
|
|
1224
|
+
if (live.length === 0) {
|
|
1225
|
+
done(FAILED_RESEED_RESULT);
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
const participants = live.map((sub) => Object.freeze({ sub, epoch: sub.feed.beginReseed() }));
|
|
1229
|
+
const reseedOrdinal = ++recovery.reseedOrdinal;
|
|
1230
|
+
let settled = false;
|
|
1231
|
+
let captureSucceeded = false;
|
|
1232
|
+
let markerRetired = false;
|
|
1233
|
+
let captureLines: readonly string[] | null = null;
|
|
1234
|
+
// One pane authority capture is enough for every subscriber. Per-feed
|
|
1235
|
+
// epochs still independently fence delivery, while membership is frozen
|
|
1236
|
+
// across both FIFO replies so no subscriber can join half a snapshot.
|
|
1237
|
+
this.input.flush();
|
|
1238
|
+
const history = this.opts.historyLines ?? DEFAULT_HISTORY_LINES;
|
|
1239
|
+
const internalReadMarker = registerInternalReadOperation(pane.runtimeId);
|
|
1240
|
+
const participantsExact = (): boolean => {
|
|
1241
|
+
if (
|
|
1242
|
+
this.recoveryPane(recovery) !== pane ||
|
|
1243
|
+
recovery.reseedOrdinal !== reseedOrdinal ||
|
|
1244
|
+
participants.some(
|
|
1245
|
+
({ sub }) => sub.closed || sub.frozen || sub.pane !== pane || !pane.subs.has(sub),
|
|
1246
|
+
)
|
|
1247
|
+
)
|
|
1248
|
+
return false;
|
|
1249
|
+
const current = [...pane.subs].filter((sub) => !sub.frozen && !sub.closed);
|
|
1250
|
+
return (
|
|
1251
|
+
current.length === participants.length &&
|
|
1252
|
+
current.every((sub) => participants.some((participant) => participant.sub === sub))
|
|
1253
|
+
);
|
|
1254
|
+
};
|
|
1255
|
+
const retireMarker = (): void => {
|
|
1256
|
+
if (markerRetired) return;
|
|
1257
|
+
markerRetired = true;
|
|
1258
|
+
this.retireInternalReadMarker(pane.runtimeId, internalReadMarker);
|
|
1259
|
+
};
|
|
1260
|
+
const fail = (): void => {
|
|
1261
|
+
if (settled) return;
|
|
1262
|
+
settled = true;
|
|
1263
|
+
if (!captureSucceeded) retireMarker();
|
|
1264
|
+
for (const { sub } of participants) sub.feed.abortCurrent();
|
|
1265
|
+
done(FAILED_RESEED_RESULT);
|
|
1266
|
+
};
|
|
1267
|
+
this.io.commandListInline(
|
|
1268
|
+
`set-option -p -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION} ${internalReadMarker} ; capture-pane -p -e -J -S -${history} -t ${pane.runtimeId}`,
|
|
1269
|
+
2,
|
|
1270
|
+
1,
|
|
1271
|
+
(reply) => {
|
|
1272
|
+
if (!reply.ok) {
|
|
1273
|
+
fail();
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
captureSucceeded = true;
|
|
1277
|
+
if (!participantsExact()) {
|
|
1278
|
+
fail();
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
captureLines = Object.freeze([...reply.lines]);
|
|
1282
|
+
for (const { sub, epoch } of participants) sub.feed.captureReply(epoch, captureLines);
|
|
1283
|
+
},
|
|
1284
|
+
);
|
|
1285
|
+
this.io.commandInline(
|
|
1286
|
+
`display-message -p -t ${pane.runtimeId} "${RECOVERY_CURSOR_PROBE_FORMAT}"`,
|
|
1287
|
+
(reply) => {
|
|
1288
|
+
if (settled) return;
|
|
1289
|
+
if (!participantsExact() || captureLines === null || !reply.ok) {
|
|
1290
|
+
fail();
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
const cursorLine = reply.lines[0] ?? "";
|
|
1294
|
+
const fallbackSize = this.layoutSizeFor(pane.runtimeId);
|
|
1295
|
+
const deliveries = participants.map(({ sub, epoch }) => ({
|
|
1296
|
+
sub,
|
|
1297
|
+
epoch,
|
|
1298
|
+
events: sub.feed.cursorReply(epoch, cursorLine, fallbackSize),
|
|
1299
|
+
}));
|
|
1300
|
+
if (!participantsExact() || deliveries.some(({ events }) => events.length === 0)) {
|
|
1301
|
+
fail();
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
let published = false;
|
|
1305
|
+
const publish = (): boolean => {
|
|
1306
|
+
if (published) return true;
|
|
1307
|
+
if (!participantsExact()) return false;
|
|
1308
|
+
published = true;
|
|
1309
|
+
for (const { sub, events } of deliveries) for (const event of events) sub.onEvent(event);
|
|
1310
|
+
return participantsExact();
|
|
1311
|
+
};
|
|
1312
|
+
if (!deferPublish && !publish()) {
|
|
1313
|
+
fail();
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
for (const { sub, epoch } of deliveries) sub.feed.quarantine(epoch);
|
|
1317
|
+
settled = true;
|
|
1318
|
+
done({
|
|
1319
|
+
ok: true,
|
|
1320
|
+
fingerprint: snapshotFingerprint(captureLines, cursorLine, fallbackSize),
|
|
1321
|
+
publish,
|
|
1322
|
+
hold: () => {},
|
|
1323
|
+
});
|
|
1324
|
+
},
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
private reseedRecoverySubscribersAtomic(
|
|
1329
|
+
pane: PaneRecord,
|
|
1330
|
+
recovery: RecoveryRecord,
|
|
1331
|
+
done: (result: ReseedResult) => void,
|
|
1332
|
+
deferPublish: boolean,
|
|
1333
|
+
): void {
|
|
1334
|
+
const live = [...pane.subs].filter((sub) => !sub.frozen && !sub.closed);
|
|
1335
|
+
if (live.length === 0) {
|
|
1336
|
+
done(FAILED_RESEED_RESULT);
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
const participants = live.map((sub) => Object.freeze({ sub, epoch: sub.feed.beginReseed() }));
|
|
1340
|
+
const reseedOrdinal = ++recovery.reseedOrdinal;
|
|
1341
|
+
const nonce = this.opts.generateAtomicHookNonce?.() ?? randomBytes(24).toString("hex");
|
|
1342
|
+
if (!/^[0-9a-f]{32,128}$/u.test(nonce)) {
|
|
1343
|
+
for (const { sub } of participants) sub.feed.abortCurrent();
|
|
1344
|
+
done(FAILED_RESEED_RESULT);
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
const hookName = `@tmux_ide_atomic_${nonce}`;
|
|
1348
|
+
const expectedName = `@tmux_ide_atomic_expected_${nonce}`;
|
|
1349
|
+
const ownerName = `@tmux_ide_atomic_owner_${nonce}`;
|
|
1350
|
+
const internalReadMarker = registerInternalReadOperation(pane.runtimeId);
|
|
1351
|
+
recovery.atomicCollectorNonce = nonce;
|
|
1352
|
+
recovery.collectorStarted = false;
|
|
1353
|
+
recovery.collectorLastCompletedOrdinal = -1;
|
|
1354
|
+
recovery.collectorCaptureLineCount = 0;
|
|
1355
|
+
recovery.collectorCaptureByteCount = 0;
|
|
1356
|
+
recovery.collectorContinueObserved = false;
|
|
1357
|
+
recovery.collectorStatusObserved = false;
|
|
1358
|
+
recovery.collectorObserverEmissionObserved = false;
|
|
1359
|
+
recovery.collectorFailureReason = null;
|
|
1360
|
+
const participantsExact = (): boolean => {
|
|
1361
|
+
if (
|
|
1362
|
+
this.recoveryPane(recovery) !== pane ||
|
|
1363
|
+
recovery.reseedOrdinal !== reseedOrdinal ||
|
|
1364
|
+
participants.some(
|
|
1365
|
+
({ sub }) => sub.closed || sub.frozen || sub.pane !== pane || !pane.subs.has(sub),
|
|
1366
|
+
)
|
|
1367
|
+
)
|
|
1368
|
+
return false;
|
|
1369
|
+
const current = [...pane.subs].filter((sub) => !sub.frozen && !sub.closed);
|
|
1370
|
+
return (
|
|
1371
|
+
current.length === participants.length &&
|
|
1372
|
+
current.every((sub) => participants.some((participant) => participant.sub === sub))
|
|
1373
|
+
);
|
|
1374
|
+
};
|
|
1375
|
+
let settled = false;
|
|
1376
|
+
let observerEmitted = false;
|
|
1377
|
+
const hookOwned = `#{==:#{${ownerName}},${nonce}}`;
|
|
1378
|
+
const hookUnchanged = `#{==:#{${hookName}},#{${expectedName}}}`;
|
|
1379
|
+
const cleanupHook = (): void => {
|
|
1380
|
+
this.io.commandListInline(
|
|
1381
|
+
`if-shell -t ${pane.runtimeId} -F "#{&&:${hookOwned},${hookUnchanged}}" ` +
|
|
1382
|
+
`${tmuxSingleQuote(`set-option -pu -t ${pane.runtimeId} ${hookName}`)} ` +
|
|
1383
|
+
tmuxSingleQuote(
|
|
1384
|
+
`display-message -p -t ${pane.runtimeId} tmux-ide-atomic-cleanup-hook-skip-v1:${nonce}`,
|
|
1385
|
+
),
|
|
1386
|
+
2,
|
|
1387
|
+
1,
|
|
1388
|
+
() => {},
|
|
1389
|
+
);
|
|
1390
|
+
this.io.commandListInline(
|
|
1391
|
+
`if-shell -t ${pane.runtimeId} -F "${hookOwned}" ` +
|
|
1392
|
+
tmuxSingleQuote(`set-option -pu -t ${pane.runtimeId} ${expectedName}`) +
|
|
1393
|
+
` ${tmuxSingleQuote(
|
|
1394
|
+
`display-message -p -t ${pane.runtimeId} tmux-ide-atomic-cleanup-expected-skip-v1:${nonce}`,
|
|
1395
|
+
)}`,
|
|
1396
|
+
2,
|
|
1397
|
+
1,
|
|
1398
|
+
() => {},
|
|
1399
|
+
);
|
|
1400
|
+
this.io.commandListInline(
|
|
1401
|
+
`if-shell -t ${pane.runtimeId} -F "${hookOwned}" ` +
|
|
1402
|
+
tmuxSingleQuote(`set-option -pu -t ${pane.runtimeId} ${ownerName}`) +
|
|
1403
|
+
` ${tmuxSingleQuote(
|
|
1404
|
+
`display-message -p -t ${pane.runtimeId} tmux-ide-atomic-cleanup-owner-skip-v1:${nonce}`,
|
|
1405
|
+
)}`,
|
|
1406
|
+
2,
|
|
1407
|
+
1,
|
|
1408
|
+
() => {},
|
|
1409
|
+
);
|
|
1410
|
+
};
|
|
1411
|
+
const fail = (statusObserved = false): void => {
|
|
1412
|
+
if (settled) return;
|
|
1413
|
+
settled = true;
|
|
1414
|
+
if (recovery.atomicCollectorNonce === nonce) recovery.atomicCollectorNonce = null;
|
|
1415
|
+
cleanupHook();
|
|
1416
|
+
if (!statusObserved && !observerEmitted)
|
|
1417
|
+
this.retireInternalReadMarker(pane.runtimeId, internalReadMarker);
|
|
1418
|
+
for (const { sub } of participants) sub.feed.abortCurrent();
|
|
1419
|
+
done(FAILED_RESEED_RESULT);
|
|
1420
|
+
};
|
|
1421
|
+
let observer: {
|
|
1422
|
+
readonly bufferName: string;
|
|
1423
|
+
readonly signalChannel: string;
|
|
1424
|
+
readonly record: string;
|
|
1425
|
+
} | null;
|
|
1426
|
+
try {
|
|
1427
|
+
observer = this.opts.internalReadHookEmission?.(pane.runtimeId, internalReadMarker) ?? null;
|
|
1428
|
+
} catch {
|
|
1429
|
+
fail();
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
const safeObserver =
|
|
1433
|
+
observer !== null &&
|
|
1434
|
+
/^[A-Za-z0-9._-]{1,256}$/u.test(observer.bufferName) &&
|
|
1435
|
+
/^[A-Za-z0-9._-]{1,256}$/u.test(observer.signalChannel) &&
|
|
1436
|
+
/^[A-Za-z0-9%:._|-]{1,1024}$/u.test(observer.record);
|
|
1437
|
+
if (!safeObserver) {
|
|
1438
|
+
fail();
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
const sentinel = (kind: string): string =>
|
|
1442
|
+
`display-message -p -t ${pane.runtimeId} ` + `"%tmux-ide-atomic-v1 ${nonce} ${kind}"`;
|
|
1443
|
+
const observerCommands =
|
|
1444
|
+
` ; set-buffer -a -b ${observer!.bufferName} ${observer!.record}` +
|
|
1445
|
+
` ; wait-for -S ${observer!.signalChannel}`;
|
|
1446
|
+
const body =
|
|
1447
|
+
`set-option -po -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION} ${internalReadMarker}` +
|
|
1448
|
+
` ; ${sentinel("start")}` +
|
|
1449
|
+
` ; capture-pane -p -e -J -S -${this.opts.historyLines ?? DEFAULT_HISTORY_LINES} -t ${pane.runtimeId}` +
|
|
1450
|
+
` ; ${sentinel("capture-end")}` +
|
|
1451
|
+
` ; display-message -p -t ${pane.runtimeId} "${RECOVERY_CURSOR_PROBE_FORMAT}"` +
|
|
1452
|
+
` ; ${sentinel("cursor-end")}` +
|
|
1453
|
+
` ; refresh-client -A ${pane.runtimeId}:continue` +
|
|
1454
|
+
observerCommands +
|
|
1455
|
+
` ; if-shell -t ${pane.runtimeId} -F ` +
|
|
1456
|
+
`"#{==:#{${INTERNAL_READ_OPERATION_OPTION}},${internalReadMarker}}" ` +
|
|
1457
|
+
tmuxSingleQuote(`set-option -pu -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION}`) +
|
|
1458
|
+
` ${tmuxSingleQuote(`${sentinel("marker-rejected")}`)}` +
|
|
1459
|
+
` ; ${sentinel("status-ok")}` +
|
|
1460
|
+
` ; set-option -pu -t ${pane.runtimeId} ${hookName}` +
|
|
1461
|
+
` ; ${sentinel("complete")}`;
|
|
1462
|
+
this.input.flush();
|
|
1463
|
+
const invoke = (reply: { ok: boolean }): void => {
|
|
1464
|
+
if (!reply.ok || !participantsExact()) {
|
|
1465
|
+
fail();
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
const remaining = Math.floor(
|
|
1469
|
+
RECOVERY_ABSOLUTE_DEADLINE_MS - (this.recoveryNowMs() - recovery.startedAtMs),
|
|
1470
|
+
);
|
|
1471
|
+
if (remaining <= 0) {
|
|
1472
|
+
fail();
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
const armed = this.io.armAtomicPaneSnapshotCollector!(
|
|
1476
|
+
{
|
|
1477
|
+
nonce,
|
|
1478
|
+
runtimePaneId: pane.runtimeId,
|
|
1479
|
+
maxCaptureBytes: RECOVERY_CAPTURE_MAX_BYTES,
|
|
1480
|
+
maxCaptureLines: RECOVERY_CAPTURE_MAX_LINES,
|
|
1481
|
+
maxCursorBytes: RECOVERY_CURSOR_MAX_BYTES,
|
|
1482
|
+
observerCommandCount: 2,
|
|
1483
|
+
onProgress: (progress) => this.noteAtomicCollectorProgress(recovery, nonce, progress),
|
|
1484
|
+
onSettled: (result: AtomicPaneSnapshotResult) => {
|
|
1485
|
+
if (recovery.atomicCollectorNonce === nonce) recovery.atomicCollectorNonce = null;
|
|
1486
|
+
recovery.collectorStarted ||= result.started;
|
|
1487
|
+
recovery.collectorLastCompletedOrdinal = Math.max(
|
|
1488
|
+
recovery.collectorLastCompletedOrdinal,
|
|
1489
|
+
result.lastCompletedOrdinal,
|
|
1490
|
+
);
|
|
1491
|
+
recovery.collectorCaptureLineCount = Math.max(
|
|
1492
|
+
recovery.collectorCaptureLineCount,
|
|
1493
|
+
result.captureLineCount,
|
|
1494
|
+
);
|
|
1495
|
+
recovery.collectorCaptureByteCount = Math.max(
|
|
1496
|
+
recovery.collectorCaptureByteCount,
|
|
1497
|
+
result.captureByteCount,
|
|
1498
|
+
);
|
|
1499
|
+
recovery.collectorContinueObserved ||= result.continueObserved;
|
|
1500
|
+
recovery.collectorStatusObserved ||= result.statusObserved;
|
|
1501
|
+
recovery.collectorObserverEmissionObserved ||= result.observerEmissionObserved;
|
|
1502
|
+
recovery.collectorFailureReason = result.failureReason;
|
|
1503
|
+
observerEmitted = result.observerEmissionObserved && safeObserver;
|
|
1504
|
+
cleanupHook();
|
|
1505
|
+
if (settled) return;
|
|
1506
|
+
if (!result.ok || !participantsExact() || result.cursorLine === null) {
|
|
1507
|
+
fail(result.statusObserved);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
const captureLines = Object.freeze([...result.captureLines]);
|
|
1511
|
+
for (const { sub, epoch } of participants) sub.feed.captureReply(epoch, captureLines);
|
|
1512
|
+
const fallbackSize = this.layoutSizeFor(pane.runtimeId);
|
|
1513
|
+
const deliveries = participants.map(({ sub, epoch }) => ({
|
|
1514
|
+
sub,
|
|
1515
|
+
epoch,
|
|
1516
|
+
events: sub.feed.cursorReply(epoch, result.cursorLine!, fallbackSize),
|
|
1517
|
+
}));
|
|
1518
|
+
if (!participantsExact() || deliveries.some(({ events }) => events.length === 0)) {
|
|
1519
|
+
fail(true);
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
let published = false;
|
|
1523
|
+
const publish = (): boolean => {
|
|
1524
|
+
if (published) return true;
|
|
1525
|
+
if (!participantsExact()) return false;
|
|
1526
|
+
published = true;
|
|
1527
|
+
for (const { sub, events } of deliveries)
|
|
1528
|
+
for (const event of events) sub.onEvent(event);
|
|
1529
|
+
return participantsExact();
|
|
1530
|
+
};
|
|
1531
|
+
if (!deferPublish && !publish()) {
|
|
1532
|
+
fail(true);
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
for (const { sub, epoch } of deliveries) sub.feed.quarantine(epoch);
|
|
1536
|
+
settled = true;
|
|
1537
|
+
done({
|
|
1538
|
+
ok: true,
|
|
1539
|
+
fingerprint: snapshotFingerprint(captureLines, result.cursorLine, fallbackSize),
|
|
1540
|
+
publish,
|
|
1541
|
+
hold: () => {},
|
|
1542
|
+
});
|
|
1543
|
+
},
|
|
1544
|
+
},
|
|
1545
|
+
remaining,
|
|
1546
|
+
);
|
|
1547
|
+
if (!armed) {
|
|
1548
|
+
fail();
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
const rejected = `tmux-ide-atomic-invoke-rejected-v1:${nonce}`;
|
|
1552
|
+
this.io.commandListInline(
|
|
1553
|
+
`if-shell -t ${pane.runtimeId} -F "#{&&:${hookOwned},${hookUnchanged}}" ` +
|
|
1554
|
+
`${tmuxSingleQuote(`set-hook -Rp -t ${pane.runtimeId} ${hookName}`)} ` +
|
|
1555
|
+
tmuxSingleQuote(`display-message -p -t ${pane.runtimeId} ${rejected}`),
|
|
1556
|
+
2,
|
|
1557
|
+
1,
|
|
1558
|
+
(hookReply) => {
|
|
1559
|
+
if (!hookReply.ok || hookReply.lines.length > 0) {
|
|
1560
|
+
this.io.retireAtomicPaneSnapshotCollector?.(nonce, "retired");
|
|
1561
|
+
fail();
|
|
1562
|
+
}
|
|
1563
|
+
},
|
|
1564
|
+
);
|
|
1565
|
+
};
|
|
1566
|
+
// Three owner-local create-only writes avoid a command-group partial-error
|
|
1567
|
+
// ambiguity: every accepted step has its own ordered reply and any later
|
|
1568
|
+
// failure can conditionally retire exactly the already-created prefix.
|
|
1569
|
+
this.io.commandInline(
|
|
1570
|
+
`set-option -po -t ${pane.runtimeId} ${ownerName} ${nonce}`,
|
|
1571
|
+
(ownerReply) => {
|
|
1572
|
+
if (!ownerReply.ok || !participantsExact()) {
|
|
1573
|
+
fail();
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
this.io.commandInline(
|
|
1577
|
+
`set-option -po -t ${pane.runtimeId} ${expectedName} ${tmuxSingleQuote(body)}`,
|
|
1578
|
+
(expectedReply) => {
|
|
1579
|
+
if (!expectedReply.ok || !participantsExact()) {
|
|
1580
|
+
fail();
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
this.io.commandInline(
|
|
1584
|
+
`set-option -po -t ${pane.runtimeId} ${hookName} ${tmuxSingleQuote(body)}`,
|
|
1585
|
+
invoke,
|
|
1586
|
+
);
|
|
1587
|
+
},
|
|
1588
|
+
);
|
|
1589
|
+
},
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
private armRecoveryQuiet(recovery: RecoveryRecord, callback: () => void): void {
|
|
1594
|
+
recovery.cancelQuiet?.();
|
|
1595
|
+
recovery.cancelQuiet = this.scheduleRecovery(() => {
|
|
1596
|
+
recovery.cancelQuiet = null;
|
|
1597
|
+
if (this.recoveryPane(recovery)) callback();
|
|
1598
|
+
}, RECOVERY_QUIET_MS);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
private beginFinalRecovery(recovery: RecoveryRecord): void {
|
|
1602
|
+
const pane = this.recoveryPane(recovery);
|
|
1603
|
+
if (!pane) return;
|
|
1604
|
+
if (recovery.attempts >= RECOVERY_MAX_ATTEMPTS) {
|
|
1605
|
+
this.failRecovery(recovery, "attempts-exhausted");
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
recovery.attempts += 1;
|
|
1609
|
+
recovery.stage = "final";
|
|
1610
|
+
this.noteRecoveryProgress(recovery);
|
|
1611
|
+
// The final read is only a private candidate. Publishing it here can put
|
|
1612
|
+
// expensive replica projection ahead of the confirmation timers and, more
|
|
1613
|
+
// importantly, exposes a snapshot that has not yet survived the two-read
|
|
1614
|
+
// authority proof.
|
|
1615
|
+
this.reseedRecoverySubscribers(
|
|
1616
|
+
pane,
|
|
1617
|
+
recovery,
|
|
1618
|
+
({ ok, fingerprint }) => {
|
|
1619
|
+
const current = this.recoveryPane(recovery);
|
|
1620
|
+
if (!current) return;
|
|
1621
|
+
if (!ok || fingerprint === null) {
|
|
1622
|
+
this.armRecoveryQuiet(recovery, () => this.beginFinalRecovery(recovery));
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
recovery.outputOrdinal = this.outputOrdinals.get(recovery.runtimeId) ?? 0;
|
|
1626
|
+
recovery.candidateFingerprint = fingerprint;
|
|
1627
|
+
recovery.confirmationFingerprint = null;
|
|
1628
|
+
recovery.confirmationOrdinal = 0;
|
|
1629
|
+
recovery.stage = "confirm";
|
|
1630
|
+
this.observeRecovery(current, recovery, "final-reseed");
|
|
1631
|
+
this.noteRecoveryProgress(recovery);
|
|
1632
|
+
this.armRecoveryQuiet(recovery, () => this.confirmRecovery(recovery));
|
|
1633
|
+
},
|
|
1634
|
+
true,
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
private confirmRecovery(recovery: RecoveryRecord): void {
|
|
1639
|
+
const pane = this.recoveryPane(recovery);
|
|
1640
|
+
if (!pane) return;
|
|
1641
|
+
if ((this.outputOrdinals.get(recovery.runtimeId) ?? 0) !== recovery.outputOrdinal) {
|
|
1642
|
+
this.beginFinalRecovery(recovery);
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
recovery.stage = "final";
|
|
1646
|
+
this.noteRecoveryProgress(recovery);
|
|
1647
|
+
this.reseedRecoverySubscribers(
|
|
1648
|
+
pane,
|
|
1649
|
+
recovery,
|
|
1650
|
+
({ ok, fingerprint, publish }) => {
|
|
1651
|
+
const current = this.recoveryPane(recovery);
|
|
1652
|
+
if (!current) return;
|
|
1653
|
+
if (!ok || fingerprint === null) {
|
|
1654
|
+
this.armRecoveryQuiet(recovery, () => this.beginFinalRecovery(recovery));
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
const outputOrdinal = this.outputOrdinals.get(recovery.runtimeId) ?? 0;
|
|
1658
|
+
const ordinalExact = outputOrdinal === recovery.outputOrdinal;
|
|
1659
|
+
const candidateExact = ordinalExact && fingerprint === recovery.candidateFingerprint;
|
|
1660
|
+
const consecutiveExact =
|
|
1661
|
+
candidateExact &&
|
|
1662
|
+
recovery.confirmationFingerprint !== null &&
|
|
1663
|
+
fingerprint === recovery.confirmationFingerprint;
|
|
1664
|
+
recovery.confirmationOrdinal += 1;
|
|
1665
|
+
this.observeRecovery(current, recovery, "confirmation-reseed", null, consecutiveExact);
|
|
1666
|
+
this.noteRecoveryProgress(recovery);
|
|
1667
|
+
if (!ordinalExact) {
|
|
1668
|
+
recovery.stage = "confirm";
|
|
1669
|
+
this.armRecoveryQuiet(recovery, () => this.beginFinalRecovery(recovery));
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
if (!candidateExact) {
|
|
1673
|
+
if (recovery.attempts >= RECOVERY_MAX_ATTEMPTS) {
|
|
1674
|
+
this.failRecovery(recovery, "attempts-exhausted");
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
// A changed confirmation replaces the private candidate without
|
|
1678
|
+
// becoming observable. Two subsequent reads must confirm this truth.
|
|
1679
|
+
recovery.attempts += 1;
|
|
1680
|
+
recovery.candidateFingerprint = fingerprint;
|
|
1681
|
+
recovery.confirmationFingerprint = null;
|
|
1682
|
+
recovery.outputOrdinal = outputOrdinal;
|
|
1683
|
+
recovery.stage = "confirm";
|
|
1684
|
+
this.armRecoveryQuiet(recovery, () => this.confirmRecovery(recovery));
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
if (!consecutiveExact) {
|
|
1688
|
+
recovery.confirmationFingerprint = fingerprint;
|
|
1689
|
+
recovery.outputOrdinal = outputOrdinal;
|
|
1690
|
+
recovery.stage = "confirm";
|
|
1691
|
+
this.armRecoveryQuiet(recovery, () => this.confirmRecovery(recovery));
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
// This publisher belongs to the current second matching read, not the
|
|
1695
|
+
// older candidate. Publish exactly once while every participant is
|
|
1696
|
+
// still fenced, then synchronously retire recovery before downstream
|
|
1697
|
+
// projection work can run.
|
|
1698
|
+
if (!publish()) {
|
|
1699
|
+
recovery.stage = "confirm";
|
|
1700
|
+
this.armRecoveryQuiet(recovery, () => this.beginFinalRecovery(recovery));
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
this.convergeRecovery(current, recovery);
|
|
1704
|
+
},
|
|
1705
|
+
true,
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
private convergeRecovery(pane: PaneRecord, recovery: RecoveryRecord): void {
|
|
1710
|
+
recovery.cancelCommandDeadline?.();
|
|
1711
|
+
recovery.cancelCommandDeadline = null;
|
|
1712
|
+
recovery.cancelNoProgressDeadline?.();
|
|
1713
|
+
recovery.cancelNoProgressDeadline = null;
|
|
1714
|
+
recovery.cancelAbsoluteDeadline?.();
|
|
1715
|
+
recovery.cancelAbsoluteDeadline = null;
|
|
1716
|
+
this.recoveries.delete(recovery.runtimeId);
|
|
1717
|
+
recovery.retired = true;
|
|
1718
|
+
this.retireContinueNotificationOwner(recovery);
|
|
1719
|
+
this.ledger.noteContinued(recovery.runtimeId);
|
|
1720
|
+
if (recovery.reason === "requested") this.ledger.clearRequest(recovery.runtimeId);
|
|
1721
|
+
for (const sub of pane.subs) {
|
|
1722
|
+
if (!sub.frozen && !sub.closed) {
|
|
1723
|
+
sub.feed.releaseQuarantine();
|
|
1724
|
+
sub.onEvent({ type: "flow", state: "resumed", reason: recovery.reason });
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
this.observeRecovery(pane, recovery, "converged", null, true);
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
private noteRecoveryOutput(pane: PaneRecord, outputOrdinal: number): void {
|
|
1731
|
+
const recovery = this.recoveries.get(pane.runtimeId);
|
|
1732
|
+
if (!recovery || recovery.paneIncarnation !== pane.incarnation) return;
|
|
1733
|
+
recovery.outputOrdinal = outputOrdinal;
|
|
1734
|
+
if (recovery.continueReply) this.noteRecoveryProgress(recovery);
|
|
1735
|
+
if (recovery.stage === "quiet")
|
|
1736
|
+
this.armRecoveryQuiet(recovery, () => this.beginFinalRecovery(recovery));
|
|
1737
|
+
else if (recovery.stage === "confirm")
|
|
1738
|
+
this.armRecoveryQuiet(recovery, () => this.beginFinalRecovery(recovery));
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
private restartRecoveryAfterOutputOverflow(pane: PaneRecord): void {
|
|
1742
|
+
const recovery = this.recoveries.get(pane.runtimeId);
|
|
1743
|
+
if (recovery?.paneIncarnation === pane.incarnation) {
|
|
1744
|
+
if (recovery.stage === "quiet" || recovery.stage === "confirm")
|
|
1745
|
+
this.armRecoveryQuiet(recovery, () => this.beginFinalRecovery(recovery));
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
this.beginLocalOverflowRecovery(pane);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
private failRecovery(
|
|
1752
|
+
recovery: RecoveryRecord,
|
|
1753
|
+
failureReason: MirrorFlowRecoveryFailureReason,
|
|
1754
|
+
): void {
|
|
1755
|
+
const pane = this.recoveryPane(recovery);
|
|
1756
|
+
if (!pane) return;
|
|
1757
|
+
recovery.cancelQuiet?.();
|
|
1758
|
+
recovery.cancelQuiet = null;
|
|
1759
|
+
recovery.cancelCommandDeadline?.();
|
|
1760
|
+
recovery.cancelCommandDeadline = null;
|
|
1761
|
+
recovery.cancelNoProgressDeadline?.();
|
|
1762
|
+
recovery.cancelNoProgressDeadline = null;
|
|
1763
|
+
recovery.cancelAbsoluteDeadline?.();
|
|
1764
|
+
recovery.cancelAbsoluteDeadline = null;
|
|
1765
|
+
recovery.retired = true;
|
|
1766
|
+
const collectorNonce = recovery.atomicCollectorNonce;
|
|
1767
|
+
recovery.atomicCollectorNonce = null;
|
|
1768
|
+
if (collectorNonce) this.io.retireAtomicPaneSnapshotCollector?.(collectorNonce, "retired");
|
|
1769
|
+
this.recoveries.delete(recovery.runtimeId);
|
|
1770
|
+
this.retireContinueNotificationOwner(recovery);
|
|
1771
|
+
for (const sub of pane.subs) sub.feed.abortCurrent();
|
|
1772
|
+
this.observeRecovery(pane, recovery, "nonconverged", failureReason);
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
private removeContinueNotificationOwner(recovery: RecoveryRecord): void {
|
|
1776
|
+
const queue = this.continueNotificationQueues.get(recovery.runtimeId);
|
|
1777
|
+
if (!queue) return;
|
|
1778
|
+
const index = queue.findIndex((entry) => entry.kind === "owner" && entry.recovery === recovery);
|
|
1779
|
+
if (index < 0) return;
|
|
1780
|
+
queue.splice(index, 1);
|
|
1781
|
+
this.compactContinueNotificationQueue(recovery.runtimeId, queue);
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
private retireContinueNotificationOwner(recovery: RecoveryRecord): void {
|
|
1785
|
+
if (!recovery.continueReply) return;
|
|
1786
|
+
const queue = this.continueNotificationQueues.get(recovery.runtimeId);
|
|
1787
|
+
if (!queue) return;
|
|
1788
|
+
const index = queue.findIndex((entry) => entry.kind === "owner" && entry.recovery === recovery);
|
|
1789
|
+
if (index < 0) return;
|
|
1790
|
+
queue.splice(index, 1, { kind: "debt", count: 1, saturated: false });
|
|
1791
|
+
this.compactContinueNotificationQueue(recovery.runtimeId, queue);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
private compactContinueNotificationQueue(
|
|
1795
|
+
runtime: string,
|
|
1796
|
+
queue: ContinueNotificationEntry[],
|
|
1797
|
+
): void {
|
|
1798
|
+
for (let index = 1; index < queue.length; ) {
|
|
1799
|
+
const previous = queue[index - 1];
|
|
1800
|
+
const current = queue[index];
|
|
1801
|
+
if (previous?.kind !== "debt" || current?.kind !== "debt") {
|
|
1802
|
+
index += 1;
|
|
1803
|
+
continue;
|
|
1804
|
+
}
|
|
1805
|
+
const total = previous.count + current.count;
|
|
1806
|
+
previous.count = Math.min(total, MAX_CONTINUE_NOTIFICATION_DEBT);
|
|
1807
|
+
previous.saturated =
|
|
1808
|
+
previous.saturated || current.saturated || total > MAX_CONTINUE_NOTIFICATION_DEBT;
|
|
1809
|
+
queue.splice(index, 1);
|
|
1810
|
+
}
|
|
1811
|
+
if (queue.length === 0) this.continueNotificationQueues.delete(runtime);
|
|
1812
|
+
else this.continueNotificationQueues.set(runtime, queue);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
/** Continue + reseed EVERY backpressure-paused pane that still has an
|
|
1816
|
+
* unfrozen subscriber. %pause is sticky and hits quiet panes after any
|
|
1817
|
+
* stall — recovering only the noisy pane leaves siblings dark. */
|
|
1818
|
+
private recoverSticky(): void {
|
|
1819
|
+
for (const runtime of this.ledger.stickyRecoverySet()) {
|
|
1820
|
+
if (this.recoveries.has(runtime)) continue;
|
|
1821
|
+
const pane = this.panesByRuntime.get(runtime);
|
|
1822
|
+
const live = pane ? [...pane.subs].filter((sub) => !sub.frozen && !sub.closed) : [];
|
|
1823
|
+
if (live.length === 0) continue; // nobody watching: staying paused is free
|
|
1824
|
+
this.beginRecovery(pane!, "backpressure");
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
private closeSub(sub: SubRecord): void {
|
|
1829
|
+
if (sub.closed) return;
|
|
1830
|
+
sub.closed = true;
|
|
1831
|
+
const pane = sub.pane;
|
|
1832
|
+
pane.subs.delete(sub);
|
|
1833
|
+
if ([...pane.subs].every((candidate) => candidate.closed || candidate.frozen))
|
|
1834
|
+
this.cancelRecovery(pane.runtimeId);
|
|
1835
|
+
// Ticket return on departure: a pane parked by a now-gone subscriber must
|
|
1836
|
+
// not stay paused forever.
|
|
1837
|
+
if (pane.subs.size === 0 && this.ledger.isRequested(pane.runtimeId)) {
|
|
1838
|
+
this.ledger.clearRequest(pane.runtimeId);
|
|
1839
|
+
this.continuePane(pane.runtimeId);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
// ── Notifications (channel order is the invariant) ──────────────────────
|
|
1844
|
+
|
|
1845
|
+
private onNotify(name: string, rest: string): void {
|
|
1846
|
+
if (
|
|
1847
|
+
name === "layout-change" ||
|
|
1848
|
+
name === "window-pane-changed" ||
|
|
1849
|
+
name === "session-window-changed" ||
|
|
1850
|
+
STRUCTURAL_NOTIFICATIONS.has(name)
|
|
1851
|
+
) {
|
|
1852
|
+
this.windowAuthorityOrdinal += 1;
|
|
1853
|
+
}
|
|
1854
|
+
// Layout changes remain a second honest wake-up: a native resize can arrive
|
|
1855
|
+
// before the once-per-second subscription notification. The inventory
|
|
1856
|
+
// (not either notification) remains the proof.
|
|
1857
|
+
if (
|
|
1858
|
+
this.opts.onNativeClientActivity &&
|
|
1859
|
+
(NATIVE_CLIENT_NOTIFICATIONS.has(name) || name === "layout-change")
|
|
1860
|
+
) {
|
|
1861
|
+
this.probeNativeClientActivity();
|
|
1862
|
+
}
|
|
1863
|
+
if (name === "pause") {
|
|
1864
|
+
const runtime = rest.trim().split(/\s+/)[0] ?? "";
|
|
1865
|
+
if (!runtime.startsWith("%")) return;
|
|
1866
|
+
this.cancelRecovery(runtime);
|
|
1867
|
+
this.ledger.notePause(runtime);
|
|
1868
|
+
const pane = this.panesByRuntime.get(runtime);
|
|
1869
|
+
if (pane) {
|
|
1870
|
+
for (const sub of pane.subs) {
|
|
1871
|
+
if (!sub.frozen && !sub.closed) {
|
|
1872
|
+
sub.onEvent({ type: "flow", state: "paused", reason: "backpressure" });
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
this.recoverSticky();
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
if (name === "continue") {
|
|
1880
|
+
const runtime = rest.trim().split(/\s+/)[0] ?? "";
|
|
1881
|
+
if (runtime.startsWith("%")) {
|
|
1882
|
+
const queue = this.continueNotificationQueues.get(runtime);
|
|
1883
|
+
const entry = queue?.[0] ?? null;
|
|
1884
|
+
if (entry?.kind === "debt") {
|
|
1885
|
+
if (!entry.saturated) {
|
|
1886
|
+
entry.count -= 1;
|
|
1887
|
+
if (entry.count === 0) queue!.shift();
|
|
1888
|
+
}
|
|
1889
|
+
this.compactContinueNotificationQueue(runtime, queue!);
|
|
1890
|
+
} else if (entry?.kind === "owner") {
|
|
1891
|
+
queue!.shift();
|
|
1892
|
+
this.compactContinueNotificationQueue(runtime, queue!);
|
|
1893
|
+
const owner = entry.recovery;
|
|
1894
|
+
const pane = this.recoveryPane(owner);
|
|
1895
|
+
owner.continueNotify = true;
|
|
1896
|
+
if (pane) {
|
|
1897
|
+
this.observeRecovery(pane, owner, "continue-notify");
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
if (name === "layout-change") {
|
|
1904
|
+
const change = parseLayoutChange(rest);
|
|
1905
|
+
if (!change) return;
|
|
1906
|
+
const parsed = parseLayout(change.visible);
|
|
1907
|
+
if (!parsed) {
|
|
1908
|
+
this.scheduleSync(); // never guess from a failed parse
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
this.layoutByWindow.set(change.windowId, { ...parsed, zoomed: change.zoomed });
|
|
1912
|
+
// Resync on BOTH structural deltas: an unknown leaf (new pane) and a
|
|
1913
|
+
// known pane of this window missing from the leaves (a killed pane in a
|
|
1914
|
+
// surviving window emits only %layout-change — without this, its
|
|
1915
|
+
// subscribers never receive `closed`). Closure itself still comes only
|
|
1916
|
+
// from the truth reply; a probe failure never reads as absence.
|
|
1917
|
+
const leafIds = new Set(parsed.leaves.map((leaf) => leaf.id));
|
|
1918
|
+
const knownPaneVanished = [...this.panesByRuntime.values()].some(
|
|
1919
|
+
(pane) => pane.windowRuntimeId === change.windowId && !leafIds.has(pane.runtimeId),
|
|
1920
|
+
);
|
|
1921
|
+
if (parsed.leaves.some((leaf) => !this.panesByRuntime.has(leaf.id)) || knownPaneVanished) {
|
|
1922
|
+
this.scheduleSync();
|
|
1923
|
+
}
|
|
1924
|
+
this.emitLayout(change.windowId);
|
|
1925
|
+
this.emitLayoutAuthority();
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
if (name === "window-pane-changed") {
|
|
1929
|
+
const change = parseWindowPaneChanged(rest);
|
|
1930
|
+
if (!change) return;
|
|
1931
|
+
this.activePaneByWindow.set(change.windowId, change.paneId);
|
|
1932
|
+
for (const pane of this.panesByRuntime.values()) {
|
|
1933
|
+
if (pane.windowRuntimeId === change.windowId)
|
|
1934
|
+
pane.active = pane.runtimeId === change.paneId;
|
|
1935
|
+
}
|
|
1936
|
+
this.emitLayout(change.windowId);
|
|
1937
|
+
this.emitLayoutAuthority();
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
if (name === "session-window-changed") {
|
|
1941
|
+
const change = parseSessionWindowChanged(rest);
|
|
1942
|
+
if (!change) return;
|
|
1943
|
+
const previous = this.currentWindow;
|
|
1944
|
+
this.currentWindow = change.windowId;
|
|
1945
|
+
if (previous === change.windowId) return;
|
|
1946
|
+
/*
|
|
1947
|
+
* Re-emit BOTH windows.
|
|
1948
|
+
*
|
|
1949
|
+
* `currentWindow` is carried on the layout frame, and this notification is
|
|
1950
|
+
* the only thing that changes it. Without a re-emit the flag stays as it
|
|
1951
|
+
* was until something else about a layout happens to move — so a view
|
|
1952
|
+
* whose window tabs come from these frames (m50) would keep marking the
|
|
1953
|
+
* window the user just left as the one they are in, indefinitely.
|
|
1954
|
+
*/
|
|
1955
|
+
if (previous) this.emitLayout(previous);
|
|
1956
|
+
this.emitLayout(change.windowId);
|
|
1957
|
+
this.emitLayoutAuthority();
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
if (STRUCTURAL_NOTIFICATIONS.has(name)) this.scheduleSync();
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
private probeNativeClientActivity(): void {
|
|
1964
|
+
if (this.nativeClientProbePending || this.disposed) return;
|
|
1965
|
+
this.nativeClientProbePending = true;
|
|
1966
|
+
void this.io
|
|
1967
|
+
.request(
|
|
1968
|
+
`list-clients -t "${this.opts.session}" -F "#{client_control_mode}\t#{client_activity}"`,
|
|
1969
|
+
)
|
|
1970
|
+
.then((lines) => {
|
|
1971
|
+
// The daemon's own mirror is a control-mode client. Only a tmux-owned
|
|
1972
|
+
// attached client (control mode = 0) is honest evidence for yielding
|
|
1973
|
+
// geometry; notification names alone can include our own lifecycle.
|
|
1974
|
+
if (lines.some((line) => /^0\t\d+$/u.test(line.trim()))) {
|
|
1975
|
+
this.opts.onNativeClientActivity?.();
|
|
1976
|
+
}
|
|
1977
|
+
})
|
|
1978
|
+
.catch(() => undefined)
|
|
1979
|
+
.finally(() => {
|
|
1980
|
+
this.nativeClientProbePending = false;
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
private emitLayout(windowRuntimeId: string): void {
|
|
1985
|
+
const event = this.layoutEventFor(windowRuntimeId);
|
|
1986
|
+
if (!event) return;
|
|
1987
|
+
for (const subscriber of this.layoutSubscribers) subscriber(event);
|
|
1988
|
+
for (const pane of this.panesByRuntime.values()) {
|
|
1989
|
+
if (pane.windowRuntimeId !== windowRuntimeId) continue;
|
|
1990
|
+
for (const sub of pane.subs) {
|
|
1991
|
+
if (!sub.closed && sub.onLayout) sub.onLayout(event);
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
private emitLayoutAuthority(): void {
|
|
1997
|
+
const runtimeSessionId = this.attachedIdentity?.runtimeSessionId;
|
|
1998
|
+
if (!runtimeSessionId || this.layoutAuthoritySubscribers.size === 0) return;
|
|
1999
|
+
this.layoutTopologyEpoch += 1;
|
|
2000
|
+
for (const subscriber of this.layoutAuthoritySubscribers)
|
|
2001
|
+
this.emitLayoutAuthorityTo(subscriber, runtimeSessionId);
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
private emitLayoutAuthorityTo(
|
|
2005
|
+
subscriber: (snapshot: MirrorLayoutAuthoritySnapshot) => void,
|
|
2006
|
+
runtimeSessionId: string,
|
|
2007
|
+
): void {
|
|
2008
|
+
const layouts = [...this.layoutByWindow.keys()]
|
|
2009
|
+
.map((runtimeId) => this.layoutEventFor(runtimeId))
|
|
2010
|
+
.filter((event): event is MirrorLayoutEvent => event !== null);
|
|
2011
|
+
subscriber({
|
|
2012
|
+
session: this.opts.session,
|
|
2013
|
+
runtimeSessionId,
|
|
2014
|
+
topologyEpoch: this.layoutTopologyEpoch,
|
|
2015
|
+
layouts,
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
/**
|
|
2020
|
+
* Hand ONE new subscriber the geometry of its owning window.
|
|
2021
|
+
*
|
|
2022
|
+
* Without it a subscriber's first layout frame arrives only when a layout
|
|
2023
|
+
* happens to change, so a view built from these frames opens empty and stays
|
|
2024
|
+
* empty until the user moves something — which reads as the app failing to
|
|
2025
|
+
* find the session's windows at all.
|
|
2026
|
+
*/
|
|
2027
|
+
private emitLayoutSnapshot(sub: SubRecord): void {
|
|
2028
|
+
if (!sub.onLayout) return;
|
|
2029
|
+
const windowRuntimeId = sub.pane.windowRuntimeId;
|
|
2030
|
+
if (windowRuntimeId === null) return;
|
|
2031
|
+
const event = this.layoutEventFor(windowRuntimeId);
|
|
2032
|
+
if (!sub.closed && event) sub.onLayout(event);
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
private layoutEventFor(windowRuntimeId: string): MirrorLayoutEvent | null {
|
|
2036
|
+
const layout = this.layoutByWindow.get(windowRuntimeId);
|
|
2037
|
+
if (!layout) return null;
|
|
2038
|
+
const windowRecord = this.windowsByRuntime.get(windowRuntimeId) ?? null;
|
|
2039
|
+
const activePane = this.activePaneByWindow.get(windowRuntimeId) ?? "";
|
|
2040
|
+
const event: MirrorLayoutEvent = {
|
|
2041
|
+
type: "layout",
|
|
2042
|
+
session: this.opts.session,
|
|
2043
|
+
semanticWindowId: windowRecord?.semanticId ?? null,
|
|
2044
|
+
windowName: windowRecord?.name ?? null,
|
|
2045
|
+
currentWindow: windowRuntimeId === this.currentWindow,
|
|
2046
|
+
cols: layout.width,
|
|
2047
|
+
rows: layout.height,
|
|
2048
|
+
zoomed: layout.zoomed,
|
|
2049
|
+
paneBorderStatus: windowRecord?.paneBorderStatus ?? "off",
|
|
2050
|
+
panes: layout.leaves.map((leaf) => {
|
|
2051
|
+
const pane = this.panesByRuntime.get(leaf.id) ?? null;
|
|
2052
|
+
const display = pane
|
|
2053
|
+
? resolvePaneDisplayName({
|
|
2054
|
+
semanticPaneId: pane.semanticId,
|
|
2055
|
+
configuredName: pane.descriptor?.name,
|
|
2056
|
+
configuredNameSource: pane.descriptor?.nameSource,
|
|
2057
|
+
currentCommand: pane.descriptor?.currentCommand,
|
|
2058
|
+
title: pane.descriptor?.title,
|
|
2059
|
+
paneType: pane.descriptor?.type,
|
|
2060
|
+
})
|
|
2061
|
+
: null;
|
|
2062
|
+
return {
|
|
2063
|
+
semanticPaneId: pane?.semanticId ?? null,
|
|
2064
|
+
displayName: display?.name ?? null,
|
|
2065
|
+
displayNameSource: display?.source ?? null,
|
|
2066
|
+
left: leaf.left,
|
|
2067
|
+
top: leaf.top,
|
|
2068
|
+
width: leaf.width,
|
|
2069
|
+
height: leaf.height,
|
|
2070
|
+
active: leaf.id === activePane,
|
|
2071
|
+
};
|
|
2072
|
+
}),
|
|
2073
|
+
};
|
|
2074
|
+
return event;
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
// ── Truth sync + identity join ───────────────────────────────────────────
|
|
2078
|
+
|
|
2079
|
+
private scheduleSync(): void {
|
|
2080
|
+
if (this.cancelSync || this.disposed) return;
|
|
2081
|
+
const schedule =
|
|
2082
|
+
this.opts.scheduleSync ??
|
|
2083
|
+
((callback: () => void, delayMs: number) => {
|
|
2084
|
+
const timer = setTimeout(callback, delayMs);
|
|
2085
|
+
return () => clearTimeout(timer);
|
|
2086
|
+
});
|
|
2087
|
+
this.cancelSync = schedule(() => {
|
|
2088
|
+
this.cancelSync = null;
|
|
2089
|
+
void this.syncNow().catch(() => {});
|
|
2090
|
+
}, SYNC_DEBOUNCE_MS);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
private async syncNow(): Promise<void> {
|
|
2094
|
+
if (this.disposed) return;
|
|
2095
|
+
const lines = await this.io.request(
|
|
2096
|
+
`list-panes -s -t "${this.opts.session}" -F "#{pane_id}\t#{pane_active}\t#{window_id}\t#{?window_active,1,0}"`,
|
|
2097
|
+
);
|
|
2098
|
+
const truth: Array<{
|
|
2099
|
+
runtimePaneId: string;
|
|
2100
|
+
active: boolean;
|
|
2101
|
+
runtimeWindowId: string;
|
|
2102
|
+
windowActive: boolean;
|
|
2103
|
+
}> = [];
|
|
2104
|
+
for (const line of lines) {
|
|
2105
|
+
const [runtime = "", active = "", windowId = "", windowActive = ""] = line.split("\t");
|
|
2106
|
+
if (!/^%[0-9]+$/u.test(runtime)) continue;
|
|
2107
|
+
truth.push({
|
|
2108
|
+
runtimePaneId: runtime,
|
|
2109
|
+
active: active === "1",
|
|
2110
|
+
runtimeWindowId: windowId,
|
|
2111
|
+
windowActive: windowActive === "1",
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
const { listed, movedWindowRuntimeIds } = this.applyPaneTruth(truth);
|
|
2115
|
+
await this.syncWindows(this.opts.session, movedWindowRuntimeIds);
|
|
2116
|
+
this.discovery.discover(listed);
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
private applyPaneTruth(
|
|
2120
|
+
truth: readonly {
|
|
2121
|
+
runtimePaneId: string;
|
|
2122
|
+
active: boolean;
|
|
2123
|
+
runtimeWindowId: string;
|
|
2124
|
+
windowActive: boolean;
|
|
2125
|
+
}[],
|
|
2126
|
+
): { listed: Set<string>; movedWindowRuntimeIds: Set<string> } {
|
|
2127
|
+
const listed = new Set<string>();
|
|
2128
|
+
const movedWindowRuntimeIds = new Set<string>();
|
|
2129
|
+
this.truthActive.clear();
|
|
2130
|
+
this.truthWindow.clear();
|
|
2131
|
+
this.activePaneByWindow.clear();
|
|
2132
|
+
for (const row of truth) {
|
|
2133
|
+
listed.add(row.runtimePaneId);
|
|
2134
|
+
this.truthActive.set(row.runtimePaneId, row.active);
|
|
2135
|
+
this.truthWindow.set(row.runtimePaneId, row.runtimeWindowId);
|
|
2136
|
+
if (row.active) this.activePaneByWindow.set(row.runtimeWindowId, row.runtimePaneId);
|
|
2137
|
+
if (row.windowActive) this.currentWindow = row.runtimeWindowId;
|
|
2138
|
+
}
|
|
2139
|
+
// Closure is decided ONLY by a successful truth reply that omits the pane
|
|
2140
|
+
// (probe failure never reads as absence — a thrown request skips all this).
|
|
2141
|
+
for (const [runtime, pane] of [...this.panesByRuntime]) {
|
|
2142
|
+
if (listed.has(runtime)) {
|
|
2143
|
+
pane.active = this.truthActive.get(runtime) ?? pane.active;
|
|
2144
|
+
const nextWindowRuntimeId = this.truthWindow.get(runtime) ?? pane.windowRuntimeId;
|
|
2145
|
+
if (nextWindowRuntimeId !== pane.windowRuntimeId && nextWindowRuntimeId !== null)
|
|
2146
|
+
movedWindowRuntimeIds.add(nextWindowRuntimeId);
|
|
2147
|
+
pane.windowRuntimeId = nextWindowRuntimeId;
|
|
2148
|
+
continue;
|
|
2149
|
+
}
|
|
2150
|
+
this.cancelRecovery(runtime);
|
|
2151
|
+
this.continueNotificationQueues.delete(runtime);
|
|
2152
|
+
this.panesByRuntime.delete(runtime);
|
|
2153
|
+
this.outputOrdinals.delete(runtime);
|
|
2154
|
+
this.panesBySemantic.delete(pane.semanticId);
|
|
2155
|
+
this.ledger.forget(runtime);
|
|
2156
|
+
this.ageByRuntime.delete(runtime);
|
|
2157
|
+
for (const sub of pane.subs) {
|
|
2158
|
+
if (!sub.closed) {
|
|
2159
|
+
sub.closed = true;
|
|
2160
|
+
sub.onEvent({ type: "closed" });
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
pane.subs.clear();
|
|
2164
|
+
}
|
|
2165
|
+
return { listed, movedWindowRuntimeIds };
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
private async refreshTrustedInventory(
|
|
2169
|
+
expectedRuntimeSessionId: string,
|
|
2170
|
+
attempt = 0,
|
|
2171
|
+
): Promise<TrustedMirrorSessionInventory> {
|
|
2172
|
+
const authorityOrdinal = this.windowAuthorityOrdinal;
|
|
2173
|
+
const beforeLines = await this.io.request(
|
|
2174
|
+
`list-panes -s -t "${expectedRuntimeSessionId}" -F "${SESSION_PANE_DESCRIPTOR_FORMAT}"`,
|
|
2175
|
+
);
|
|
2176
|
+
if (this.disposed) throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
2177
|
+
const parsed = parseSessionPaneDescriptorReply(beforeLines);
|
|
2178
|
+
if (
|
|
2179
|
+
parsed.malformedUtf8Records !== 0 ||
|
|
2180
|
+
parsed.descriptors.length === 0 ||
|
|
2181
|
+
parsed.descriptors.length !== beforeLines.length
|
|
2182
|
+
) {
|
|
2183
|
+
throw new Error(`trusted inventory for ${this.opts.session} is malformed`);
|
|
2184
|
+
}
|
|
2185
|
+
const descriptors = parsed.descriptors;
|
|
2186
|
+
const runtimePaneIds = new Set(descriptors.map((pane) => pane.runtimePaneId));
|
|
2187
|
+
const runtimeSessionIds = new Set(descriptors.map((pane) => pane.runtimeSessionId));
|
|
2188
|
+
const activeWindowIds = new Set(
|
|
2189
|
+
descriptors.filter((pane) => pane.windowActive).map((pane) => pane.windowId),
|
|
2190
|
+
);
|
|
2191
|
+
const globallyActivePanes = descriptors.filter((pane) => pane.paneActive && pane.windowActive);
|
|
2192
|
+
if (
|
|
2193
|
+
runtimePaneIds.size !== descriptors.length ||
|
|
2194
|
+
runtimeSessionIds.size !== 1 ||
|
|
2195
|
+
runtimeSessionIds.values().next().value !== expectedRuntimeSessionId ||
|
|
2196
|
+
descriptors.some((pane) => pane.sessionName !== this.opts.session) ||
|
|
2197
|
+
descriptors.some((pane) => pane.windowId === null) ||
|
|
2198
|
+
activeWindowIds.size !== 1 ||
|
|
2199
|
+
globallyActivePanes.length !== 1
|
|
2200
|
+
) {
|
|
2201
|
+
throw new Error(`trusted inventory for ${this.opts.session} is inconsistent`);
|
|
2202
|
+
}
|
|
2203
|
+
const computedWindowCounts = new Map<string, number>();
|
|
2204
|
+
for (const descriptor of descriptors) {
|
|
2205
|
+
const runtimeWindowId = descriptor.windowId!;
|
|
2206
|
+
computedWindowCounts.set(
|
|
2207
|
+
runtimeWindowId,
|
|
2208
|
+
(computedWindowCounts.get(runtimeWindowId) ?? 0) + 1,
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
if (
|
|
2212
|
+
descriptors.some(
|
|
2213
|
+
(pane) =>
|
|
2214
|
+
pane.windowPaneCount !== computedWindowCounts.get(pane.windowId!) ||
|
|
2215
|
+
pane.sessionWindowCount !== computedWindowCounts.size,
|
|
2216
|
+
)
|
|
2217
|
+
) {
|
|
2218
|
+
throw new Error(`trusted inventory for ${this.opts.session} has incomplete counts`);
|
|
2219
|
+
}
|
|
2220
|
+
const windowStage = await this.stageWindows(expectedRuntimeSessionId);
|
|
2221
|
+
const repairedPanes = await this.repairTrustedPaneIdentity(descriptors, windowStage.layouts);
|
|
2222
|
+
const afterLines = await this.io.request(
|
|
2223
|
+
`list-panes -s -t "${expectedRuntimeSessionId}" -F "${SESSION_PANE_DESCRIPTOR_FORMAT}"`,
|
|
2224
|
+
);
|
|
2225
|
+
const confirmedWindowStage = await this.stageWindows(expectedRuntimeSessionId);
|
|
2226
|
+
const coherent =
|
|
2227
|
+
beforeLines.length === afterLines.length &&
|
|
2228
|
+
beforeLines.every((line, index) => line === afterLines[index]);
|
|
2229
|
+
if (
|
|
2230
|
+
windowStage.repairedIdentity ||
|
|
2231
|
+
confirmedWindowStage.repairedIdentity ||
|
|
2232
|
+
repairedPanes ||
|
|
2233
|
+
!coherent ||
|
|
2234
|
+
!this.windowStagesEqual(windowStage, confirmedWindowStage) ||
|
|
2235
|
+
authorityOrdinal !== this.windowAuthorityOrdinal
|
|
2236
|
+
) {
|
|
2237
|
+
if (attempt >= 1)
|
|
2238
|
+
throw new Error(`trusted inventory for ${this.opts.session} did not settle`);
|
|
2239
|
+
return await this.refreshTrustedInventory(expectedRuntimeSessionId, attempt + 1);
|
|
2240
|
+
}
|
|
2241
|
+
if (this.disposed) throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
2242
|
+
const activeWindowId = activeWindowIds.values().next().value;
|
|
2243
|
+
const descriptorWindowByPane = new Map(
|
|
2244
|
+
descriptors.map((descriptor) => [descriptor.runtimePaneId, descriptor.windowId!]),
|
|
2245
|
+
);
|
|
2246
|
+
const stagedPaneIds = new Set<string>();
|
|
2247
|
+
let stagedPaneCount = 0;
|
|
2248
|
+
let stagedPaneMembershipExact = true;
|
|
2249
|
+
for (const [runtimeWindowId, layout] of confirmedWindowStage.layouts) {
|
|
2250
|
+
if (layout.leaves.length !== computedWindowCounts.get(runtimeWindowId)) {
|
|
2251
|
+
stagedPaneMembershipExact = false;
|
|
2252
|
+
break;
|
|
2253
|
+
}
|
|
2254
|
+
for (const leaf of layout.leaves) {
|
|
2255
|
+
stagedPaneCount += 1;
|
|
2256
|
+
if (stagedPaneIds.has(leaf.id) || descriptorWindowByPane.get(leaf.id) !== runtimeWindowId) {
|
|
2257
|
+
stagedPaneMembershipExact = false;
|
|
2258
|
+
break;
|
|
2259
|
+
}
|
|
2260
|
+
stagedPaneIds.add(leaf.id);
|
|
2261
|
+
}
|
|
2262
|
+
if (!stagedPaneMembershipExact) break;
|
|
2263
|
+
}
|
|
2264
|
+
if (
|
|
2265
|
+
confirmedWindowStage.currentWindow !== activeWindowId ||
|
|
2266
|
+
confirmedWindowStage.windows.size !== computedWindowCounts.size ||
|
|
2267
|
+
!stagedPaneMembershipExact ||
|
|
2268
|
+
stagedPaneCount !== descriptors.length ||
|
|
2269
|
+
stagedPaneIds.size !== descriptors.length ||
|
|
2270
|
+
[...computedWindowCounts.keys()].some(
|
|
2271
|
+
(runtimeWindowId) => !confirmedWindowStage.windows.has(runtimeWindowId),
|
|
2272
|
+
) ||
|
|
2273
|
+
descriptors.some((descriptor) => {
|
|
2274
|
+
const pane = this.panesByRuntime.get(descriptor.runtimePaneId);
|
|
2275
|
+
const window = confirmedWindowStage.windows.get(descriptor.windowId!);
|
|
2276
|
+
return (
|
|
2277
|
+
!pane ||
|
|
2278
|
+
!window?.semanticId ||
|
|
2279
|
+
descriptor.semanticPaneId !== pane.semanticId ||
|
|
2280
|
+
descriptor.semanticWindowId !== window.semanticId ||
|
|
2281
|
+
!WorkspaceIdSchemaZ.safeParse(pane.semanticId).success ||
|
|
2282
|
+
!WorkspaceIdSchemaZ.safeParse(window.semanticId).success
|
|
2283
|
+
);
|
|
2284
|
+
})
|
|
2285
|
+
) {
|
|
2286
|
+
throw new Error(`trusted inventory for ${this.opts.session} lacks verified identity`);
|
|
2287
|
+
}
|
|
2288
|
+
const previousCurrentWindow = this.currentWindow;
|
|
2289
|
+
const { movedWindowRuntimeIds } = this.applyPaneTruth(
|
|
2290
|
+
descriptors.map((pane) => ({
|
|
2291
|
+
runtimePaneId: pane.runtimePaneId,
|
|
2292
|
+
active: pane.paneActive,
|
|
2293
|
+
runtimeWindowId: pane.windowId!,
|
|
2294
|
+
windowActive: pane.windowActive,
|
|
2295
|
+
})),
|
|
2296
|
+
);
|
|
2297
|
+
for (const descriptor of descriptors) {
|
|
2298
|
+
const pane = this.panesByRuntime.get(descriptor.runtimePaneId)!;
|
|
2299
|
+
pane.descriptor = descriptor;
|
|
2300
|
+
pane.active = descriptor.paneActive;
|
|
2301
|
+
}
|
|
2302
|
+
this.commitWindowStage(confirmedWindowStage, movedWindowRuntimeIds, previousCurrentWindow);
|
|
2303
|
+
if (
|
|
2304
|
+
this.degraded ||
|
|
2305
|
+
this.panesByRuntime.size !== descriptors.length ||
|
|
2306
|
+
this.windowsByRuntime.size !== computedWindowCounts.size ||
|
|
2307
|
+
[...computedWindowCounts.keys()].some(
|
|
2308
|
+
(runtimeWindowId) => !this.windowsByRuntime.has(runtimeWindowId),
|
|
2309
|
+
)
|
|
2310
|
+
) {
|
|
2311
|
+
throw new Error(`trusted inventory for ${this.opts.session} is degraded`);
|
|
2312
|
+
}
|
|
2313
|
+
const windowCounts = computedWindowCounts;
|
|
2314
|
+
const sessionWindowCount = computedWindowCounts.size;
|
|
2315
|
+
const panes: TrustedMirrorPaneInventory[] = descriptors.map((descriptor) => {
|
|
2316
|
+
const record = this.panesByRuntime.get(descriptor.runtimePaneId);
|
|
2317
|
+
const runtimeWindowId = descriptor.windowId!;
|
|
2318
|
+
const window = this.windowsByRuntime.get(runtimeWindowId);
|
|
2319
|
+
if (
|
|
2320
|
+
!record ||
|
|
2321
|
+
record.windowRuntimeId !== descriptor.windowId ||
|
|
2322
|
+
!window?.semanticId ||
|
|
2323
|
+
descriptor.semanticPaneId !== record.semanticId ||
|
|
2324
|
+
descriptor.semanticWindowId !== window.semanticId ||
|
|
2325
|
+
!WorkspaceIdSchemaZ.safeParse(record.semanticId).success ||
|
|
2326
|
+
!WorkspaceIdSchemaZ.safeParse(window.semanticId).success
|
|
2327
|
+
) {
|
|
2328
|
+
throw new Error(`trusted inventory for ${this.opts.session} lacks verified identity`);
|
|
2329
|
+
}
|
|
2330
|
+
return Object.freeze({
|
|
2331
|
+
runtimeSessionId: descriptor.runtimeSessionId,
|
|
2332
|
+
runtimeWindowId,
|
|
2333
|
+
runtimePaneId: descriptor.runtimePaneId,
|
|
2334
|
+
semanticWindowId: window.semanticId,
|
|
2335
|
+
semanticPaneId: record.semanticId,
|
|
2336
|
+
windowPaneCount: windowCounts.get(runtimeWindowId)!,
|
|
2337
|
+
sessionWindowCount,
|
|
2338
|
+
paneIndex: descriptor.paneIndex,
|
|
2339
|
+
title: descriptor.title ?? "",
|
|
2340
|
+
currentCommand: descriptor.currentCommand ?? "",
|
|
2341
|
+
active: descriptor.paneActive && descriptor.windowActive,
|
|
2342
|
+
role: descriptor.role,
|
|
2343
|
+
name: descriptor.name,
|
|
2344
|
+
type: descriptor.type,
|
|
2345
|
+
missionStamp: descriptor.missionStamp,
|
|
2346
|
+
dir: descriptor.cwd ?? "",
|
|
2347
|
+
});
|
|
2348
|
+
});
|
|
2349
|
+
return Object.freeze({
|
|
2350
|
+
sessionName: this.opts.session,
|
|
2351
|
+
runtimeSessionId: descriptors[0]!.runtimeSessionId,
|
|
2352
|
+
panes: Object.freeze(panes),
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
private async syncWindows(
|
|
2357
|
+
target = this.opts.session,
|
|
2358
|
+
requiredLayoutEmits: ReadonlySet<string> = new Set(),
|
|
2359
|
+
): Promise<boolean> {
|
|
2360
|
+
const stage = await this.stageWindows(target);
|
|
2361
|
+
this.commitWindowStage(stage, requiredLayoutEmits);
|
|
2362
|
+
return stage.repairedIdentity;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
private commitWindowStage(
|
|
2366
|
+
stage: WindowSyncStage,
|
|
2367
|
+
requiredLayoutEmits: ReadonlySet<string> = new Set(),
|
|
2368
|
+
previousCurrentWindow = this.currentWindow,
|
|
2369
|
+
): void {
|
|
2370
|
+
const changedWindows = new Set<string>();
|
|
2371
|
+
for (const [runtimeId, record] of stage.windows) {
|
|
2372
|
+
const previous = this.windowsByRuntime.get(runtimeId);
|
|
2373
|
+
const previousLayout = this.layoutByWindow.get(runtimeId);
|
|
2374
|
+
const nextLayout = stage.layouts.get(runtimeId)!;
|
|
2375
|
+
if (
|
|
2376
|
+
!previous ||
|
|
2377
|
+
previous.name !== record.name ||
|
|
2378
|
+
previous.semanticId !== record.semanticId ||
|
|
2379
|
+
previous.paneBorderStatus !== record.paneBorderStatus ||
|
|
2380
|
+
!previousLayout ||
|
|
2381
|
+
previousLayout.zoomed !== nextLayout.zoomed ||
|
|
2382
|
+
previousLayout.width !== nextLayout.width ||
|
|
2383
|
+
previousLayout.height !== nextLayout.height ||
|
|
2384
|
+
previousLayout.leaves.length !== nextLayout.leaves.length ||
|
|
2385
|
+
previousLayout.leaves.some((leaf, index) => {
|
|
2386
|
+
const candidate = nextLayout.leaves[index];
|
|
2387
|
+
return (
|
|
2388
|
+
!candidate ||
|
|
2389
|
+
leaf.id !== candidate.id ||
|
|
2390
|
+
leaf.left !== candidate.left ||
|
|
2391
|
+
leaf.top !== candidate.top ||
|
|
2392
|
+
leaf.width !== candidate.width ||
|
|
2393
|
+
leaf.height !== candidate.height
|
|
2394
|
+
);
|
|
2395
|
+
})
|
|
2396
|
+
) {
|
|
2397
|
+
changedWindows.add(runtimeId);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
const windowSetChanged = stage.windows.size !== this.windowsByRuntime.size;
|
|
2401
|
+
if (previousCurrentWindow !== stage.currentWindow) {
|
|
2402
|
+
if (stage.windows.has(previousCurrentWindow)) changedWindows.add(previousCurrentWindow);
|
|
2403
|
+
if (stage.windows.has(stage.currentWindow)) changedWindows.add(stage.currentWindow);
|
|
2404
|
+
}
|
|
2405
|
+
this.currentWindow = stage.currentWindow;
|
|
2406
|
+
this.windowsByRuntime.clear();
|
|
2407
|
+
for (const [key, value] of stage.windows) this.windowsByRuntime.set(key, value);
|
|
2408
|
+
this.layoutByWindow.clear();
|
|
2409
|
+
for (const [key, value] of stage.layouts) this.layoutByWindow.set(key, value);
|
|
2410
|
+
const layoutEmits = windowSetChanged
|
|
2411
|
+
? new Set(stage.windows.keys())
|
|
2412
|
+
: new Set(
|
|
2413
|
+
[...changedWindows, ...requiredLayoutEmits].filter((runtimeId) =>
|
|
2414
|
+
stage.windows.has(runtimeId),
|
|
2415
|
+
),
|
|
2416
|
+
);
|
|
2417
|
+
for (const runtimeId of layoutEmits) this.emitLayout(runtimeId);
|
|
2418
|
+
this.emitLayoutAuthority();
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
private windowStagesEqual(left: WindowSyncStage, right: WindowSyncStage): boolean {
|
|
2422
|
+
if (
|
|
2423
|
+
left.currentWindow !== right.currentWindow ||
|
|
2424
|
+
left.windows.size !== right.windows.size ||
|
|
2425
|
+
left.layouts.size !== right.layouts.size
|
|
2426
|
+
) {
|
|
2427
|
+
return false;
|
|
2428
|
+
}
|
|
2429
|
+
for (const [runtimeId, leftWindow] of left.windows) {
|
|
2430
|
+
const rightWindow = right.windows.get(runtimeId);
|
|
2431
|
+
const leftLayout = left.layouts.get(runtimeId);
|
|
2432
|
+
const rightLayout = right.layouts.get(runtimeId);
|
|
2433
|
+
if (
|
|
2434
|
+
!rightWindow ||
|
|
2435
|
+
!leftLayout ||
|
|
2436
|
+
!rightLayout ||
|
|
2437
|
+
leftWindow.semanticId !== rightWindow.semanticId ||
|
|
2438
|
+
leftWindow.name !== rightWindow.name ||
|
|
2439
|
+
leftWindow.paneBorderStatus !== rightWindow.paneBorderStatus ||
|
|
2440
|
+
leftLayout.zoomed !== rightLayout.zoomed ||
|
|
2441
|
+
leftLayout.width !== rightLayout.width ||
|
|
2442
|
+
leftLayout.height !== rightLayout.height ||
|
|
2443
|
+
leftLayout.leaves.length !== rightLayout.leaves.length ||
|
|
2444
|
+
leftLayout.leaves.some((leaf, index) => {
|
|
2445
|
+
const candidate = rightLayout.leaves[index];
|
|
2446
|
+
return (
|
|
2447
|
+
!candidate ||
|
|
2448
|
+
leaf.id !== candidate.id ||
|
|
2449
|
+
leaf.left !== candidate.left ||
|
|
2450
|
+
leaf.top !== candidate.top ||
|
|
2451
|
+
leaf.width !== candidate.width ||
|
|
2452
|
+
leaf.height !== candidate.height
|
|
2453
|
+
);
|
|
2454
|
+
})
|
|
2455
|
+
) {
|
|
2456
|
+
return false;
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
return true;
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
private async stageWindows(target = this.opts.session): Promise<WindowSyncStage> {
|
|
2463
|
+
const lines = await this.io.request(
|
|
2464
|
+
`list-windows -t "${target}" -F "#{window_id}\t#{qa:@tmux_ide_window_id}\t#{qa:window_name}\t#{window_active}\t#{window_visible_layout}\t#{?window_zoomed_flag,1,0}\t#{pane-border-status}"`,
|
|
2465
|
+
);
|
|
2466
|
+
interface Row {
|
|
2467
|
+
runtimeId: string;
|
|
2468
|
+
stamp: string | null;
|
|
2469
|
+
name: string | null;
|
|
2470
|
+
active: boolean;
|
|
2471
|
+
visible: string;
|
|
2472
|
+
zoomed: boolean;
|
|
2473
|
+
paneBorderStatus: "top" | "bottom" | "off";
|
|
2474
|
+
}
|
|
2475
|
+
const rows: Row[] = [];
|
|
2476
|
+
const seenRuntimeIds = new Set<string>();
|
|
2477
|
+
for (const raw of lines) {
|
|
2478
|
+
// Replies are latin1 byte strings; recover UTF-8 window names first.
|
|
2479
|
+
const line = Buffer.from(raw, "latin1").toString("utf8");
|
|
2480
|
+
const parts = line.split("\t");
|
|
2481
|
+
if (parts.length !== 7) {
|
|
2482
|
+
throw new Error(`window layout truth for ${this.opts.session} is malformed`);
|
|
2483
|
+
}
|
|
2484
|
+
const [
|
|
2485
|
+
runtimeId = "",
|
|
2486
|
+
stampRaw = "",
|
|
2487
|
+
nameRaw = "",
|
|
2488
|
+
active = "",
|
|
2489
|
+
visible = "",
|
|
2490
|
+
zoomed = "",
|
|
2491
|
+
borderStatus = "off",
|
|
2492
|
+
] = parts;
|
|
2493
|
+
if (
|
|
2494
|
+
!/^@[0-9]+$/u.test(runtimeId) ||
|
|
2495
|
+
seenRuntimeIds.has(runtimeId) ||
|
|
2496
|
+
(active !== "0" && active !== "1") ||
|
|
2497
|
+
(zoomed !== "0" && zoomed !== "1") ||
|
|
2498
|
+
(borderStatus !== "top" && borderStatus !== "bottom" && borderStatus !== "off")
|
|
2499
|
+
) {
|
|
2500
|
+
throw new Error(`window layout truth for ${this.opts.session} is malformed`);
|
|
2501
|
+
}
|
|
2502
|
+
seenRuntimeIds.add(runtimeId);
|
|
2503
|
+
const stamp = decodeTmuxArgument(stampRaw);
|
|
2504
|
+
const name = decodeTmuxArgument(nameRaw);
|
|
2505
|
+
rows.push({
|
|
2506
|
+
runtimeId,
|
|
2507
|
+
stamp: stamp.length > 0 ? stamp : null,
|
|
2508
|
+
name: name.length > 0 ? name : null,
|
|
2509
|
+
active: active === "1",
|
|
2510
|
+
visible,
|
|
2511
|
+
zoomed: zoomed === "1",
|
|
2512
|
+
paneBorderStatus: borderStatus,
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
if (rows.length === 0) {
|
|
2516
|
+
throw new Error(`window layout truth for ${this.opts.session} is missing`);
|
|
2517
|
+
}
|
|
2518
|
+
const activeRows = rows.filter(({ active }) => active);
|
|
2519
|
+
if (activeRows.length !== 1) {
|
|
2520
|
+
throw new Error(
|
|
2521
|
+
`window layout truth for ${this.opts.session} has inconsistent active window`,
|
|
2522
|
+
);
|
|
2523
|
+
}
|
|
2524
|
+
const nextLayoutByWindow = new Map<string, ParsedLayout & { zoomed: boolean }>();
|
|
2525
|
+
for (const row of rows) {
|
|
2526
|
+
const parsed = parseLayout(row.visible);
|
|
2527
|
+
if (!parsed) {
|
|
2528
|
+
throw new Error(`window layout truth for ${this.opts.session} is malformed`);
|
|
2529
|
+
}
|
|
2530
|
+
nextLayoutByWindow.set(row.runtimeId, { ...parsed, zoomed: row.zoomed });
|
|
2531
|
+
}
|
|
2532
|
+
// Valid unique stamps are identity; missing/invalid/duplicated stamps are
|
|
2533
|
+
// ALL regenerated and stamped back (the pane policy, applied to windows).
|
|
2534
|
+
const stampCounts = new Map<string, number>();
|
|
2535
|
+
for (const row of rows) {
|
|
2536
|
+
if (row.stamp && WorkspaceIdSchemaZ.safeParse(row.stamp).success) {
|
|
2537
|
+
stampCounts.set(row.stamp, (stampCounts.get(row.stamp) ?? 0) + 1);
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
const claimed = new Set(stampCounts.keys());
|
|
2541
|
+
const generateWindowId = this.opts.generateWindowId ?? defaultMirrorWindowId;
|
|
2542
|
+
let repairedIdentity = false;
|
|
2543
|
+
const next = new Map<string, WindowRecord>();
|
|
2544
|
+
let nextCurrentWindow = "";
|
|
2545
|
+
for (const row of rows) {
|
|
2546
|
+
if (row.active) nextCurrentWindow = row.runtimeId;
|
|
2547
|
+
let semanticId: string | null = null;
|
|
2548
|
+
if (row.stamp && stampCounts.get(row.stamp) === 1) {
|
|
2549
|
+
semanticId = row.stamp;
|
|
2550
|
+
} else {
|
|
2551
|
+
repairedIdentity = true;
|
|
2552
|
+
let candidate: string | null = null;
|
|
2553
|
+
for (let attempt = 0; attempt < 32 && !candidate; attempt += 1) {
|
|
2554
|
+
const generated = generateWindowId();
|
|
2555
|
+
if (WorkspaceIdSchemaZ.safeParse(generated).success && !claimed.has(generated)) {
|
|
2556
|
+
candidate = generated;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
if (candidate) {
|
|
2560
|
+
claimed.add(candidate);
|
|
2561
|
+
const ok = await this.io
|
|
2562
|
+
.request(
|
|
2563
|
+
`set-option -w -t ${row.runtimeId} ${WORKSPACE_SEMANTIC_WINDOW_OPTION} "${candidate}"`,
|
|
2564
|
+
)
|
|
2565
|
+
.then(
|
|
2566
|
+
() => true,
|
|
2567
|
+
() => false,
|
|
2568
|
+
);
|
|
2569
|
+
if (ok) semanticId = candidate;
|
|
2570
|
+
else {
|
|
2571
|
+
this.pushDiagnostic({
|
|
2572
|
+
code: "WINDOW_STAMP_BACK_FAILED",
|
|
2573
|
+
message: `Could not stamp semantic window identity ${candidate}.`,
|
|
2574
|
+
degraded: true,
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
next.set(row.runtimeId, {
|
|
2580
|
+
runtimeId: row.runtimeId,
|
|
2581
|
+
semanticId,
|
|
2582
|
+
name: row.name,
|
|
2583
|
+
paneBorderStatus: row.paneBorderStatus,
|
|
2584
|
+
});
|
|
2585
|
+
}
|
|
2586
|
+
return {
|
|
2587
|
+
windows: next,
|
|
2588
|
+
layouts: nextLayoutByWindow,
|
|
2589
|
+
currentWindow: nextCurrentWindow,
|
|
2590
|
+
repairedIdentity,
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
private async reconcileIdentity(
|
|
2595
|
+
descriptors: readonly SessionPaneDescriptor[],
|
|
2596
|
+
listed: ReadonlySet<string>,
|
|
2597
|
+
): Promise<boolean> {
|
|
2598
|
+
if (this.disposed) return false;
|
|
2599
|
+
const snapshots: WorkspaceTmuxPaneSnapshot[] = descriptors
|
|
2600
|
+
.filter((descriptor) => listed.has(descriptor.runtimePaneId))
|
|
2601
|
+
.map((descriptor) => ({
|
|
2602
|
+
runtimePaneId: descriptor.runtimePaneId,
|
|
2603
|
+
semanticPaneId: descriptor.semanticPaneId,
|
|
2604
|
+
role: descriptor.role,
|
|
2605
|
+
type: descriptor.type,
|
|
2606
|
+
currentCommand: descriptor.currentCommand,
|
|
2607
|
+
cwd: descriptor.cwd,
|
|
2608
|
+
title: descriptor.title,
|
|
2609
|
+
rect: this.rectFor(descriptor.runtimePaneId),
|
|
2610
|
+
active: this.truthActive.get(descriptor.runtimePaneId) ?? false,
|
|
2611
|
+
}));
|
|
2612
|
+
const plan = planWorkspaceTmuxReconciliation({
|
|
2613
|
+
panes: snapshots,
|
|
2614
|
+
generateSemanticPaneId: this.opts.generatePaneId ?? defaultMirrorPaneId,
|
|
2615
|
+
});
|
|
2616
|
+
const outcomes: WorkspaceTmuxStampOutcome[] = await Promise.all(
|
|
2617
|
+
plan.stampEffects.map((effect) =>
|
|
2618
|
+
this.io
|
|
2619
|
+
.request(
|
|
2620
|
+
`set-option -p -t ${effect.runtimePaneId} ${WORKSPACE_SEMANTIC_PANE_OPTION} "${effect.value}"`,
|
|
2621
|
+
)
|
|
2622
|
+
.then(
|
|
2623
|
+
() => ({ runtimePaneId: effect.runtimePaneId, ok: true }),
|
|
2624
|
+
(cause: unknown) => ({
|
|
2625
|
+
runtimePaneId: effect.runtimePaneId,
|
|
2626
|
+
ok: false,
|
|
2627
|
+
error: cause instanceof Error ? cause.message : String(cause),
|
|
2628
|
+
}),
|
|
2629
|
+
),
|
|
2630
|
+
),
|
|
2631
|
+
);
|
|
2632
|
+
if (this.disposed) return plan.stampEffects.length > 0;
|
|
2633
|
+
const reconciliation = finalizeWorkspaceTmuxReconciliation(plan, outcomes);
|
|
2634
|
+
const descriptorByRuntime = new Map(descriptors.map((d) => [d.runtimePaneId, d]));
|
|
2635
|
+
for (const verified of reconciliation.panes) {
|
|
2636
|
+
if (!listed.has(verified.runtimePaneId)) continue;
|
|
2637
|
+
const descriptor = descriptorByRuntime.get(verified.runtimePaneId) ?? null;
|
|
2638
|
+
const windowRuntimeId =
|
|
2639
|
+
this.truthWindow.get(verified.runtimePaneId) ?? descriptor?.windowId ?? null;
|
|
2640
|
+
const existingBySemantic = this.panesBySemantic.get(verified.semanticPaneId);
|
|
2641
|
+
const existingByRuntime = this.panesByRuntime.get(verified.runtimePaneId);
|
|
2642
|
+
if (existingBySemantic && existingBySemantic.runtimeId !== verified.runtimePaneId) {
|
|
2643
|
+
// The semantic identity moved to a different runtime address (respawn/
|
|
2644
|
+
// restore). Follow it and reseed every live subscriber — the old
|
|
2645
|
+
// address's bytes are a different pane's now.
|
|
2646
|
+
const retiredRuntime = existingBySemantic.runtimeId;
|
|
2647
|
+
this.cancelRecovery(retiredRuntime);
|
|
2648
|
+
this.continueNotificationQueues.delete(retiredRuntime);
|
|
2649
|
+
this.panesByRuntime.delete(retiredRuntime);
|
|
2650
|
+
this.outputOrdinals.delete(retiredRuntime);
|
|
2651
|
+
this.ledger.forget(retiredRuntime);
|
|
2652
|
+
existingBySemantic.runtimeId = verified.runtimePaneId;
|
|
2653
|
+
existingBySemantic.incarnation = ++this.paneIncarnation;
|
|
2654
|
+
existingBySemantic.descriptor = descriptor;
|
|
2655
|
+
existingBySemantic.active = verified.active;
|
|
2656
|
+
existingBySemantic.windowRuntimeId = windowRuntimeId;
|
|
2657
|
+
this.panesByRuntime.set(verified.runtimePaneId, existingBySemantic);
|
|
2658
|
+
for (const sub of existingBySemantic.subs) {
|
|
2659
|
+
if (!sub.closed && !sub.frozen) this.reseedPlain(sub);
|
|
2660
|
+
}
|
|
2661
|
+
continue;
|
|
2662
|
+
}
|
|
2663
|
+
if (existingByRuntime && existingByRuntime.semanticId === verified.semanticPaneId) {
|
|
2664
|
+
existingByRuntime.descriptor = descriptor;
|
|
2665
|
+
existingByRuntime.active = verified.active;
|
|
2666
|
+
existingByRuntime.windowRuntimeId = windowRuntimeId;
|
|
2667
|
+
continue;
|
|
2668
|
+
}
|
|
2669
|
+
if (existingByRuntime) {
|
|
2670
|
+
// The runtime address was restamped to a new identity (duplicate
|
|
2671
|
+
// resolution). The old semantic id is gone.
|
|
2672
|
+
this.panesBySemantic.delete(existingByRuntime.semanticId);
|
|
2673
|
+
this.cancelRecovery(existingByRuntime.runtimeId);
|
|
2674
|
+
this.continueNotificationQueues.delete(existingByRuntime.runtimeId);
|
|
2675
|
+
this.ledger.forget(existingByRuntime.runtimeId);
|
|
2676
|
+
this.outputOrdinals.delete(existingByRuntime.runtimeId);
|
|
2677
|
+
for (const sub of existingByRuntime.subs) {
|
|
2678
|
+
if (sub.closed) continue;
|
|
2679
|
+
sub.closed = true;
|
|
2680
|
+
sub.feed.abortCurrent();
|
|
2681
|
+
sub.onEvent({ type: "closed" });
|
|
2682
|
+
}
|
|
2683
|
+
existingByRuntime.subs.clear();
|
|
2684
|
+
existingByRuntime.incarnation = ++this.paneIncarnation;
|
|
2685
|
+
existingByRuntime.semanticId = verified.semanticPaneId;
|
|
2686
|
+
existingByRuntime.descriptor = descriptor;
|
|
2687
|
+
existingByRuntime.active = verified.active;
|
|
2688
|
+
existingByRuntime.windowRuntimeId = windowRuntimeId;
|
|
2689
|
+
this.panesBySemantic.set(verified.semanticPaneId, existingByRuntime);
|
|
2690
|
+
continue;
|
|
2691
|
+
}
|
|
2692
|
+
const record: PaneRecord = {
|
|
2693
|
+
runtimeId: verified.runtimePaneId,
|
|
2694
|
+
semanticId: verified.semanticPaneId,
|
|
2695
|
+
descriptor,
|
|
2696
|
+
active: verified.active,
|
|
2697
|
+
windowRuntimeId,
|
|
2698
|
+
subs: new Set(),
|
|
2699
|
+
incarnation: ++this.paneIncarnation,
|
|
2700
|
+
};
|
|
2701
|
+
this.panesByRuntime.set(record.runtimeId, record);
|
|
2702
|
+
this.panesBySemantic.set(record.semanticId, record);
|
|
2703
|
+
}
|
|
2704
|
+
// Diagnostics cross the semantic boundary too: rewrite runtime addresses
|
|
2705
|
+
// to the joined semantic id (or an honest placeholder for panes that never
|
|
2706
|
+
// verified) so `%N` never leaves the service.
|
|
2707
|
+
const semanticByRuntime = new Map(
|
|
2708
|
+
reconciliation.panes.map((pane) => [pane.runtimePaneId, pane.semanticPaneId]),
|
|
2709
|
+
);
|
|
2710
|
+
this.diagnostics = reconciliation.diagnostics.map((diagnostic) => ({
|
|
2711
|
+
code: diagnostic.code,
|
|
2712
|
+
message: diagnostic.message.replace(
|
|
2713
|
+
/%[0-9]+/gu,
|
|
2714
|
+
(runtime) => semanticByRuntime.get(runtime) ?? "(unidentified pane)",
|
|
2715
|
+
),
|
|
2716
|
+
degraded: diagnostic.degraded,
|
|
2717
|
+
}));
|
|
2718
|
+
this.degraded = reconciliation.degraded;
|
|
2719
|
+
/*
|
|
2720
|
+
* Re-emit every window's layout now that panes carry semantic identity.
|
|
2721
|
+
*
|
|
2722
|
+
* A pane created by a split appears in the %layout-change frame BEFORE its
|
|
2723
|
+
* `@tmux_ide_pane_id` stamp exists, so the frame names it null — and a
|
|
2724
|
+
* consumer that renders semantic identities has nothing to draw for it. The
|
|
2725
|
+
* stamp-back lands here, in a sync, which emits no layout of its own; so
|
|
2726
|
+
* without this the new pane stays invisible until something else happens to
|
|
2727
|
+
* move a layout, and a split looks like it did not reach the view.
|
|
2728
|
+
*/
|
|
2729
|
+
for (const runtimeId of this.layoutByWindow.keys()) this.emitLayout(runtimeId);
|
|
2730
|
+
this.emitLayoutAuthority();
|
|
2731
|
+
this.settleFirstJoin();
|
|
2732
|
+
return plan.stampEffects.length > 0;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
private async repairTrustedPaneIdentity(
|
|
2736
|
+
descriptors: readonly SessionPaneDescriptor[],
|
|
2737
|
+
layouts: ReadonlyMap<string, ParsedLayout & { zoomed: boolean }>,
|
|
2738
|
+
): Promise<boolean> {
|
|
2739
|
+
const rectForRuntime = (runtimePaneId: string): WorkspacePaneRect => {
|
|
2740
|
+
for (const layout of layouts.values()) {
|
|
2741
|
+
const leaf = layout.leaves.find(({ id }) => id === runtimePaneId);
|
|
2742
|
+
if (leaf) {
|
|
2743
|
+
return {
|
|
2744
|
+
left: leaf.left,
|
|
2745
|
+
top: leaf.top,
|
|
2746
|
+
width: leaf.width,
|
|
2747
|
+
height: leaf.height,
|
|
2748
|
+
};
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
return { left: 0, top: 0, width: 1, height: 1 };
|
|
2752
|
+
};
|
|
2753
|
+
const plan = planWorkspaceTmuxReconciliation({
|
|
2754
|
+
panes: descriptors.map((descriptor) => ({
|
|
2755
|
+
runtimePaneId: descriptor.runtimePaneId,
|
|
2756
|
+
semanticPaneId: descriptor.semanticPaneId,
|
|
2757
|
+
role: descriptor.role,
|
|
2758
|
+
type: descriptor.type,
|
|
2759
|
+
currentCommand: descriptor.currentCommand,
|
|
2760
|
+
cwd: descriptor.cwd,
|
|
2761
|
+
title: descriptor.title,
|
|
2762
|
+
rect: rectForRuntime(descriptor.runtimePaneId),
|
|
2763
|
+
active: descriptor.paneActive && descriptor.windowActive,
|
|
2764
|
+
})),
|
|
2765
|
+
generateSemanticPaneId: this.opts.generatePaneId ?? defaultMirrorPaneId,
|
|
2766
|
+
});
|
|
2767
|
+
if (plan.stampEffects.length === 0) return false;
|
|
2768
|
+
const outcomes = await Promise.all(
|
|
2769
|
+
plan.stampEffects.map((effect) =>
|
|
2770
|
+
this.io
|
|
2771
|
+
.request(
|
|
2772
|
+
`set-option -p -t ${effect.runtimePaneId} ${WORKSPACE_SEMANTIC_PANE_OPTION} "${effect.value}"`,
|
|
2773
|
+
)
|
|
2774
|
+
.then(
|
|
2775
|
+
() => true,
|
|
2776
|
+
() => false,
|
|
2777
|
+
),
|
|
2778
|
+
),
|
|
2779
|
+
);
|
|
2780
|
+
if (outcomes.some((ok) => !ok)) {
|
|
2781
|
+
throw new Error(`trusted inventory for ${this.opts.session} could not repair identity`);
|
|
2782
|
+
}
|
|
2783
|
+
return true;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
private settleFirstJoin(): void {
|
|
2787
|
+
this.resolveFirstJoin?.();
|
|
2788
|
+
this.resolveFirstJoin = null;
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
private rectFor(runtime: string): WorkspacePaneRect {
|
|
2792
|
+
for (const layout of this.layoutByWindow.values()) {
|
|
2793
|
+
const leaf = layout.leaves.find((candidate) => candidate.id === runtime);
|
|
2794
|
+
if (leaf) return { left: leaf.left, top: leaf.top, width: leaf.width, height: leaf.height };
|
|
2795
|
+
}
|
|
2796
|
+
return { left: 0, top: 0, width: 1, height: 1 };
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
private pushDiagnostic(diagnostic: MirrorDiagnostic): void {
|
|
2800
|
+
this.diagnostics = [...this.diagnostics.slice(-31), diagnostic];
|
|
2801
|
+
if (diagnostic.degraded) this.degraded = true;
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
private onChannelExit(): void {
|
|
2805
|
+
if (this.disposed) return;
|
|
2806
|
+
this.settleFirstJoin();
|
|
2807
|
+
for (const runtime of [...this.recoveries.keys()]) this.cancelRecovery(runtime);
|
|
2808
|
+
this.continueNotificationQueues.clear();
|
|
2809
|
+
for (const pane of this.panesByRuntime.values()) {
|
|
2810
|
+
for (const sub of pane.subs) {
|
|
2811
|
+
if (!sub.closed) {
|
|
2812
|
+
sub.closed = true;
|
|
2813
|
+
sub.onEvent({ type: "closed" });
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
pane.subs.clear();
|
|
2817
|
+
}
|
|
2818
|
+
this.opts.onExit?.();
|
|
2819
|
+
}
|
|
2820
|
+
}
|