@duckmind/dm-windows-x64 0.61.4 → 0.61.9
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/dm.exe +0 -0
- package/extensions/.dm-extensions.json +211 -67
- package/extensions/dm-subagents/agents/claude-code-writer.md +15 -0
- package/extensions/dm-subagents/agents/claude-code.md +15 -0
- package/extensions/dm-subagents/agents/codex-exec-writer.md +15 -0
- package/extensions/dm-subagents/agents/codex-exec.md +15 -0
- package/extensions/dm-subagents/agents/cursor-agent-writer.md +14 -0
- package/extensions/dm-subagents/agents/cursor-agent.md +14 -0
- package/extensions/dm-subagents/agents/delegate.md +3 -2
- package/extensions/dm-subagents/agents/oracle.md +10 -5
- package/extensions/dm-subagents/agents/researcher.md +2 -2
- package/extensions/dm-subagents/agents/reviewer.md +17 -7
- package/extensions/dm-subagents/agents/scout.md +5 -5
- package/extensions/dm-subagents/agents/worker.md +6 -2
- package/extensions/dm-subagents/async-retention-discovery-worker.mjs +167 -0
- package/extensions/dm-subagents/index.js +4 -0
- package/extensions/dm-subagents/inspector-runner.mjs +10 -0
- package/extensions/dm-subagents/install.mjs +3 -2
- package/extensions/dm-subagents/package.json +2 -2
- package/extensions/dm-subagents/prompts/council.md +60 -0
- package/extensions/dm-subagents/prompts/parallel-review.md +5 -1
- package/extensions/dm-subagents/prompts/review-loop.md +13 -7
- package/extensions/dm-subagents/skills/council-mode/SKILL.md +59 -0
- package/extensions/dm-subagents/skills/council-mode/references/pass-contracts.md +150 -0
- package/extensions/dm-subagents/skills/dm-subagents/SKILL.md +96 -911
- package/extensions/dm-subagents/skills/dm-subagents/references/constraints-and-recipes.md +70 -0
- package/extensions/dm-subagents/skills/dm-subagents/references/execution-controls.md +539 -0
- package/extensions/dm-subagents/skills/dm-subagents/references/management-authoring-rpc.md +161 -0
- package/extensions/dm-subagents/skills/dm-subagents/references/multi-lane-orchestration.md +51 -0
- package/extensions/dm-subagents/skills/dm-subagents/references/prompting-and-roles.md +295 -0
- package/extensions/dm-subagents/skills/dm-subagents/references/review-and-validation.md +73 -0
- package/extensions/dm-subagents/src/agents/agent-management.js +716 -484
- package/extensions/dm-subagents/src/agents/agent-refinements.js +563 -0
- package/extensions/dm-subagents/src/agents/agent-serializer.js +70 -5
- package/extensions/dm-subagents/src/agents/agents.js +1447 -299
- package/extensions/dm-subagents/src/agents/builtin-names.js +15 -0
- package/extensions/dm-subagents/src/agents/chain-serializer.js +12 -7
- package/extensions/dm-subagents/src/agents/frontmatter.js +64 -14
- package/extensions/dm-subagents/src/agents/identity.js +1 -1
- package/extensions/dm-subagents/src/agents/proactive-skills.js +14 -11
- package/extensions/dm-subagents/src/agents/runtime-agent-events.js +49 -0
- package/extensions/dm-subagents/src/agents/runtime-agent-registry.js +412 -0
- package/extensions/dm-subagents/src/agents/skills.js +52 -35
- package/extensions/dm-subagents/src/api/agents.js +6 -0
- package/extensions/dm-subagents/src/api/background-work.js +151 -0
- package/extensions/dm-subagents/src/api/capability-ceiling.js +12 -0
- package/extensions/dm-subagents/src/api/control-channel.js +3 -0
- package/extensions/dm-subagents/src/api/delegation.js +5 -0
- package/extensions/dm-subagents/src/api/dm-args.js +3 -0
- package/extensions/dm-subagents/src/api/external-job-provider.js +137 -0
- package/extensions/dm-subagents/src/api/external-runs.js +233 -0
- package/extensions/dm-subagents/src/api/intercom-bridge.js +3 -0
- package/extensions/dm-subagents/src/api/preflight.js +322 -0
- package/extensions/dm-subagents/src/api/project-panes.js +11 -0
- package/extensions/dm-subagents/src/api/shared-types.js +4 -0
- package/extensions/dm-subagents/src/extension/config.js +175 -0
- package/extensions/dm-subagents/src/extension/control-notices.js +4 -43
- package/extensions/dm-subagents/src/extension/doctor.js +71 -17
- package/extensions/dm-subagents/src/extension/fanout-child.js +49 -32
- package/extensions/dm-subagents/src/extension/index.js +711 -265
- package/extensions/dm-subagents/src/extension/public-execution.js +114 -0
- package/extensions/dm-subagents/src/extension/rpc.js +427 -22
- package/extensions/dm-subagents/src/extension/schemas.js +158 -65
- package/extensions/dm-subagents/src/extension/steering-notices.js +23 -0
- package/extensions/dm-subagents/src/extension/subagent-guide.js +31 -0
- package/extensions/dm-subagents/src/extension/tool-description.js +92 -74
- package/extensions/dm-subagents/src/extension/tool-result.js +7 -0
- package/extensions/dm-subagents/src/inspectors/herdr/actions.js +218 -0
- package/extensions/dm-subagents/src/inspectors/herdr/client.js +123 -0
- package/extensions/dm-subagents/src/inspectors/herdr/focus.js +47 -0
- package/extensions/dm-subagents/src/inspectors/herdr/inspector-runner.js +160 -0
- package/extensions/dm-subagents/src/inspectors/herdr/project-panes.js +618 -0
- package/extensions/dm-subagents/src/inspectors/herdr/session-roots-codec.js +21 -0
- package/extensions/dm-subagents/src/inspectors/herdr/shell-command.js +15 -0
- package/extensions/dm-subagents/src/integrations/herdr-status.js +377 -0
- package/extensions/dm-subagents/src/intercom/intercom-bridge.js +17 -13
- package/extensions/dm-subagents/src/intercom/native-supervisor-channel.js +371 -79
- package/extensions/dm-subagents/src/intercom/result-intercom.js +47 -7
- package/extensions/dm-subagents/src/missions/actions.js +394 -0
- package/extensions/dm-subagents/src/missions/goal-driver.js +149 -0
- package/extensions/dm-subagents/src/missions/lifecycle.js +331 -0
- package/extensions/dm-subagents/src/missions/store.js +548 -0
- package/extensions/dm-subagents/src/missions/types.js +9 -0
- package/extensions/dm-subagents/src/missions/workflow-state.js +245 -0
- package/extensions/dm-subagents/src/policy/authority.js +37 -0
- package/extensions/dm-subagents/src/profiles/profiles.js +36 -18
- package/extensions/dm-subagents/src/runs/background/active-async-capacity.js +427 -0
- package/extensions/dm-subagents/src/runs/background/active-run-index.js +122 -0
- package/extensions/dm-subagents/src/runs/background/async-execution.js +925 -137
- package/extensions/dm-subagents/src/runs/background/async-job-tracker.js +515 -148
- package/extensions/dm-subagents/src/runs/background/async-resume.js +378 -51
- package/extensions/dm-subagents/src/runs/background/async-retention.js +828 -0
- package/extensions/dm-subagents/src/runs/background/async-status-snapshot.js +31 -0
- package/extensions/dm-subagents/src/runs/background/async-status.js +259 -22
- package/extensions/dm-subagents/src/runs/background/auto-drain.js +46 -0
- package/extensions/dm-subagents/src/runs/background/chain-append.js +50 -15
- package/extensions/dm-subagents/src/runs/background/chain-root-attachment.js +67 -12
- package/extensions/dm-subagents/src/runs/background/completion-batcher.js +5 -1
- package/extensions/dm-subagents/src/runs/background/completion-dedupe.js +3 -11
- package/extensions/dm-subagents/src/runs/background/completion-replay.js +245 -0
- package/extensions/dm-subagents/src/runs/background/control-channel.js +423 -36
- package/extensions/dm-subagents/src/runs/background/fleet-view.js +132 -59
- package/extensions/dm-subagents/src/runs/background/index-segment.js +38 -0
- package/extensions/dm-subagents/src/runs/background/inspect-rpc.js +373 -0
- package/extensions/dm-subagents/src/runs/background/notify.js +357 -57
- package/extensions/dm-subagents/src/runs/background/owned-process-tree.js +86 -0
- package/extensions/dm-subagents/src/runs/background/process-terminal.js +269 -0
- package/extensions/dm-subagents/src/runs/background/result-delivery-ownership.js +34 -0
- package/extensions/dm-subagents/src/runs/background/result-files.js +469 -0
- package/extensions/dm-subagents/src/runs/background/result-watcher.js +540 -75
- package/extensions/dm-subagents/src/runs/background/resume-guidance.js +44 -0
- package/extensions/dm-subagents/src/runs/background/retained-children.js +119 -0
- package/extensions/dm-subagents/src/runs/background/run-id-query.js +5 -0
- package/extensions/dm-subagents/src/runs/background/run-id-resolver.js +93 -9
- package/extensions/dm-subagents/src/runs/background/run-status.js +303 -32
- package/extensions/dm-subagents/src/runs/background/scheduled-runs.js +784 -376
- package/extensions/dm-subagents/src/runs/background/stale-run-reconciler.js +75 -34
- package/extensions/dm-subagents/src/runs/background/steering.js +221 -0
- package/extensions/dm-subagents/src/runs/background/subagent-runner.js +3106 -844
- package/extensions/dm-subagents/src/runs/background/subagent-wait.js +529 -0
- package/extensions/dm-subagents/src/runs/background/terminal-run-index.js +106 -0
- package/extensions/dm-subagents/src/runs/background/top-level-async.js +1 -1
- package/extensions/dm-subagents/src/runs/background/wait-completions.js +155 -0
- package/extensions/dm-subagents/src/runs/background/wait-config.js +46 -0
- package/extensions/dm-subagents/src/runs/background/wait-subscriptions.js +278 -0
- package/extensions/dm-subagents/src/runs/background/wait-tool.js +47 -0
- package/extensions/dm-subagents/src/runs/foreground/async-dismiss-action.js +81 -0
- package/extensions/dm-subagents/src/runs/foreground/async-steering-action.js +245 -0
- package/extensions/dm-subagents/src/runs/foreground/async-stop-action.js +74 -0
- package/extensions/dm-subagents/src/runs/foreground/execution.js +1401 -342
- package/extensions/dm-subagents/src/runs/foreground/foreground-control.js +133 -0
- package/extensions/dm-subagents/src/runs/foreground/foreground-history.js +148 -0
- package/extensions/dm-subagents/src/runs/foreground/prompt-audit.js +139 -0
- package/extensions/dm-subagents/src/runs/foreground/subagent-executor.js +4278 -1441
- package/extensions/dm-subagents/src/runs/foreground/workflow-detach-reconcile.js +278 -0
- package/extensions/dm-subagents/src/runs/foreground/workflow-foreground-steering.js +155 -0
- package/extensions/dm-subagents/src/runs/shared/abort-recovery.js +97 -0
- package/extensions/dm-subagents/src/runs/shared/acceptance.js +597 -148
- package/extensions/dm-subagents/src/runs/shared/agent-contract.js +35 -0
- package/extensions/dm-subagents/src/runs/shared/async-status-projection.js +472 -0
- package/extensions/dm-subagents/src/runs/shared/background-process-options.js +6 -0
- package/extensions/dm-subagents/src/runs/shared/capability-ceiling.js +175 -0
- package/extensions/dm-subagents/src/runs/shared/child-identity.js +32 -0
- package/extensions/dm-subagents/src/runs/shared/child-launch-plan.js +65 -0
- package/extensions/dm-subagents/src/runs/shared/child-protocol.js +447 -0
- package/extensions/dm-subagents/src/runs/shared/claude-code-adapter.js +120 -0
- package/extensions/dm-subagents/src/runs/shared/codex-exec-adapter.js +129 -0
- package/extensions/dm-subagents/src/runs/shared/completion-evidence.js +40 -0
- package/extensions/dm-subagents/src/runs/shared/completion-guard.js +140 -83
- package/extensions/dm-subagents/src/runs/shared/context-mode.js +38 -0
- package/extensions/dm-subagents/src/runs/shared/cursor-agent-adapter.js +101 -0
- package/extensions/dm-subagents/src/runs/shared/dm-args.js +445 -72
- package/extensions/dm-subagents/src/runs/shared/dm-spawn.js +27 -16
- package/extensions/dm-subagents/src/runs/shared/dynamic-fanout.js +19 -6
- package/extensions/dm-subagents/src/runs/shared/extension-bindings.js +81 -0
- package/extensions/dm-subagents/src/runs/shared/external-cli-contract.js +134 -0
- package/extensions/dm-subagents/src/runs/shared/external-cli-preflight.js +98 -0
- package/extensions/dm-subagents/src/runs/shared/external-cli-runner.js +419 -0
- package/extensions/dm-subagents/src/runs/shared/external-job-bridge.js +404 -0
- package/extensions/dm-subagents/src/runs/shared/external-job-runner.js +334 -0
- package/extensions/dm-subagents/src/runs/shared/fast-mode-extension.js +8 -0
- package/extensions/dm-subagents/src/runs/shared/host-step-status.js +228 -0
- package/extensions/dm-subagents/src/runs/shared/lane-metadata.js +104 -0
- package/extensions/dm-subagents/src/runs/shared/launch-cwd.js +17 -0
- package/extensions/dm-subagents/src/runs/shared/llm-intent-arbiter.js +190 -0
- package/extensions/dm-subagents/src/runs/shared/long-running-guard.js +48 -3
- package/extensions/dm-subagents/src/runs/shared/mcp-config-sources.js +387 -0
- package/extensions/dm-subagents/src/runs/shared/mcp-direct-tool-allowlist.js +212 -137
- package/extensions/dm-subagents/src/runs/shared/mcp-direct-tool-grant.js +131 -0
- package/extensions/dm-subagents/src/runs/shared/model-exclusions.js +207 -0
- package/extensions/dm-subagents/src/runs/shared/model-fallback.js +225 -55
- package/extensions/dm-subagents/src/runs/shared/model-scope.js +85 -28
- package/extensions/dm-subagents/src/runs/shared/mutation-evidence.js +182 -0
- package/extensions/dm-subagents/src/runs/shared/nested-events.js +264 -102
- package/extensions/dm-subagents/src/runs/shared/nested-render.js +15 -5
- package/extensions/dm-subagents/src/runs/shared/orca-progress-tabs.js +505 -0
- package/extensions/dm-subagents/src/runs/shared/parallel-handoff.js +653 -0
- package/extensions/dm-subagents/src/runs/shared/parallel-utils.js +29 -12
- package/extensions/dm-subagents/src/runs/shared/permissions.js +108 -0
- package/extensions/dm-subagents/src/runs/shared/process-signal.js +13 -0
- package/extensions/dm-subagents/src/runs/shared/run-fanout-budget.js +257 -0
- package/extensions/dm-subagents/src/runs/shared/run-history.js +133 -13
- package/extensions/dm-subagents/src/runs/shared/runtime-acknowledged-extensions.js +62 -0
- package/extensions/dm-subagents/src/runs/shared/session-lease.js +225 -0
- package/extensions/dm-subagents/src/runs/shared/single-output.js +129 -27
- package/extensions/dm-subagents/src/runs/shared/spawn-budget.js +95 -0
- package/extensions/dm-subagents/src/runs/shared/structured-output.js +129 -10
- package/extensions/dm-subagents/src/runs/shared/subagent-control.js +66 -11
- package/extensions/dm-subagents/src/runs/shared/subagent-prompt-runtime.js +548 -70
- package/extensions/dm-subagents/src/runs/shared/subagent-startup-retry.js +50 -0
- package/extensions/dm-subagents/src/runs/shared/task-intent.js +130 -0
- package/extensions/dm-subagents/src/runs/shared/tool-availability.js +59 -0
- package/extensions/dm-subagents/src/runs/shared/tool-budget.js +7 -5
- package/extensions/dm-subagents/src/runs/shared/tool-timeout.js +64 -0
- package/extensions/dm-subagents/src/runs/shared/usage-budget.js +74 -0
- package/extensions/dm-subagents/src/runs/shared/workflow-graph.js +22 -0
- package/extensions/dm-subagents/src/runs/shared/worktree-cleanup-plan.js +721 -0
- package/extensions/dm-subagents/src/runs/shared/worktree.js +168 -19
- package/extensions/dm-subagents/src/shared/accessible-dir.js +35 -0
- package/extensions/dm-subagents/src/shared/agent-stream-options.js +3 -0
- package/extensions/dm-subagents/src/shared/artifacts.js +170 -11
- package/extensions/dm-subagents/src/shared/atomic-json.js +36 -38
- package/extensions/dm-subagents/src/shared/capacity-resilient-json.js +77 -0
- package/extensions/dm-subagents/src/shared/child-session-name.js +15 -0
- package/extensions/dm-subagents/src/shared/child-transcript.js +57 -2
- package/extensions/dm-subagents/src/shared/completion-owner.js +7 -0
- package/extensions/dm-subagents/src/shared/display-text.js +142 -0
- package/extensions/dm-subagents/src/shared/extension-context.js +17 -0
- package/extensions/dm-subagents/src/shared/file-coalescer.js +9 -0
- package/extensions/dm-subagents/src/shared/file-system-retry.js +56 -0
- package/extensions/dm-subagents/src/shared/fork-context.js +96 -33
- package/extensions/dm-subagents/src/shared/formatters.js +21 -7
- package/extensions/dm-subagents/src/shared/launch-contract.js +94 -0
- package/extensions/dm-subagents/src/shared/model-info.js +10 -5
- package/extensions/dm-subagents/src/shared/node-executable.js +19 -0
- package/extensions/dm-subagents/src/shared/prompt-resources.js +10 -0
- package/extensions/dm-subagents/src/shared/pruned-fork.js +427 -0
- package/extensions/dm-subagents/src/shared/session-file-trust.js +19 -0
- package/extensions/dm-subagents/src/shared/session-tokens.js +14 -3
- package/extensions/dm-subagents/src/shared/settings.js +39 -47
- package/extensions/dm-subagents/src/shared/shortcuts.js +16 -0
- package/extensions/dm-subagents/src/shared/status-format.js +9 -2
- package/extensions/dm-subagents/src/shared/thinking-ceiling.js +41 -0
- package/extensions/dm-subagents/src/shared/types.js +47 -7
- package/extensions/dm-subagents/src/shared/utf8.js +12 -0
- package/extensions/dm-subagents/src/shared/utils.js +151 -131
- package/extensions/dm-subagents/src/shared/watch-strategy.js +3 -0
- package/extensions/dm-subagents/src/shared/workflow-child-permit.js +84 -0
- package/extensions/dm-subagents/src/slash/delegation-adapters.js +274 -0
- package/extensions/dm-subagents/src/slash/delegation-json.js +113 -0
- package/extensions/dm-subagents/src/slash/delegation-request.js +152 -0
- package/extensions/dm-subagents/src/slash/prompt-template-bridge.js +294 -243
- package/extensions/dm-subagents/src/slash/prompt-workflows.js +35 -73
- package/extensions/dm-subagents/src/slash/selector.js +101 -0
- package/extensions/dm-subagents/src/slash/slash-bridge.js +17 -1
- package/extensions/dm-subagents/src/slash/slash-commands.js +722 -732
- package/extensions/dm-subagents/src/slash/slash-live-state.js +37 -19
- package/extensions/dm-subagents/src/slash/subagents-admin.js +410 -0
- package/extensions/dm-subagents/src/tui/fleet-status.js +824 -0
- package/extensions/dm-subagents/src/tui/fleet-transcript.js +479 -0
- package/extensions/dm-subagents/src/tui/fleet.js +1326 -0
- package/extensions/dm-subagents/src/tui/render-helpers.js +22 -0
- package/extensions/dm-subagents/src/tui/render.js +1511 -261
- package/extensions/dm-subagents/src/watchdog/change-signature.js +220 -0
- package/extensions/dm-subagents/src/watchdog/child-status.js +151 -0
- package/extensions/dm-subagents/src/watchdog/emission-guard.js +90 -0
- package/extensions/dm-subagents/src/watchdog/lsp-diagnostics.js +484 -0
- package/extensions/dm-subagents/src/watchdog/model-selection.js +154 -0
- package/extensions/dm-subagents/src/watchdog/permission-arbiter.js +138 -0
- package/extensions/dm-subagents/src/watchdog/register-child.js +112 -0
- package/extensions/dm-subagents/src/watchdog/register-main.js +419 -0
- package/extensions/dm-subagents/src/watchdog/render.js +54 -0
- package/extensions/dm-subagents/src/watchdog/review.js +251 -0
- package/extensions/dm-subagents/src/watchdog/runtime.js +803 -0
- package/extensions/dm-subagents/src/watchdog/scope.js +56 -0
- package/extensions/dm-subagents/src/watchdog/settings.js +515 -0
- package/extensions/dm-subagents/src/watchdog/tool-actions.js +151 -0
- package/extensions/dm-subagents/src/watchdog/turn-delta.js +169 -0
- package/extensions/dm-subagents/src/watchdog/types.js +29 -0
- package/extensions/dm-subagents/src/watchdog/warning-format.js +58 -0
- package/extensions/dm-subagents/src/workflows/chat-progress.js +116 -0
- package/extensions/dm-subagents/src/workflows/host-command.js +227 -0
- package/extensions/dm-subagents/src/workflows/scripted-workflow.js +2011 -0
- package/extensions/dm-subagents/src/workflows/workflow-child-summary.js +116 -0
- package/extensions/dm-subagents/src/workflows/workflow-preflight.js +243 -0
- package/extensions/dm-subagents/src/workflows/workflow-receipt.js +387 -0
- package/extensions/dm-subagents/src/workflows/workflow-settlement.js +189 -0
- package/package.json +4 -3
- package/extensions/dm-fff/package.json +0 -21
- package/extensions/dm-fff/src/index.js +0 -691
- package/extensions/dm-fff/src/query.js +0 -60
- package/extensions/dm-subagents/agents/context-builder.md +0 -46
- package/extensions/dm-subagents/agents/planner.md +0 -55
- package/extensions/dm-subagents/prompts/parallel-context-build.md +0 -55
- package/extensions/dm-subagents/prompts/parallel-handoff-plan.md +0 -61
- package/extensions/dm-subagents/src/runs/background/wait.js +0 -206
- package/extensions/dm-subagents/src/runs/foreground/chain-clarify.js +0 -1013
- package/extensions/dm-subagents/src/runs/foreground/chain-execution.js +0 -981
- package/extensions/dm-subagents/src/runs/shared/turn-budget.js +0 -50
|
@@ -0,0 +1,824 @@
|
|
|
1
|
+
import { isKeyRelease, Key, matchesKey, truncateToWidth, visibleWidth } from "@duckmind/dm-tui";
|
|
2
|
+
import { snapshotExternalRuns } from "../api/external-runs.js";
|
|
3
|
+
import { formatModelThinking } from "../shared/formatters.js";
|
|
4
|
+
import { projectAsyncWorkflowRows } from "../runs/shared/async-status-projection.js";
|
|
5
|
+
import { contextModeLabel } from "../runs/shared/context-mode.js";
|
|
6
|
+
import { formatWorkflowJsonPreview } from "../workflows/scripted-workflow.js";
|
|
7
|
+
import { hostStepReportName, hostStepVerdictLabel } from "../runs/shared/host-step-status.js";
|
|
8
|
+
import { isStaleExtensionContextError } from "../shared/extension-context.js";
|
|
9
|
+
export const FLEET_STATUS_WIDGET_KEY = "subagent-fleet-status";
|
|
10
|
+
const MAX_AGENT_ROWS = 6;
|
|
11
|
+
const REFRESH_MS = 500;
|
|
12
|
+
export function resolveFleetViewPlacement(value) {
|
|
13
|
+
return value === "aboveEditor" ? "aboveEditor" : "belowEditor";
|
|
14
|
+
}
|
|
15
|
+
export function formatFleetElapsed(ms) {
|
|
16
|
+
return `${Math.max(0, Math.round(ms / 1000))}s`;
|
|
17
|
+
}
|
|
18
|
+
export function formatFleetTokens(count, window) {
|
|
19
|
+
const compact = (value) => value >= 1e6 ? `${(value / 1e6).toFixed(1)}M` : value >= 1000 ? `${(value / 1000).toFixed(1)}k` : `${Math.max(0, Math.round(value))}`;
|
|
20
|
+
return window !== undefined ? `↓ ${compact(window)} window · ${compact(count)} spent` : `↓ ${compact(count)} tokens`;
|
|
21
|
+
}
|
|
22
|
+
function rightAlign(left, right, width) {
|
|
23
|
+
const rightWidth = visibleWidth(right);
|
|
24
|
+
const maxLeftWidth = Math.max(0, width - rightWidth - 1);
|
|
25
|
+
const leftClamped = truncateToWidth(left, maxLeftWidth);
|
|
26
|
+
const gap = Math.max(1, width - visibleWidth(leftClamped) - rightWidth);
|
|
27
|
+
return truncateToWidth(`${leftClamped}${" ".repeat(gap)}${right}`, width);
|
|
28
|
+
}
|
|
29
|
+
function isActiveState(value) {
|
|
30
|
+
return value === "running" || value === "queued" || value === "pending";
|
|
31
|
+
}
|
|
32
|
+
function nestedRunLabel(run) {
|
|
33
|
+
if (run.agent)
|
|
34
|
+
return run.agent;
|
|
35
|
+
if (run.agents?.length)
|
|
36
|
+
return run.agents.length === 1 ? run.agents[0] : `${run.agents.slice(0, 2).join(", ")}${run.agents.length > 2 ? ` +${run.agents.length - 2}` : ""}`;
|
|
37
|
+
return run.id;
|
|
38
|
+
}
|
|
39
|
+
function nestedActivity(node) {
|
|
40
|
+
if (node.currentTool)
|
|
41
|
+
return `tool ${node.currentTool}`;
|
|
42
|
+
if (node.currentPath)
|
|
43
|
+
return node.currentPath.split(/[\\/]/).at(-1);
|
|
44
|
+
if (node.activityState === "needs_attention")
|
|
45
|
+
return "needs attention";
|
|
46
|
+
if (node.activityState === "active_long_running")
|
|
47
|
+
return "long-running";
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
function visibleWorkflowRows(rows, visibleLimit) {
|
|
51
|
+
if (!rows?.length)
|
|
52
|
+
return [];
|
|
53
|
+
if (rows.length <= visibleLimit)
|
|
54
|
+
return rows;
|
|
55
|
+
const selected = new Set;
|
|
56
|
+
for (const [index, row] of rows.entries()) {
|
|
57
|
+
if (!isWorkflowRowTerminal(row))
|
|
58
|
+
selected.add(index);
|
|
59
|
+
if (selected.size >= visibleLimit)
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
for (let index = rows.length - 1;index >= 0 && selected.size < visibleLimit; index--)
|
|
63
|
+
selected.add(index);
|
|
64
|
+
const visible = [...selected].sort((left, right) => left - right).map((index) => rows[index]);
|
|
65
|
+
return [{ name: `… +${rows.length - visible.length} hidden workflow steps`, state: "complete", overflow: rows.length - visible.length }, ...visible];
|
|
66
|
+
}
|
|
67
|
+
function isWorkflowRowTerminal(row) {
|
|
68
|
+
if (row.kind)
|
|
69
|
+
return row.state === "done" || row.state === "cancelled" || row.state === "error";
|
|
70
|
+
return row.state === "complete" || row.state === "completed";
|
|
71
|
+
}
|
|
72
|
+
function nestedStatusGlyph(state, theme) {
|
|
73
|
+
if (state === "running")
|
|
74
|
+
return theme.fg("accent", "●");
|
|
75
|
+
if (state === "queued" || state === "pending" || state === "planned")
|
|
76
|
+
return theme.fg("muted", "◦");
|
|
77
|
+
if (state === "complete" || state === "completed")
|
|
78
|
+
return theme.fg("success", "✓");
|
|
79
|
+
if (state === "failed" || state === "rejected")
|
|
80
|
+
return theme.fg("error", "✗");
|
|
81
|
+
return theme.fg("warning", "■");
|
|
82
|
+
}
|
|
83
|
+
function nestedStepDisplayCount(steps, start = 0) {
|
|
84
|
+
let count = 0;
|
|
85
|
+
for (let index = start;index < (steps?.length ?? 0); index++) {
|
|
86
|
+
count += 1 + nestedDisplayCount(steps[index].children);
|
|
87
|
+
}
|
|
88
|
+
return count;
|
|
89
|
+
}
|
|
90
|
+
function nestedDisplayCount(children, start = 0) {
|
|
91
|
+
let count = 0;
|
|
92
|
+
for (let index = start;index < (children?.length ?? 0); index++) {
|
|
93
|
+
const child = children[index];
|
|
94
|
+
const steps = child.mode === "parallel" || child.mode === "chain" ? child.steps ?? [] : [];
|
|
95
|
+
count += steps.length > 0 ? nestedStepDisplayCount(steps) : 1;
|
|
96
|
+
count += nestedDisplayCount(child.children);
|
|
97
|
+
}
|
|
98
|
+
return count;
|
|
99
|
+
}
|
|
100
|
+
function nestedFleetRows(children, visibleLimit) {
|
|
101
|
+
const rows = [];
|
|
102
|
+
let omitted = 0;
|
|
103
|
+
const appendRuns = (runs, depth) => {
|
|
104
|
+
for (let runIndex = 0;runIndex < (runs?.length ?? 0); runIndex++) {
|
|
105
|
+
const child = runs[runIndex];
|
|
106
|
+
const steps = child.mode === "parallel" || child.mode === "chain" ? child.steps ?? [] : [];
|
|
107
|
+
if (steps.length > 0) {
|
|
108
|
+
for (let stepIndex = 0;stepIndex < steps.length; stepIndex++) {
|
|
109
|
+
if (rows.length >= visibleLimit) {
|
|
110
|
+
omitted += nestedStepDisplayCount(steps, stepIndex);
|
|
111
|
+
omitted += nestedDisplayCount(child.children);
|
|
112
|
+
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
const step = steps[stepIndex];
|
|
116
|
+
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
117
|
+
const activity = nestedActivity(step);
|
|
118
|
+
rows.push({
|
|
119
|
+
name: step.agent,
|
|
120
|
+
state: step.status,
|
|
121
|
+
depth,
|
|
122
|
+
...modelThinking ? { modelThinking } : {},
|
|
123
|
+
...activity ? { activity } : {},
|
|
124
|
+
...step.startedAt !== undefined ? { startedAt: step.startedAt } : {}
|
|
125
|
+
});
|
|
126
|
+
if (!appendRuns(step.children, depth + 1)) {
|
|
127
|
+
omitted += nestedStepDisplayCount(steps, stepIndex + 1);
|
|
128
|
+
omitted += nestedDisplayCount(child.children);
|
|
129
|
+
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
if (rows.length >= visibleLimit) {
|
|
135
|
+
omitted += nestedDisplayCount(runs, runIndex);
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
const modelThinking = formatModelThinking(child.model, child.thinking) || undefined;
|
|
139
|
+
const activity = nestedActivity(child);
|
|
140
|
+
rows.push({
|
|
141
|
+
name: nestedRunLabel(child),
|
|
142
|
+
state: child.state,
|
|
143
|
+
depth,
|
|
144
|
+
...modelThinking ? { modelThinking } : {},
|
|
145
|
+
...activity ? { activity } : {},
|
|
146
|
+
...child.startedAt !== undefined ? { startedAt: child.startedAt } : {}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (!appendRuns(child.children, depth + 1)) {
|
|
150
|
+
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return true;
|
|
155
|
+
};
|
|
156
|
+
appendRuns(children, 0);
|
|
157
|
+
if (omitted > 0)
|
|
158
|
+
rows.push({ name: `… +${omitted} more nested leaves`, state: "complete", depth: 0, overflow: omitted });
|
|
159
|
+
return rows;
|
|
160
|
+
}
|
|
161
|
+
function fleetTreeRows(entries) {
|
|
162
|
+
const rows = [];
|
|
163
|
+
const entryKeys = new Set(entries.map((entry) => entry.key));
|
|
164
|
+
const childrenByParent = new Map;
|
|
165
|
+
for (const entry of entries) {
|
|
166
|
+
if (!entry.parentKey || !entryKeys.has(entry.parentKey))
|
|
167
|
+
continue;
|
|
168
|
+
const children = childrenByParent.get(entry.parentKey) ?? [];
|
|
169
|
+
children.push(entry);
|
|
170
|
+
childrenByParent.set(entry.parentKey, children);
|
|
171
|
+
}
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
if (entry.parentKey && entryKeys.has(entry.parentKey))
|
|
174
|
+
continue;
|
|
175
|
+
rows.push({ kind: "owner", entry });
|
|
176
|
+
const attached = childrenByParent.get(entry.key) ?? [];
|
|
177
|
+
const workflowRows = visibleWorkflowRows(entry.workflowRows, attached.length > 0 ? 2 : 4);
|
|
178
|
+
for (const [index, child] of attached.entries()) {
|
|
179
|
+
const nested = nestedFleetRows(child.nestedChildren, 3);
|
|
180
|
+
const laterRows = index < attached.length - 1 || workflowRows.length > 0 || Boolean(entry.nestedChildren?.length);
|
|
181
|
+
rows.push({ kind: "child", entry: child, last: !laterRows && nested.length === 0 });
|
|
182
|
+
for (const [nestedIndex, row] of nested.entries())
|
|
183
|
+
rows.push({
|
|
184
|
+
kind: "nested",
|
|
185
|
+
ownerKey: child.key,
|
|
186
|
+
row: { ...row, depth: row.depth + 1 },
|
|
187
|
+
last: nestedIndex === nested.length - 1 && !laterRows
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
for (const [index, row] of workflowRows.entries())
|
|
191
|
+
rows.push({ kind: "workflow", ownerKey: entry.key, row, last: index === workflowRows.length - 1 && !entry.nestedChildren?.length });
|
|
192
|
+
const nested = nestedFleetRows(entry.nestedChildren, attached.length > 0 ? 3 : 4);
|
|
193
|
+
for (const [index, row] of nested.entries())
|
|
194
|
+
rows.push({ kind: "nested", ownerKey: entry.key, row, last: index === nested.length - 1 });
|
|
195
|
+
}
|
|
196
|
+
return rows;
|
|
197
|
+
}
|
|
198
|
+
function foregroundDescription(control, description) {
|
|
199
|
+
if (!control.parentWorkflowRunId)
|
|
200
|
+
return description;
|
|
201
|
+
const workflow = `workflow child: ${control.parentWorkflowRunId}${control.workflowKey ? ` (${control.workflowKey})` : ""}`;
|
|
202
|
+
return description ? `${workflow} · ${description}` : workflow;
|
|
203
|
+
}
|
|
204
|
+
function workflowIdentityCandidates(step) {
|
|
205
|
+
return [...new Set([step.workflowKey, step.runId].filter((value) => typeof value === "string" && value.length > 0))];
|
|
206
|
+
}
|
|
207
|
+
function asyncJobIdentityCandidates(job) {
|
|
208
|
+
return [...new Set([job.workflowKey, job.asyncId].filter((value) => typeof value === "string" && value.length > 0))];
|
|
209
|
+
}
|
|
210
|
+
function linkedWorkflowParentKey(parentWorkflowRunId, activeWorkflowKeys) {
|
|
211
|
+
if (!parentWorkflowRunId)
|
|
212
|
+
return;
|
|
213
|
+
const parentKey = `async:${parentWorkflowRunId}`;
|
|
214
|
+
return activeWorkflowKeys.has(parentKey) ? parentKey : undefined;
|
|
215
|
+
}
|
|
216
|
+
function workflowStepsWithoutMaterializedChildren(steps, materializedChildIds) {
|
|
217
|
+
if (!steps?.length || !materializedChildIds?.size)
|
|
218
|
+
return steps;
|
|
219
|
+
return steps.filter((step) => !workflowIdentityCandidates(step).some((identity) => materializedChildIds.has(identity)));
|
|
220
|
+
}
|
|
221
|
+
function activeLeafAgentCount(entries) {
|
|
222
|
+
return entries.filter((entry) => !entry.workflowWrapper && !entry.surface).length;
|
|
223
|
+
}
|
|
224
|
+
function projectPaneNeedsAttention(pane) {
|
|
225
|
+
return ["attention", "blocked", "paused", "failed", "error"].some((status) => pane.agentStatus.includes(status)) || pane.summary?.includes("⚠") === true;
|
|
226
|
+
}
|
|
227
|
+
function projectName(projectRoot) {
|
|
228
|
+
return projectRoot.split(/[\\/]/).filter(Boolean).at(-1) ?? projectRoot;
|
|
229
|
+
}
|
|
230
|
+
function projectPaneEntries(state) {
|
|
231
|
+
return [...state.herdrProjectPanes?.values() ?? []].filter((pane) => pane.state === "open").sort((left, right) => left.openedAt.localeCompare(right.openedAt) || left.projectRoot.localeCompare(right.projectRoot)).map((pane) => ({
|
|
232
|
+
key: `project-pane:${pane.projectRoot}`,
|
|
233
|
+
surface: "project-pane",
|
|
234
|
+
agent: `${projectName(pane.projectRoot)} · ${pane.paneId}`,
|
|
235
|
+
description: pane.summary,
|
|
236
|
+
startedAt: Date.parse(pane.openedAt) || pane.refreshedAt,
|
|
237
|
+
tokens: 0,
|
|
238
|
+
state: pane.agentStatus || "unknown",
|
|
239
|
+
projectPane: pane
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
export function collectFleetStatusEntries(state) {
|
|
243
|
+
const entries = [];
|
|
244
|
+
const activeWorkflowKeys = new Set([...state.asyncJobs.values()].filter((job) => job.mode === "workflow" && isActiveState(job.status)).map((job) => `async:${job.asyncId}`));
|
|
245
|
+
const materializedChildrenByWorkflow = new Map;
|
|
246
|
+
for (const job of state.asyncJobs.values()) {
|
|
247
|
+
if (!isActiveState(job.status) || !job.parentWorkflowRunId)
|
|
248
|
+
continue;
|
|
249
|
+
const parentKey = linkedWorkflowParentKey(job.parentWorkflowRunId, activeWorkflowKeys);
|
|
250
|
+
if (!parentKey)
|
|
251
|
+
continue;
|
|
252
|
+
const childIds = materializedChildrenByWorkflow.get(parentKey) ?? new Set;
|
|
253
|
+
for (const identity of asyncJobIdentityCandidates(job))
|
|
254
|
+
childIds.add(identity);
|
|
255
|
+
materializedChildrenByWorkflow.set(parentKey, childIds);
|
|
256
|
+
}
|
|
257
|
+
for (const control of state.foregroundControls.values()) {
|
|
258
|
+
const linkedParentKey = linkedWorkflowParentKey(control.parentWorkflowRunId, activeWorkflowKeys);
|
|
259
|
+
if (control.activeChildren) {
|
|
260
|
+
const nestedChildren = control.nestedChildren ?? [];
|
|
261
|
+
const nestedChildrenByParentStep = new Map;
|
|
262
|
+
for (const nested of nestedChildren) {
|
|
263
|
+
if (nested.parentStepIndex === undefined)
|
|
264
|
+
continue;
|
|
265
|
+
const children = nestedChildrenByParentStep.get(nested.parentStepIndex) ?? [];
|
|
266
|
+
children.push(nested);
|
|
267
|
+
nestedChildrenByParentStep.set(nested.parentStepIndex, children);
|
|
268
|
+
}
|
|
269
|
+
for (const child of [...control.activeChildren.values()].sort((left, right) => left.index - right.index)) {
|
|
270
|
+
const modelThinking = formatModelThinking(child.model, child.thinking) || undefined;
|
|
271
|
+
const childNestedChildren = nestedChildrenByParentStep.get(child.index) ?? (control.activeChildren.size === 1 && nestedChildren.length ? nestedChildren : undefined);
|
|
272
|
+
entries.push({
|
|
273
|
+
key: `foreground-active:${control.runId}:${child.index}`,
|
|
274
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
275
|
+
agent: child.agent,
|
|
276
|
+
...modelThinking ? { modelThinking } : {},
|
|
277
|
+
description: foregroundDescription(control, child.description),
|
|
278
|
+
startedAt: child.startedAt,
|
|
279
|
+
tokens: child.tokens ?? 0,
|
|
280
|
+
...child.window !== undefined ? { window: child.window } : {},
|
|
281
|
+
state: "running",
|
|
282
|
+
...childNestedChildren?.length ? { nestedChildren: childNestedChildren } : {}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const modelThinking = formatModelThinking(control.model, control.thinking) || undefined;
|
|
288
|
+
entries.push({
|
|
289
|
+
key: `foreground-active:${control.runId}:${control.currentIndex ?? 0}`,
|
|
290
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
291
|
+
agent: control.currentAgent ?? control.mode,
|
|
292
|
+
...modelThinking ? { modelThinking } : {},
|
|
293
|
+
description: foregroundDescription(control, control.description),
|
|
294
|
+
startedAt: control.startedAt,
|
|
295
|
+
tokens: control.tokens ?? 0,
|
|
296
|
+
...control.window !== undefined ? { window: control.window } : {},
|
|
297
|
+
state: "running",
|
|
298
|
+
...control.nestedChildren?.length ? { nestedChildren: control.nestedChildren } : {}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
for (const job of state.asyncJobs.values()) {
|
|
302
|
+
if (!isActiveState(job.status))
|
|
303
|
+
continue;
|
|
304
|
+
const startedAt = job.startedAt ?? job.updatedAt ?? Date.now();
|
|
305
|
+
const linkedParentKey = linkedWorkflowParentKey(job.parentWorkflowRunId, activeWorkflowKeys);
|
|
306
|
+
if (job.mode === "workflow") {
|
|
307
|
+
const latestEmit = job.workflow?.emits?.length ? formatWorkflowJsonPreview(job.workflow.emits.at(-1), 120) : undefined;
|
|
308
|
+
const workflowSteps = workflowStepsWithoutMaterializedChildren(job.steps, materializedChildrenByWorkflow.get(`async:${job.asyncId}`));
|
|
309
|
+
const workflowRows = projectAsyncWorkflowRows(workflowSteps, job.workflowGraph ?? job.hostSteps, job.preflight);
|
|
310
|
+
entries.push({
|
|
311
|
+
key: `async:${job.asyncId}`,
|
|
312
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
313
|
+
workflowWrapper: true,
|
|
314
|
+
agent: "workflow",
|
|
315
|
+
description: latestEmit !== undefined ? `latest emit: ${latestEmit}` : job.description,
|
|
316
|
+
startedAt,
|
|
317
|
+
tokens: job.totalTokens?.total ?? 0,
|
|
318
|
+
...job.totalTokens?.window !== undefined ? { window: job.totalTokens.window } : {},
|
|
319
|
+
state: job.status,
|
|
320
|
+
...workflowRows.length ? { workflowRows } : {},
|
|
321
|
+
...job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}
|
|
322
|
+
});
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
const steps = job.steps?.length ? job.steps : job.agents?.map((agent, index) => {
|
|
326
|
+
const pending = job.status === "queued" || job.mode === "chain" && !job.activeParallelGroup && index !== (job.currentStep ?? 0);
|
|
327
|
+
return { agent, index, status: pending ? "pending" : "running" };
|
|
328
|
+
});
|
|
329
|
+
if (!steps?.length) {
|
|
330
|
+
entries.push({
|
|
331
|
+
key: `async:${job.asyncId}`,
|
|
332
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
333
|
+
agent: job.mode ?? "subagent",
|
|
334
|
+
description: job.description,
|
|
335
|
+
startedAt,
|
|
336
|
+
tokens: job.totalTokens?.total ?? 0,
|
|
337
|
+
...job.totalTokens?.window !== undefined ? { window: job.totalTokens.window } : {},
|
|
338
|
+
state: job.status,
|
|
339
|
+
...job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}
|
|
340
|
+
});
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
for (const [offset, step] of steps.entries()) {
|
|
344
|
+
if (!isActiveState(step.status))
|
|
345
|
+
continue;
|
|
346
|
+
const index = step.index ?? offset;
|
|
347
|
+
if (step.status === "pending" && job.mode === "chain" && !job.activeParallelGroup && index !== (job.currentStep ?? 0))
|
|
348
|
+
continue;
|
|
349
|
+
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
350
|
+
entries.push({
|
|
351
|
+
key: `async:${job.asyncId}:${index}`,
|
|
352
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
353
|
+
agent: step.label ? `${step.label} (${step.agent})` : step.agent,
|
|
354
|
+
...modelThinking ? { modelThinking } : {},
|
|
355
|
+
description: step.description ?? job.description,
|
|
356
|
+
startedAt: step.startedAt ?? startedAt,
|
|
357
|
+
tokens: step.tokens?.total ?? (steps.length === 1 ? job.totalTokens?.total ?? 0 : 0),
|
|
358
|
+
...(step.tokens?.window ?? (steps.length === 1 ? job.totalTokens?.window : undefined)) !== undefined ? { window: step.tokens?.window ?? job.totalTokens?.window } : {},
|
|
359
|
+
state: step.status,
|
|
360
|
+
...(step.children?.length ?? 0) > 0 ? { nestedChildren: step.children } : job.nestedChildren?.filter((nested) => nested.parentStepIndex === index).length ? { nestedChildren: job.nestedChildren.filter((nested) => nested.parentStepIndex === index) } : {}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (state.currentSessionId) {
|
|
365
|
+
try {
|
|
366
|
+
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => console.warn(`[dm-subagents] Removed ${message}`) })) {
|
|
367
|
+
if (!isActiveState(run.state))
|
|
368
|
+
continue;
|
|
369
|
+
entries.push({
|
|
370
|
+
key: `external:${run.id}`,
|
|
371
|
+
agent: `external · ${run.label}`,
|
|
372
|
+
description: run.currentAction ?? `source: ${run.source}`,
|
|
373
|
+
startedAt: run.startedAt,
|
|
374
|
+
tokens: 0,
|
|
375
|
+
state: run.state,
|
|
376
|
+
external: true
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
} catch (cause) {
|
|
380
|
+
console.warn(`[dm-subagents] Failed to inspect external jobs: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
entries.push(...projectPaneEntries(state));
|
|
384
|
+
return entries.sort((left, right) => left.startedAt - right.startedAt || left.key.localeCompare(right.key));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export class SubagentFleetStatus {
|
|
388
|
+
ctx;
|
|
389
|
+
ui;
|
|
390
|
+
tui;
|
|
391
|
+
inputUnsubscribe;
|
|
392
|
+
timer;
|
|
393
|
+
widgetRegistered = false;
|
|
394
|
+
active = false;
|
|
395
|
+
selectedKey = "main";
|
|
396
|
+
inspectorOpen = false;
|
|
397
|
+
lastRenderKey = "";
|
|
398
|
+
entries = [];
|
|
399
|
+
state;
|
|
400
|
+
openInspector;
|
|
401
|
+
refreshMs;
|
|
402
|
+
maxAgentRows;
|
|
403
|
+
placement;
|
|
404
|
+
constructor(state, openInspector, options = {}) {
|
|
405
|
+
this.state = state;
|
|
406
|
+
this.openInspector = openInspector;
|
|
407
|
+
this.refreshMs = options.refreshMs ?? REFRESH_MS;
|
|
408
|
+
this.maxAgentRows = options.maxAgentRows ?? MAX_AGENT_ROWS;
|
|
409
|
+
this.placement = options.placement ?? "belowEditor";
|
|
410
|
+
}
|
|
411
|
+
setContext(ctx) {
|
|
412
|
+
if (!ctx.hasUI)
|
|
413
|
+
return;
|
|
414
|
+
const ui = ctx.ui;
|
|
415
|
+
if (this.ui === ui) {
|
|
416
|
+
this.ctx = ctx;
|
|
417
|
+
this.refresh();
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
this.clearUiRegistration();
|
|
421
|
+
this.ctx = ctx;
|
|
422
|
+
this.ui = ui;
|
|
423
|
+
if (typeof ui.onTerminalInput === "function") {
|
|
424
|
+
this.inputUnsubscribe = ui.onTerminalInput((data) => this.handleKey(data));
|
|
425
|
+
}
|
|
426
|
+
this.timer = setInterval(() => this.refresh(), this.refreshMs);
|
|
427
|
+
this.timer.unref?.();
|
|
428
|
+
this.refresh();
|
|
429
|
+
}
|
|
430
|
+
dispose() {
|
|
431
|
+
this.clearUiRegistration();
|
|
432
|
+
this.ctx = undefined;
|
|
433
|
+
this.ui = undefined;
|
|
434
|
+
this.entries = [];
|
|
435
|
+
this.active = false;
|
|
436
|
+
this.selectedKey = "main";
|
|
437
|
+
this.inspectorOpen = false;
|
|
438
|
+
this.lastRenderKey = "";
|
|
439
|
+
}
|
|
440
|
+
refresh() {
|
|
441
|
+
const ctx = this.getActiveUiContext();
|
|
442
|
+
if (!ctx)
|
|
443
|
+
return;
|
|
444
|
+
if (this.state.widgetsSuspended) {
|
|
445
|
+
this.clearWidget();
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
this.entries = collectFleetStatusEntries(this.state);
|
|
449
|
+
this.clampSelection();
|
|
450
|
+
if (this.inspectorOpen || this.state.fleetInspectorOpen) {
|
|
451
|
+
this.lastRenderKey = "";
|
|
452
|
+
this.clearWidget();
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (!this.hasInlineSurface()) {
|
|
456
|
+
this.active = false;
|
|
457
|
+
this.selectedKey = "main";
|
|
458
|
+
this.lastRenderKey = "";
|
|
459
|
+
this.clearWidget();
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
const renderKey = this.getRenderKey();
|
|
463
|
+
if (!this.widgetRegistered) {
|
|
464
|
+
ctx.ui.setWidget(FLEET_STATUS_WIDGET_KEY, (tui, theme) => {
|
|
465
|
+
this.tui = tui;
|
|
466
|
+
return {
|
|
467
|
+
render: (width) => this.render(width, theme),
|
|
468
|
+
invalidate: () => {
|
|
469
|
+
this.lastRenderKey = "";
|
|
470
|
+
},
|
|
471
|
+
dispose: () => {
|
|
472
|
+
if (this.tui !== tui)
|
|
473
|
+
return;
|
|
474
|
+
this.widgetRegistered = false;
|
|
475
|
+
this.tui = undefined;
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}, { placement: this.placement });
|
|
479
|
+
this.widgetRegistered = true;
|
|
480
|
+
this.lastRenderKey = renderKey;
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (renderKey === this.lastRenderKey) {
|
|
484
|
+
if (this.entries.some((entry) => entry.state === "running"))
|
|
485
|
+
this.tui?.requestRender();
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
this.lastRenderKey = renderKey;
|
|
489
|
+
this.tui?.requestRender();
|
|
490
|
+
}
|
|
491
|
+
handleKey(data) {
|
|
492
|
+
if (this.state.widgetsSuspended)
|
|
493
|
+
return;
|
|
494
|
+
const ctx = this.getActiveUiContext();
|
|
495
|
+
if (!ctx || this.entries.length === 0 || isKeyRelease(data))
|
|
496
|
+
return;
|
|
497
|
+
if (this.inspectorOpen)
|
|
498
|
+
return;
|
|
499
|
+
if (!this.editorHasFocus()) {
|
|
500
|
+
if (this.active)
|
|
501
|
+
this.deactivate();
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (!this.active) {
|
|
505
|
+
const activates = matchesKey(data, "down") || matchesKey(data, "left");
|
|
506
|
+
if (!activates || ctx.ui.getEditorText() !== "")
|
|
507
|
+
return;
|
|
508
|
+
this.active = true;
|
|
509
|
+
this.selectedKey = "main";
|
|
510
|
+
this.refresh();
|
|
511
|
+
return { consume: true };
|
|
512
|
+
}
|
|
513
|
+
const roster = this.rosterKeys();
|
|
514
|
+
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
515
|
+
if (matchesKey(data, "down") || matchesKey(data, "j")) {
|
|
516
|
+
this.selectedKey = roster[Math.min(roster.length - 1, selectedIndex + 1)] ?? "main";
|
|
517
|
+
this.refresh();
|
|
518
|
+
return { consume: true };
|
|
519
|
+
}
|
|
520
|
+
if (matchesKey(data, "up") || matchesKey(data, "k")) {
|
|
521
|
+
if (selectedIndex === 0) {
|
|
522
|
+
this.deactivate();
|
|
523
|
+
return { consume: true };
|
|
524
|
+
}
|
|
525
|
+
this.selectedKey = roster[selectedIndex - 1] ?? "main";
|
|
526
|
+
this.refresh();
|
|
527
|
+
return { consume: true };
|
|
528
|
+
}
|
|
529
|
+
if (matchesKey(data, "escape")) {
|
|
530
|
+
this.deactivate();
|
|
531
|
+
return { consume: true };
|
|
532
|
+
}
|
|
533
|
+
if (matchesKey(data, Key.enter)) {
|
|
534
|
+
if (this.selectedKey === "main") {
|
|
535
|
+
this.deactivate();
|
|
536
|
+
return { consume: true };
|
|
537
|
+
}
|
|
538
|
+
this.inspectorOpen = true;
|
|
539
|
+
this.refresh();
|
|
540
|
+
const selectedKey = this.selectedKey;
|
|
541
|
+
Promise.resolve().then(() => this.openInspector(selectedKey)).catch((error) => ctx.ui.notify(error instanceof Error ? error.message : String(error), "error")).finally(() => {
|
|
542
|
+
this.inspectorOpen = false;
|
|
543
|
+
this.refresh();
|
|
544
|
+
});
|
|
545
|
+
return { consume: true };
|
|
546
|
+
}
|
|
547
|
+
this.deactivate();
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
render(width, theme) {
|
|
551
|
+
if (!this.hasInlineSurface())
|
|
552
|
+
return [];
|
|
553
|
+
if (!this.active) {
|
|
554
|
+
const workEntries = this.entries.filter((entry) => !entry.surface);
|
|
555
|
+
const projectEntries = this.entries.filter((entry) => entry.surface === "project-pane");
|
|
556
|
+
const tokens = workEntries.reduce((total, entry) => total + entry.tokens, 0);
|
|
557
|
+
const nativeEntries = workEntries.filter((entry) => !entry.external);
|
|
558
|
+
const window = nativeEntries.length > 0 && nativeEntries.every((entry) => entry.window !== undefined) ? nativeEntries.reduce((total, entry) => total + entry.window, 0) : undefined;
|
|
559
|
+
const capacity = this.state.activeAsyncCapacity;
|
|
560
|
+
const hasNativeRows = workEntries.some((entry) => !entry.external);
|
|
561
|
+
const showNativeSummary = hasNativeRows || Boolean(capacity?.used);
|
|
562
|
+
const asyncRuns = capacity && showNativeSummary ? `Async runs ${capacity.used}/${capacity.limit || "∞"}` : "";
|
|
563
|
+
const activeEntries = activeLeafAgentCount(workEntries);
|
|
564
|
+
const noun = workEntries.some((entry) => entry.external) ? "job" : "agent";
|
|
565
|
+
const agents = activeEntries > 0 ? `${activeEntries} active ${noun}${activeEntries === 1 ? "" : "s"}` : "";
|
|
566
|
+
const paneAttention = projectEntries.filter((entry) => entry.projectPane && projectPaneNeedsAttention(entry.projectPane)).length;
|
|
567
|
+
const panes = projectEntries.length > 0 ? `${projectEntries.length} pane${projectEntries.length === 1 ? "" : "s"}${paneAttention ? ` (${paneAttention} ⚠)` : ""}` : "";
|
|
568
|
+
const label = [agents, asyncRuns, panes].filter(Boolean).join(" · ");
|
|
569
|
+
const detail = [showNativeSummary ? formatFleetTokens(tokens, window) : undefined, "↓/← to inspect"].filter(Boolean).join(" · ");
|
|
570
|
+
return [truncateToWidth(` ${theme.fg("muted", label)}${label && detail ? " · " : ""}${theme.fg("dim", detail)}`, width)];
|
|
571
|
+
}
|
|
572
|
+
const roster = this.rosterKeys();
|
|
573
|
+
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
574
|
+
const rosterIndexByKey = new Map;
|
|
575
|
+
for (const [index, entry] of this.entries.entries()) {
|
|
576
|
+
if (!rosterIndexByKey.has(entry.key))
|
|
577
|
+
rosterIndexByKey.set(entry.key, index + 1);
|
|
578
|
+
}
|
|
579
|
+
const lines = [truncateToWidth(` ${theme.fg("dim", "↑↓/jk select · enter inspect · esc back")}`, width), ""];
|
|
580
|
+
lines.push(truncateToWidth(` ${this.bullet(0, selectedIndex, theme)} main`, width));
|
|
581
|
+
const workEntries = this.entries.filter((entry) => !entry.surface);
|
|
582
|
+
const tree = fleetTreeRows(workEntries);
|
|
583
|
+
const selectedTreeIndex = Math.max(0, tree.findIndex((row) => (row.kind === "owner" || row.kind === "child") && row.entry.key === this.selectedKey));
|
|
584
|
+
const visibleCount = Math.min(this.maxAgentRows, tree.length);
|
|
585
|
+
const start = selectedTreeIndex < visibleCount ? 0 : selectedTreeIndex - visibleCount + 1;
|
|
586
|
+
const hiddenBelow = tree.length - (start + visibleCount);
|
|
587
|
+
if (start > 0)
|
|
588
|
+
lines.push(rightAlign("", theme.fg("dim", `↑ ${start} more`), width));
|
|
589
|
+
for (let index = start;index < start + visibleCount; index++) {
|
|
590
|
+
const row = tree[index];
|
|
591
|
+
if (row.kind === "owner" || row.kind === "child") {
|
|
592
|
+
const rosterIndex = rosterIndexByKey.get(row.entry.key) ?? 0;
|
|
593
|
+
lines.push(this.renderEntry(rosterIndex, selectedIndex, row.entry, width, theme, row.kind === "child" ? row.last ? "└─" : "├─" : undefined));
|
|
594
|
+
} else if (row.kind === "workflow") {
|
|
595
|
+
lines.push(this.renderWorkflowRow(row.row, row.last, width, theme));
|
|
596
|
+
} else {
|
|
597
|
+
lines.push(this.renderNestedRow(row.row, row.last, width, theme));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
if (hiddenBelow > 0)
|
|
601
|
+
lines.push(rightAlign("", theme.fg("dim", `↓ ${hiddenBelow} more`), width));
|
|
602
|
+
this.renderProjectPaneSection(lines, selectedIndex, width, theme, rosterIndexByKey);
|
|
603
|
+
return lines;
|
|
604
|
+
}
|
|
605
|
+
renderProjectPaneSection(lines, selectedIndex, width, theme, rosterIndexByKey) {
|
|
606
|
+
const entries = this.entries.filter((entry) => entry.surface === "project-pane");
|
|
607
|
+
if (!entries.length)
|
|
608
|
+
return;
|
|
609
|
+
lines.push("", truncateToWidth(` ${theme.fg("dim", "project panes")}`, width));
|
|
610
|
+
for (const entry of entries) {
|
|
611
|
+
const rosterIndex = rosterIndexByKey.get(entry.key) ?? 0;
|
|
612
|
+
lines.push(this.renderEntry(rosterIndex, selectedIndex, entry, width, theme));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
renderEntry(rosterIndex, selectedIndex, entry, width, theme, branch) {
|
|
616
|
+
const agent = entry.modelThinking ? `${entry.agent} (${entry.modelThinking})` : entry.agent;
|
|
617
|
+
const prefix = branch ? ` ${branch}` : " ";
|
|
618
|
+
const left = `${prefix} ${this.bullet(rosterIndex, selectedIndex, theme)} ${theme.fg("muted", agent)} · ${entry.state}`;
|
|
619
|
+
const elapsed = Date.now() - entry.startedAt;
|
|
620
|
+
const rightText = entry.projectPane ? `${entry.projectPane.summary ?? "—"} · ${formatFleetElapsed(Date.now() - entry.projectPane.refreshedAt)} ago` : entry.external ? formatFleetElapsed(elapsed) : `${formatFleetElapsed(elapsed)} · ${formatFleetTokens(entry.tokens, entry.window)}`;
|
|
621
|
+
const right = theme.fg("dim", rightText);
|
|
622
|
+
return rightAlign(left, right, width);
|
|
623
|
+
}
|
|
624
|
+
renderNestedRow(row, last, width, theme) {
|
|
625
|
+
const marker = last ? "└─" : "├─";
|
|
626
|
+
const indent = " ".repeat(row.depth + 1);
|
|
627
|
+
if (row.overflow !== undefined)
|
|
628
|
+
return truncateToWidth(`${indent}${marker} ${theme.fg("dim", `+${row.overflow} nested leaves`)}`, width);
|
|
629
|
+
const modelThinking = row.modelThinking ? ` (${row.modelThinking})` : "";
|
|
630
|
+
const activity = row.activity ? ` · ${row.activity}` : "";
|
|
631
|
+
const left = `${indent}${marker} ${nestedStatusGlyph(row.state, theme)} ${theme.fg("muted", `${row.name}${modelThinking}`)} · ${row.state}${activity}`;
|
|
632
|
+
const elapsed = row.startedAt !== undefined ? ` · ${formatFleetElapsed(Date.now() - row.startedAt)}` : "";
|
|
633
|
+
return truncateToWidth(`${left}${theme.fg("dim", elapsed)}`, width);
|
|
634
|
+
}
|
|
635
|
+
workflowRowGlyph(row, theme) {
|
|
636
|
+
if (!row.kind)
|
|
637
|
+
return nestedStatusGlyph(row.state, theme);
|
|
638
|
+
const state = row.state;
|
|
639
|
+
if (state === "pending")
|
|
640
|
+
return theme.fg("muted", "◦");
|
|
641
|
+
if (state === "running")
|
|
642
|
+
return theme.fg("accent", "●");
|
|
643
|
+
if (state === "done")
|
|
644
|
+
return row.verdict === "pass" ? theme.fg("success", "✓") : row.verdict === "fail" ? theme.fg("error", "✗") : theme.fg("warning", "■");
|
|
645
|
+
if (state === "error")
|
|
646
|
+
return theme.fg("error", "✗");
|
|
647
|
+
return theme.fg("warning", "■");
|
|
648
|
+
}
|
|
649
|
+
workflowRowStateLabel(row, theme) {
|
|
650
|
+
const state = row.kind ? hostStepVerdictLabel(row.state, row.verdict) : row.state;
|
|
651
|
+
if (state === "running")
|
|
652
|
+
return theme.fg("accent", state);
|
|
653
|
+
if (state === "pending" || state === "queued")
|
|
654
|
+
return theme.fg("muted", state);
|
|
655
|
+
if (state === "pass" || state === "complete" || state === "completed")
|
|
656
|
+
return theme.fg("success", state === "pass" ? "pass" : "complete");
|
|
657
|
+
if (state === "fail" || state === "failed" || state === "error")
|
|
658
|
+
return theme.fg("error", state === "fail" ? "fail" : state);
|
|
659
|
+
return theme.fg("warning", state);
|
|
660
|
+
}
|
|
661
|
+
renderWorkflowRow(row, last, width, theme) {
|
|
662
|
+
const marker = last ? "└─" : "├─";
|
|
663
|
+
const indent = " ";
|
|
664
|
+
if (row.overflow !== undefined)
|
|
665
|
+
return truncateToWidth(`${indent}${marker} ${theme.fg("dim", `+${row.overflow} hidden workflow steps`)}`, width);
|
|
666
|
+
const context = contextModeLabel(row.context);
|
|
667
|
+
const modelThinking = row.modelThinking ? ` (${row.modelThinking})` : "";
|
|
668
|
+
const activity = row.activity ? ` · ${row.activity}` : "";
|
|
669
|
+
const kind = row.kind ? `${row.kind}: ` : "";
|
|
670
|
+
const hints = row.preflight ? [
|
|
671
|
+
row.preflight.mode ? `mode:${row.preflight.mode}` : undefined,
|
|
672
|
+
row.preflight.decision ? `decision:${row.preflight.decision}` : undefined,
|
|
673
|
+
row.preflight.claims?.length ? `claims:${row.preflight.claims.join(",")}` : undefined,
|
|
674
|
+
row.preflight.expectedOutput ? `expected:${row.preflight.expectedOutput}` : undefined,
|
|
675
|
+
row.preflight.independence ? `independence:${row.preflight.independence}` : undefined
|
|
676
|
+
].filter((value) => Boolean(value)).join(" · ") : "";
|
|
677
|
+
const left = `${indent}${marker} ${this.workflowRowGlyph(row, theme)} ${theme.fg("muted", `${kind}${row.name}${context ? ` ${context}` : ""}${modelThinking}`)} · ${this.workflowRowStateLabel(row, theme)}${activity}${hints ? ` · ${hints}` : ""}`;
|
|
678
|
+
const details = [
|
|
679
|
+
row.startedAt !== undefined ? formatFleetElapsed(Date.now() - row.startedAt) : undefined,
|
|
680
|
+
row.tokens !== undefined ? formatFleetTokens(row.tokens, row.window) : undefined,
|
|
681
|
+
row.provider ? `provider:${row.provider}` : undefined,
|
|
682
|
+
row.role ? `role:${row.role}` : undefined,
|
|
683
|
+
row.target,
|
|
684
|
+
row.detail,
|
|
685
|
+
row.reasonCode ? `reason:${row.reasonCode}` : undefined,
|
|
686
|
+
row.freshness?.stale ? "stale" : row.freshness?.observedRef ? `ref:${row.freshness.observedRef}` : undefined,
|
|
687
|
+
row.reportPath ? `out:${hostStepReportName(row.reportPath)}` : undefined
|
|
688
|
+
].filter(Boolean).join(" · ");
|
|
689
|
+
return truncateToWidth(`${left}${details ? theme.fg("dim", ` · ${details}`) : ""}`, width);
|
|
690
|
+
}
|
|
691
|
+
bullet(rosterIndex, selectedIndex, theme) {
|
|
692
|
+
return rosterIndex === selectedIndex ? theme.fg("accent", ">") : " ";
|
|
693
|
+
}
|
|
694
|
+
rosterKeys() {
|
|
695
|
+
return ["main", ...this.entries.map((entry) => entry.key)];
|
|
696
|
+
}
|
|
697
|
+
clampSelection() {
|
|
698
|
+
if (!this.rosterKeys().includes(this.selectedKey))
|
|
699
|
+
this.selectedKey = "main";
|
|
700
|
+
}
|
|
701
|
+
deactivate() {
|
|
702
|
+
this.active = false;
|
|
703
|
+
this.selectedKey = "main";
|
|
704
|
+
this.refresh();
|
|
705
|
+
}
|
|
706
|
+
editorHasFocus() {
|
|
707
|
+
const focused = this.tui?.focusedComponent;
|
|
708
|
+
if (!focused || typeof focused !== "object")
|
|
709
|
+
return false;
|
|
710
|
+
const candidate = focused;
|
|
711
|
+
return typeof candidate.render === "function" && typeof candidate.invalidate === "function" && typeof candidate.handleInput === "function" && typeof candidate.getText === "function" && typeof candidate.setText === "function";
|
|
712
|
+
}
|
|
713
|
+
getRenderKey() {
|
|
714
|
+
const now = Date.now();
|
|
715
|
+
return JSON.stringify({
|
|
716
|
+
active: this.active,
|
|
717
|
+
selected: this.selectedKey,
|
|
718
|
+
inspectorOpen: this.inspectorOpen,
|
|
719
|
+
entries: this.entries.map((entry) => this.active ? [
|
|
720
|
+
entry.key,
|
|
721
|
+
entry.surface,
|
|
722
|
+
entry.parentKey,
|
|
723
|
+
entry.agent,
|
|
724
|
+
entry.state,
|
|
725
|
+
entry.modelThinking,
|
|
726
|
+
entry.description,
|
|
727
|
+
entry.external,
|
|
728
|
+
Math.round((now - entry.startedAt) / 1000),
|
|
729
|
+
entry.tokens,
|
|
730
|
+
visibleWorkflowRows(entry.workflowRows, entry.parentKey ? 2 : 4).map((row) => [
|
|
731
|
+
row.kind,
|
|
732
|
+
row.name,
|
|
733
|
+
row.state,
|
|
734
|
+
row.context,
|
|
735
|
+
row.modelThinking,
|
|
736
|
+
row.activity,
|
|
737
|
+
row.startedAt,
|
|
738
|
+
row.tokens,
|
|
739
|
+
row.provider,
|
|
740
|
+
row.role,
|
|
741
|
+
row.verdict,
|
|
742
|
+
row.reasonCode,
|
|
743
|
+
row.detail,
|
|
744
|
+
row.target,
|
|
745
|
+
row.freshness,
|
|
746
|
+
row.reportPath,
|
|
747
|
+
row.overflow
|
|
748
|
+
]),
|
|
749
|
+
nestedFleetRows(entry.nestedChildren, entry.parentKey ? 3 : 4).map((row) => [
|
|
750
|
+
row.name,
|
|
751
|
+
row.state,
|
|
752
|
+
row.modelThinking,
|
|
753
|
+
row.activity,
|
|
754
|
+
row.startedAt,
|
|
755
|
+
row.depth,
|
|
756
|
+
row.overflow
|
|
757
|
+
])
|
|
758
|
+
] : [entry.key, entry.state, entry.external, entry.surface, entry.tokens, entry.projectPane?.refreshedAt, entry.projectPane?.summary])
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
hasInlineSurface() {
|
|
762
|
+
return this.entries.length > 0 || Boolean(this.state.activeAsyncCapacity?.used);
|
|
763
|
+
}
|
|
764
|
+
getActiveUiContext() {
|
|
765
|
+
const ctx = this.ctx;
|
|
766
|
+
if (!ctx)
|
|
767
|
+
return;
|
|
768
|
+
try {
|
|
769
|
+
return ctx.hasUI ? ctx : undefined;
|
|
770
|
+
} catch (error) {
|
|
771
|
+
if (!isStaleExtensionContextError(error))
|
|
772
|
+
throw error;
|
|
773
|
+
this.clearUiRegistration();
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
clearWidget() {
|
|
778
|
+
if (!this.widgetRegistered)
|
|
779
|
+
return;
|
|
780
|
+
try {
|
|
781
|
+
this.ui?.setWidget(FLEET_STATUS_WIDGET_KEY, undefined);
|
|
782
|
+
} catch (error) {
|
|
783
|
+
if (!isStaleExtensionContextError(error))
|
|
784
|
+
throw error;
|
|
785
|
+
this.clearUiRegistration();
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
this.widgetRegistered = false;
|
|
789
|
+
this.tui = undefined;
|
|
790
|
+
}
|
|
791
|
+
clearUiRegistration() {
|
|
792
|
+
if (this.timer)
|
|
793
|
+
clearInterval(this.timer);
|
|
794
|
+
this.timer = undefined;
|
|
795
|
+
const inputUnsubscribe = this.inputUnsubscribe;
|
|
796
|
+
const ui = this.ui;
|
|
797
|
+
const widgetRegistered = this.widgetRegistered;
|
|
798
|
+
this.inputUnsubscribe = undefined;
|
|
799
|
+
this.ctx = undefined;
|
|
800
|
+
this.ui = undefined;
|
|
801
|
+
this.widgetRegistered = false;
|
|
802
|
+
this.tui = undefined;
|
|
803
|
+
const cleanupErrors = [];
|
|
804
|
+
try {
|
|
805
|
+
inputUnsubscribe?.();
|
|
806
|
+
} catch (error) {
|
|
807
|
+
if (!isStaleExtensionContextError(error))
|
|
808
|
+
cleanupErrors.push(error);
|
|
809
|
+
}
|
|
810
|
+
if (ui && widgetRegistered) {
|
|
811
|
+
try {
|
|
812
|
+
ui.setWidget(FLEET_STATUS_WIDGET_KEY, undefined);
|
|
813
|
+
} catch (error) {
|
|
814
|
+
if (!isStaleExtensionContextError(error))
|
|
815
|
+
cleanupErrors.push(error);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if (cleanupErrors.length === 1)
|
|
819
|
+
throw cleanupErrors[0];
|
|
820
|
+
if (cleanupErrors.length > 1) {
|
|
821
|
+
throw new AggregateError(cleanupErrors, "Failed to clean up FleetView UI registration");
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|