gentle-pi 4.6.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -55
- package/assets/agents/gentle-ai-explore.md +4 -3
- package/assets/agents/gentle-ai-verify.md +23 -6
- package/assets/agents/gentle-ai-worker.md +9 -6
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +2 -3
- package/assets/agents/jd-judge-b.md +2 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +759 -16
- package/assets/design-canvas/canvas.js +2 -1497
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +6 -1
- package/assets/migrations/agent-body-history.json +40 -1
- package/assets/orchestrator-delegation-reference.md +10 -16
- package/assets/orchestrator-delegation.md +5 -5
- package/assets/orchestrator-full-delegation-card.md +64 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +5 -5
- package/assets/orchestrator-prompts.md +2 -2
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +14 -13
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +12 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +21 -25
- package/bin/gentle-shell.mjs +292 -65
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/agent-status.md +61 -0
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +20 -10
- package/docs/delegated-verification.md +46 -8
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +40 -0
- package/docs/gentle-shell.md +91 -30
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +17 -4
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +142 -45
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +53 -0
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +11 -1
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +3 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +559 -66
- package/extensions/gentle-ai.ts +2001 -518
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +398 -115
- package/extensions/gentle-todo.ts +66 -27
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +349 -167
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +93 -6
- package/lib/agents-history.ts +24 -5
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +55 -7
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +272 -16
- package/lib/agents-session-transport.ts +17 -1
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +197 -32
- package/lib/card-content-policy.ts +8 -6
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +236 -17
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +204 -14
- package/lib/gentle-shell-bundled.ts +106 -28
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/hidden-tools.ts +35 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +358 -144
- package/lib/jobs-view.ts +198 -11
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +31 -4
- package/lib/nan-provider.ts +42 -28
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +172 -20
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +129 -0
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +116 -0
- package/lib/review-coordinator.ts +407 -0
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +63 -4
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/reviewer-stream.ts +87 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/verifier-admission.ts +1 -1
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +46 -16
- package/package.json +3 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +106 -28
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +169 -17
- package/runtime/review-integration-v2.mjs +63 -4
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +179 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +33 -22
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +46 -16
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +40 -28
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +50 -19
- package/scripts/voice-worker.cjs +32 -6
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +16 -13
- package/skills/gentle-ai/SKILL.md +7 -7
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -11
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +10 -11
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +106 -1
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +215 -3
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +12 -1
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +99 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +51 -3
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +31 -6
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-safety.test.ts +11 -0
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +32 -10
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -695
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +160 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1403 -20
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +135 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +233 -43
- package/tests/gentle-design.test.ts +386 -1
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +293 -31
- package/tests/gentle-shell-launcher.test.ts +78 -11
- package/tests/gentle-shell.test.ts +1017 -146
- package/tests/gentle-todo.test.ts +51 -11
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +8 -4
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +97 -0
- package/tests/inprocess-reviewer.test.ts +249 -4
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +115 -14
- package/tests/installer-preflight.test.ts +54 -5
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +215 -13
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/jobs-view.test.ts +260 -6
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +17 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +13 -2
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +35 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +154 -0
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +13 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +4 -3
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +16 -13
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +372 -0
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +25 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/questionnaire-view.test.ts +115 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +17 -12
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +112 -1
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +189 -0
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +80 -2
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +66 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +107 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +98 -12
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +462 -0
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +105 -11
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +39 -2
- package/tests/review-reviewer-evidence.test.ts +223 -0
- package/tests/review-risk-assessment.test.ts +126 -8
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +53 -3
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +122 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +1461 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +264 -0
- package/tests/task-size-routing-contract.test.ts +45 -12
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +162 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +77 -6
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +276 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +62 -18
- package/tests/yolo-session-policy.test.ts +270 -1
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
// Where the artboards sit: design/<slug>/layout.json through the api/designs/<slug>/layout
|
|
2
|
+
// routes, Row / Column / Grid (Free once an artboard is moved by hand), moving an artboard
|
|
3
|
+
// by dragging any part of it, the selected artboard, and Space held to pan from anywhere.
|
|
4
|
+
// Artboards are placed in the world by position, not by the flow of a row: the world is as
|
|
5
|
+
// big as their bounds, so Fit, the minimap and focus mode read it as before.
|
|
6
|
+
|
|
7
|
+
// The room between boards in every arrangement, and the system board's key in layout.json,
|
|
8
|
+
// where every artboard is keyed by its file (which ends in .html, so the two never meet).
|
|
9
|
+
const BOARD_GAP = 80;
|
|
10
|
+
const SYSTEM_KEY = "system";
|
|
11
|
+
const ARRANGEMENTS = ["row", "column", "grid"];
|
|
12
|
+
// The farthest a board may sit from the origin on each axis, as the server's layout.json rules say
|
|
13
|
+
// (DESIGN_LAYOUT_COORDINATE_MAX in lib/design-layout.ts): a layout past it is none this page uses.
|
|
14
|
+
const COORDINATE_MAX = 2_000_000;
|
|
15
|
+
|
|
16
|
+
// Every string this module shows, in English; canvas-i18n-es.js has the Spanish. A server's reason stays as it came.
|
|
17
|
+
const TEXT = Object.freeze({
|
|
18
|
+
saveFailed: (slug, reason) => `The layout of ${slug} could not be saved: ${reason}`,
|
|
19
|
+
readFailed: (slug, reason) => `design/${slug}/layout.json could not be read: ${reason}`,
|
|
20
|
+
unusable: "it holds no layout this page can use",
|
|
21
|
+
error: "error",
|
|
22
|
+
});
|
|
23
|
+
// fetchLayout's reason for a layout.json that holds no layout this page can use: TEXT.unusable, in the language shown.
|
|
24
|
+
const UNUSABLE = Object.freeze({});
|
|
25
|
+
|
|
26
|
+
export function init(ctx) {
|
|
27
|
+
const { win, doc, els, store, api, ui, actions } = ctx;
|
|
28
|
+
const { state } = store;
|
|
29
|
+
const { getJson, postJson } = api;
|
|
30
|
+
const { setStatus } = ui;
|
|
31
|
+
const T = ctx.i18n.text("layout", TEXT);
|
|
32
|
+
|
|
33
|
+
// The artboard being moved by the pointer (canvas-view.js hands it over): { board, from, moved, view }, `view` the
|
|
34
|
+
// layout view it was pressed in. This module's own state, like the pan drag in canvas-view.js.
|
|
35
|
+
let moving = null;
|
|
36
|
+
// Saves go out one after another, in gesture order, so the server writes the newest layout last.
|
|
37
|
+
let saving = Promise.resolve();
|
|
38
|
+
// Layout saves queued or on their way to the server.
|
|
39
|
+
let saves = 0;
|
|
40
|
+
// The latest layout read (onLayoutChange, readLayoutNow); a newer read or a save makes an older read's reply stale.
|
|
41
|
+
let reads = 0;
|
|
42
|
+
// A layout.json change came while saves were on their way or a press was on an artboard: layout.json is read
|
|
43
|
+
// again once both are over.
|
|
44
|
+
let readPending = false;
|
|
45
|
+
// The layout views taken so far (useLayout): a save's reply only touches the view it was made from, never one
|
|
46
|
+
// taken after the page left the design and came back.
|
|
47
|
+
let views = 0;
|
|
48
|
+
// layout.json change reads on their way (onLayoutChange): a save that makes one stale and then fails reads the
|
|
49
|
+
// file again, so another page's change is never lost.
|
|
50
|
+
let changeReads = 0;
|
|
51
|
+
// The layout errors the status line keeps showing for a design ({ slug, reason }): the last save that failed, while
|
|
52
|
+
// the layout it left is still unsaved, and the last read of layout.json that failed, until one answers or a save succeeds.
|
|
53
|
+
// While that read error stands nothing is saved (saveLayout): the file is never written over before it can be read.
|
|
54
|
+
let saveError = null;
|
|
55
|
+
let readError = null;
|
|
56
|
+
// The layout error the status line was given last ({ slug, kind, text }), in the language it was shown in: an answer
|
|
57
|
+
// or a save that succeeds clears the status line only while it still shows that text, whatever the language is now.
|
|
58
|
+
let shownError = null;
|
|
59
|
+
|
|
60
|
+
/** A board's key in layout.json: its artboard file, or the system board's own key. */
|
|
61
|
+
function layoutKey(board) {
|
|
62
|
+
return board.system ? SYSTEM_KEY : board.artboard.file;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** A world child's box in world px: its manifest width, and its frame (at its manifest height) below its label. */
|
|
66
|
+
function layoutSize(wrapper) {
|
|
67
|
+
const box = wrapper.children[wrapper.children.length - 1];
|
|
68
|
+
const size = wrapper.layoutSize ?? { width: 0, height: 0 };
|
|
69
|
+
return { width: size.width, height: (box ? box.offsetTop : 0) + size.height };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const isCoordinate = (value) => Number.isInteger(value) && Math.abs(value) <= COORDINATE_MAX;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* api/designs/<slug>/layout's layout, or null when it holds none this page can use: an unknown arrangement, or a
|
|
76
|
+
* position that is no integer within COORDINATE_MAX (so the world and the minimap keep a sane size). Positions are
|
|
77
|
+
* keyed in an object without a prototype, so a key such as `__proto__` is just another board's key.
|
|
78
|
+
*/
|
|
79
|
+
function readLayout(value) {
|
|
80
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
81
|
+
if (value.arrangement !== "free" && !ARRANGEMENTS.includes(value.arrangement)) return null;
|
|
82
|
+
const raw = value.positions;
|
|
83
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
84
|
+
const positions = Object.create(null);
|
|
85
|
+
for (const [key, position] of Object.entries(raw)) {
|
|
86
|
+
if (!position || !isCoordinate(position.x) || !isCoordinate(position.y)) return null;
|
|
87
|
+
positions[key] = { x: position.x, y: position.y };
|
|
88
|
+
}
|
|
89
|
+
return { arrangement: value.arrangement, positions };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The saved layout of design `slug`, as { layout, error }: layout null when it has none; undefined when layout.json
|
|
94
|
+
* cannot be used (the server cannot read or use it, or it holds a layout this page's readLayout rejects) or the read
|
|
95
|
+
* itself failed (an error reply, no connection), with `error` saying why. A failed read says nothing about the
|
|
96
|
+
* boards: the canvas never fails on it.
|
|
97
|
+
*/
|
|
98
|
+
async function fetchLayout(slug) {
|
|
99
|
+
try {
|
|
100
|
+
const data = await getJson(`api/designs/${encodeURIComponent(slug)}/layout`);
|
|
101
|
+
const value = data ? data.layout : null;
|
|
102
|
+
if (value === null || value === undefined) return { layout: null, error: "" };
|
|
103
|
+
const layout = readLayout(value);
|
|
104
|
+
return layout ? { layout, error: "" } : { layout: undefined, error: UNUSABLE };
|
|
105
|
+
} catch (error) {
|
|
106
|
+
// Only a layout.json the server cannot read or use is news for the status line; an HTTP error or no
|
|
107
|
+
// connection says nothing about the file, and the layout shown stays without a word, as before.
|
|
108
|
+
const unreadable = Boolean(error && error.body && error.body.error === "unreadable-layout");
|
|
109
|
+
return { layout: undefined, error: unreadable ? error.message || T.error : null };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The text of a layout error of `kind` ("save" or "read") in the current language, now given to the status line. */
|
|
114
|
+
function errorText(kind, { slug, reason }) {
|
|
115
|
+
const text = kind === "save" ? T.saveFailed(slug, reason) : T.readFailed(slug, reason === UNUSABLE ? T.unusable : reason);
|
|
116
|
+
shownError = { slug, kind, text };
|
|
117
|
+
return text;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The status line still shows the layout error of `slug` given last (of `kind`, when named): the exact text, or the start of it with `prefix`. */
|
|
121
|
+
function showsError(slug, kind, prefix) {
|
|
122
|
+
if (!shownError || shownError.slug !== slug || (kind && shownError.kind !== kind) || !els.status.classList.contains("gd-error")) return false;
|
|
123
|
+
const text = els.status.textContent;
|
|
124
|
+
return prefix ? text.startsWith(shownError.text) : text === shownError.text;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The layout error the status line shows for the design shown: a failed save while its layout is unsaved, then a failed read. */
|
|
128
|
+
function layoutError() {
|
|
129
|
+
const slug = state.slug;
|
|
130
|
+
const shown = state.layout && state.layout.slug === slug ? state.layout : null;
|
|
131
|
+
if (saveError && saveError.slug === slug && shown && shown.unsaved) return errorText("save", saveError);
|
|
132
|
+
if (readError && readError.slug === slug) return errorText("read", readError);
|
|
133
|
+
return "";
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A read of design `slug`'s layout answered (`error` empty) or failed: its read error is kept, or cleared from the status line. */
|
|
137
|
+
function noteRead(slug, error, show) {
|
|
138
|
+
// null: the read failed for a reason that says nothing about layout.json (keep what the status line says).
|
|
139
|
+
if (error === null) return;
|
|
140
|
+
if (error) {
|
|
141
|
+
readError = { slug, reason: error };
|
|
142
|
+
if (show) setStatus(errorText("read", readError), true);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (!readError || readError.slug !== slug) return;
|
|
146
|
+
readError = null;
|
|
147
|
+
if (show && showsError(slug, "read", false)) {
|
|
148
|
+
const rest = layoutError();
|
|
149
|
+
setStatus(rest, Boolean(rest));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Takes `layout` (null: none, a row) as design `slug`'s; the boards move at the next applyLayout. `saved` is what
|
|
155
|
+
* layout.json is known to hold (this read, or later a save the server took); `unsaved` marks a layout whose last
|
|
156
|
+
* save failed, which stays until layout.json holds something else. Each call is a new view of the layout.
|
|
157
|
+
*/
|
|
158
|
+
function useLayout(slug, layout) {
|
|
159
|
+
views += 1;
|
|
160
|
+
store.setLayout({ layout: { slug, view: views, arrangement: layout ? layout.arrangement : "row", positions: layout ? layout.positions : {}, saved: JSON.stringify(layout) } });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** loadManifest's read of design `slug`'s layout: { layout, error, read }, numbered like onLayoutChange's reads. */
|
|
164
|
+
async function readLayoutNow(slug) {
|
|
165
|
+
const read = ++reads;
|
|
166
|
+
return { ...(await fetchLayout(slug)), read };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* loadManifest's layout: taken unless this page already shows a layout of the design that is newer than the read
|
|
171
|
+
* (a save or a read went out after it, or a save is still in flight, which is newer than the file), or the file
|
|
172
|
+
* still holds what this page knew (the layout shown, already placed, or one whose save failed). A read that failed
|
|
173
|
+
* keeps the layout shown; with none shown the boards sit in a row. loadManifest then shows layoutError's text.
|
|
174
|
+
*/
|
|
175
|
+
function takeLayout(slug, { layout, read, error }) {
|
|
176
|
+
const shown = state.layout && state.layout.slug === slug ? state.layout : null;
|
|
177
|
+
noteRead(slug, error, false);
|
|
178
|
+
if (layout === undefined) {
|
|
179
|
+
if (!shown) useLayout(slug, null);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (!shown || (read === reads && saves === 0 && JSON.stringify(layout) !== shown.saved)) useLayout(slug, layout);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** No design shown (the system-only view, an empty notice): no layout, nothing selected, nothing to arrange. */
|
|
186
|
+
function clearLayout() {
|
|
187
|
+
cancelMove();
|
|
188
|
+
store.setLayout({ layout: null });
|
|
189
|
+
selectBoard(null);
|
|
190
|
+
renderArrange();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** The top left of a box right of the boxes `rects`, top-aligned with them. */
|
|
194
|
+
function spotAfter(rects) {
|
|
195
|
+
if (rects.length === 0) return { x: 0, y: 0 };
|
|
196
|
+
return { x: Math.max(...rects.map((rect) => rect.x + rect.width)) + BOARD_GAP, y: Math.min(...rects.map((rect) => rect.y)) };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Positions of `boards` in arrangement `kind`, in order, BOARD_GAP apart: a grid of roughly square columns, each as
|
|
201
|
+
* wide as its widest board, and rows as tall as their tallest; a row is a grid of one row, a column one of one column.
|
|
202
|
+
*/
|
|
203
|
+
function arranged(kind, boards) {
|
|
204
|
+
const columns = Math.max(1, kind === "row" ? boards.length : kind === "column" ? 1 : Math.ceil(Math.sqrt(boards.length)));
|
|
205
|
+
const widths = [];
|
|
206
|
+
const heights = [];
|
|
207
|
+
boards.forEach((board, index) => {
|
|
208
|
+
const size = layoutSize(board.wrapper);
|
|
209
|
+
const column = index % columns;
|
|
210
|
+
const row = Math.floor(index / columns);
|
|
211
|
+
widths[column] = Math.max(widths[column] ?? 0, size.width);
|
|
212
|
+
heights[row] = Math.max(heights[row] ?? 0, size.height);
|
|
213
|
+
});
|
|
214
|
+
const starts = (lengths) => lengths.map((_, index) => lengths.slice(0, index).reduce((sum, length) => sum + length + BOARD_GAP, 0));
|
|
215
|
+
const xs = starts(widths);
|
|
216
|
+
const ys = starts(heights);
|
|
217
|
+
return Object.fromEntries(boards.map((board, index) => [layoutKey(board), { x: xs[index % columns], y: ys[Math.floor(index / columns)] }]));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function place(wrapper, at) {
|
|
221
|
+
wrapper.layoutAt = at;
|
|
222
|
+
wrapper.style.left = `${at.x}px`;
|
|
223
|
+
wrapper.style.top = `${at.y}px`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The world as big as the bounds of the boards placed in it, so Fit sees every board. */
|
|
227
|
+
function sizeWorld() {
|
|
228
|
+
let right = 0;
|
|
229
|
+
let bottom = 0;
|
|
230
|
+
for (const board of actions.allBoards()) {
|
|
231
|
+
if (!board.wrapper.layoutAt) continue;
|
|
232
|
+
const size = layoutSize(board.wrapper);
|
|
233
|
+
right = Math.max(right, board.wrapper.layoutAt.x + size.width);
|
|
234
|
+
bottom = Math.max(bottom, board.wrapper.layoutAt.y + size.height);
|
|
235
|
+
}
|
|
236
|
+
els.world.style.width = `${right}px`;
|
|
237
|
+
els.world.style.height = `${bottom}px`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Puts every board where the layout says and sizes the world to their bounds. An arrangement is laid out again
|
|
242
|
+
* from the boards' sizes; a free layout keeps each board's position, a board it does not know goes after the
|
|
243
|
+
* others, and one the design lost drops out. No board sits left of or above the world's top left: when one went
|
|
244
|
+
* there, everything shifts back and the view (or, in focus mode, the view to restore) follows, so nothing jumps.
|
|
245
|
+
* Without a layout (the system-only view) the boards sit in a row.
|
|
246
|
+
*/
|
|
247
|
+
function applyLayout() {
|
|
248
|
+
const boards = actions.allBoards();
|
|
249
|
+
const layout = state.layout;
|
|
250
|
+
const arrangement = layout ? layout.arrangement : "row";
|
|
251
|
+
const keys = boards.map(layoutKey);
|
|
252
|
+
let positions = {};
|
|
253
|
+
if (arrangement === "free") {
|
|
254
|
+
const rects = [];
|
|
255
|
+
const known = boards.filter((board, index) => layout.positions[keys[index]]);
|
|
256
|
+
for (const board of [...known, ...boards.filter((board) => !known.includes(board))]) {
|
|
257
|
+
const key = layoutKey(board);
|
|
258
|
+
positions[key] = layout.positions[key] ?? spotAfter(rects);
|
|
259
|
+
rects.push({ ...positions[key], ...layoutSize(board.wrapper) });
|
|
260
|
+
}
|
|
261
|
+
} else positions = arranged(arrangement, boards);
|
|
262
|
+
const shiftX = Math.min(0, ...keys.map((key) => positions[key].x));
|
|
263
|
+
const shiftY = Math.min(0, ...keys.map((key) => positions[key].y));
|
|
264
|
+
const placed = Object.fromEntries(keys.map((key) => [key, { x: positions[key].x - shiftX, y: positions[key].y - shiftY }]));
|
|
265
|
+
if (layout) store.setLayout({ layout: { ...layout, positions: placed } });
|
|
266
|
+
boards.forEach((board, index) => place(board.wrapper, placed[keys[index]]));
|
|
267
|
+
sizeWorld();
|
|
268
|
+
if (shiftX !== 0 || shiftY !== 0) {
|
|
269
|
+
if (!state.focus) {
|
|
270
|
+
store.setView({ x: state.x + shiftX * state.zoom, y: state.y + shiftY * state.zoom });
|
|
271
|
+
actions.applyView();
|
|
272
|
+
} else if (state.savedView) {
|
|
273
|
+
const saved = state.savedView;
|
|
274
|
+
store.setFocus({ savedView: { ...saved, x: saved.x + shiftX * saved.zoom, y: saved.y + shiftY * saved.zoom } });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
actions.renderMinimap();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* placeBoards' layout step: a move or a selection of a board that was replaced ends, then every board is placed,
|
|
282
|
+
* and a layout.json change put off until the design's boards showed is read.
|
|
283
|
+
*/
|
|
284
|
+
function layoutBoards(boards) {
|
|
285
|
+
if (moving && (!state.layout || state.layout.view !== moving.view)) cancelMove();
|
|
286
|
+
else if (moving && !boards.includes(moving.board)) {
|
|
287
|
+
// The same layout, rebuilt (a design.json reload): the move goes on with the board that replaced this one.
|
|
288
|
+
const key = layoutKey(moving.board);
|
|
289
|
+
const next = boards.find((board) => layoutKey(board) === key);
|
|
290
|
+
if (next) {
|
|
291
|
+
moving.board = next;
|
|
292
|
+
next.wrapper.classList.add("gd-lifted");
|
|
293
|
+
} else moving = null;
|
|
294
|
+
}
|
|
295
|
+
if (state.selected && !boards.includes(state.selected)) selectBoard(null);
|
|
296
|
+
// An arrangement places every board again: a board already moved stays where it was dragged until the release.
|
|
297
|
+
const dragged = moving && moving.moved && state.layout.arrangement !== "free" ? state.layout.positions[layoutKey(moving.board)] : null;
|
|
298
|
+
applyLayout();
|
|
299
|
+
if (dragged) moveBoard(moving.board, dragged);
|
|
300
|
+
readAgain();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Puts `board` at `at` while it is dragged; it is saved on release (finishMove). */
|
|
304
|
+
function moveBoard(board, at) {
|
|
305
|
+
store.setLayout({ layout: { ...state.layout, positions: { ...state.layout.positions, [layoutKey(board)]: at } } });
|
|
306
|
+
board.wrapper.classList.add("gd-lifted");
|
|
307
|
+
place(board.wrapper, at);
|
|
308
|
+
sizeWorld();
|
|
309
|
+
actions.renderMinimap();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** A press on `board` that may become a move; false when the board has no place in a layout (nothing to move). */
|
|
313
|
+
function beginMove(board) {
|
|
314
|
+
const from = state.layout ? state.layout.positions[layoutKey(board)] : null;
|
|
315
|
+
if (!from) return false;
|
|
316
|
+
moving = { board, from, moved: false, view: state.layout.view };
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* A move whose layout is gone (another design, another page's layout taken meanwhile, no design shown) ends
|
|
322
|
+
* without a save: its offsets belong to the layout it was pressed in.
|
|
323
|
+
*/
|
|
324
|
+
function cancelMove() {
|
|
325
|
+
if (!moving) return;
|
|
326
|
+
moving.board.wrapper.classList.remove("gd-lifted");
|
|
327
|
+
moving = null;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** The pointer went (dx, dy) screen px from where the move began: in world px, so the board stays under it at any zoom. */
|
|
331
|
+
function moveBy(dx, dy) {
|
|
332
|
+
if (!moving || !state.layout) return;
|
|
333
|
+
moving.moved = true;
|
|
334
|
+
moveBoard(moving.board, { x: Math.round(moving.from.x + dx / state.zoom), y: Math.round(moving.from.y + dy / state.zoom) });
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** The press ended: a release keeps a moved board where it is, by hand; a cancel (the browser took the pointer) puts it back. */
|
|
338
|
+
function endMove(keep) {
|
|
339
|
+
const ended = moving;
|
|
340
|
+
moving = null;
|
|
341
|
+
if (ended) {
|
|
342
|
+
if (ended.moved) {
|
|
343
|
+
if (keep) finishMove();
|
|
344
|
+
else moveBoard(ended.board, ended.from);
|
|
345
|
+
}
|
|
346
|
+
ended.board.wrapper.classList.remove("gd-lifted");
|
|
347
|
+
}
|
|
348
|
+
readAgain();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** A board moved by hand: the layout is free from now on, and it is saved once. */
|
|
352
|
+
function finishMove() {
|
|
353
|
+
store.setLayout({ layout: { ...state.layout, arrangement: "free" } });
|
|
354
|
+
applyLayout();
|
|
355
|
+
renderArrange();
|
|
356
|
+
saveLayout();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Writes the layout of the design shown to its layout.json, after the saves before it; a failure says so in the
|
|
361
|
+
* status line and the boards stay, unsaved, until layout.json holds something this page did not know (another
|
|
362
|
+
* page's change wins); a later save that succeeds clears that error. A read on its way is older than this layout,
|
|
363
|
+
* and a change that came meanwhile is read once the last save is done. Nothing is saved while the boards shown
|
|
364
|
+
* are still another design's, nor while layout.json cannot be used (the last read of it failed with the reason in
|
|
365
|
+
* the status line): moves and arrangements then change only the view, and saves resume once a read answers with a
|
|
366
|
+
* layout or with none. A reply that comes after the page left the design and came back leaves the layout
|
|
367
|
+
* read since alone: what it holds is what layout.json held then, so the save's own change event still shows.
|
|
368
|
+
*/
|
|
369
|
+
function saveLayout() {
|
|
370
|
+
const slug = state.slug;
|
|
371
|
+
const layout = state.layout;
|
|
372
|
+
if (!slug || !state.manifest || state.manifest.slug !== slug || !layout || layout.slug !== slug) return;
|
|
373
|
+
if (readError && readError.slug === slug) return;
|
|
374
|
+
const body = { arrangement: layout.arrangement, positions: layout.positions };
|
|
375
|
+
// A change read this save makes stale: a save that fails leaves the file as that change wrote it, so it is read again.
|
|
376
|
+
const staleChange = changeReads > 0;
|
|
377
|
+
reads += 1;
|
|
378
|
+
saves += 1;
|
|
379
|
+
saving = saving.then(async () => {
|
|
380
|
+
const reply = await postJson(`api/designs/${encodeURIComponent(slug)}/layout`, body).catch((error) => ({ ok: false, body: { error: error.message } }));
|
|
381
|
+
saves -= 1;
|
|
382
|
+
// A read that went out while this save was on its way may hold the file from before it.
|
|
383
|
+
if (reply.ok) reads += 1;
|
|
384
|
+
else if (staleChange) readPending = true;
|
|
385
|
+
if (state.layout && state.layout.view === layout.view) {
|
|
386
|
+
store.setLayout({ layout: reply.ok ? { ...state.layout, saved: JSON.stringify(body), unsaved: false } : { ...state.layout, unsaved: true } });
|
|
387
|
+
}
|
|
388
|
+
if (!reply.ok) {
|
|
389
|
+
// Kept while the layout is unsaved, so a design.json reload shows it again (loadManifest).
|
|
390
|
+
saveError = { slug, reason: reply.body.reason || reply.body.error || T.error };
|
|
391
|
+
if (slug === state.slug) setStatus(errorText("save", saveError), true);
|
|
392
|
+
} else {
|
|
393
|
+
if (saveError && saveError.slug === slug) saveError = null;
|
|
394
|
+
// layout.json now holds this save: an earlier failed read of it is over too.
|
|
395
|
+
if (readError && readError.slug === slug) readError = null;
|
|
396
|
+
// A retry that succeeds clears this design's layout error, in the language it was shown in, never another status.
|
|
397
|
+
if (showsError(slug, null, true)) setStatus("", false);
|
|
398
|
+
}
|
|
399
|
+
readAgain();
|
|
400
|
+
}).catch(() => {});
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** The layout.json change put off by a save or a press is read once no save is on its way and no press is on an artboard. */
|
|
404
|
+
function readAgain() {
|
|
405
|
+
if (!readPending || saves > 0 || moving) return;
|
|
406
|
+
readPending = false;
|
|
407
|
+
onLayoutChange().catch(() => {});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* layout.json changed: another page moved or arranged the boards, so they move here too; the page's own save is no
|
|
412
|
+
* news, a read that fails keeps the layout shown, and a change of a design whose boards are not shown yet (a design
|
|
413
|
+
* switch still loading) is read once they are.
|
|
414
|
+
*/
|
|
415
|
+
async function onLayoutChange() {
|
|
416
|
+
const slug = state.slug;
|
|
417
|
+
if (!slug) return;
|
|
418
|
+
if (saves > 0 || moving) {
|
|
419
|
+
readPending = true;
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
const read = ++reads;
|
|
423
|
+
changeReads += 1;
|
|
424
|
+
const { layout, error } = await fetchLayout(slug).finally(() => {
|
|
425
|
+
changeReads -= 1;
|
|
426
|
+
});
|
|
427
|
+
if (read !== reads || slug !== state.slug) return;
|
|
428
|
+
noteRead(slug, error, true);
|
|
429
|
+
if (layout === undefined) return;
|
|
430
|
+
if (moving || !state.manifest || state.manifest.slug !== slug) {
|
|
431
|
+
readPending = true;
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (state.layout && JSON.stringify(layout) === state.layout.saved) return;
|
|
435
|
+
useLayout(slug, layout);
|
|
436
|
+
applyLayout();
|
|
437
|
+
renderArrange();
|
|
438
|
+
if (state.focus) actions.centerFocus();
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The boards changed size after they were placed (a handoff row grew or shrank their labels): an arrangement is
|
|
443
|
+
* laid out again, so its gaps stay 80 px; a free layout, or a board being moved, stays where it is. The artboard
|
|
444
|
+
* in use stays centered, since focus mode cannot pan.
|
|
445
|
+
*/
|
|
446
|
+
function boardsResized(options) {
|
|
447
|
+
if (!moving && (!state.layout || state.layout.arrangement !== "free")) applyLayout();
|
|
448
|
+
else {
|
|
449
|
+
sizeWorld();
|
|
450
|
+
actions.renderMinimap();
|
|
451
|
+
}
|
|
452
|
+
if (state.focus) actions.centerFocus(options);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* The Row / Column / Grid buttons: the current arrangement pressed (none for a hand-made layout), off without a
|
|
457
|
+
* design or with no board shown (an empty notice), inside an artboard and in Compare.
|
|
458
|
+
*/
|
|
459
|
+
function renderArrange() {
|
|
460
|
+
const arrangement = state.layout ? state.layout.arrangement : "row";
|
|
461
|
+
const shown = actions.allBoards().some((board) => board.wrapper.parentElement === els.world);
|
|
462
|
+
const off = Boolean(state.focus) || Boolean(state.compare) || !state.manifest || !shown;
|
|
463
|
+
for (const kind of ARRANGEMENTS) {
|
|
464
|
+
els.arrange[kind].setAttribute("aria-pressed", String(arrangement === kind));
|
|
465
|
+
els.arrange[kind].disabled = off;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** Lays every board out as a row, a column or a grid, saves it and shows them all. */
|
|
470
|
+
function arrange(kind) {
|
|
471
|
+
if (state.focus || state.compare || !state.manifest || state.manifest.slug !== state.slug || !state.layout) return;
|
|
472
|
+
store.setLayout({ layout: { ...state.layout, arrangement: kind } });
|
|
473
|
+
applyLayout();
|
|
474
|
+
renderArrange();
|
|
475
|
+
saveLayout();
|
|
476
|
+
actions.fit();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
for (const kind of ARRANGEMENTS) els.arrange[kind].addEventListener("click", () => arrange(kind));
|
|
480
|
+
|
|
481
|
+
/** The artboard pressed last shows selected, all of it; null clears it. */
|
|
482
|
+
function selectBoard(board) {
|
|
483
|
+
store.setSelected(board);
|
|
484
|
+
for (const candidate of actions.allBoards()) candidate.wrapper.classList.toggle("gd-selected", candidate === board);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Esc clears the selected artboard first; the next Esc reaches the popover's (leave Comment mode). Not while an
|
|
488
|
+
// artboard is in use, a dialog, a menu or the comment box is open: their Esc is theirs.
|
|
489
|
+
doc.addEventListener("keydown", (event) => {
|
|
490
|
+
if (event.defaultPrevented || event.key !== "Escape" || event.shiftKey || !state.selected) return;
|
|
491
|
+
if (state.focus || state.compare || state.menu || !els.popover.hidden || els.shortcuts.hasAttribute("open")) return;
|
|
492
|
+
event.preventDefault();
|
|
493
|
+
selectBoard(null);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// Space held pans from anywhere, over an artboard too. Not while typing or from a button or a link (Space is
|
|
497
|
+
// theirs), with the comment box, a menu or the shortcuts list open, in Compare or while an artboard is in use.
|
|
498
|
+
// A shield opens its artboard on Space first (its own keydown), so this one then sees focus mode and stays out.
|
|
499
|
+
// Row / Column / Grid keep the focus a click gave them: there Space pans too, unless the keyboard reached the
|
|
500
|
+
// button (it shows its focus ring, :focus-visible), where Space presses it as on any button.
|
|
501
|
+
const pointerFocusedArrange = (target) => ARRANGEMENTS.some((kind) => els.arrange[kind] === target) && !target.matches(":focus-visible");
|
|
502
|
+
const spaceTarget = (target) => target === doc.body || target === doc.documentElement || target === els.viewport || Boolean(target && typeof target.closest === "function" && target.closest(".gd-shield")) || Boolean(target && pointerFocusedArrange(target));
|
|
503
|
+
function releaseSpace() {
|
|
504
|
+
store.setSpace(false);
|
|
505
|
+
els.viewport.classList.remove("gd-space-pan");
|
|
506
|
+
}
|
|
507
|
+
doc.addEventListener("keydown", (event) => {
|
|
508
|
+
if (event.key !== " " || event.ctrlKey || event.metaKey || event.altKey || !spaceTarget(event.target)) return;
|
|
509
|
+
if (state.focus || state.compare || state.menu || !els.popover.hidden || els.shortcuts.hasAttribute("open")) return;
|
|
510
|
+
event.preventDefault();
|
|
511
|
+
store.setSpace(true);
|
|
512
|
+
els.viewport.classList.add("gd-space-pan");
|
|
513
|
+
});
|
|
514
|
+
doc.addEventListener("keyup", (event) => {
|
|
515
|
+
if (event.key !== " " || !state.space) return;
|
|
516
|
+
// The release of a Space that panned presses no button (a browser activates a button on Space's keyup).
|
|
517
|
+
event.preventDefault();
|
|
518
|
+
releaseSpace();
|
|
519
|
+
});
|
|
520
|
+
// The release never comes once the window loses focus.
|
|
521
|
+
win.addEventListener("blur", () => {
|
|
522
|
+
if (state.space) releaseSpace();
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
return { layoutSize, readLayoutNow, takeLayout, layoutError, clearLayout, sizeWorld, layoutBoards, boardsResized, beginMove, moveBy, endMove, onLayoutChange, renderArrange, selectBoard };
|
|
526
|
+
}
|