gentle-pi 4.6.0 → 4.7.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 +10 -11
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +5 -2
- package/assets/agents/gentle-ai-worker.md +3 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +16 -1
- package/assets/orchestrator-delegation-reference.md +4 -4
- package/assets/orchestrator-delegation.md +1 -1
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +7 -5
- package/assets/orchestrator.md +3 -3
- package/bin/gentle-shell.mjs +164 -56
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/delegated-verification.md +29 -7
- package/docs/gentle-agents-activity.md +14 -0
- package/docs/gentle-shell.md +54 -16
- package/docs/install-wizard.md +1 -1
- package/docs/permission-modes.md +9 -4
- package/docs/readme-reference.md +75 -30
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -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/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +326 -34
- package/extensions/gentle-ai.ts +1496 -454
- package/extensions/gentle-shell.ts +293 -63
- package/extensions/gentle-todo.ts +18 -2
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +175 -18
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +46 -0
- package/lib/agents-history.ts +24 -5
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-runner.ts +183 -12
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/card-content-policy.ts +8 -6
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- 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-design.ts +3 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +270 -140
- package/lib/jobs-view.ts +198 -11
- package/lib/model-routing-authority.ts +22 -4
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +96 -19
- 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 +104 -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-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +46 -10
- package/lib/review-integration-v2.ts +7 -1
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -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-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/verifier-admission.ts +1 -1
- 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/yolo-session-policy.ts +40 -15
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +93 -16
- package/runtime/review-integration-v2.mjs +7 -1
- package/scripts/build-full-delegation-card.mjs +175 -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-preflight.mjs +5 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- 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/verify-package-files.mjs +12 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +2 -2
- 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/skill-registry/SKILL.md +4 -2
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +178 -2
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -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 +43 -3
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +30 -5
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +3 -3
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -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 +131 -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 +1070 -12
- package/tests/gentle-ai-binary.test.ts +3 -1
- 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 +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +113 -38
- package/tests/gentle-design.test.ts +21 -0
- 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 +207 -31
- package/tests/gentle-shell-launcher.test.ts +77 -10
- package/tests/gentle-shell.test.ts +899 -59
- package/tests/gentle-todo.test.ts +19 -2
- 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/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +176 -4
- package/tests/installer-posix-bootstrap.test.ts +1 -1
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/jobs-view.test.ts +260 -6
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +4 -1
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +3 -1
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +11 -9
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/pi-update-launcher.test.ts +8 -0
- package/tests/pnpm-workspace-config.test.ts +58 -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/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 +16 -11
- 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 +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- 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 +1 -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 +76 -0
- 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 +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -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-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- 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 +12 -2
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -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-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-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/skill-registry.test.ts +838 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +5 -3
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verify-first-launch-contract.test.ts +78 -3
- 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 +28 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +23 -18
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
1
5
|
import assert from "node:assert/strict";
|
|
2
6
|
import { test } from "node:test";
|
|
3
7
|
import { VisualCustomizeView, type CustomizeInline, type CustomizeRow } from "../lib/visual-customize-view.ts";
|
|
4
8
|
import { CommandPalette } from "../lib/command-palette.ts";
|
|
5
|
-
import {
|
|
9
|
+
import { stripAnsi } from "../lib/terminal-theme.ts";
|
|
10
|
+
import { TuiAltScreen, visibleWidth, type Terminal, type TuiMouseEvent, type TuiMouseEventResult } from "@earendil-works/pi-tui";
|
|
6
11
|
import { getThemeByName, Theme } from "../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js";
|
|
7
12
|
|
|
8
13
|
const theme = { fg: (_role: string, text: string) => text };
|
|
@@ -118,7 +123,7 @@ test("profile name submission never accepts a hidden field at heights 3–5, inc
|
|
|
118
123
|
|
|
119
124
|
test("profile preview and cancel never apply; keyboard name and confirmations require deliberate input", async () => {
|
|
120
125
|
const events: string[] = [];
|
|
121
|
-
const profile = { name: "Desk", themeName: "Light Theme", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
126
|
+
const profile = { name: "Desk", themeName: "Light Theme", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, surface: "tinted" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
122
127
|
const view = new VisualCustomizeView({ rows: [], theme, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
123
128
|
list: () => [profile], save: (name, replace) => { events.push(`save:${name}:${replace}`); }, apply: (name) => { events.push(`apply:${name}`); }, delete: (name) => { events.push(`delete:${name}`); }, reset: () => { events.push("reset"); },
|
|
124
129
|
} });
|
|
@@ -147,7 +152,7 @@ test("profile preview and cancel never apply; keyboard name and confirmations re
|
|
|
147
152
|
|
|
148
153
|
test("profile confirmation stays visible at six rows for every destructive or applying action", async () => {
|
|
149
154
|
const events: string[] = [];
|
|
150
|
-
const profile = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
155
|
+
const profile = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, surface: "tinted" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
151
156
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => 6, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
152
157
|
list: () => [profile], save: (name, replace) => { events.push(`save:${name}:${replace}`); }, apply: (name) => { events.push(`apply:${name}`); }, delete: (name) => { events.push(`delete:${name}`); }, reset: () => { events.push("reset"); },
|
|
153
158
|
} });
|
|
@@ -165,7 +170,7 @@ test("profile confirmation stays visible at six rows for every destructive or ap
|
|
|
165
170
|
|
|
166
171
|
test("profile confirmation captures selected name across catalog mutation and cancels vanished targets", async () => {
|
|
167
172
|
const events: string[] = [];
|
|
168
|
-
const base = { themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
173
|
+
const base = { themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, surface: "tinted" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
169
174
|
let catalog = [{ ...base, name: "Desk" }, { ...base, name: "Mobile" }];
|
|
170
175
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => 6, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
171
176
|
list: () => catalog, save: (name, replace) => { events.push(`save:${name}:${replace}`); }, apply: (name) => { events.push(`apply:${name}`); }, delete: (name) => { events.push(`delete:${name}`); }, reset: () => { events.push("reset"); },
|
|
@@ -190,7 +195,7 @@ test("profile confirmation captures selected name across catalog mutation and ca
|
|
|
190
195
|
test("unrendered or clipped confirmations cannot be accepted", () => {
|
|
191
196
|
const events: string[] = [];
|
|
192
197
|
let height = 6;
|
|
193
|
-
const base = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
198
|
+
const base = { name: "Desk", themeName: "Light", animationPolicy: "potato" as const, banner: { showRose: false, showTextLogo: true, color: "cyan" as const }, visual: { statusPlacement: "hidden" as const, headerPlacement: "below-input" as const, density: "compact" as const, surface: "tinted" as const, visibility: { changes: false, rdd: false, agents: true, todo: false, usageCost: true, modelDetails: false, contextWarning: false, stats: false } } };
|
|
194
199
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => height, requestRender: () => {}, onClose: () => {}, profiles: {
|
|
195
200
|
list: () => [base], save: () => {}, apply: () => {}, delete: () => { events.push("delete"); }, reset: () => { events.push("reset"); },
|
|
196
201
|
} });
|
|
@@ -204,7 +209,7 @@ test("unrendered or clipped confirmations cannot be accepted", () => {
|
|
|
204
209
|
|
|
205
210
|
test("profile confirmations cannot execute after an unrendered resize hides full identity and yes", () => {
|
|
206
211
|
const name = "A".repeat(64);
|
|
207
|
-
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
212
|
+
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, surface: "tinted" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
208
213
|
for (const [key, action] of [["a", "apply"], ["d", "delete"], ["r", "replace"], ["z", "reset"]] as const) {
|
|
209
214
|
for (const width of [100, 36]) for (const shortHeight of [1, 2]) {
|
|
210
215
|
let height = 12;
|
|
@@ -226,7 +231,7 @@ test("profile confirmations cannot execute after an unrendered resize hides full
|
|
|
226
231
|
});
|
|
227
232
|
|
|
228
233
|
test("profile confirmation refuses a changed target identity without another render", () => {
|
|
229
|
-
let catalog = [{ name: "First", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } }];
|
|
234
|
+
let catalog = [{ name: "First", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, surface: "tinted" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } }];
|
|
230
235
|
const effects: string[] = [];
|
|
231
236
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => 12, requestRender: () => {}, onClose: () => {}, profiles: { list: () => catalog, save: () => {}, apply: name => { effects.push(name); }, delete: () => {}, reset: () => {} } });
|
|
232
237
|
view.handleInput("p"); view.handleInput("a");
|
|
@@ -263,7 +268,7 @@ test("main controls require a visible selected row at the last rendered width an
|
|
|
263
268
|
});
|
|
264
269
|
|
|
265
270
|
test("profile confirmation refuses same-name content drift for apply, replace and delete", () => {
|
|
266
|
-
const original = { name: "Desk", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
271
|
+
const original = { name: "Desk", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, surface: "tinted" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
267
272
|
for (const key of ["a", "r", "d"]) {
|
|
268
273
|
let catalog = [original];
|
|
269
274
|
const effects: string[] = [];
|
|
@@ -313,7 +318,7 @@ test("category panel renders bounded wide and narrow frames with independent nav
|
|
|
313
318
|
test("long profile confirmation displays complete identity and yes instruction before accepting", async () => {
|
|
314
319
|
const name = "A".repeat(64);
|
|
315
320
|
const events: string[] = [];
|
|
316
|
-
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
321
|
+
const profile = { name, themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, surface: "tinted" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
317
322
|
let height = 8;
|
|
318
323
|
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => height, requestRender: () => {}, onClose: () => {}, profiles: { list: () => [profile], save: () => {}, apply: value => { events.push(value); }, delete: () => {}, reset: () => {} } });
|
|
319
324
|
view.handleInput("p");
|
|
@@ -939,3 +944,562 @@ test("inline notification choices retain their sound keys instead of advertising
|
|
|
939
944
|
const rendered = view.render(120).join("\n");
|
|
940
945
|
assert.match(rendered, /f sound · p test/); assert.doesNotMatch(rendered, /p profiles/);
|
|
941
946
|
});
|
|
947
|
+
|
|
948
|
+
// Pointer coordinates are component-local terminal cells, not string indices.
|
|
949
|
+
function point(frame: string[], text: string): { x: number; y: number } {
|
|
950
|
+
const y = frame.findIndex(line => line.includes(text));
|
|
951
|
+
assert.ok(y >= 0, `missing ${JSON.stringify(text)} in ${frame.join("\n")}`);
|
|
952
|
+
const line = frame[y]!;
|
|
953
|
+
return { x: visibleWidth(line.slice(0, line.indexOf(text))), y };
|
|
954
|
+
}
|
|
955
|
+
function pointer(frame: string[], x: number, y: number, button: TuiMouseEvent["button"] = "left", type: TuiMouseEvent["type"] = "click"): TuiMouseEvent {
|
|
956
|
+
return { type, button, x, y, screenX: x + 9, screenY: y + 4, width: visibleWidth(frame[0]!), height: frame.length, shift: false, alt: false, ctrl: false };
|
|
957
|
+
}
|
|
958
|
+
function click(view: VisualCustomizeView, frame: string[], text: string, button: TuiMouseEvent["button"] = "left"): TuiMouseEventResult | undefined {
|
|
959
|
+
const { x, y } = point(frame, text);
|
|
960
|
+
return (view as unknown as { handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined }).handleMouse(pointer(frame, x, y, button));
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
test("mouse selects categories, activates plain rows and explicitly applies visible choices", async () => {
|
|
964
|
+
const effects: string[] = [];
|
|
965
|
+
let selected = "one";
|
|
966
|
+
const rows: CustomizeRow[] = [
|
|
967
|
+
{ category: "Animations", label: "Speed", action: () => { effects.push("speed"); } },
|
|
968
|
+
{ category: "Layout", label: "Reset layout", action: () => { effects.push("reset"); } },
|
|
969
|
+
...["one", "界two", "three"].map(value => ({ category: "Layout" as const, label: value,
|
|
970
|
+
choice: { setting: "Mode", value, current: () => selected === value, applyOnMove: false },
|
|
971
|
+
action: () => { selected = value; effects.push(value); } })),
|
|
972
|
+
];
|
|
973
|
+
const view = new VisualCustomizeView({ rows, theme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
974
|
+
let frame = view.render(110);
|
|
975
|
+
assert.equal(click(view, frame, "Layout")?.handled, true);
|
|
976
|
+
assert.deepEqual(effects, [], "category selection never applies");
|
|
977
|
+
frame = view.render(110);
|
|
978
|
+
assert.equal(click(view, frame, "Reset layout")?.handled, true);
|
|
979
|
+
await tick();
|
|
980
|
+
assert.deepEqual(effects, ["reset"]);
|
|
981
|
+
frame = view.render(110);
|
|
982
|
+
assert.equal(click(view, frame, "界two")?.handled, true);
|
|
983
|
+
await tick();
|
|
984
|
+
assert.equal(selected, "界two");
|
|
985
|
+
assert.deepEqual(effects, ["reset", "界two"], "click is an explicit apply even for deferred choices");
|
|
986
|
+
frame = view.render(110);
|
|
987
|
+
for (const button of ["right", "middle"] as const) click(view, frame, "three", button);
|
|
988
|
+
const handler = view as unknown as { handleMouse(event: TuiMouseEvent): unknown };
|
|
989
|
+
for (const [x, y] of [[0, 0], [109, 0], [109, frame.length - 1], [2, 2], [108, 4]]) handler.handleMouse(pointer(frame, x!, y!));
|
|
990
|
+
await tick();
|
|
991
|
+
assert.deepEqual(effects, ["reset", "界two"], "non-primary clicks and blank or border cells do nothing");
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
test("mouse tracks scrolled rows and narrow categories and choices without hitting clipped values", async () => {
|
|
995
|
+
const effects: string[] = [];
|
|
996
|
+
const choices: CustomizeRow[] = ["auto", "right", "bottom"].map(value => ({ category: "Layout", label: value,
|
|
997
|
+
choice: { setting: "Status placement", value, current: () => value === "auto", applyOnMove: false }, action: () => { effects.push(value); } }));
|
|
998
|
+
const view = new VisualCustomizeView({ rows: [
|
|
999
|
+
{ category: "Animations", label: "Speed", action() {} },
|
|
1000
|
+
...choices,
|
|
1001
|
+
...Array.from({ length: 9 }, (_, index): CustomizeRow => ({ category: "Layout", label: `Row ${index}`, action: () => { effects.push(`row:${index}`); } })),
|
|
1002
|
+
], theme, rowsAvailable: () => 8, requestRender() {}, onClose() {} });
|
|
1003
|
+
let frame = view.render(36);
|
|
1004
|
+
click(view, frame, "Layout");
|
|
1005
|
+
frame = view.render(36);
|
|
1006
|
+
assert.match(frame.join("\n"), /‹ auto ›/);
|
|
1007
|
+
click(view, frame, "›");
|
|
1008
|
+
await tick();
|
|
1009
|
+
assert.deepEqual(effects, [], "narrow arrows retain deferred keyboard navigation");
|
|
1010
|
+
frame = view.render(36);
|
|
1011
|
+
assert.match(frame.join("\n"), /‹ right ›/);
|
|
1012
|
+
click(view, frame, "right");
|
|
1013
|
+
await tick();
|
|
1014
|
+
assert.deepEqual(effects, ["right"], "only the visible value is explicitly applied");
|
|
1015
|
+
assert.equal(view.focus("Row 8"), true);
|
|
1016
|
+
frame = view.render(36);
|
|
1017
|
+
assert.match(frame.join("\n"), /Row 7[\s\S]*Row 8/);
|
|
1018
|
+
click(view, frame, "Row 7");
|
|
1019
|
+
await tick();
|
|
1020
|
+
assert.deepEqual(effects, ["right", "row:7"], "the painted scrolled row, not its original index, runs");
|
|
1021
|
+
|
|
1022
|
+
const clipped: CustomizeRow = { category: "Layout", label: "wide", choice: { setting: "a very long setting name", value: "unseen choice value", current: () => true }, action: () => { effects.push("clipped"); } };
|
|
1023
|
+
const small = new VisualCustomizeView({ rows: [clipped], theme, rowsAvailable: () => 8, requestRender() {}, onClose() {} });
|
|
1024
|
+
frame = small.render(22);
|
|
1025
|
+
assert.doesNotMatch(frame.join("\n"), /unseen choice value/);
|
|
1026
|
+
const line = frame.findIndex(value => value.includes("a very"));
|
|
1027
|
+
const handler = small as unknown as { handleMouse(event: TuiMouseEvent): unknown };
|
|
1028
|
+
handler.handleMouse(pointer(frame, 20, line));
|
|
1029
|
+
await tick();
|
|
1030
|
+
assert.deepEqual(effects, ["right", "row:7"], "a clipped value cannot be activated");
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
test("mouse ignores stale dimensions, hidden rows, invalidation and pending tasks", async () => {
|
|
1034
|
+
let height = 12, visible = true;
|
|
1035
|
+
let release!: () => void;
|
|
1036
|
+
const effects: string[] = [];
|
|
1037
|
+
const view = new VisualCustomizeView({ rows: [
|
|
1038
|
+
{ label: "Slow", action: () => { effects.push("slow"); return new Promise<void>(resolve => { release = resolve; }); } },
|
|
1039
|
+
{ label: "Hidden later", visible: () => visible, action: () => { effects.push("hidden"); } },
|
|
1040
|
+
], theme, rowsAvailable: () => height, requestRender() {}, onClose() {} });
|
|
1041
|
+
let frame = view.render(80);
|
|
1042
|
+
const handler = view as unknown as { handleMouse(event: TuiMouseEvent): unknown };
|
|
1043
|
+
const target = point(frame, "Hidden later");
|
|
1044
|
+
height = 5;
|
|
1045
|
+
handler.handleMouse(pointer(frame, target.x, target.y));
|
|
1046
|
+
height = 12;
|
|
1047
|
+
handler.handleMouse({ ...pointer(frame, target.x, target.y), width: 79 });
|
|
1048
|
+
visible = false;
|
|
1049
|
+
handler.handleMouse(pointer(frame, target.x, target.y));
|
|
1050
|
+
assert.deepEqual(effects, [], "a resized or hidden target cannot act using a stale frame");
|
|
1051
|
+
visible = true;
|
|
1052
|
+
frame = view.render(80);
|
|
1053
|
+
view.invalidate();
|
|
1054
|
+
click(view, frame, "Hidden later");
|
|
1055
|
+
assert.deepEqual(effects, [], "invalidated geometry cannot act");
|
|
1056
|
+
frame = view.render(80);
|
|
1057
|
+
click(view, frame, "Slow");
|
|
1058
|
+
frame = view.render(80);
|
|
1059
|
+
click(view, frame, "Hidden later");
|
|
1060
|
+
assert.deepEqual(effects, ["slow"], "an unfinished action owns the view");
|
|
1061
|
+
release(); await tick();
|
|
1062
|
+
frame = view.render(80);
|
|
1063
|
+
click(view, frame, "Hidden later"); await tick();
|
|
1064
|
+
assert.deepEqual(effects, ["slow", "hidden"]);
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
test("mouse confirms only the visible yes control, never another row or a hidden prompt", async () => {
|
|
1068
|
+
let height = 12;
|
|
1069
|
+
const answers: boolean[] = [];
|
|
1070
|
+
const view = inlineView(async inline => { answers.push(await inline.confirm("Proceed?")); }, { rowsAvailable: () => height });
|
|
1071
|
+
let frame = view.render(80);
|
|
1072
|
+
click(view, frame, "Field row"); await tick();
|
|
1073
|
+
frame = view.render(80);
|
|
1074
|
+
click(view, frame, "Field row");
|
|
1075
|
+
click(view, frame, "y yes", "right");
|
|
1076
|
+
assert.deepEqual(answers, [], "neither another row nor a right click answers consent");
|
|
1077
|
+
click(view, frame, "y yes"); await tick();
|
|
1078
|
+
assert.deepEqual(answers, [true]);
|
|
1079
|
+
frame = view.render(80); click(view, frame, "Field row"); await tick();
|
|
1080
|
+
frame = view.render(80);
|
|
1081
|
+
height = 4;
|
|
1082
|
+
click(view, frame, "y yes"); await tick();
|
|
1083
|
+
assert.deepEqual(answers, [true], "a confirmation hidden by an unrendered resize cannot be accepted");
|
|
1084
|
+
view.handleInput("n"); await tick();
|
|
1085
|
+
assert.deepEqual(answers, [true, false]);
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
test("confirmation message text is not mistaken for its yes or cancel controls", async () => {
|
|
1089
|
+
const answers: boolean[] = [];
|
|
1090
|
+
const view = inlineView(async inline => { answers.push(await inline.confirm("Does y yes mean cancel?")); });
|
|
1091
|
+
let frame = view.render(80);
|
|
1092
|
+
click(view, frame, "Field row"); await tick();
|
|
1093
|
+
frame = view.render(80);
|
|
1094
|
+
click(view, frame, "y yes");
|
|
1095
|
+
click(view, frame, "cancel");
|
|
1096
|
+
await tick();
|
|
1097
|
+
assert.deepEqual(answers, [], "the words in the question are not consent controls");
|
|
1098
|
+
const y = frame.findIndex(line => line.includes("Does y yes"));
|
|
1099
|
+
const x = visibleWidth(frame[y]!.slice(0, frame[y]!.lastIndexOf("y yes")));
|
|
1100
|
+
(view as unknown as { handleMouse(event: TuiMouseEvent): unknown }).handleMouse(pointer(frame, x, y));
|
|
1101
|
+
await tick();
|
|
1102
|
+
assert.deepEqual(answers, [true], "only the actual yes instruction grants consent");
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
test("profile confirmation mouse yes retains target fingerprint and visible-prompt guards", async () => {
|
|
1106
|
+
const profile = { name: "Desk y yes", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, surface: "tinted" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
1107
|
+
let catalog = [profile];
|
|
1108
|
+
const effects: string[] = [];
|
|
1109
|
+
const view = new VisualCustomizeView({ rows: [], theme, rowsAvailable: () => 12, requestRender() {}, onClose() {}, profiles: {
|
|
1110
|
+
list: () => catalog, save() {}, apply: name => { effects.push(name); }, delete() {}, reset() {},
|
|
1111
|
+
} });
|
|
1112
|
+
view.handleInput("p"); view.handleInput("a");
|
|
1113
|
+
let frame = view.render(80);
|
|
1114
|
+
click(view, frame, "y yes"); await tick();
|
|
1115
|
+
assert.deepEqual(effects, [], "a profile name containing yes cannot authorize itself");
|
|
1116
|
+
const confirm = () => {
|
|
1117
|
+
const y = frame.findIndex(line => line.includes("Confirm apply"));
|
|
1118
|
+
const x = visibleWidth(frame[y]!.slice(0, frame[y]!.lastIndexOf("y yes")));
|
|
1119
|
+
(view as unknown as { handleMouse(event: TuiMouseEvent): unknown }).handleMouse(pointer(frame, x, y));
|
|
1120
|
+
};
|
|
1121
|
+
catalog = [{ ...profile, themeName: "light" }];
|
|
1122
|
+
confirm(); await tick();
|
|
1123
|
+
assert.deepEqual(effects, [], "changed profile content is refused");
|
|
1124
|
+
catalog = [profile]; view.handleInput("a"); frame = view.render(80);
|
|
1125
|
+
confirm(); await tick();
|
|
1126
|
+
assert.deepEqual(effects, ["Desk y yes"]);
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
test("centered fullscreen overlay receives a real SGR click in local coordinates", async () => {
|
|
1130
|
+
let input: ((data: string) => void) | undefined;
|
|
1131
|
+
const terminal: Terminal = {
|
|
1132
|
+
start(onInput) { input = onInput; }, stop() {}, async drainInput() {}, write() {}, get columns() { return 120; }, get rows() { return 30; }, get kittyProtocolActive() { return false; }, moveBy() {}, hideCursor() {}, showCursor() {}, clearLine() {}, clearFromCursor() {}, clearScreen() {}, setTitle() {}, setProgress() {}, setProgramStatus() {},
|
|
1133
|
+
};
|
|
1134
|
+
const effects: string[] = [];
|
|
1135
|
+
const view = new VisualCustomizeView({ rows: [{ label: "Apply this", action: () => { effects.push("applied"); } }], theme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1136
|
+
const tui = new TuiAltScreen(terminal, false, undefined, { mouse: true });
|
|
1137
|
+
const overlay = tui.showOverlay(view, { anchor: "center", width: 80, maxHeight: 12 });
|
|
1138
|
+
tui.start(); tui.renderNow(true);
|
|
1139
|
+
try {
|
|
1140
|
+
const frame = view.render(80);
|
|
1141
|
+
const bounds = overlay.getBounds();
|
|
1142
|
+
assert.ok(bounds && bounds.col > 0 && bounds.row > 0);
|
|
1143
|
+
const target = point(frame, "Apply this");
|
|
1144
|
+
const x = bounds.col + target.x + 1, y = bounds.row + target.y + 1;
|
|
1145
|
+
input?.(`\x1b[<0;${x};${y}M`);
|
|
1146
|
+
input?.(`\x1b[<0;${x};${y}m`);
|
|
1147
|
+
await tick();
|
|
1148
|
+
assert.deepEqual(effects, ["applied"]);
|
|
1149
|
+
} finally { tui.stop(); }
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
// Independent permission and consent boundary regressions.
|
|
1153
|
+
function boundaryMouseEvent(frame: string[], text: string, delta = 0, type: TuiMouseEvent["type"] = "click"): TuiMouseEvent {
|
|
1154
|
+
const y = frame.findIndex(line => line.includes(text));
|
|
1155
|
+
assert.ok(y >= 0, `Missing ${text}: ${frame.join("\n")}`);
|
|
1156
|
+
const x = visibleWidth(frame[y]!.slice(0, frame[y]!.indexOf(text))) + delta;
|
|
1157
|
+
return { type, button: "left", x, y, screenX: x, screenY: y, width: visibleWidth(frame[0]!), height: frame.length, shift: false, alt: false, ctrl: false };
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
test("permission mouse press, preview arrows, explicit values, and hidden stale targets preserve write boundaries", async t => {
|
|
1161
|
+
const directory = mkdtempSync(join(tmpdir(), "mouse-permission-"));
|
|
1162
|
+
t.after(() => rmSync(directory, { recursive: true, force: true }));
|
|
1163
|
+
for (const width of [44, 80, 160]) {
|
|
1164
|
+
const path = join(directory, `state-${width}.json`);
|
|
1165
|
+
writeFileSync(path, '{"mode":"NORMAL"}\n');
|
|
1166
|
+
const hash = () => createHash("sha256").update(readFileSync(path)).digest("hex");
|
|
1167
|
+
const before = hash();
|
|
1168
|
+
let mode = "NORMAL", visible = true, height = 12;
|
|
1169
|
+
const rows: CustomizeRow[] = ["NORMAL", "AUTO (beta)", "YOLO", "SUPER-YOLO"].map(value => ({
|
|
1170
|
+
category: "Editor", label: `Session permissions: ${value}`, visible: () => visible,
|
|
1171
|
+
choice: { setting: "Session permissions", value, current: () => value === mode, applyOnMove: false },
|
|
1172
|
+
action: () => { mode = value; writeFileSync(path, JSON.stringify({ mode })); },
|
|
1173
|
+
}));
|
|
1174
|
+
const view = new VisualCustomizeView({ rows, theme, rowsAvailable: () => height, requestRender() {}, onClose() {} });
|
|
1175
|
+
view.render(width); view.focus("Session permissions: NORMAL");
|
|
1176
|
+
let frame = view.render(width);
|
|
1177
|
+
view.handleMouse(boundaryMouseEvent(frame, "NORMAL", 0, "press"));
|
|
1178
|
+
assert.equal(hash(), before, "press alone grants nothing");
|
|
1179
|
+
if (frame.some(line => line.includes("‹ NORMAL ›"))) view.handleMouse(boundaryMouseEvent(frame, "›"));
|
|
1180
|
+
else { view.handleMouse(boundaryMouseEvent(frame, "Session permissions")); view.handleInput("\x1b[C"); }
|
|
1181
|
+
await tick(); assert.equal(hash(), before, "preview movement grants nothing");
|
|
1182
|
+
frame = view.render(width);
|
|
1183
|
+
view.handleMouse(boundaryMouseEvent(frame, "AUTO (beta)")); await tick();
|
|
1184
|
+
assert.equal(mode, "AUTO (beta)");
|
|
1185
|
+
const committed = hash();
|
|
1186
|
+
frame = view.render(width);
|
|
1187
|
+
const stale = boundaryMouseEvent(frame, "AUTO (beta)");
|
|
1188
|
+
visible = false; view.handleMouse(stale); assert.equal(hash(), committed);
|
|
1189
|
+
visible = true; height = 3; view.handleMouse(stale); assert.equal(hash(), committed);
|
|
1190
|
+
height = 12; view.dispose(); view.handleMouse(stale); assert.equal(hash(), committed);
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
test("inline input and capture block permission mouse targets until keyboard cancellation", async () => {
|
|
1195
|
+
for (const kind of ["input", "capture"] as const) {
|
|
1196
|
+
let applied = 0;
|
|
1197
|
+
const view = new VisualCustomizeView({ rows: [
|
|
1198
|
+
{ label: "Open modal", action: async inline => {
|
|
1199
|
+
if (kind === "input") await inline.input({ prompt: "Name", value: "sample" });
|
|
1200
|
+
else await inline.capture("Press a key");
|
|
1201
|
+
} },
|
|
1202
|
+
{ label: "Elevate permission", action: () => { applied++; } },
|
|
1203
|
+
], theme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1204
|
+
let frame = view.render(80);
|
|
1205
|
+
view.handleMouse(boundaryMouseEvent(frame, "Open modal")); await tick();
|
|
1206
|
+
frame = view.render(80);
|
|
1207
|
+
assert.equal(view.handleMouse(boundaryMouseEvent(frame, "Elevate permission")), undefined);
|
|
1208
|
+
assert.equal(applied, 0);
|
|
1209
|
+
view.handleInput("\x1b"); await tick();
|
|
1210
|
+
frame = view.render(80); view.handleMouse(boundaryMouseEvent(frame, "Elevate permission")); await tick();
|
|
1211
|
+
assert.equal(applied, 1);
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
|
|
1215
|
+
test("inline consent accepts each painted yes cell but neither adjacent cell", async () => {
|
|
1216
|
+
for (const delta of [-1, 0, 1, 2, 3, 4, 5]) {
|
|
1217
|
+
const answers: boolean[] = [];
|
|
1218
|
+
const view = new VisualCustomizeView({ rows: [{ label: "Proceed", action: async inline => { answers.push(await inline.confirm("Change permission?")); } }], theme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1219
|
+
let frame = view.render(80); view.handleMouse(boundaryMouseEvent(frame, "Proceed")); await tick();
|
|
1220
|
+
frame = view.render(80); view.handleMouse(boundaryMouseEvent(frame, "y yes", delta)); await tick();
|
|
1221
|
+
assert.deepEqual(answers, delta >= 0 && delta < 5 ? [true] : []);
|
|
1222
|
+
view.dispose(); await tick();
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
|
|
1226
|
+
const hoverTheme = {
|
|
1227
|
+
fg: (role: string, text: string) => role === "warning" ? `\x1b[33m${text}\x1b[39m` : text,
|
|
1228
|
+
bg: (_role: string, text: string) => `\x1b[44m${text}\x1b[49m`,
|
|
1229
|
+
};
|
|
1230
|
+
const warning = (text: string) => `\x1b[33m${text}\x1b[39m`;
|
|
1231
|
+
function move(view: VisualCustomizeView, frame: string[], text: string): TuiMouseEventResult | undefined {
|
|
1232
|
+
const { x, y } = point(frame, text);
|
|
1233
|
+
return view.handleMouse(pointer(frame, x, y, "none", "move"));
|
|
1234
|
+
}
|
|
1235
|
+
function plain(frame: string[]): string[] { return frame.map(stripAnsi); }
|
|
1236
|
+
|
|
1237
|
+
test("hover paints exactly the existing category, setting, value and plain-row targets without changing selection", () => {
|
|
1238
|
+
const actions: string[] = [];
|
|
1239
|
+
const rows: CustomizeRow[] = [
|
|
1240
|
+
{ category: "Editor", label: "Reset settings", action: () => { actions.push("reset"); } },
|
|
1241
|
+
... ["NORMAL", "AUTO"].map(value => ({ category: "Editor" as const, label: value,
|
|
1242
|
+
choice: { setting: "Permissions", value, current: () => value === "NORMAL", applyOnMove: false },
|
|
1243
|
+
action: () => { actions.push(value); } })),
|
|
1244
|
+
{ category: "Layout", label: "Other", action: () => { actions.push("other"); } },
|
|
1245
|
+
];
|
|
1246
|
+
const view = new VisualCustomizeView({ rows, theme: hoverTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1247
|
+
let frame = view.render(100);
|
|
1248
|
+
const original = plain(frame);
|
|
1249
|
+
for (const [target, painted] of [["Layout", "Layout"], ["Permissions", "Permissions"], ["AUTO", "○ AUTO"], ["Reset settings", "Reset settings"]]) {
|
|
1250
|
+
assert.equal(move(view, frame, target!)?.render, true, target);
|
|
1251
|
+
frame = view.render(100);
|
|
1252
|
+
assert.ok(frame.join("\n").includes(warning(painted!)), `hover ${target} uses warning on its hit span`);
|
|
1253
|
+
assert.deepEqual(plain(frame), original, "hover must not move focus, change preview, or alter text");
|
|
1254
|
+
assert.deepEqual(actions, [], "hover must not apply any action or permission");
|
|
1255
|
+
assert.equal(move(view, frame, target!)?.render, false, "repeated motion does not redraw");
|
|
1256
|
+
}
|
|
1257
|
+
const blank = pointer(frame, 2, 0, "none", "move");
|
|
1258
|
+
assert.equal(view.handleMouse(blank)?.render, true);
|
|
1259
|
+
frame = view.render(100);
|
|
1260
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"), "blank card cells clear hover");
|
|
1261
|
+
assert.equal(view.handleMouse(blank)?.render, false);
|
|
1262
|
+
assert.deepEqual(actions, []);
|
|
1263
|
+
view.handleInput("\x1b[C"); view.handleInput("\r");
|
|
1264
|
+
assert.deepEqual(actions, ["reset"], "keyboard activation remains unchanged");
|
|
1265
|
+
});
|
|
1266
|
+
|
|
1267
|
+
test("compact arrows and values hover independently, while clipped choices and headings are not targets", () => {
|
|
1268
|
+
const actions: string[] = [];
|
|
1269
|
+
const view = new VisualCustomizeView({ rows: ["normal", "elevated"].map(value => ({
|
|
1270
|
+
category: "Editor", label: value, choice: { setting: "Permission mode", value, current: () => value === "normal", applyOnMove: false },
|
|
1271
|
+
action: () => { actions.push(value); },
|
|
1272
|
+
})), theme: hoverTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1273
|
+
let frame = view.render(36);
|
|
1274
|
+
assert.match(plain(frame).join("\n"), /‹ normal ›/);
|
|
1275
|
+
assert.equal(move(view, frame, "normal")?.render, true);
|
|
1276
|
+
frame = view.render(36);
|
|
1277
|
+
assert.ok(frame.join("\n").includes(warning("normal")));
|
|
1278
|
+
assert.equal(move(view, frame, "›")?.render, true);
|
|
1279
|
+
frame = view.render(36);
|
|
1280
|
+
assert.ok(frame.join("\n").includes(warning("›")));
|
|
1281
|
+
assert.equal(move(view, frame, "Editor ·")?.render, true);
|
|
1282
|
+
frame = view.render(36);
|
|
1283
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"));
|
|
1284
|
+
assert.deepEqual(actions, []);
|
|
1285
|
+
click(view, frame, "›");
|
|
1286
|
+
frame = view.render(36);
|
|
1287
|
+
assert.match(plain(frame).join("\n"), /‹ elevated ›/);
|
|
1288
|
+
assert.deepEqual(actions, [], "the compact deferred arrow still previews only");
|
|
1289
|
+
|
|
1290
|
+
const clipped = new VisualCustomizeView({ rows: [{ category: "Editor", label: "long", choice: {
|
|
1291
|
+
setting: "A long setting name", value: "an unseen permission", current: () => true,
|
|
1292
|
+
}, action: () => { actions.push("hidden"); } }], theme: hoverTheme, rowsAvailable: () => 8, requestRender() {}, onClose() {} });
|
|
1293
|
+
frame = clipped.render(22);
|
|
1294
|
+
assert.doesNotMatch(plain(frame).join("\n"), /an unseen permission/);
|
|
1295
|
+
const line = frame.findIndex(value => value.includes("A long"));
|
|
1296
|
+
clipped.handleMouse(pointer(frame, 20, line, "none", "move"));
|
|
1297
|
+
assert.ok(!clipped.render(22).join("\n").includes("\x1b[33m"));
|
|
1298
|
+
assert.deepEqual(actions, []);
|
|
1299
|
+
});
|
|
1300
|
+
|
|
1301
|
+
test("hover clears on keyboard, focus, resize, invalidation, disposal and stale row identity", () => {
|
|
1302
|
+
let height = 12, visible = true;
|
|
1303
|
+
const actions: string[] = [];
|
|
1304
|
+
const rows: CustomizeRow[] = [
|
|
1305
|
+
{ label: "First", action: () => { actions.push("first"); } },
|
|
1306
|
+
{ label: "Second", visible: () => visible, action: () => { actions.push("second"); } },
|
|
1307
|
+
];
|
|
1308
|
+
const view = new VisualCustomizeView({ rows, theme: hoverTheme, rowsAvailable: () => height, requestRender() {}, onClose() {} });
|
|
1309
|
+
let frame = view.render(80);
|
|
1310
|
+
const hoverFirst = () => { move(view, frame, "First"); frame = view.render(80); assert.ok(frame.join("\n").includes(warning("First"))); };
|
|
1311
|
+
hoverFirst(); view.handleInput("\x1b[B"); frame = view.render(80);
|
|
1312
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"));
|
|
1313
|
+
hoverFirst(); assert.equal(view.focus("Second"), true); frame = view.render(80);
|
|
1314
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"));
|
|
1315
|
+
hoverFirst(); frame = view.render(79);
|
|
1316
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"), "width resize clears hover");
|
|
1317
|
+
frame = view.render(80); hoverFirst(); height = 11; frame = view.render(80);
|
|
1318
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"), "height resize clears hover");
|
|
1319
|
+
height = 12; frame = view.render(80); hoverFirst(); view.invalidate(); frame = view.render(80);
|
|
1320
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"));
|
|
1321
|
+
hoverFirst(); const stale = pointer(frame, point(frame, "First").x, point(frame, "First").y, "none", "move");
|
|
1322
|
+
rows[0] = { label: "Other", action: () => { actions.push("other"); } };
|
|
1323
|
+
view.handleMouse(stale); frame = view.render(80);
|
|
1324
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"), "a different row cannot inherit stale hover");
|
|
1325
|
+
move(view, frame, "Second"); frame = view.render(80); visible = false;
|
|
1326
|
+
view.handleMouse(pointer(frame, point(frame, "Second").x, point(frame, "Second").y, "none", "move"));
|
|
1327
|
+
frame = view.render(80);
|
|
1328
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"), "hidden rows cannot retain hover");
|
|
1329
|
+
move(view, frame, "Other"); view.dispose(); frame = view.render(80);
|
|
1330
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"));
|
|
1331
|
+
assert.deepEqual(actions, []);
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1334
|
+
test("inline consent hover is presentation only and its actual yes and cancel spans retain their guards", async () => {
|
|
1335
|
+
const answers: boolean[] = [];
|
|
1336
|
+
const view = new VisualCustomizeView({ rows: [
|
|
1337
|
+
{ label: "Proceed", action: async inline => { answers.push(await inline.confirm("Change permission?")); } },
|
|
1338
|
+
{ label: "Other action", action: () => { throw new Error("modal guard bypassed"); } },
|
|
1339
|
+
], theme: hoverTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1340
|
+
let frame = view.render(80); click(view, frame, "Proceed"); await tick();
|
|
1341
|
+
frame = view.render(80);
|
|
1342
|
+
const prompt = frame;
|
|
1343
|
+
move(view, frame, "Other action"); frame = view.render(80);
|
|
1344
|
+
assert.deepEqual(frame, prompt, "the blocked row is not hoverable during consent");
|
|
1345
|
+
assert.equal(move(view, frame, "y yes")?.render, true);
|
|
1346
|
+
frame = view.render(80);
|
|
1347
|
+
assert.ok(frame.join("\n").includes(warning("y yes")));
|
|
1348
|
+
assert.deepEqual(answers, []);
|
|
1349
|
+
move(view, frame, "cancel"); frame = view.render(80);
|
|
1350
|
+
assert.ok(frame.join("\n").includes(warning("cancel")));
|
|
1351
|
+
assert.deepEqual(answers, []);
|
|
1352
|
+
click(view, frame, "cancel"); await tick();
|
|
1353
|
+
assert.deepEqual(answers, [false]);
|
|
1354
|
+
frame = view.render(80); click(view, frame, "Proceed"); await tick();
|
|
1355
|
+
frame = view.render(80); move(view, frame, "y yes"); frame = view.render(80);
|
|
1356
|
+
click(view, frame, "y yes"); await tick();
|
|
1357
|
+
assert.deepEqual(answers, [false, true]);
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
test("profile confirmation hover does not grant consent or defeat changed identity", async () => {
|
|
1361
|
+
const profile = { name: "Desk", themeName: "dark", animationPolicy: "quality" as const, banner: { showRose: true, showTextLogo: true, color: "pink" as const }, visual: { statusPlacement: "auto" as const, headerPlacement: "top" as const, density: "comfortable" as const, surface: "tinted" as const, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false } } };
|
|
1362
|
+
let catalog = [profile];
|
|
1363
|
+
const effects: string[] = [];
|
|
1364
|
+
const view = new VisualCustomizeView({ rows: [], theme: hoverTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {}, profiles: {
|
|
1365
|
+
list: () => catalog, save() {}, apply: name => { effects.push(name); }, delete() {}, reset() {},
|
|
1366
|
+
} });
|
|
1367
|
+
view.handleInput("p"); view.handleInput("a");
|
|
1368
|
+
let frame = view.render(80);
|
|
1369
|
+
move(view, frame, "y yes"); frame = view.render(80);
|
|
1370
|
+
assert.ok(frame.join("\n").includes(warning("y yes")));
|
|
1371
|
+
assert.deepEqual(effects, []);
|
|
1372
|
+
catalog = [{ ...profile, themeName: "light" }];
|
|
1373
|
+
click(view, frame, "y yes"); await tick();
|
|
1374
|
+
assert.deepEqual(effects, [], "hover and click cannot accept a changed fingerprint");
|
|
1375
|
+
assert.match(plain(view.render(80)).join("\n"), /Profile changed/);
|
|
1376
|
+
});
|
|
1377
|
+
|
|
1378
|
+
test("real fullscreen SGR motion clears inside the card, documents outside-overlay dispatch, and preserves clicks", async t => {
|
|
1379
|
+
let input: ((data: string) => void) | undefined;
|
|
1380
|
+
const terminal: Terminal = {
|
|
1381
|
+
start(onInput) { input = onInput; }, stop() {}, async drainInput() {}, write() {}, get columns() { return 120; }, get rows() { return 30; }, get kittyProtocolActive() { return false; }, moveBy() {}, hideCursor() {}, showCursor() {}, clearLine() {}, clearFromCursor() {}, clearScreen() {}, setTitle() {}, setProgress() {}, setProgramStatus() {},
|
|
1382
|
+
};
|
|
1383
|
+
const effects: string[] = [], received: TuiMouseEvent[] = [];
|
|
1384
|
+
const view = new VisualCustomizeView({ rows: [{ label: "Apply this", action: () => { effects.push("applied"); } }], theme: hoverTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1385
|
+
const wrapper = { render: (width: number) => view.render(width), invalidate: () => view.invalidate(), handleInput: (data: string) => view.handleInput(data), handleMouse: (event: TuiMouseEvent) => { received.push(event); return view.handleMouse(event); } };
|
|
1386
|
+
const tui = new TuiAltScreen(terminal, false, undefined, { mouse: true });
|
|
1387
|
+
const overlay = tui.showOverlay(wrapper, { anchor: "center", width: 80, maxHeight: 12 });
|
|
1388
|
+
tui.start(); tui.renderNow(true);
|
|
1389
|
+
try {
|
|
1390
|
+
let frame = view.render(80);
|
|
1391
|
+
const bounds = overlay.getBounds();
|
|
1392
|
+
assert.ok(bounds && bounds.col > 0 && bounds.row > 0);
|
|
1393
|
+
const target = point(frame, "Apply this");
|
|
1394
|
+
const send = (code: number, x: number, y: number, release = false) => input?.(`\x1b[<${code};${x + 1};${y + 1}${release ? "m" : "M"}`);
|
|
1395
|
+
send(35, bounds.col + target.x, bounds.row + target.y);
|
|
1396
|
+
frame = view.render(80);
|
|
1397
|
+
assert.ok(frame.join("\n").includes(warning("Apply this")), "SGR motion reaches the view");
|
|
1398
|
+
const beforeOutside = received.length;
|
|
1399
|
+
send(35, bounds.col - 1, bounds.row + target.y);
|
|
1400
|
+
assert.equal(received.length, beforeOutside, "the native driver does not send outside-overlay motion to the overlay");
|
|
1401
|
+
frame = view.render(80);
|
|
1402
|
+
assert.ok(frame.join("\n").includes(warning("Apply this")), "outside leave cannot be observed by this view");
|
|
1403
|
+
t.diagnostic("TuiAltScreen outside-overlay SGR motion is not dispatched to the centered overlay; hover remains until re-entry or lifecycle clear.");
|
|
1404
|
+
send(35, bounds.col + 1, bounds.row);
|
|
1405
|
+
frame = view.render(80);
|
|
1406
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"), "blank in-card motion clears hover");
|
|
1407
|
+
send(0, bounds.col + target.x, bounds.row + target.y);
|
|
1408
|
+
send(0, bounds.col + target.x, bounds.row + target.y, true);
|
|
1409
|
+
await tick();
|
|
1410
|
+
assert.deepEqual(effects, ["applied"]);
|
|
1411
|
+
} finally { tui.stop(); }
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
test("inline and profile consent labels visibly change from text to warning only on hover", async () => {
|
|
1415
|
+
const piTheme = getThemeByName("dark");
|
|
1416
|
+
assert.ok(piTheme);
|
|
1417
|
+
const answers: boolean[] = [];
|
|
1418
|
+
const inline = new VisualCustomizeView({ rows: [{ label: "Proceed", action: async bridge => { answers.push(await bridge.confirm("Change permission?")); } }], theme: piTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1419
|
+
let frame = inline.render(80); click(inline, frame, "Proceed"); await tick();
|
|
1420
|
+
frame = inline.render(80);
|
|
1421
|
+
assert.ok(frame.join("\n").includes(piTheme.fg("text", "y yes")), "idle yes must differ from the warning prompt");
|
|
1422
|
+
assert.ok(frame.join("\n").includes(piTheme.fg("text", "cancel")));
|
|
1423
|
+
move(inline, frame, "y yes"); frame = inline.render(80);
|
|
1424
|
+
assert.ok(frame.join("\n").includes(piTheme.fg("warning", "y yes")));
|
|
1425
|
+
assert.ok(frame.join("\n").includes(piTheme.fg("text", "cancel")));
|
|
1426
|
+
assert.deepEqual(answers, []);
|
|
1427
|
+
inline.handleInput("n"); await tick();
|
|
1428
|
+
assert.deepEqual(answers, [false]);
|
|
1429
|
+
|
|
1430
|
+
let resets = 0;
|
|
1431
|
+
const profiles = new VisualCustomizeView({ rows: [], theme: piTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {}, profiles: {
|
|
1432
|
+
list: () => [], save() {}, apply() {}, delete() {}, reset: () => { resets++; },
|
|
1433
|
+
} });
|
|
1434
|
+
profiles.handleInput("p"); profiles.handleInput("z"); frame = profiles.render(80);
|
|
1435
|
+
assert.ok(frame.join("\n").includes(piTheme.fg("text", "cancel")));
|
|
1436
|
+
move(profiles, frame, "cancel"); frame = profiles.render(80);
|
|
1437
|
+
assert.ok(frame.join("\n").includes(piTheme.fg("warning", "cancel")));
|
|
1438
|
+
assert.equal(resets, 0);
|
|
1439
|
+
profiles.handleInput("n");
|
|
1440
|
+
assert.equal(resets, 0);
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
test("hover preserves ANSI background and restores terminal color after the card border", () => {
|
|
1444
|
+
const piTheme = getThemeByName("dark");
|
|
1445
|
+
assert.ok(piTheme);
|
|
1446
|
+
const view = new VisualCustomizeView({ rows: [{ label: "Selected", action() {} }], theme: piTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1447
|
+
let frame = view.render(80);
|
|
1448
|
+
const row = point(frame, "Selected").y;
|
|
1449
|
+
const before = frame[row]!;
|
|
1450
|
+
const background = before.match(/\x1b\[48;(?:2;\d+;\d+;\d+|5;\d+)m/)?.[0];
|
|
1451
|
+
assert.ok(background, "the focused row has a truecolor or 256-color background");
|
|
1452
|
+
move(view, frame, "Selected"); frame = view.render(80);
|
|
1453
|
+
const after = frame[row]!;
|
|
1454
|
+
assert.equal(stripAnsi(after), stripAnsi(before));
|
|
1455
|
+
assert.ok(after.indexOf(background) >= 0 && after.indexOf(background) < after.indexOf("Selected"), "hover preserves the exact rendered background");
|
|
1456
|
+
assert.ok(after.indexOf("\x1b[49m", after.indexOf("Selected")) > after.indexOf("Selected"));
|
|
1457
|
+
assert.ok(after.endsWith("\x1b[39m"), "the right border must not leak foreground color to the next line");
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
test("busy rows cannot acquire hover, and become hoverable after the task settles", async () => {
|
|
1461
|
+
let release!: () => void;
|
|
1462
|
+
const effects: string[] = [];
|
|
1463
|
+
const view = new VisualCustomizeView({ rows: [
|
|
1464
|
+
{ label: "Slow", action: () => { effects.push("slow"); return new Promise<void>(resolve => { release = resolve; }); } },
|
|
1465
|
+
{ label: "Other", action: () => { effects.push("other"); } },
|
|
1466
|
+
], theme: hoverTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1467
|
+
let frame = view.render(80); click(view, frame, "Slow");
|
|
1468
|
+
frame = view.render(80); move(view, frame, "Other"); frame = view.render(80);
|
|
1469
|
+
assert.ok(!frame.join("\n").includes(warning("Other")));
|
|
1470
|
+
assert.deepEqual(effects, ["slow"]);
|
|
1471
|
+
release(); await tick(); frame = view.render(80);
|
|
1472
|
+
move(view, frame, "Other"); frame = view.render(80);
|
|
1473
|
+
assert.ok(frame.join("\n").includes(warning("Other")));
|
|
1474
|
+
assert.deepEqual(effects, ["slow"]);
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1477
|
+
test("wide target cells and same-object label drift retain geometry and identity guards", () => {
|
|
1478
|
+
let label = "界two";
|
|
1479
|
+
const effects: string[] = [];
|
|
1480
|
+
const view = new VisualCustomizeView({ rows: [{ label: () => label, action: () => { effects.push(label); } }], theme: hoverTheme, rowsAvailable: () => 12, requestRender() {}, onClose() {} });
|
|
1481
|
+
let frame = view.render(80);
|
|
1482
|
+
const initial = plain(frame), location = point(frame, label);
|
|
1483
|
+
view.handleMouse(pointer(frame, location.x + 1, location.y, "none", "move"));
|
|
1484
|
+
frame = view.render(80);
|
|
1485
|
+
assert.ok(frame.join("\n").includes(warning("界two")), "both cells of a wide grapheme share the target");
|
|
1486
|
+
assert.deepEqual(plain(frame), initial);
|
|
1487
|
+
label = "界six";
|
|
1488
|
+
frame = view.render(80);
|
|
1489
|
+
assert.ok(!frame.join("\n").includes("\x1b[33m"), "a changed label must not inherit hover at the same coordinates");
|
|
1490
|
+
assert.deepEqual(effects, []);
|
|
1491
|
+
});
|
|
1492
|
+
|
|
1493
|
+
test("actual Customize ANSI fixtures for parent visual capture", t => {
|
|
1494
|
+
const piTheme = getThemeByName("dark");
|
|
1495
|
+
assert.ok(piTheme);
|
|
1496
|
+
for (const [width, height] of [[100, 24], [36, 12], [76, 5]] as const) {
|
|
1497
|
+
const view = new VisualCustomizeView({ rows: [{ category: "Editor", label: "Permission mode", action() {} }], theme: piTheme, rowsAvailable: () => height, requestRender() {}, onClose() {} });
|
|
1498
|
+
const before = view.render(width);
|
|
1499
|
+
move(view, before, "Permission mode");
|
|
1500
|
+
const after = view.render(width);
|
|
1501
|
+
assert.deepEqual(plain(after), plain(before));
|
|
1502
|
+
assert.notDeepEqual(after, before, "hover must change actual themed ANSI output");
|
|
1503
|
+
t.diagnostic(`ANSI_FIXTURE ${JSON.stringify({ width, height, before, after })}`);
|
|
1504
|
+
}
|
|
1505
|
+
});
|