@selesai/code 0.13.15 → 0.13.18
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/CHANGELOG.md +37 -0
- package/README.md +2 -14
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.js +3 -9
- package/dist/bun/{register-bedrock.js → runtime-setup.js} +5 -0
- package/dist/bun/sandbox-env-setup.d.ts +1 -0
- package/dist/bun/sandbox-env-setup.js +3 -0
- package/dist/cli/auth-command.d.ts +23 -0
- package/dist/cli/auth-command.js +102 -0
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.js +11 -0
- package/dist/cli.js +2 -14
- package/dist/config.d.ts +3 -2
- package/dist/config.js +9 -4
- package/dist/core/agent-session-runtime.js +15 -7
- package/dist/core/agent-session.d.ts +2 -6
- package/dist/core/agent-session.js +15 -4
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/types.d.ts +16 -2
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.js +4 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +5 -2
- package/dist/core/provider-composer.js +8 -2
- package/dist/core/session-export.d.ts +3 -0
- package/dist/core/session-export.js +31 -0
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.js +40 -13
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/system-prompt.js +10 -10
- package/dist/core/tools/bash.js +3 -117
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.js +5 -163
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.js +10 -122
- package/dist/core/tools/renderers/bash.d.ts +11 -0
- package/dist/core/tools/renderers/bash.js +129 -0
- package/dist/core/tools/renderers/edit.d.ts +22 -0
- package/dist/core/tools/renderers/edit.js +166 -0
- package/dist/core/tools/renderers/find.d.ts +9 -0
- package/dist/core/tools/renderers/find.js +63 -0
- package/dist/core/tools/renderers/grep.d.ts +9 -0
- package/dist/core/tools/renderers/grep.js +68 -0
- package/dist/core/tools/renderers/index.d.ts +27 -0
- package/dist/core/tools/renderers/index.js +46 -0
- package/dist/core/tools/renderers/ls.d.ts +9 -0
- package/dist/core/tools/renderers/ls.js +57 -0
- package/dist/core/tools/renderers/read.d.ts +10 -0
- package/dist/core/tools/renderers/read.js +128 -0
- package/dist/core/tools/renderers/write.d.ts +9 -0
- package/dist/core/tools/renderers/write.js +152 -0
- package/dist/core/tools/write.js +5 -146
- package/dist/extensions/capability-gateway/index.ts +12 -1
- package/dist/extensions/capability-gateway/integration.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +18 -0
- package/dist/extensions/pi-hermes-memory/README.md +16 -12
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +1 -1
- package/dist/extensions/pi-hermes-memory/package-lock.json +587 -62
- package/dist/extensions/pi-hermes-memory/package.json +4 -4
- package/dist/extensions/pi-hermes-memory/src/config.ts +32 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +12 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +109 -51
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +9 -3
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +257 -98
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +9 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +5 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +22 -2
- package/dist/extensions/pi-hermes-memory/src/paths.ts +1 -1
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +58 -1
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +60 -8
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +169 -7
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +7 -21
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +134 -15
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +4 -2
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +24 -9
- package/dist/extensions/pi-hermes-memory/src/types.ts +11 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +42 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +159 -3
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +452 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +39 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/corruption-recovery-integration.test.ts +91 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +29 -0
- package/dist/extensions/pi-hermes-memory/tests/store/fts-query.test.ts +116 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +163 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +233 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +12 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +175 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +2 -2
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +22 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +37 -1
- package/dist/extensions/pi-intercom/CHANGELOG.md +13 -0
- package/dist/extensions/pi-intercom/README.md +16 -2
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +19 -2
- package/dist/extensions/pi-intercom/broker/spawn.ts +4 -4
- package/dist/extensions/pi-intercom/index.ts +1 -1
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +121 -2
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.test.ts +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +1 -6
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +7 -6
- package/dist/extensions/pi-rewind-hook/index.test.ts +7 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +36 -4
- package/dist/extensions/pi-subagents/CHANGELOG.md +120 -0
- package/dist/extensions/pi-subagents/README.md +3 -3
- package/dist/extensions/pi-subagents/agents/researcher.md +23 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +1 -1
- package/dist/extensions/pi-subagents/agents/scout.md +1 -1
- package/dist/extensions/pi-subagents/docs/agents.md +32 -16
- package/dist/extensions/pi-subagents/docs/configuration.md +41 -15
- package/dist/extensions/pi-subagents/docs/extension-api.md +109 -6
- package/dist/extensions/pi-subagents/docs/missions.md +2 -0
- package/dist/extensions/pi-subagents/docs/models.md +58 -1
- package/dist/extensions/pi-subagents/docs/observability.md +50 -12
- package/dist/extensions/pi-subagents/docs/tool-reference.md +17 -10
- package/dist/extensions/pi-subagents/docs/watchdog.md +1 -1
- package/dist/extensions/pi-subagents/docs/workflows.md +26 -9
- package/dist/extensions/pi-subagents/package-lock.json +747 -177
- package/dist/extensions/pi-subagents/package.json +6 -4
- package/dist/extensions/pi-subagents/runner-server-preload.mjs +13 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +21 -4
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +2 -0
- package/dist/extensions/pi-subagents/src/agents/advertised-agent-prompt.ts +63 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +61 -16
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +2 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +8 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +0 -1
- package/dist/extensions/pi-subagents/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
- package/dist/extensions/pi-subagents/src/api/preflight.ts +7 -4
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -2
- package/dist/extensions/pi-subagents/src/api/workflow-resources.ts +6 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +4 -2
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +2 -10
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +9 -11
- package/dist/extensions/pi-subagents/src/extension/index.ts +99 -10
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +13 -0
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +7 -23
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +11 -8
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +25 -7
- package/dist/extensions/pi-subagents/src/integrations/pi-web-session-liveness.ts +73 -0
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +228 -136
- package/dist/extensions/pi-subagents/src/intercom/supervisor-ui.ts +244 -0
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +37 -16
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +18 -18
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +51 -25
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +46 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +10 -12
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +18 -15
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +40 -29
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +8 -0
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +79 -247
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/background/owned-process-tree.ts +6 -6
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +24 -24
- package/dist/extensions/pi-subagents/src/runs/background/retained-nested-route-tracker.ts +96 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-child-session.ts +642 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +75 -6
- package/dist/extensions/pi-subagents/src/runs/background/runner-aliases.ts +163 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-launch.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-sessions.ts +31 -0
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +597 -1092
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +3 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +20 -17
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +296 -394
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +630 -283
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +78 -98
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +16 -3
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +47 -47
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +1 -2
- package/dist/extensions/pi-subagents/src/runs/shared/child-hooks.ts +174 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch.ts +319 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-lifecycle.ts +25 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-runtime-config.ts +126 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-session.ts +373 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-tool-plan.ts +530 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +11 -11
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +30 -20
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +5 -4
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +84 -15
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +37 -53
- package/dist/extensions/pi-subagents/src/runs/shared/nested-path.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +18 -7
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +57 -12
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +3 -4
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +0 -11
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +4 -1
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-drain-observation.ts +42 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-model-continuation.ts +69 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-session-evidence.ts +307 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-fanout-budget.ts +8 -21
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +3 -30
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +17 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +99 -386
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +18 -62
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +0 -14
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +31 -9
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-setup-command.ts +190 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +506 -226
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +1 -1
- package/dist/extensions/pi-subagents/src/shared/jsonl-writer.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/model-response-aliases.ts +13 -0
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +0 -6
- package/dist/extensions/pi-subagents/src/shared/types.ts +145 -89
- package/dist/extensions/pi-subagents/src/shared/utils.ts +13 -6
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +2 -0
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +18 -13
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +0 -6
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +1 -1
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +11 -6
- package/dist/extensions/pi-subagents/src/tui/render.ts +277 -46
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +0 -1
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +12 -12
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +116 -15
- package/dist/extensions/pi-subagents/src/workflows/workflow-checklist.ts +15 -18
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +57 -8
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +19 -19
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/workflow-resources.ts +97 -22
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +3 -0
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +336 -21
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-1.test.ts +1181 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-2.test.ts +2240 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-3.test.ts +2268 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-4.test.ts +1512 -0
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +231 -16
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +4 -18
- package/dist/extensions/pi-subagents/test/integration/foreign-workflow-steering.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +9 -15
- package/dist/extensions/pi-subagents/test/integration/in-process-child.test.ts +374 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +20 -10
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +18 -6
- package/dist/extensions/pi-subagents/test/integration/recovered-assistant-error.test.ts +151 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +42 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +150 -25
- package/dist/extensions/pi-subagents/test/integration/result-publication.test.ts +354 -0
- package/dist/extensions/pi-subagents/test/integration/shared-cwd-terminal-evidence.test.ts +117 -0
- package/dist/extensions/pi-subagents/test/integration/single-execution.part-1.test.ts +3678 -0
- package/dist/extensions/pi-subagents/test/integration/{single-execution.test.ts → single-execution.part-2.test.ts} +500 -4207
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/integration/workflow-result-publication.test.ts +127 -0
- package/dist/extensions/pi-subagents/test/integration/workflow-steer-inbox.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-child.ts +31 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-clean-install.mjs +74 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-extension.ts +16 -0
- package/dist/extensions/pi-subagents/test/support/async-execution-fixture.ts +699 -0
- package/dist/extensions/pi-subagents/test/support/fake-child-session.ts +418 -0
- package/dist/extensions/pi-subagents/test/support/foreign-workflow-steer-host.mjs +13 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +30 -76
- package/dist/extensions/pi-subagents/test/support/notify-diagnostics-fixture.ts +84 -0
- package/dist/extensions/pi-subagents/test/support/result-publication-capacity-preload.mjs +70 -0
- package/dist/extensions/pi-subagents/test/support/runner-child-session-factory.ts +17 -0
- package/dist/extensions/pi-subagents/test/support/single-execution-fixture.ts +390 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance-compaction.test.ts +120 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +24 -3
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-prompt.test.ts +87 -0
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-refresh.test.ts +163 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +70 -31
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +78 -3
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +2 -8
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +73 -66
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +51 -1
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/async-spawn-preload.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +9 -8
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +10 -7
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +48 -6
- package/dist/extensions/pi-subagents/test/unit/child-runtime-config.test.ts +90 -0
- package/dist/extensions/pi-subagents/test/unit/{pi-args-permission-system.test.ts → child-tool-plan-permission-system.test.ts} +48 -86
- package/dist/extensions/pi-subagents/test/unit/child-tool-plan.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +18 -18
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +9 -9
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +8 -7
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +225 -65
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +17 -22
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +11 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +47 -3
- package/dist/extensions/pi-subagents/test/unit/foreign-workflow-steering.test.ts +74 -0
- package/dist/extensions/pi-subagents/test/unit/fork-cache-key.test.ts +23 -29
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +96 -4
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +4 -4
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +116 -55
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +58 -1
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +104 -3
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +31 -1
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +102 -51
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +196 -6
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +181 -38
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +62 -70
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +58 -53
- package/dist/extensions/pi-subagents/test/unit/notify-diagnostics.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +13 -5
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +21 -5
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +5 -4
- package/dist/extensions/pi-subagents/test/unit/permissions.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +28 -2
- package/dist/extensions/pi-subagents/test/unit/pi-web-session-liveness.test.ts +209 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +38 -1
- package/dist/extensions/pi-subagents/test/unit/prompt-audit-optional-peers.test.ts +43 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +24 -2
- package/dist/extensions/pi-subagents/test/unit/readonly-drain-observation.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-model-continuation.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-session-evidence.test.ts +1329 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +29 -80
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +11 -8
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/retained-nested-route-tracker.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +38 -12
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +89 -1
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +2 -16
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +27 -3
- package/dist/extensions/pi-subagents/test/unit/scheduled-supervisor-demand.test.ts +215 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +15 -11
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +237 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +14 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +130 -739
- package/dist/extensions/pi-subagents/test/unit/supervisor-ask-registration.test.ts +682 -0
- package/dist/extensions/pi-subagents/test/unit/supervisor-ui.test.ts +137 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +1 -11
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +23 -3
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +8 -1
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +19 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +72 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-checklist.test.ts +17 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-child-summary.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +12 -2
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +46 -6
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-resources.test.ts +133 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +53 -2
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +222 -14
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +526 -85
- package/dist/extensions/pi-web-agent/src/backends/config.ts +1 -0
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +5 -3
- package/dist/extensions/pi-web-agent/src/search/tokenin.ts +7 -3
- package/dist/extensions/pi-web-agent/src/types.ts +1 -1
- package/dist/extensions/pi-zentui/README.md +17 -0
- package/dist/extensions/pi-zentui/assets/screenshots/footer-status-hyperlink.png +0 -0
- package/dist/extensions/pi-zentui/docs/configuration.md +71 -2
- package/dist/extensions/pi-zentui/extensions/zentui/config.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-transfer.ts +14 -0
- package/dist/extensions/pi-zentui/extensions/zentui/extension-status.ts +29 -13
- package/dist/extensions/pi-zentui/extensions/zentui/footer-layout.ts +5 -4
- package/dist/extensions/pi-zentui/extensions/zentui/footer-text.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer.ts +11 -10
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +77 -3
- package/dist/extensions/pi-zentui/extensions/zentui/presets.ts +77 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-command.ts +103 -2
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-extension-segments.ts +115 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line.ts +87 -5
- package/dist/extensions/pi-zentui/package-lock.json +277 -517
- package/dist/extensions/pi-zentui/package.json +7 -4
- package/dist/extensions/pi-zentui/test/config-presets.test.ts +238 -0
- package/dist/extensions/pi-zentui/test/editor-transfer.test.ts +24 -1
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +570 -2
- package/dist/extensions/pi-zentui/test/extension-status.test.ts +90 -0
- package/dist/extensions/pi-zentui/test/footer-hyperlink.test.ts +243 -0
- package/dist/extensions/pi-zentui/test/package-contents.mjs +1 -0
- package/dist/extensions/pi-zentui/test/presets.test.ts +121 -0
- package/dist/extensions/pi-zentui/test/settings-command.test.ts +205 -1
- package/dist/extensions/pi-zentui/test/working-line-extension-segments.test.ts +139 -0
- package/dist/extensions/pi-zentui/test/working-line-lifecycle.integration.test.ts +237 -3
- package/dist/extensions/pi-zentui/test/working-line.test.ts +94 -2
- package/dist/index.d.ts +1 -1
- package/dist/main.js +4 -1
- package/dist/modes/interactive/chat-viewport.d.ts +19 -0
- package/dist/modes/interactive/chat-viewport.js +27 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.js +30 -13
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.js +39 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -0
- package/dist/modes/interactive/components/markdown-transform.js +18 -0
- package/dist/modes/interactive/components/model-selector.js +19 -17
- package/dist/modes/interactive/components/scoped-models-selector.js +21 -23
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -1
- package/dist/modes/interactive/components/settings-selector.js +128 -20
- package/dist/modes/interactive/components/settings-submenu.d.ts +71 -0
- package/dist/modes/interactive/components/settings-submenu.js +164 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.js +75 -18
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.js +35 -33
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/interactive-mode.d.ts +13 -15
- package/dist/modes/interactive/interactive-mode.js +144 -80
- package/dist/modes/interactive/session-share.d.ts +15 -0
- package/dist/modes/interactive/session-share.js +183 -0
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-json.d.ts +83 -0
- package/dist/modes/interactive/theme/theme-json.js +129 -0
- package/dist/modes/interactive/theme/theme-schema.json +9 -1
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/tui-renderer.d.ts +20 -0
- package/dist/modes/interactive/tui-renderer.js +65 -0
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/management-http.d.ts +24 -0
- package/dist/utils/management-http.js +53 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.js +8 -0
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.js +43 -21
- package/docs/docs.json +0 -4
- package/package.json +4 -4
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +0 -415
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +0 -1059
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +0 -116
- package/dist/extensions/pi-subagents/src/shared/post-exit-stdio-guard.ts +0 -85
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +0 -224
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +0 -6986
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +0 -447
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +0 -185
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +0 -311
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +0 -84
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +0 -202
- package/dist/extensions/pi-subagents/test/unit/close-grace-timer.test.ts +0 -101
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +0 -2347
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +0 -104
- package/dist/extensions/pi-subagents/test/unit/windows-hide-spawn.test.ts +0 -49
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +0 -1465
- package/dist/skills/imagegen-frontend-web/SKILL.md +0 -987
- package/dist/skills/implanger/SKILL.md +0 -70
- package/dist/skills/output/SKILL.md +0 -49
- package/dist/skills/planger/SKILL.md +0 -167
- package/dist/skills/workflow/SKILL.md +0 -95
- package/docs/workflows.md +0 -18
- /package/dist/bun/{register-bedrock.d.ts → runtime-setup.d.ts} +0 -0
|
@@ -10,15 +10,17 @@ import {
|
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
import { tmpdir } from "node:os";
|
|
12
12
|
import { dirname, join } from "node:path";
|
|
13
|
-
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
import type { ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
14
14
|
import {
|
|
15
15
|
AssistantMessageComponent,
|
|
16
|
+
CustomEditor,
|
|
17
|
+
InteractiveMode,
|
|
16
18
|
initTheme,
|
|
17
19
|
ModelSelectorComponent,
|
|
18
20
|
SettingsSelectorComponent,
|
|
19
21
|
UserMessageComponent,
|
|
20
22
|
} from "@earendil-works/pi-coding-agent";
|
|
21
|
-
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
23
|
+
import { Container, type EditorComponent, visibleWidth } from "@earendil-works/pi-tui";
|
|
22
24
|
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
|
|
23
25
|
import {
|
|
24
26
|
discoverAccentRailLayoutPatchTargetFromEntrypoint,
|
|
@@ -108,6 +110,8 @@ type SettingsCommandDeps = Parameters<typeof registerZentuiSettingsCommand>[1];
|
|
|
108
110
|
const settingsCommandDefaults: SettingsCommandDeps = {
|
|
109
111
|
sessionLifecycle: inactiveSessionLifecycle,
|
|
110
112
|
getConfig: () => defaultConfig,
|
|
113
|
+
applyPreset: () => ({ applied: true }),
|
|
114
|
+
reconcilePresetEditor: () => ({ applied: true }),
|
|
111
115
|
setEditorComponent: () => ({ applied: true }),
|
|
112
116
|
setPolished() {},
|
|
113
117
|
setPolishedCopyFriendly() {},
|
|
@@ -6116,6 +6120,7 @@ describe("Pi docs compliance", () => {
|
|
|
6116
6120
|
) as { handleInput?: (data: string) => void };
|
|
6117
6121
|
component.handleInput?.("\x1b[B");
|
|
6118
6122
|
component.handleInput?.("\x1b[B");
|
|
6123
|
+
component.handleInput?.("\x1b[B");
|
|
6119
6124
|
component.handleInput?.(" ");
|
|
6120
6125
|
},
|
|
6121
6126
|
},
|
|
@@ -6180,6 +6185,7 @@ describe("Pi docs compliance", () => {
|
|
|
6180
6185
|
rendered = component.render?.(80).join("\n") ?? "";
|
|
6181
6186
|
component.handleInput?.("\x1b[B");
|
|
6182
6187
|
component.handleInput?.("\x1b[B");
|
|
6188
|
+
component.handleInput?.("\x1b[B");
|
|
6183
6189
|
component.handleInput?.(" ");
|
|
6184
6190
|
},
|
|
6185
6191
|
},
|
|
@@ -7243,3 +7249,565 @@ describe("three-state Footer lifecycle", () => {
|
|
|
7243
7249
|
await emit(handlers, "session_shutdown", ctx);
|
|
7244
7250
|
});
|
|
7245
7251
|
});
|
|
7252
|
+
|
|
7253
|
+
describe("component preset lifecycle", () => {
|
|
7254
|
+
type EditorFactory = NonNullable<Parameters<ExtensionContext["ui"]["setEditorComponent"]>[0]>;
|
|
7255
|
+
type SettingsComponent = { handleInput(data: string): void; render(width: number): string[] };
|
|
7256
|
+
function presetMenuHost() {
|
|
7257
|
+
initTheme(undefined, false);
|
|
7258
|
+
let focused: unknown;
|
|
7259
|
+
const tui = {
|
|
7260
|
+
requestRender() {},
|
|
7261
|
+
terminal: { rows: 40, columns: 160 },
|
|
7262
|
+
setFocus(component: unknown) {
|
|
7263
|
+
focused = component;
|
|
7264
|
+
},
|
|
7265
|
+
};
|
|
7266
|
+
const native = new CustomEditor(
|
|
7267
|
+
tui as never,
|
|
7268
|
+
{ borderColor: (s: string) => s, selectList: {} } as never,
|
|
7269
|
+
{ matches: () => false } as never,
|
|
7270
|
+
);
|
|
7271
|
+
const host = {
|
|
7272
|
+
editor: native as EditorComponent,
|
|
7273
|
+
defaultEditor: native,
|
|
7274
|
+
editorComponentFactory: undefined as EditorFactory | undefined,
|
|
7275
|
+
editorContainer: new Container(),
|
|
7276
|
+
ui: tui,
|
|
7277
|
+
keybindings: { matches: () => false },
|
|
7278
|
+
disposeActiveSelector() {},
|
|
7279
|
+
};
|
|
7280
|
+
// Exercise Pi's actual custom-panel restoration and editor replacement contracts.
|
|
7281
|
+
const methods = InteractiveMode.prototype as unknown as {
|
|
7282
|
+
showExtensionCustom(this: unknown, factory: unknown): Promise<unknown>;
|
|
7283
|
+
setCustomEditorComponent(this: unknown, factory: EditorFactory | undefined): void;
|
|
7284
|
+
};
|
|
7285
|
+
const setEditorComponent = vi.fn((factory: EditorFactory | undefined) =>
|
|
7286
|
+
methods.setCustomEditorComponent.call(host, factory),
|
|
7287
|
+
);
|
|
7288
|
+
const notify = vi.fn();
|
|
7289
|
+
const custom = vi.fn((factory: unknown) => methods.showExtensionCustom.call(host, factory));
|
|
7290
|
+
let footer: ReturnType<FooterFactory> | undefined;
|
|
7291
|
+
const ctx = makeContext({
|
|
7292
|
+
ui: {
|
|
7293
|
+
notify,
|
|
7294
|
+
custom,
|
|
7295
|
+
setEditorComponent,
|
|
7296
|
+
getEditorComponent: () => host.editorComponentFactory,
|
|
7297
|
+
getEditorText: () => host.editor.getExpandedText?.() ?? host.editor.getText(),
|
|
7298
|
+
setEditorText: (text: string) => host.editor.setText(text),
|
|
7299
|
+
setFooter(next: FooterFactory | undefined) {
|
|
7300
|
+
footer?.dispose?.();
|
|
7301
|
+
footer = next?.(tui, makeTheme(), {
|
|
7302
|
+
onBranchChange: () => () => {},
|
|
7303
|
+
getExtensionStatuses: () => new Map(),
|
|
7304
|
+
});
|
|
7305
|
+
},
|
|
7306
|
+
},
|
|
7307
|
+
});
|
|
7308
|
+
return {
|
|
7309
|
+
ctx,
|
|
7310
|
+
host,
|
|
7311
|
+
custom,
|
|
7312
|
+
notify,
|
|
7313
|
+
setEditorComponent,
|
|
7314
|
+
focused: () => focused,
|
|
7315
|
+
footer: () => footer,
|
|
7316
|
+
};
|
|
7317
|
+
}
|
|
7318
|
+
|
|
7319
|
+
it.each(["native", "predecessor", "owned"])(
|
|
7320
|
+
"keeps the preset menu open over %s and installs only the final editor after Pi restores the draft",
|
|
7321
|
+
async (initial) => {
|
|
7322
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7323
|
+
writeFileSync(
|
|
7324
|
+
configPath,
|
|
7325
|
+
JSON.stringify({
|
|
7326
|
+
projectRefreshIntervalMs: 0,
|
|
7327
|
+
components: { editor: { enabled: initial === "owned" } },
|
|
7328
|
+
}),
|
|
7329
|
+
);
|
|
7330
|
+
const commands = new Map<string, unknown>();
|
|
7331
|
+
const handlers = loadExtension({ commands });
|
|
7332
|
+
const h = presetMenuHost();
|
|
7333
|
+
const predecessor: EditorFactory = (tui, theme, keys) => new CustomEditor(tui, theme, keys);
|
|
7334
|
+
if (initial === "predecessor") h.ctx.ui.setEditorComponent(predecessor);
|
|
7335
|
+
try {
|
|
7336
|
+
await emit(handlers, "session_start", h.ctx);
|
|
7337
|
+
const previousFactory = h.ctx.ui.getEditorComponent();
|
|
7338
|
+
const previousEditor = h.host.editor;
|
|
7339
|
+
const draft = Array.from({ length: 100 }, (_, i) => `unsent draft line ${i}`).join("\n");
|
|
7340
|
+
h.host.editor.handleInput?.(`\x1b[200~${draft}\x1b[201~`);
|
|
7341
|
+
expect(h.host.editor.getText()).toContain("[paste #");
|
|
7342
|
+
expect(h.ctx.ui.getEditorText()).toBe(draft);
|
|
7343
|
+
h.setEditorComponent.mockClear();
|
|
7344
|
+
const command = commands.get("zentui") as {
|
|
7345
|
+
handler(args: string, ctx: unknown): Promise<void>;
|
|
7346
|
+
};
|
|
7347
|
+
let finished = false;
|
|
7348
|
+
const pending = command.handler("", h.ctx).then(() => {
|
|
7349
|
+
finished = true;
|
|
7350
|
+
});
|
|
7351
|
+
await Promise.resolve();
|
|
7352
|
+
const menu = h.focused() as SettingsComponent;
|
|
7353
|
+
const ids = ["opencode", "opencode-copy-friendly", "rail", "minimalist"];
|
|
7354
|
+
for (const id of ids) {
|
|
7355
|
+
menu.handleInput("\r");
|
|
7356
|
+
expect(JSON.parse(readFileSync(configPath, "utf8")).components.editor.style).toBe(
|
|
7357
|
+
id === "rail" ? "accent-rail" : id,
|
|
7358
|
+
);
|
|
7359
|
+
expect(h.focused()).toBe(menu);
|
|
7360
|
+
expect(h.host.editorContainer.children).toEqual([menu]);
|
|
7361
|
+
expect(finished).toBe(false);
|
|
7362
|
+
expect(h.ctx.ui.getEditorComponent()).toBe(previousFactory);
|
|
7363
|
+
expect(h.host.editor).toBe(previousEditor);
|
|
7364
|
+
expect(h.setEditorComponent).not.toHaveBeenCalled();
|
|
7365
|
+
}
|
|
7366
|
+
expect(h.footer()?.render(100)).toEqual([]);
|
|
7367
|
+
expect(UserMessageComponent.prototype.render).toBe(originalUserMessageRender);
|
|
7368
|
+
// Continue adjusting the selected preset without leaving the same panel.
|
|
7369
|
+
menu.handleInput("\t");
|
|
7370
|
+
menu.handleInput("\x1b[B");
|
|
7371
|
+
menu.handleInput("\r"); // Minimalist -> Opencode; final config must win.
|
|
7372
|
+
menu.handleInput("\x1b[Z");
|
|
7373
|
+
expect(menu.render(160).join("\n")).toContain("Custom");
|
|
7374
|
+
menu.handleInput("\x1b");
|
|
7375
|
+
await pending;
|
|
7376
|
+
expect(h.custom).toHaveBeenCalledTimes(1);
|
|
7377
|
+
expect(h.setEditorComponent).toHaveBeenCalledTimes(initial === "owned" ? 0 : 1);
|
|
7378
|
+
expect(h.host.editor).toBeInstanceOf(
|
|
7379
|
+
initial === "predecessor" ? WrappedPolishedEditorProduction : PolishedEditorProduction,
|
|
7380
|
+
);
|
|
7381
|
+
expect(h.ctx.ui.getEditorText()).toBe(draft);
|
|
7382
|
+
expect(h.focused()).toBe(h.host.editor);
|
|
7383
|
+
expect(h.host.editor.render(160).join("\n")).toContain("│");
|
|
7384
|
+
expect(h.host.editor.render(160).join("\n")).not.toContain("╭");
|
|
7385
|
+
expect(h.notify.mock.calls.every(([, severity]) => severity === "info")).toBe(true);
|
|
7386
|
+
await command.handler("editor disable", h.ctx);
|
|
7387
|
+
expect(h.ctx.ui.getEditorComponent()).toBe(
|
|
7388
|
+
initial === "predecessor" ? predecessor : undefined,
|
|
7389
|
+
);
|
|
7390
|
+
expect(h.ctx.ui.getEditorText()).toBe(draft);
|
|
7391
|
+
} finally {
|
|
7392
|
+
await emit(handlers, "session_shutdown", h.ctx);
|
|
7393
|
+
}
|
|
7394
|
+
},
|
|
7395
|
+
);
|
|
7396
|
+
|
|
7397
|
+
it.each(["transfer-failure", "shutdown", "replacement-session", "stale-owner"])(
|
|
7398
|
+
"safely handles %s before a pending preset editor is installed",
|
|
7399
|
+
async (failure) => {
|
|
7400
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7401
|
+
writeFileSync(
|
|
7402
|
+
configPath,
|
|
7403
|
+
JSON.stringify({ projectRefreshIntervalMs: 0, components: { editor: { enabled: false } } }),
|
|
7404
|
+
);
|
|
7405
|
+
const commands = new Map<string, unknown>();
|
|
7406
|
+
const handlers = loadExtension({ commands });
|
|
7407
|
+
const h = presetMenuHost();
|
|
7408
|
+
try {
|
|
7409
|
+
await emit(handlers, "session_start", h.ctx);
|
|
7410
|
+
h.ctx.ui.setEditorText("unsent draft");
|
|
7411
|
+
const command = commands.get("zentui") as {
|
|
7412
|
+
handler(args: string, ctx: unknown): Promise<void>;
|
|
7413
|
+
};
|
|
7414
|
+
const pending = command.handler("", h.ctx);
|
|
7415
|
+
await Promise.resolve();
|
|
7416
|
+
const menu = h.focused() as SettingsComponent;
|
|
7417
|
+
menu.handleInput("\r");
|
|
7418
|
+
menu.handleInput("\r");
|
|
7419
|
+
expect(h.setEditorComponent).not.toHaveBeenCalled();
|
|
7420
|
+
if (failure === "transfer-failure")
|
|
7421
|
+
h.ctx.ui.getEditorText = () => {
|
|
7422
|
+
throw new Error("snapshot unavailable");
|
|
7423
|
+
};
|
|
7424
|
+
if (failure === "shutdown" || failure === "replacement-session")
|
|
7425
|
+
await emit(handlers, "session_shutdown", h.ctx);
|
|
7426
|
+
if (failure === "replacement-session") await emit(handlers, "session_start", h.ctx);
|
|
7427
|
+
if (failure === "stale-owner") {
|
|
7428
|
+
const staleFactory = Object.assign(() => h.host.defaultEditor, {
|
|
7429
|
+
[Symbol.for("pi-zentui.editor-factory")]: true,
|
|
7430
|
+
});
|
|
7431
|
+
h.ctx.ui.setEditorComponent(staleFactory);
|
|
7432
|
+
}
|
|
7433
|
+
h.setEditorComponent.mockClear();
|
|
7434
|
+
h.notify.mockClear();
|
|
7435
|
+
menu.handleInput("\x1b");
|
|
7436
|
+
await pending;
|
|
7437
|
+
expect(h.setEditorComponent).not.toHaveBeenCalled();
|
|
7438
|
+
expect(h.host.editor.getText()).toBe("unsent draft");
|
|
7439
|
+
if (failure === "transfer-failure" || failure === "stale-owner") {
|
|
7440
|
+
expect(h.notify).toHaveBeenCalledWith(
|
|
7441
|
+
expect.stringMatching(/Preset saved: editor.*reload Pi/),
|
|
7442
|
+
"warning",
|
|
7443
|
+
);
|
|
7444
|
+
} else expect(h.notify).not.toHaveBeenCalled();
|
|
7445
|
+
expect(JSON.parse(readFileSync(configPath, "utf8")).components.editor.style).toBe(
|
|
7446
|
+
"opencode-copy-friendly",
|
|
7447
|
+
);
|
|
7448
|
+
} finally {
|
|
7449
|
+
await emit(handlers, "session_shutdown", h.ctx);
|
|
7450
|
+
}
|
|
7451
|
+
},
|
|
7452
|
+
);
|
|
7453
|
+
it("honors an editor disable after preset selection without briefly installing an editor", async () => {
|
|
7454
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7455
|
+
writeFileSync(
|
|
7456
|
+
configPath,
|
|
7457
|
+
JSON.stringify({ projectRefreshIntervalMs: 0, components: { editor: { enabled: false } } }),
|
|
7458
|
+
);
|
|
7459
|
+
const commands = new Map<string, unknown>();
|
|
7460
|
+
const handlers = loadExtension({ commands });
|
|
7461
|
+
const h = presetMenuHost();
|
|
7462
|
+
try {
|
|
7463
|
+
await emit(handlers, "session_start", h.ctx);
|
|
7464
|
+
h.ctx.ui.setEditorText("unsent draft");
|
|
7465
|
+
const command = commands.get("zentui") as {
|
|
7466
|
+
handler(args: string, ctx: unknown): Promise<void>;
|
|
7467
|
+
};
|
|
7468
|
+
const pending = command.handler("", h.ctx);
|
|
7469
|
+
await Promise.resolve();
|
|
7470
|
+
const menu = h.focused() as SettingsComponent;
|
|
7471
|
+
menu.handleInput("\r");
|
|
7472
|
+
menu.handleInput("\t");
|
|
7473
|
+
menu.handleInput("\r");
|
|
7474
|
+
await pending;
|
|
7475
|
+
expect(h.setEditorComponent).not.toHaveBeenCalled();
|
|
7476
|
+
expect(h.ctx.ui.getEditorComponent()).toBeUndefined();
|
|
7477
|
+
expect(h.ctx.ui.getEditorText()).toBe("unsent draft");
|
|
7478
|
+
expect(JSON.parse(readFileSync(configPath, "utf8")).components.editor.enabled).toBe(false);
|
|
7479
|
+
} finally {
|
|
7480
|
+
await emit(handlers, "session_shutdown", h.ctx);
|
|
7481
|
+
}
|
|
7482
|
+
});
|
|
7483
|
+
|
|
7484
|
+
it("keeps settings usable after a failed subsequent save and installs the last successful selection on exit", async () => {
|
|
7485
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7486
|
+
writeFileSync(
|
|
7487
|
+
configPath,
|
|
7488
|
+
JSON.stringify({ projectRefreshIntervalMs: 0, components: { editor: { enabled: false } } }),
|
|
7489
|
+
);
|
|
7490
|
+
const commands = new Map<string, unknown>();
|
|
7491
|
+
const handlers = loadExtension({ commands });
|
|
7492
|
+
const h = presetMenuHost();
|
|
7493
|
+
try {
|
|
7494
|
+
await emit(handlers, "session_start", h.ctx);
|
|
7495
|
+
const command = commands.get("zentui") as {
|
|
7496
|
+
handler(args: string, ctx: unknown): Promise<void>;
|
|
7497
|
+
};
|
|
7498
|
+
const pending = command.handler("", h.ctx);
|
|
7499
|
+
await Promise.resolve();
|
|
7500
|
+
const menu = h.focused() as SettingsComponent;
|
|
7501
|
+
menu.handleInput("\r");
|
|
7502
|
+
writeFileSync(configPath, "invalid JSON");
|
|
7503
|
+
menu.handleInput("\r");
|
|
7504
|
+
expect(h.focused()).toBe(menu);
|
|
7505
|
+
expect(h.setEditorComponent).not.toHaveBeenCalled();
|
|
7506
|
+
expect(h.notify).toHaveBeenLastCalledWith(
|
|
7507
|
+
expect.stringContaining("Could not update Zentui settings"),
|
|
7508
|
+
"error",
|
|
7509
|
+
);
|
|
7510
|
+
expect(stripPromptMarks(menu.render(160).join("\n"))).toMatch(/Preset\s+Opencode\s*\n/);
|
|
7511
|
+
expect(menu.render(160).join("\n")).not.toContain("Opencode (copy-friendly)");
|
|
7512
|
+
menu.handleInput("\x1b");
|
|
7513
|
+
await pending;
|
|
7514
|
+
expect(h.setEditorComponent).toHaveBeenCalledTimes(1);
|
|
7515
|
+
expect(h.host.editor).toBeInstanceOf(PolishedEditorProduction);
|
|
7516
|
+
expect(readFileSync(configPath, "utf8")).toBe("invalid JSON");
|
|
7517
|
+
} finally {
|
|
7518
|
+
await emit(handlers, "session_shutdown", h.ctx);
|
|
7519
|
+
}
|
|
7520
|
+
});
|
|
7521
|
+
|
|
7522
|
+
it("enables an editor through a preset while preserving its predecessor and draft", async () => {
|
|
7523
|
+
writeFileSync(
|
|
7524
|
+
join(isolatedAgentDir.path, "zentui.json"),
|
|
7525
|
+
JSON.stringify({ projectRefreshIntervalMs: 0, components: { editor: { enabled: false } } }),
|
|
7526
|
+
);
|
|
7527
|
+
const commands = new Map<string, unknown>();
|
|
7528
|
+
const handlers = loadExtension({ commands });
|
|
7529
|
+
const ctx = makeContext({ ui: { notify() {} } });
|
|
7530
|
+
const predecessor = () => ({ render: () => ["predecessor"], invalidate() {} });
|
|
7531
|
+
ctx.ui.setEditorComponent(predecessor);
|
|
7532
|
+
ctx.ui.setEditorText("draft before enabling");
|
|
7533
|
+
try {
|
|
7534
|
+
await emit(handlers, "session_start", ctx);
|
|
7535
|
+
expect(ctx.ui.getEditorComponent()).toBe(predecessor);
|
|
7536
|
+
const command = commands.get("zentui") as {
|
|
7537
|
+
handler(args: string, ctx: unknown): Promise<void>;
|
|
7538
|
+
};
|
|
7539
|
+
await command.handler("preset rail", ctx);
|
|
7540
|
+
expect(ctx.ui.getEditorComponent()).not.toBe(predecessor);
|
|
7541
|
+
expect(ctx.ui.getEditorText()).toBe("draft before enabling");
|
|
7542
|
+
await command.handler("editor disable", ctx);
|
|
7543
|
+
expect(ctx.ui.getEditorComponent()).toBe(predecessor);
|
|
7544
|
+
expect(ctx.ui.getEditorText()).toBe("draft before enabling");
|
|
7545
|
+
} finally {
|
|
7546
|
+
await emit(handlers, "session_shutdown", ctx);
|
|
7547
|
+
}
|
|
7548
|
+
});
|
|
7549
|
+
|
|
7550
|
+
it("reports blocked editor transfer while persisting the entire preset and reconciling independent surfaces", async () => {
|
|
7551
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7552
|
+
writeFileSync(
|
|
7553
|
+
configPath,
|
|
7554
|
+
JSON.stringify({ projectRefreshIntervalMs: 0, components: { editor: { enabled: false } } }),
|
|
7555
|
+
);
|
|
7556
|
+
const commands = new Map<string, unknown>();
|
|
7557
|
+
const handlers = loadExtension({ commands });
|
|
7558
|
+
const notify = vi.fn();
|
|
7559
|
+
let footer: ReturnType<FooterFactory> | undefined;
|
|
7560
|
+
const ctx = makeContext({
|
|
7561
|
+
ui: {
|
|
7562
|
+
notify,
|
|
7563
|
+
getEditorText() {
|
|
7564
|
+
throw new Error("transfer blocked");
|
|
7565
|
+
},
|
|
7566
|
+
setFooter(next: FooterFactory | undefined) {
|
|
7567
|
+
footer?.dispose?.();
|
|
7568
|
+
footer = next?.({ requestRender() {} }, makeTheme(), {
|
|
7569
|
+
onBranchChange: () => () => {},
|
|
7570
|
+
getExtensionStatuses: () => new Map(),
|
|
7571
|
+
});
|
|
7572
|
+
},
|
|
7573
|
+
},
|
|
7574
|
+
});
|
|
7575
|
+
try {
|
|
7576
|
+
await emit(handlers, "session_start", ctx);
|
|
7577
|
+
await (
|
|
7578
|
+
commands.get("zentui") as { handler(args: string, ctx: unknown): Promise<void> }
|
|
7579
|
+
).handler("preset minimalist", ctx);
|
|
7580
|
+
expect(ctx.ui.getEditorComponent()).toBeUndefined();
|
|
7581
|
+
expect(footer?.render(80)).toEqual([]);
|
|
7582
|
+
expect(UserMessageComponent.prototype.render).toBe(originalUserMessageRender);
|
|
7583
|
+
expect(JSON.parse(readFileSync(configPath, "utf8")).components).toMatchObject({
|
|
7584
|
+
editor: { enabled: true, style: "minimalist" },
|
|
7585
|
+
footer: { style: "hidden" },
|
|
7586
|
+
userMessages: { enabled: false },
|
|
7587
|
+
});
|
|
7588
|
+
expect(notify).toHaveBeenCalledWith(
|
|
7589
|
+
expect.stringMatching(/Preset saved: Minimalist.*reload Pi/),
|
|
7590
|
+
"warning",
|
|
7591
|
+
);
|
|
7592
|
+
} finally {
|
|
7593
|
+
await emit(handlers, "session_shutdown", ctx);
|
|
7594
|
+
}
|
|
7595
|
+
});
|
|
7596
|
+
it("warns when a preset retains a prior-instance editor after failed startup transfer", async () => {
|
|
7597
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7598
|
+
writeFileSync(configPath, JSON.stringify({ projectRefreshIntervalMs: 0 }));
|
|
7599
|
+
const firstHandlers = loadExtension();
|
|
7600
|
+
const commands = new Map<string, unknown>();
|
|
7601
|
+
const reloadedHandlers = loadExtension({ commands });
|
|
7602
|
+
const notify = vi.fn();
|
|
7603
|
+
let transferBlocked = false;
|
|
7604
|
+
let editorFactory: unknown;
|
|
7605
|
+
let editorText = "unsent draft";
|
|
7606
|
+
let footer: ReturnType<FooterFactory> | undefined;
|
|
7607
|
+
const getEditorText = vi.fn(() => {
|
|
7608
|
+
if (transferBlocked) throw new Error("expanded text unavailable");
|
|
7609
|
+
return editorText;
|
|
7610
|
+
});
|
|
7611
|
+
const setEditorText = vi.fn((text: string) => {
|
|
7612
|
+
editorText = text;
|
|
7613
|
+
});
|
|
7614
|
+
const setEditorComponent = vi.fn((factory: unknown) => {
|
|
7615
|
+
editorFactory = factory;
|
|
7616
|
+
});
|
|
7617
|
+
const ctx = makeContext({
|
|
7618
|
+
ui: {
|
|
7619
|
+
notify,
|
|
7620
|
+
getEditorText,
|
|
7621
|
+
setEditorText,
|
|
7622
|
+
setEditorComponent,
|
|
7623
|
+
getEditorComponent: () => editorFactory,
|
|
7624
|
+
setFooter(next: FooterFactory | undefined) {
|
|
7625
|
+
footer?.dispose?.();
|
|
7626
|
+
footer = next?.({ requestRender() {} }, makeTheme(), {
|
|
7627
|
+
onBranchChange: () => () => {},
|
|
7628
|
+
getExtensionStatuses: () => new Map(),
|
|
7629
|
+
});
|
|
7630
|
+
},
|
|
7631
|
+
},
|
|
7632
|
+
});
|
|
7633
|
+
try {
|
|
7634
|
+
await emit(firstHandlers, "session_start", ctx);
|
|
7635
|
+
const firstFactory = editorFactory;
|
|
7636
|
+
expect(firstFactory).toBeTypeOf("function");
|
|
7637
|
+
transferBlocked = true;
|
|
7638
|
+
getEditorText.mockClear();
|
|
7639
|
+
setEditorText.mockClear();
|
|
7640
|
+
setEditorComponent.mockClear();
|
|
7641
|
+
await emit(reloadedHandlers, "session_start", ctx);
|
|
7642
|
+
expect(getEditorText).toHaveBeenCalled();
|
|
7643
|
+
expect(editorFactory).toBe(firstFactory);
|
|
7644
|
+
notify.mockClear();
|
|
7645
|
+
|
|
7646
|
+
await (
|
|
7647
|
+
commands.get("zentui") as { handler(args: string, ctx: unknown): Promise<void> }
|
|
7648
|
+
).handler("preset minimalist", ctx);
|
|
7649
|
+
|
|
7650
|
+
expect(editorFactory).toBe(firstFactory);
|
|
7651
|
+
expect(editorText).toBe("unsent draft");
|
|
7652
|
+
expect(setEditorComponent).not.toHaveBeenCalled();
|
|
7653
|
+
expect(setEditorText).not.toHaveBeenCalled();
|
|
7654
|
+
expect(footer?.render(80)).toEqual([]);
|
|
7655
|
+
expect(UserMessageComponent.prototype.render).toBe(originalUserMessageRender);
|
|
7656
|
+
expect(JSON.parse(readFileSync(configPath, "utf8")).components).toMatchObject({
|
|
7657
|
+
editor: { enabled: true, style: "minimalist" },
|
|
7658
|
+
footer: { style: "hidden" },
|
|
7659
|
+
userMessages: { enabled: false },
|
|
7660
|
+
});
|
|
7661
|
+
expect(notify).toHaveBeenCalledWith(
|
|
7662
|
+
expect.stringMatching(/Preset saved: Minimalist.*another Zentui instance.*reload Pi/),
|
|
7663
|
+
"warning",
|
|
7664
|
+
);
|
|
7665
|
+
} finally {
|
|
7666
|
+
transferBlocked = false;
|
|
7667
|
+
await emit(reloadedHandlers, "session_shutdown", ctx);
|
|
7668
|
+
await emit(firstHandlers, "session_shutdown", ctx);
|
|
7669
|
+
}
|
|
7670
|
+
});
|
|
7671
|
+
|
|
7672
|
+
it("transitions all four presets without reacquiring selectors, Working line, or Thinking", async () => {
|
|
7673
|
+
initTheme(undefined, false);
|
|
7674
|
+
vi.useFakeTimers();
|
|
7675
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7676
|
+
writeFileSync(
|
|
7677
|
+
configPath,
|
|
7678
|
+
JSON.stringify({
|
|
7679
|
+
projectRefreshIntervalMs: 0,
|
|
7680
|
+
components: {
|
|
7681
|
+
footer: { styles: { starship: { format: "$time" } } },
|
|
7682
|
+
workingLine: { enabled: true },
|
|
7683
|
+
},
|
|
7684
|
+
}),
|
|
7685
|
+
);
|
|
7686
|
+
const commands = new Map<string, unknown>();
|
|
7687
|
+
const handlers = loadExtension({ commands });
|
|
7688
|
+
let footer: ReturnType<FooterFactory> | undefined;
|
|
7689
|
+
const branchCleanup = vi.fn();
|
|
7690
|
+
const subscribe = vi.fn(() => branchCleanup);
|
|
7691
|
+
const render = vi.fn();
|
|
7692
|
+
const setWorkingMessage = vi.fn();
|
|
7693
|
+
const setWorkingIndicator = vi.fn();
|
|
7694
|
+
const ctx = makeContext({
|
|
7695
|
+
ui: {
|
|
7696
|
+
notify() {},
|
|
7697
|
+
setWorkingMessage,
|
|
7698
|
+
setWorkingIndicator,
|
|
7699
|
+
setFooter(next: FooterFactory | undefined) {
|
|
7700
|
+
footer?.dispose?.();
|
|
7701
|
+
footer = next?.({ requestRender: render }, makeTheme(), {
|
|
7702
|
+
onBranchChange: subscribe,
|
|
7703
|
+
getExtensionStatuses: () => new Map(),
|
|
7704
|
+
});
|
|
7705
|
+
},
|
|
7706
|
+
},
|
|
7707
|
+
});
|
|
7708
|
+
try {
|
|
7709
|
+
await emit(handlers, "session_start", ctx);
|
|
7710
|
+
ctx.ui.setEditorText("unsent draft");
|
|
7711
|
+
const editor = ctx.ui.getEditorComponent();
|
|
7712
|
+
const nativeThinking = AssistantMessageComponent.prototype.updateContent;
|
|
7713
|
+
const displacedSelector = () => ["other selector"];
|
|
7714
|
+
ModelSelectorComponent.prototype.render = displacedSelector;
|
|
7715
|
+
const workingMessageCalls = setWorkingMessage.mock.calls.length;
|
|
7716
|
+
const workingIndicatorCalls = setWorkingIndicator.mock.calls.length;
|
|
7717
|
+
const command = commands.get("zentui") as {
|
|
7718
|
+
handler(args: string, ctx: unknown): Promise<void>;
|
|
7719
|
+
};
|
|
7720
|
+
for (const id of ["opencode-copy-friendly", "rail", "minimalist", "opencode"]) {
|
|
7721
|
+
await command.handler(`preset ${id}`, ctx);
|
|
7722
|
+
expect(ctx.ui.getEditorComponent()).toBe(editor);
|
|
7723
|
+
expect(ctx.ui.getEditorText()).toBe("unsent draft");
|
|
7724
|
+
expect(ModelSelectorComponent.prototype.render).toBe(displacedSelector);
|
|
7725
|
+
expect(AssistantMessageComponent.prototype.updateContent).toBe(nativeThinking);
|
|
7726
|
+
expect(setWorkingMessage).toHaveBeenCalledTimes(workingMessageCalls);
|
|
7727
|
+
expect(setWorkingIndicator).toHaveBeenCalledTimes(workingIndicatorCalls);
|
|
7728
|
+
if (id === "minimalist") {
|
|
7729
|
+
expect(footer?.render(100)).toEqual([]);
|
|
7730
|
+
expect(UserMessageComponent.prototype.render).toBe(originalUserMessageRender);
|
|
7731
|
+
expect(branchCleanup).toHaveBeenCalledTimes(1);
|
|
7732
|
+
const before = render.mock.calls.length;
|
|
7733
|
+
vi.advanceTimersByTime(1000);
|
|
7734
|
+
expect(render).toHaveBeenCalledTimes(before);
|
|
7735
|
+
} else {
|
|
7736
|
+
expect(footer?.render(100).length).toBeGreaterThan(0);
|
|
7737
|
+
expect(UserMessageComponent.prototype.render).not.toBe(originalUserMessageRender);
|
|
7738
|
+
}
|
|
7739
|
+
}
|
|
7740
|
+
expect(subscribe).toHaveBeenCalledTimes(2);
|
|
7741
|
+
const before = render.mock.calls.length;
|
|
7742
|
+
vi.advanceTimersByTime(1000);
|
|
7743
|
+
expect(render.mock.calls.length).toBeGreaterThan(before);
|
|
7744
|
+
} finally {
|
|
7745
|
+
await emit(handlers, "session_shutdown", ctx);
|
|
7746
|
+
vi.useRealTimers();
|
|
7747
|
+
}
|
|
7748
|
+
});
|
|
7749
|
+
|
|
7750
|
+
it("preserves active config and all surfaces when a preset save fails", async () => {
|
|
7751
|
+
const configPath = join(isolatedAgentDir.path, "zentui.json");
|
|
7752
|
+
writeFileSync(configPath, JSON.stringify({ projectRefreshIntervalMs: 0 }));
|
|
7753
|
+
const commands = new Map<string, unknown>();
|
|
7754
|
+
const handlers = loadExtension({ commands });
|
|
7755
|
+
const notify = vi.fn();
|
|
7756
|
+
const setFooter = vi.fn();
|
|
7757
|
+
const ctx = makeContext({ ui: { notify, setFooter } });
|
|
7758
|
+
try {
|
|
7759
|
+
await emit(handlers, "session_start", ctx);
|
|
7760
|
+
const editor = ctx.ui.getEditorComponent();
|
|
7761
|
+
const messages = UserMessageComponent.prototype.render;
|
|
7762
|
+
const calls = setFooter.mock.calls.length;
|
|
7763
|
+
writeFileSync(configPath, "{ corrupt");
|
|
7764
|
+
await (
|
|
7765
|
+
commands.get("zentui") as { handler(args: string, ctx: unknown): Promise<void> }
|
|
7766
|
+
).handler("preset minimalist", ctx);
|
|
7767
|
+
expect(ctx.ui.getEditorComponent()).toBe(editor);
|
|
7768
|
+
expect(UserMessageComponent.prototype.render).toBe(messages);
|
|
7769
|
+
expect(setFooter).toHaveBeenCalledTimes(calls);
|
|
7770
|
+
expect(notify).toHaveBeenCalledWith(expect.stringContaining("Refusing to save"), "error");
|
|
7771
|
+
expect(readFileSync(configPath, "utf8")).toBe("{ corrupt");
|
|
7772
|
+
} finally {
|
|
7773
|
+
await emit(handlers, "session_shutdown", ctx);
|
|
7774
|
+
}
|
|
7775
|
+
});
|
|
7776
|
+
|
|
7777
|
+
it.each(["rpc", "print", "json"])(
|
|
7778
|
+
"persists in %s without acquiring TUI surfaces",
|
|
7779
|
+
async (mode) => {
|
|
7780
|
+
const commands = new Map<string, unknown>();
|
|
7781
|
+
const handlers = loadExtension({ commands });
|
|
7782
|
+
const setFooter = vi.fn();
|
|
7783
|
+
const setEditorComponent = vi.fn();
|
|
7784
|
+
const ctx = makeContext({
|
|
7785
|
+
mode,
|
|
7786
|
+
hasUI: mode === "rpc",
|
|
7787
|
+
ui: { notify() {}, setFooter, setEditorComponent },
|
|
7788
|
+
});
|
|
7789
|
+
try {
|
|
7790
|
+
await emit(handlers, "session_start", ctx);
|
|
7791
|
+
const messages = UserMessageComponent.prototype.render;
|
|
7792
|
+
const selectors = ModelSelectorComponent.prototype.render;
|
|
7793
|
+
await (
|
|
7794
|
+
commands.get("zentui") as { handler(args: string, ctx: unknown): Promise<void> }
|
|
7795
|
+
).handler("preset minimalist", ctx);
|
|
7796
|
+
expect(
|
|
7797
|
+
JSON.parse(readFileSync(join(isolatedAgentDir.path, "zentui.json"), "utf8")).components,
|
|
7798
|
+
).toEqual({
|
|
7799
|
+
editor: { enabled: true, style: "minimalist" },
|
|
7800
|
+
footer: { style: "hidden" },
|
|
7801
|
+
userMessages: { enabled: false, style: "framed" },
|
|
7802
|
+
workingLine: { enabled: false },
|
|
7803
|
+
});
|
|
7804
|
+
expect(setFooter).not.toHaveBeenCalled();
|
|
7805
|
+
expect(setEditorComponent).not.toHaveBeenCalled();
|
|
7806
|
+
expect(UserMessageComponent.prototype.render).toBe(messages);
|
|
7807
|
+
expect(ModelSelectorComponent.prototype.render).toBe(selectors);
|
|
7808
|
+
} finally {
|
|
7809
|
+
await emit(handlers, "session_shutdown", ctx);
|
|
7810
|
+
}
|
|
7811
|
+
},
|
|
7812
|
+
);
|
|
7813
|
+
});
|