gentle-pi 4.7.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 +55 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +6 -6
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -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 +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- 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/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- 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 +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- 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 +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +79 -4
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +40 -19
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- 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 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -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 +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- 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 +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- 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 -878
- 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/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -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 +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- 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/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +11 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- 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 +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +11 -10
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- 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 +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- 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/provider-defect-handoff.test.ts +9 -2
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- 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 +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller.test.ts +2 -1
- 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.test.ts +271 -4
- 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-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- 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-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -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 +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- 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-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- 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 +184 -0
- package/tests/yolo-mode.test.ts +39 -0
- 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,180 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createStore } from "../assets/design-canvas/canvas-store.js";
|
|
4
|
+
|
|
5
|
+
// The canvas state (canvas-store.js): live reads, and changes only through the
|
|
6
|
+
// store's mutators, one concern each (S3).
|
|
7
|
+
|
|
8
|
+
test("the store starts with the canvas defaults and no system field", () => {
|
|
9
|
+
const { state } = createStore({ slug: "alpha" });
|
|
10
|
+
assert.deepEqual({ ...state }, {
|
|
11
|
+
slug: "alpha",
|
|
12
|
+
manifest: null,
|
|
13
|
+
boards: [],
|
|
14
|
+
systemBoard: null,
|
|
15
|
+
zoom: 1,
|
|
16
|
+
fitted: false,
|
|
17
|
+
x: 48,
|
|
18
|
+
y: 48,
|
|
19
|
+
commenting: false,
|
|
20
|
+
pick: null,
|
|
21
|
+
shot: null,
|
|
22
|
+
shotToken: 0,
|
|
23
|
+
closeTimer: 0,
|
|
24
|
+
comments: [],
|
|
25
|
+
filter: "open",
|
|
26
|
+
mode: "send",
|
|
27
|
+
activeId: null,
|
|
28
|
+
designCount: 0,
|
|
29
|
+
focus: null,
|
|
30
|
+
savedView: null,
|
|
31
|
+
savedPanel: null,
|
|
32
|
+
size: { kind: "desktop" },
|
|
33
|
+
hoverBoard: null,
|
|
34
|
+
handoffs: { slug: null, chosen: null, handoffs: {} },
|
|
35
|
+
parts: { slug: null, parts: [] },
|
|
36
|
+
tokens: [],
|
|
37
|
+
technical: false,
|
|
38
|
+
tab: "comments",
|
|
39
|
+
compare: null,
|
|
40
|
+
toastTimer: 0,
|
|
41
|
+
menu: null,
|
|
42
|
+
layout: null,
|
|
43
|
+
selected: null,
|
|
44
|
+
space: false,
|
|
45
|
+
minimap: true,
|
|
46
|
+
language: "en",
|
|
47
|
+
languageChoice: "auto",
|
|
48
|
+
});
|
|
49
|
+
assert.equal(createStore({ slug: 3 }).state.slug, null, "a slug that is not a string shows the system-only view");
|
|
50
|
+
assert.equal(createStore().state.slug, null);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("reads see the live values without copying them", () => {
|
|
54
|
+
const store = createStore();
|
|
55
|
+
const { state } = store;
|
|
56
|
+
assert.equal(store.state, state, "the read side is one object, never a per-read snapshot");
|
|
57
|
+
const boards = [{ artboard: { file: "01-a.html" } }];
|
|
58
|
+
store.setDesign({ boards });
|
|
59
|
+
assert.equal(state.boards, boards, "the same array, not a copy");
|
|
60
|
+
store.setView({ zoom: 2, x: 10, y: 20, fitted: true });
|
|
61
|
+
assert.deepEqual([state.zoom, state.x, state.y, state.fitted], [2, 10, 20, true]);
|
|
62
|
+
assert.equal(Object.isFrozen(state.boards), false, "values are not frozen either");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("state cannot be assigned outside the store's mutators", () => {
|
|
66
|
+
const store = createStore({ slug: "alpha" });
|
|
67
|
+
assert.ok(Object.isFrozen(store.state));
|
|
68
|
+
assert.throws(() => { (store.state as any).zoom = 3; }, TypeError);
|
|
69
|
+
assert.throws(() => { (store.state as any).extra = 1; }, TypeError);
|
|
70
|
+
assert.ok(Object.isFrozen(store));
|
|
71
|
+
assert.throws(() => { (store as any).setView = () => {}; }, TypeError);
|
|
72
|
+
assert.equal(store.state.zoom, 1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("each patch mutator changes only the fields of its own concern", () => {
|
|
76
|
+
const store = createStore({ slug: "alpha" });
|
|
77
|
+
const concerns: Array<[string, Record<string, unknown>]> = [
|
|
78
|
+
["setDesign", { slug: "beta", manifest: { slug: "beta" }, boards: [], systemBoard: null, designCount: 2 }],
|
|
79
|
+
["setView", { zoom: 2, x: 1, y: 2, fitted: true }],
|
|
80
|
+
["setFocus", { focus: null, savedView: { zoom: 1, x: 0, y: 0 }, savedPanel: true, size: { kind: "custom", width: 600 } }],
|
|
81
|
+
["setComments", { comments: [], activeId: "abc123", filter: "resolved" }],
|
|
82
|
+
["setPopover", { pick: null, shot: null, shotToken: 4, closeTimer: 0 }],
|
|
83
|
+
];
|
|
84
|
+
for (const [name, values] of concerns) {
|
|
85
|
+
(store as any)[name](values);
|
|
86
|
+
for (const [key, value] of Object.entries(values)) assert.deepEqual((store.state as any)[key], value, `${name} sets ${key}`);
|
|
87
|
+
}
|
|
88
|
+
const before = { ...store.state };
|
|
89
|
+
assert.throws(() => store.setView({ slug: "gamma" }), { name: "TypeError", message: "setView cannot change slug" });
|
|
90
|
+
assert.throws(() => store.setDesign({ zoom: 3 }), { name: "TypeError", message: "setDesign cannot change zoom" });
|
|
91
|
+
assert.throws(() => store.setComments({ system: {} }), { name: "TypeError", message: "setComments cannot change system" });
|
|
92
|
+
assert.deepEqual({ ...store.state }, before, "a refused patch changes nothing");
|
|
93
|
+
// A patch mixing allowed and foreign fields is refused before any field changes.
|
|
94
|
+
assert.throws(() => store.setView({ zoom: 5, slug: "x" }), { name: "TypeError", message: "setView cannot change slug" });
|
|
95
|
+
assert.throws(() => store.setComments({ filter: "open", activeId: null, zoom: 9 }), { name: "TypeError", message: "setComments cannot change zoom" });
|
|
96
|
+
assert.deepEqual({ ...store.state }, before, "a refused mixed patch changes nothing");
|
|
97
|
+
// A partial patch leaves the other fields of the concern alone.
|
|
98
|
+
store.setView({ x: 7 });
|
|
99
|
+
assert.deepEqual([store.state.zoom, store.state.x, store.state.y, store.state.fitted], [2, 7, 2, true]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("comments and handoffs can only change through their mutators", () => {
|
|
103
|
+
const store = createStore();
|
|
104
|
+
const comment = { id: "c1", file: "01-a.html", status: "open" };
|
|
105
|
+
const comments = [comment];
|
|
106
|
+
store.setComments({ comments });
|
|
107
|
+
assert.equal(store.state.comments, comments, "the same array, frozen when it is set, not copied per read");
|
|
108
|
+
assert.throws(() => { (store.state.comments as any[]).push({ id: "c2" }); }, TypeError);
|
|
109
|
+
assert.throws(() => { (store.state.comments[0] as any).status = "resolved"; }, TypeError);
|
|
110
|
+
assert.deepEqual(store.state.comments, [{ id: "c1", file: "01-a.html", status: "open" }]);
|
|
111
|
+
|
|
112
|
+
const entry = { status: "sent", queued: false };
|
|
113
|
+
store.setHandoffs({ slug: "alpha", chosen: "01-a.html", handoffs: { "01-a.html": entry } });
|
|
114
|
+
assert.throws(() => { (store.state.handoffs as any).chosen = "x"; }, TypeError);
|
|
115
|
+
assert.throws(() => { (store.state.handoffs.handoffs as any)["02-b.html"] = {}; }, TypeError);
|
|
116
|
+
assert.throws(() => { (store.state.handoffs.handoffs as any)["01-a.html"].status = "implemented"; }, TypeError);
|
|
117
|
+
assert.deepEqual(store.state.handoffs, { slug: "alpha", chosen: "01-a.html", handoffs: { "01-a.html": { status: "sent", queued: false } } });
|
|
118
|
+
assert.throws(() => { (createStore().state.handoffs as any).chosen = "x"; }, TypeError, "the initial handoffs are protected too");
|
|
119
|
+
assert.throws(() => { (createStore().state.comments as any[]).push({}); }, TypeError, "the initial comments are protected too");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("the single-field mutators set their one field", () => {
|
|
123
|
+
const store = createStore();
|
|
124
|
+
const board = { id: "board" };
|
|
125
|
+
const compare = { board };
|
|
126
|
+
const handoffs = { slug: "alpha", chosen: "01-a.html", handoffs: {} };
|
|
127
|
+
store.setHover(board);
|
|
128
|
+
store.setCommenting(true);
|
|
129
|
+
store.setMode("collect");
|
|
130
|
+
store.setHandoffs(handoffs);
|
|
131
|
+
store.setCompare(compare);
|
|
132
|
+
store.setToastTimer(9);
|
|
133
|
+
const menu = { button: board, items: [], byItem: new Map() };
|
|
134
|
+
store.setMenu(menu);
|
|
135
|
+
assert.equal(store.state.hoverBoard, board);
|
|
136
|
+
assert.equal(store.state.commenting, true);
|
|
137
|
+
assert.equal(store.state.mode, "collect");
|
|
138
|
+
assert.equal(store.state.handoffs, handoffs);
|
|
139
|
+
assert.equal(store.state.compare, compare);
|
|
140
|
+
assert.equal(store.state.toastTimer, 9);
|
|
141
|
+
assert.equal(store.state.menu, menu, "the open menu, shared, not copied");
|
|
142
|
+
store.setMenu(null);
|
|
143
|
+
assert.equal(store.state.menu, null);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("the design tokens are frozen when they are set, and Technical details is one boolean", () => {
|
|
147
|
+
const store = createStore();
|
|
148
|
+
assert.throws(() => { (store.state.tokens as any[]).push({}); }, TypeError, "the initial tokens are protected too");
|
|
149
|
+
const token = { name: "--bg", value: "#1a1218", section: "Colors", group: "color" };
|
|
150
|
+
const tokens = [token];
|
|
151
|
+
store.setTokens(tokens);
|
|
152
|
+
assert.equal(store.state.tokens, tokens, "the same array, frozen when it is set, not copied per read");
|
|
153
|
+
assert.throws(() => { (store.state.tokens as any[]).push({}); }, TypeError);
|
|
154
|
+
assert.throws(() => { (store.state.tokens[0] as any).value = "#000"; }, TypeError);
|
|
155
|
+
assert.deepEqual(store.state.tokens, [{ name: "--bg", value: "#1a1218", section: "Colors", group: "color" }]);
|
|
156
|
+
store.setTechnical(true);
|
|
157
|
+
assert.equal(store.state.technical, true);
|
|
158
|
+
store.setTechnical(false);
|
|
159
|
+
assert.equal(store.state.technical, false);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("the language changes only through setLanguage: the choice and the language it resolves to", () => {
|
|
163
|
+
const store = createStore();
|
|
164
|
+
assert.deepEqual([store.state.languageChoice, store.state.language], ["auto", "en"], "English until the canvas reads the browser");
|
|
165
|
+
store.setLanguage("auto", "es");
|
|
166
|
+
assert.deepEqual([store.state.languageChoice, store.state.language], ["auto", "es"]);
|
|
167
|
+
store.setLanguage("en", "en");
|
|
168
|
+
assert.deepEqual([store.state.languageChoice, store.state.language], ["en", "en"]);
|
|
169
|
+
assert.throws(() => { (store.state as any).language = "es"; }, TypeError);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("the panel's tab is one of two names, set through setTab", () => {
|
|
173
|
+
const store = createStore();
|
|
174
|
+
assert.equal(store.state.tab, "comments", "every page starts on Comments");
|
|
175
|
+
store.setTab("quality");
|
|
176
|
+
assert.equal(store.state.tab, "quality");
|
|
177
|
+
store.setTab("comments");
|
|
178
|
+
assert.equal(store.state.tab, "comments");
|
|
179
|
+
assert.throws(() => { (store.state as any).tab = "quality"; }, TypeError);
|
|
180
|
+
});
|