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,9 @@
|
|
|
1
1
|
import { sanitizeTerminalText } from "./terminal-theme.ts";
|
|
2
|
-
import { decodeKittyPrintable, isKeyRelease, matchesKey, Key, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { decodeKittyPrintable, isKeyRelease, matchesKey, Key, sliceByColumn, truncateToWidth, visibleWidth, type TuiMouseEvent, type TuiMouseEventResult } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { VisualProfile } from "./visual-profiles.ts";
|
|
4
4
|
import { CARD_PADDING, renderPaletteCard, renderPaletteSelection } from "./command-palette.ts";
|
|
5
5
|
import { stripAnsi } from "./terminal-theme.ts";
|
|
6
|
+
import { paintHoverable } from "./shell-hover.ts";
|
|
6
7
|
|
|
7
8
|
const MAX_INPUT_CODEPOINTS = 512;
|
|
8
9
|
const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
@@ -48,6 +49,59 @@ function rowVisible(row: CustomizeRow): boolean {
|
|
|
48
49
|
|
|
49
50
|
type LineEntry = { first: number; count: number; setting?: string };
|
|
50
51
|
|
|
52
|
+
interface PointerHit {
|
|
53
|
+
id: string;
|
|
54
|
+
x: number;
|
|
55
|
+
end: number;
|
|
56
|
+
y: number;
|
|
57
|
+
text?: string;
|
|
58
|
+
activate(): void;
|
|
59
|
+
}
|
|
60
|
+
interface HoveredHit {
|
|
61
|
+
id: string;
|
|
62
|
+
x: number;
|
|
63
|
+
end: number;
|
|
64
|
+
y: number;
|
|
65
|
+
text: string;
|
|
66
|
+
}
|
|
67
|
+
interface PointerFrame {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
available: number;
|
|
71
|
+
profile: boolean;
|
|
72
|
+
category: string;
|
|
73
|
+
rows: CustomizeRow[];
|
|
74
|
+
hits: PointerHit[];
|
|
75
|
+
}
|
|
76
|
+
interface ChoiceSpan {
|
|
77
|
+
start: number;
|
|
78
|
+
end: number;
|
|
79
|
+
index: number;
|
|
80
|
+
step?: number;
|
|
81
|
+
}
|
|
82
|
+
interface SettingLine {
|
|
83
|
+
text: string;
|
|
84
|
+
nameEnd: number;
|
|
85
|
+
spans: ChoiceSpan[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Only complete, painted consent labels are pointer targets. */
|
|
89
|
+
function confirmationHits(hits: PointerHit[], lines: readonly string[], firstRow: number, answer: (yes: boolean) => void): void {
|
|
90
|
+
const instruction = "y yes · any other key cancel";
|
|
91
|
+
const start = lines.join("").lastIndexOf(instruction);
|
|
92
|
+
if (start < 0) return;
|
|
93
|
+
let offset = 0;
|
|
94
|
+
lines.forEach((line, index) => {
|
|
95
|
+
for (const [label, position, yes] of [["y yes", start, true], ["cancel", start + instruction.length - "cancel".length, false]] as const) {
|
|
96
|
+
const at = position - offset;
|
|
97
|
+
if (at < 0 || at + label.length > line.length) continue;
|
|
98
|
+
const x = 2 + visibleWidth(line.slice(0, at));
|
|
99
|
+
hits.push({ id: yes ? "confirm:yes" : "confirm:cancel", x, end: x + visibleWidth(label), y: firstRow + index, activate: () => answer(yes) });
|
|
100
|
+
}
|
|
101
|
+
offset += line.length;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
51
105
|
export type CustomizeCategory = "Animations" | "Banner" | "Themes" | "Editor" | "History" | "Notifications" | "Layout" | "Cards" | "Sections" | "Keymaps" | "Profiles" | "Reset";
|
|
52
106
|
|
|
53
107
|
export interface CustomizeRow {
|
|
@@ -111,6 +165,8 @@ export class VisualCustomizeView {
|
|
|
111
165
|
private closed = false;
|
|
112
166
|
private busy = false;
|
|
113
167
|
private readonly options: CustomizeViewOptions;
|
|
168
|
+
private pointerFrame?: PointerFrame;
|
|
169
|
+
private hovered?: HoveredHit;
|
|
114
170
|
private error?: string;
|
|
115
171
|
private profileOpen = false;
|
|
116
172
|
private profileIndex = 0;
|
|
@@ -132,7 +188,7 @@ export class VisualCustomizeView {
|
|
|
132
188
|
/** Header and diagnostic context for the active pane; Notifications is explicitly audio. */
|
|
133
189
|
title(): string { return (this.categories[this.categoryIndex] ?? "Settings") === "Notifications" ? "Audio notifications" : "Customization"; }
|
|
134
190
|
/** Ends the interaction and resolves any pending inline field/consent as cancelled. */
|
|
135
|
-
dispose(): void { this.closed = true; this.inline.disposed = true; this.cancelInline(); }
|
|
191
|
+
dispose(): void { this.closed = true; this.clearPointer(); this.inline.disposed = true; this.cancelInline(); }
|
|
136
192
|
private cancelInline(): void {
|
|
137
193
|
const input = this.inlineInput;
|
|
138
194
|
if (input) { this.inlineInput = undefined; input.resolve(undefined); }
|
|
@@ -171,7 +227,7 @@ export class VisualCustomizeView {
|
|
|
171
227
|
try {
|
|
172
228
|
void Promise.resolve(run()).catch((error: unknown) => {
|
|
173
229
|
this.options.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
174
|
-
}).finally(() => { this.busy = false; if (!this.closed) this.options.requestRender(); });
|
|
230
|
+
}).finally(() => { this.busy = false; this.clearPointer(); if (!this.closed) this.options.requestRender(); });
|
|
175
231
|
} catch (error) {
|
|
176
232
|
this.busy = false;
|
|
177
233
|
this.options.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -232,7 +288,7 @@ export class VisualCustomizeView {
|
|
|
232
288
|
confirm.resolve(matchesKey(data, "y") && confirm.visible);
|
|
233
289
|
this.options.requestRender();
|
|
234
290
|
}
|
|
235
|
-
openProfiles(): void { this.profileOpen = true; this.error = undefined; this.options.requestRender(); }
|
|
291
|
+
openProfiles(): void { this.clearPointer(); this.profileOpen = true; this.error = undefined; this.options.requestRender(); }
|
|
236
292
|
private profileAction(action: () => void | Promise<void>): void {
|
|
237
293
|
if (this.profileBusy) return;
|
|
238
294
|
this.profileBusy = true;
|
|
@@ -240,7 +296,7 @@ export class VisualCustomizeView {
|
|
|
240
296
|
void Promise.resolve(action()).catch((error: unknown) => {
|
|
241
297
|
this.error = error instanceof Error ? error.message : String(error);
|
|
242
298
|
this.options.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
243
|
-
}).finally(() => { this.profileBusy = false; this.options.requestRender(); });
|
|
299
|
+
}).finally(() => { this.profileBusy = false; this.clearPointer(); this.options.requestRender(); });
|
|
244
300
|
} catch (error) {
|
|
245
301
|
this.profileBusy = false;
|
|
246
302
|
this.error = error instanceof Error ? error.message : String(error);
|
|
@@ -376,6 +432,7 @@ export class VisualCustomizeView {
|
|
|
376
432
|
this.categoryIndex = index;
|
|
377
433
|
const found = this.categoryRows().findIndex(row => (typeof row.label === "function" ? row.label() : row.label).includes(label));
|
|
378
434
|
if (found >= 0) {
|
|
435
|
+
this.clearPointer();
|
|
379
436
|
this.pane = "controls";
|
|
380
437
|
this.controls.set(this.categories[index]!, found);
|
|
381
438
|
this.options.requestRender();
|
|
@@ -386,8 +443,81 @@ export class VisualCustomizeView {
|
|
|
386
443
|
return false;
|
|
387
444
|
}
|
|
388
445
|
|
|
446
|
+
private clearPointer(): void {
|
|
447
|
+
this.pointerFrame = undefined;
|
|
448
|
+
this.hovered = undefined;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** Install only painted hits and retain hover solely across an identical target and geometry. */
|
|
452
|
+
private installPointerFrame(lines: string[], next: PointerFrame): string[] {
|
|
453
|
+
const previous = this.pointerFrame;
|
|
454
|
+
for (const hit of next.hits) hit.text = stripAnsi(sliceByColumn(lines[hit.y]!, hit.x, hit.end - hit.x, true));
|
|
455
|
+
const hover = this.hovered;
|
|
456
|
+
const sameFrame = previous && previous.width === next.width && previous.height === next.height
|
|
457
|
+
&& previous.available === next.available && previous.profile === next.profile && previous.category === next.category
|
|
458
|
+
&& previous.rows.length === next.rows.length && previous.rows.every((row, index) => row === next.rows[index]);
|
|
459
|
+
const hit = hover && sameFrame && next.hits.find(item => item.id === hover.id && item.x === hover.x
|
|
460
|
+
&& item.end === hover.end && item.y === hover.y && item.text === hover.text);
|
|
461
|
+
if (!hit) this.hovered = undefined;
|
|
462
|
+
const paintHit = (target: PointerHit, hovered: boolean, idleRole?: string) => {
|
|
463
|
+
const line = lines[target.y]!;
|
|
464
|
+
// Keep existing background and neighboring colors; recolor only the hit's painted cells.
|
|
465
|
+
// Column slices omit codes after the last cell, including the border's reset.
|
|
466
|
+
const trailingSgr = line.match(/(?:\x1b\[[0-9;:]*m)+$/)?.[0] ?? "";
|
|
467
|
+
lines[target.y] = sliceByColumn(line, 0, target.x, true)
|
|
468
|
+
+ paintHoverable(this.options.theme, target.text!, hovered, idleRole)
|
|
469
|
+
+ sliceByColumn(line, target.end, next.width - target.end, true) + trailingSgr;
|
|
470
|
+
};
|
|
471
|
+
// The surrounding confirmation is already warning-colored. Give its actionable
|
|
472
|
+
// cells an idle text role so the warning hover is a visible change.
|
|
473
|
+
for (const target of next.hits) if (target.id.startsWith("confirm:")) paintHit(target, target === hit, "text");
|
|
474
|
+
if (hit && !hit.id.startsWith("confirm:")) paintHit(hit, true);
|
|
475
|
+
this.pointerFrame = next;
|
|
476
|
+
return lines;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/** Mouse coordinates are local to the rendered card, including its border. */
|
|
480
|
+
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
481
|
+
if (this.closed) return undefined;
|
|
482
|
+
const moving = event.type === "move" && event.button === "none";
|
|
483
|
+
if (!moving && (event.button !== "left" || (event.type !== "press" && event.type !== "click"))) return undefined;
|
|
484
|
+
const frame = this.pointerFrame;
|
|
485
|
+
const available = this.options.rowsAvailable?.() ?? 24;
|
|
486
|
+
const height = Number.isFinite(available) ? Math.max(0, Math.min(24, Math.floor(available))) : 0;
|
|
487
|
+
let valid = Boolean(frame && event.width === frame.width && event.height === frame.height && height === frame.available
|
|
488
|
+
&& this.profileOpen === frame.profile && (this.categories[this.categoryIndex] ?? "Settings") === frame.category);
|
|
489
|
+
if (valid && frame && !frame.profile) {
|
|
490
|
+
const rows = this.categoryRows();
|
|
491
|
+
valid = rows.length === frame.rows.length && rows.every((row, index) => row === frame.rows[index]);
|
|
492
|
+
}
|
|
493
|
+
if (!valid || !frame) {
|
|
494
|
+
if (!moving) return undefined;
|
|
495
|
+
const changed = this.hovered !== undefined;
|
|
496
|
+
this.clearPointer();
|
|
497
|
+
return changed ? { handled: true, render: true } : undefined;
|
|
498
|
+
}
|
|
499
|
+
const hit = frame.hits.find(item => item.y === event.y && event.x >= item.x && event.x < item.end);
|
|
500
|
+
if (moving) {
|
|
501
|
+
const target = (this.busy && !this.inlineConfirm || this.profileBusy) ? undefined : hit;
|
|
502
|
+
const previous = this.hovered;
|
|
503
|
+
const changed = target ? !previous || previous.id !== target.id || previous.x !== target.x || previous.end !== target.end
|
|
504
|
+
|| previous.y !== target.y || previous.text !== target.text : previous !== undefined;
|
|
505
|
+
this.hovered = target && target.text !== undefined ? { id: target.id, x: target.x, end: target.end, y: target.y, text: target.text } : undefined;
|
|
506
|
+
return { handled: true, render: changed };
|
|
507
|
+
}
|
|
508
|
+
if (!hit) return undefined;
|
|
509
|
+
if (event.type === "press") return { handled: true, capture: true, render: false };
|
|
510
|
+
this.clearPointer();
|
|
511
|
+
hit.activate();
|
|
512
|
+
if (!this.closed) this.options.requestRender();
|
|
513
|
+
return { handled: true, render: true };
|
|
514
|
+
}
|
|
515
|
+
|
|
389
516
|
handleInput(data: string): void {
|
|
390
517
|
if (this.closed || isKeyRelease(data)) return;
|
|
518
|
+
const hovered = this.hovered !== undefined;
|
|
519
|
+
this.clearPointer();
|
|
520
|
+
if (hovered) this.options.requestRender();
|
|
391
521
|
if (this.inlineInput) { this.handleInlineInput(data); return; }
|
|
392
522
|
if (this.inlineConfirm) { this.handleInlineConfirm(data); return; }
|
|
393
523
|
if (this.inlineCapture) { this.handleInlineCapture(data); return; }
|
|
@@ -450,7 +580,7 @@ export class VisualCustomizeView {
|
|
|
450
580
|
}
|
|
451
581
|
|
|
452
582
|
/** One setting with its values inline (● current, ○ other); too wide, only the selected value with arrows. */
|
|
453
|
-
private renderSettingLine(rows: readonly CustomizeRow[], entry: LineEntry, width: number, nameWidth: number, focused: boolean, theme: CustomizeViewOptions["theme"]):
|
|
583
|
+
private renderSettingLine(rows: readonly CustomizeRow[], entry: LineEntry, width: number, nameWidth: number, focused: boolean, theme: CustomizeViewOptions["theme"]): SettingLine {
|
|
454
584
|
const choices = rows.slice(entry.first, entry.first + entry.count).map(row => row.choice!);
|
|
455
585
|
const isCurrent = (choice: NonNullable<CustomizeRow["choice"]>) => { try { return choice.current(); } catch { return false; } };
|
|
456
586
|
const name = sanitizeTerminalText(entry.setting!);
|
|
@@ -463,27 +593,50 @@ export class VisualCustomizeView {
|
|
|
463
593
|
return theme.fg(isCurrent(choice) || cursor ? "accent" : "muted", text);
|
|
464
594
|
};
|
|
465
595
|
let body = choices.map(mark).join(" ");
|
|
466
|
-
|
|
467
|
-
|
|
596
|
+
const bodyStart = 2 + visibleWidth(lead);
|
|
597
|
+
const spans: ChoiceSpan[] = [];
|
|
598
|
+
if (bodyStart + visibleWidth(body) > width) {
|
|
599
|
+
const value = sanitizeTerminalText(shown.value);
|
|
600
|
+
const index = choices.indexOf(shown);
|
|
601
|
+
const compact = `‹ ${value} ›`;
|
|
602
|
+
body = `${theme.fg("accent", compact)} ${theme.fg("muted", `${index + 1}/${choices.length}`)}`;
|
|
603
|
+
// Truncation replaces the last column with an ellipsis: never expose a
|
|
604
|
+
// partial value or arrows that would step from an unseen identity.
|
|
605
|
+
const limit = bodyStart + visibleWidth(body) > width ? width - 1 : width;
|
|
606
|
+
if (bodyStart + visibleWidth(compact) <= limit) {
|
|
607
|
+
if (index > 0) spans.push({ start: bodyStart, end: bodyStart + 1, index, step: -1 });
|
|
608
|
+
spans.push({ start: bodyStart + 2, end: bodyStart + 2 + visibleWidth(value), index });
|
|
609
|
+
if (index + 1 < choices.length) spans.push({ start: bodyStart + 3 + visibleWidth(value), end: bodyStart + 4 + visibleWidth(value), index, step: 1 });
|
|
610
|
+
}
|
|
611
|
+
} else {
|
|
612
|
+
let start = bodyStart;
|
|
613
|
+
choices.forEach((choice, index) => {
|
|
614
|
+
const length = visibleWidth(`○ ${sanitizeTerminalText(choice.value)}`);
|
|
615
|
+
spans.push({ start, end: start + length, index });
|
|
616
|
+
start += length + 2;
|
|
617
|
+
});
|
|
468
618
|
}
|
|
469
619
|
const text = truncateToWidth(`${focused ? theme.fg("accent", "▸ ") : " "}${theme.fg(focused ? "text" : "muted", lead)}${body}`, width, "…");
|
|
470
620
|
const padded = text + " ".repeat(Math.max(0, width - visibleWidth(text)));
|
|
471
|
-
return focused && theme.bg ? theme.bg("selectedBg", padded) : padded;
|
|
621
|
+
return { text: focused && theme.bg ? theme.bg("selectedBg", padded) : padded, nameEnd: Math.min(width, 2 + visibleWidth(name)), spans };
|
|
472
622
|
}
|
|
473
623
|
|
|
474
624
|
render(width: number): string[] {
|
|
475
625
|
if (this.profileOpen && this.options.profiles) {
|
|
476
|
-
if (width <= 0) { this.confirmationVisible = false; return []; }
|
|
626
|
+
if (width <= 0) { this.confirmationVisible = false; this.clearPointer(); return []; }
|
|
477
627
|
return this.renderProfiles(width);
|
|
478
628
|
}
|
|
479
629
|
this.mainWidth = width;
|
|
480
|
-
if (width <= 0) { this.confirmationVisible = false; return []; }
|
|
630
|
+
if (width <= 0) { this.confirmationVisible = false; this.clearPointer(); return []; }
|
|
481
631
|
const available = this.options.rowsAvailable?.() ?? 24;
|
|
482
632
|
const height = Number.isFinite(available) ? Math.max(0, Math.min(24, Math.floor(available))) : 0;
|
|
483
|
-
if (!height) return [];
|
|
633
|
+
if (!height) { this.clearPointer(); return []; }
|
|
484
634
|
// A card needs two border rows. At extreme dimensions keep the old
|
|
485
635
|
// read-only heading rather than letting invisible controls be activated.
|
|
486
|
-
if (width < CARD_PADDING + 1 || height < 4)
|
|
636
|
+
if (width < CARD_PADDING + 1 || height < 4) {
|
|
637
|
+
this.clearPointer();
|
|
638
|
+
return Array.from({ length: Math.min(height, 2) }, (_, i) => truncateToWidth(i ? "Enlarge terminal" : this.title(), width, ""));
|
|
639
|
+
}
|
|
487
640
|
const inner = width - CARD_PADDING;
|
|
488
641
|
const category = this.categories[this.categoryIndex] ?? "Settings";
|
|
489
642
|
const rows = this.categoryRows();
|
|
@@ -513,6 +666,23 @@ export class VisualCustomizeView {
|
|
|
513
666
|
const join = (left: string, right: string) => leftWidth ? `${left}${" ".repeat(Math.max(0, leftWidth - visibleWidth(stripAnsi(left))))} ${paint("│", 1, "border")} ${right}` : right;
|
|
514
667
|
const heading = navOnly ? "Categories · choose a category →" : `${category} · ${rows.length ? `${line + 1}/${entries.length}` : "empty"}`;
|
|
515
668
|
const lines: string[] = [paint(this.title(), inner, "accent")];
|
|
669
|
+
const hits: PointerHit[] = [];
|
|
670
|
+
const modal = Boolean(this.inlineInput || this.inlineConfirm || this.inlineCapture);
|
|
671
|
+
const categoryHit = (name: string, index: number, x: number, y: number, size: number) => {
|
|
672
|
+
const end = x + Math.min(visibleWidth(name), Math.max(0, size));
|
|
673
|
+
if (!modal && end > x) hits.push({ id: `category:${index}`, x, end, y, activate: () => {
|
|
674
|
+
if (this.busy) return;
|
|
675
|
+
this.categoryIndex = index;
|
|
676
|
+
this.pane = "categories";
|
|
677
|
+
if (narrow) this.enterControls();
|
|
678
|
+
} });
|
|
679
|
+
};
|
|
680
|
+
const select = (index: number, apply: boolean) => {
|
|
681
|
+
if (this.busy) return;
|
|
682
|
+
this.pane = "controls";
|
|
683
|
+
this.controls.set(category, index);
|
|
684
|
+
if (apply) this.withBusy(() => rows[index]!.action(this.inline));
|
|
685
|
+
};
|
|
516
686
|
// Commands uses a header, grouped section labels, whitespace and a footer.
|
|
517
687
|
if (showHeading) lines.push(join(leftWidth ? paint("CATEGORIES", leftWidth, "accent") : "", paint(heading, rightWidth, "accent")));
|
|
518
688
|
if (showTopGap) lines.push("");
|
|
@@ -523,14 +693,34 @@ export class VisualCustomizeView {
|
|
|
523
693
|
const row = entry ? rows[entry.first] : undefined;
|
|
524
694
|
const item = navOnly ? this.categories[start + i] : row ? typeof row.label === "function" ? row.label() : row.label : undefined;
|
|
525
695
|
const rowTheme = navOnly || this.pane === "controls" ? this.options.theme : { fg: this.options.theme.fg.bind(this.options.theme) };
|
|
526
|
-
const
|
|
527
|
-
|
|
696
|
+
const setting = entry?.setting ? this.renderSettingLine(rows, entry, rightWidth, nameWidth, start + i === position, rowTheme) : undefined;
|
|
697
|
+
const right = setting?.text ?? (item ? renderPaletteSelection(item, rightWidth, start + i === position, rowTheme) : rows.length ? "" : paint("No settings available", rightWidth, "muted"));
|
|
698
|
+
const y = lines.length + 1; // card adds its top border
|
|
699
|
+
const rightX = 2 + (leftWidth ? leftWidth + 3 : 0);
|
|
700
|
+
if (leftWidth && nav) categoryHit(nav, navStart + i, 4, y, leftWidth - 2);
|
|
701
|
+
if (navOnly && item) categoryHit(item, start + i, rightX + 2, y, rightWidth - 2);
|
|
702
|
+
else if (!modal && entry && row) {
|
|
703
|
+
if (setting) {
|
|
704
|
+
if (setting.nameEnd > 2) hits.push({ id: `setting:${entry.first}`, x: rightX + 2, end: rightX + setting.nameEnd, y, activate: () => select(this.landOn(rows, entry), false) });
|
|
705
|
+
for (const span of setting.spans) hits.push({ id: `choice:${entry.first}:${span.index}:${span.step ?? 0}`, x: rightX + span.start, end: rightX + span.end, y, activate: () => {
|
|
706
|
+
if (this.busy) return;
|
|
707
|
+
select(entry.first + span.index, span.step === undefined);
|
|
708
|
+
if (span.step) this.handleInput(span.step < 0 ? "\x1b[D" : "\x1b[C");
|
|
709
|
+
} });
|
|
710
|
+
} else {
|
|
711
|
+
const end = rightX + visibleWidth(stripAnsi(right).trimEnd());
|
|
712
|
+
if (end > rightX + 2) hits.push({ id: `row:${entry.first}`, x: rightX + 2, end, y, activate: () => select(entry.first, true) });
|
|
713
|
+
}
|
|
714
|
+
}
|
|
528
715
|
lines.push(join(left, right));
|
|
529
716
|
}
|
|
530
717
|
if (this.inlineConfirm) {
|
|
531
718
|
const shows = !navOnly && previewLines > 0 ? this.wrapInline(`${this.inlineConfirm.message} y yes · any other key cancel`, inner, previewLines) : undefined;
|
|
532
719
|
this.inlineConfirm.visible = shows !== undefined;
|
|
533
|
-
if (shows)
|
|
720
|
+
if (shows) {
|
|
721
|
+
confirmationHits(hits, shows, lines.length + 1, yes => this.handleInput(yes ? "y" : "n"));
|
|
722
|
+
for (const line of shows) lines.push(paint(line, inner, "warning"));
|
|
723
|
+
}
|
|
534
724
|
else if (previewLines > 0) lines.push(paint("Confirmation needs more space · enlarge terminal", inner, "warning"));
|
|
535
725
|
} else if (this.inlineCapture) {
|
|
536
726
|
const shows = !navOnly && previewLines > 0 ? this.wrapInline(`${this.inlineCapture.prompt} · Esc cancel`, inner, previewLines) : undefined;
|
|
@@ -558,11 +748,12 @@ export class VisualCustomizeView {
|
|
|
558
748
|
for (let i = 0; i < previewLines - 2; i++) lines.push(paint(sample[i] ?? "", inner, "muted"));
|
|
559
749
|
} else if (previewLines === 1) lines.push(paint(navOnly ? "→ controls · Esc close" : "Preview omitted · enlarge terminal", inner, "muted"));
|
|
560
750
|
if (showBottomGap) lines.push("");
|
|
561
|
-
if (showHeading) lines.push(paint(footerHint(category, navOnly, previewLines, rows[this.selected]?.keyhint, focusedSetting !== undefined, focusedSetting?.applyOnMove !== false)
|
|
751
|
+
if (showHeading) lines.push(paint(`Click · ${footerHint(category, navOnly, previewLines, rows[this.selected]?.keyhint, focusedSetting !== undefined, focusedSetting?.applyOnMove !== false)}`, inner, "muted"));
|
|
562
752
|
// The top-right close hint mirrors Commands without consuming another row.
|
|
563
753
|
const title = this.title();
|
|
564
754
|
lines[0] = paint(title + " ".repeat(Math.max(1, inner - visibleWidth(title) - 3)) + "esc", inner, "accent");
|
|
565
|
-
|
|
755
|
+
const frame = renderPaletteCard(lines.slice(0, height - 2), width, this.options.theme);
|
|
756
|
+
return this.installPointerFrame(frame, { width, height: frame.length, available: height, profile: false, category, rows, hits: hits.filter(hit => hit.y < frame.length - 1) });
|
|
566
757
|
}
|
|
567
758
|
private detailSize(width: number): { height: number; inner: number; capacity: number } {
|
|
568
759
|
const available = this.options.rowsAvailable?.() ?? 24;
|
|
@@ -580,10 +771,11 @@ export class VisualCustomizeView {
|
|
|
580
771
|
this.profileWidth = width;
|
|
581
772
|
this.profileInputVisible = false;
|
|
582
773
|
const { height, inner, capacity } = this.detailSize(width);
|
|
583
|
-
if (height < 3 || inner < 1) { this.confirmationVisible = false; return this.detailFrame(["Visual profiles", "Enlarge terminal"], width, height); }
|
|
774
|
+
if (height < 3 || inner < 1) { this.confirmationVisible = false; this.clearPointer(); return this.detailFrame(["Visual profiles", "Enlarge terminal"], width, height); }
|
|
584
775
|
let items: VisualProfile[];
|
|
585
776
|
try { items = this.options.profiles!.list(); } catch (error) {
|
|
586
777
|
this.confirmationVisible = false;
|
|
778
|
+
this.clearPointer();
|
|
587
779
|
return this.detailFrame([this.options.theme.fg("accent", "Visual profiles"), `Profiles unavailable: ${error instanceof Error ? error.message : String(error)}`, "Esc back"], width, height);
|
|
588
780
|
}
|
|
589
781
|
this.profileIndex = Math.min(this.profileIndex, Math.max(0, items.length - 1));
|
|
@@ -591,6 +783,8 @@ export class VisualCustomizeView {
|
|
|
591
783
|
const choice = this.confirmation;
|
|
592
784
|
const promptLines = choice ? this.confirmationLines(choice, inner, capacity) : undefined;
|
|
593
785
|
this.confirmationVisible = promptLines !== undefined;
|
|
786
|
+
const hits: PointerHit[] = [];
|
|
787
|
+
if (promptLines) confirmationHits(hits, promptLines, 1, yes => this.handleInput(yes ? "y" : "n"));
|
|
594
788
|
const lines: string[] = promptLines ? promptLines.map(line => this.options.theme.fg("warning", line)) : choice ? [this.options.theme.fg("warning", "Confirmation unavailable · Esc back")] : [];
|
|
595
789
|
// Input outranks the error, header and preview on tiny terminals.
|
|
596
790
|
const input = this.profileInput !== undefined ? `New profile name: ${this.profileInput}▏` : undefined;
|
|
@@ -612,8 +806,9 @@ export class VisualCustomizeView {
|
|
|
612
806
|
lines.push(...details.slice(0, free).map(line => this.options.theme.fg("text", line)));
|
|
613
807
|
for (const line of tail) if (lines.length < capacity) lines.push(this.options.theme.fg(line.startsWith("Error:") ? "error" : "accent", line));
|
|
614
808
|
if (lines.length < capacity) lines.push(this.options.theme.fg("muted", footer));
|
|
615
|
-
|
|
809
|
+
const frame = this.detailFrame(lines, width, height);
|
|
810
|
+
return this.installPointerFrame(frame, { width, height: frame.length, available: height, profile: true, category: this.categories[this.categoryIndex] ?? "Settings", rows: [], hits: hits.filter(hit => hit.y < frame.length - 1) });
|
|
616
811
|
}
|
|
617
812
|
|
|
618
|
-
invalidate(): void { this.options.requestRender(); }
|
|
813
|
+
invalidate(): void { this.clearPointer(); this.options.requestRender(); }
|
|
619
814
|
}
|
|
@@ -14,7 +14,9 @@ const rule = (label: string, width: number) => (label ? `─ ${label} ` : "").pa
|
|
|
14
14
|
|
|
15
15
|
export function layoutSchematic(settings: VisualSettings): string {
|
|
16
16
|
const rail = settings.statusPlacement === "right" || settings.statusPlacement === "auto";
|
|
17
|
-
|
|
17
|
+
// A split header draws its title row on top and its counters in a bottom status bar.
|
|
18
|
+
const split = settings.headerPlacement === "split";
|
|
19
|
+
const top = settings.headerPlacement === "top" || split;
|
|
18
20
|
// Two rail rows, filled word by word in rail order.
|
|
19
21
|
const railRows = ["", ""];
|
|
20
22
|
let row = 0;
|
|
@@ -24,15 +26,17 @@ export function layoutSchematic(settings: VisualSettings): string {
|
|
|
24
26
|
if (next.length > RAIL - 1 && row === 0) { row = 1; railRows[1] = name; }
|
|
25
27
|
else railRows[row] = next;
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
// With a rail, below-input places the bar below both columns, like split.
|
|
30
|
+
const input = top || rail ? "› input" : "› input · header";
|
|
28
31
|
const main = ["conversation", input];
|
|
29
32
|
const width = MAIN + (rail ? RAIL + 1 : 0);
|
|
30
|
-
const
|
|
33
|
+
const railBottomBar = rail && (split || !top);
|
|
34
|
+
const bottom = settings.statusPlacement === "bottom" || railBottomBar ? "status bar" : settings.statusPlacement === "auto" ? "bar under 140 cols" : "";
|
|
31
35
|
if (rail) {
|
|
32
36
|
return [
|
|
33
|
-
`┌${rule(
|
|
37
|
+
top ? `┌${rule(split ? "title" : "header", width)}┐` : `┌${rule("", MAIN)}┬${rule("Status", RAIL)}┐`,
|
|
34
38
|
...main.map((text, line) => `│ ${fill(text, MAIN - 1)}│ ${fill(railRows[line] ?? "", RAIL - 1)}│`),
|
|
35
|
-
`└${rule(bottom, MAIN)}┴${"─".repeat(RAIL)}┘`,
|
|
39
|
+
railBottomBar ? `└${rule(bottom, width)}┘` : `└${rule(bottom, MAIN)}┴${"─".repeat(RAIL)}┘`,
|
|
36
40
|
].join("\n");
|
|
37
41
|
}
|
|
38
42
|
return [
|
package/lib/visual-profiles.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { constants as fsConstants, closeSync, fstatSync, lstatSync, mkdirSync, o
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { gentlePiConfigHome } from "./agent-home.ts";
|
|
5
5
|
import { ANIMATION_POLICY, type AnimationPolicy } from "./animation-policy.ts";
|
|
6
|
-
import { isVisualSettings, normalizeVisualSettings, type VisualSettings } from "./visual-customization-policy.ts";
|
|
6
|
+
import { isVisualSettings, normalizeVisualSettings, storedVisualSettings, type VisualSettings } from "./visual-customization-policy.ts";
|
|
7
7
|
import type { BannerConfig } from "../extensions/startup-banner.ts";
|
|
8
8
|
|
|
9
9
|
export const VISUAL_PROFILES_SCHEMA = "gentle-pi.visual-profiles/v1";
|
|
@@ -155,7 +155,7 @@ function existing(options: Options): VisualProfile[] {
|
|
|
155
155
|
function write(profiles: VisualProfile[], options: Options): string {
|
|
156
156
|
const home = options.gentlePiConfigHome ?? gentlePiConfigHome();
|
|
157
157
|
const path = join(home, "visual-profiles.json");
|
|
158
|
-
const data = `${JSON.stringify({ schema: VISUAL_PROFILES_SCHEMA, profiles })}\n`;
|
|
158
|
+
const data = `${JSON.stringify({ schema: VISUAL_PROFILES_SCHEMA, profiles: profiles.map((profile) => ({ ...profile, visual: storedVisualSettings(profile.visual) })) })}\n`;
|
|
159
159
|
if (Buffer.byteLength(data) > MAX_BYTES) {
|
|
160
160
|
throw new RangeError("Visual profiles exceed 256 KB.");
|
|
161
161
|
}
|
|
@@ -47,6 +47,7 @@ export type WindowsSessionTransportHostOptions = Readonly<{
|
|
|
47
47
|
callback?: WindowsHostCallback;
|
|
48
48
|
rpcDeadlineMs?: number;
|
|
49
49
|
startupDeadlineMs?: number;
|
|
50
|
+
onBootstrapDiagnostic?: WindowsSessionBootstrapDiagnosticObserver;
|
|
50
51
|
}>;
|
|
51
52
|
export type WindowsSessionRegistryPhase = "start" | "initialize" | "cleanup";
|
|
52
53
|
export type WindowsSessionStartupMarker = "script-entered" | "native-ready";
|
|
@@ -55,6 +56,24 @@ export type WindowsSessionRegistryPhaseError = Readonly<{ class: "timed-out" | "
|
|
|
55
56
|
/** Receives one fixed, synchronous result event for an operation on this registry's own host. */
|
|
56
57
|
export type WindowsSessionRegistryPhaseEvent = Readonly<{ phase: WindowsSessionRegistryPhase; status: "succeeded" | "failed"; error: WindowsSessionRegistryPhaseError | null; lastStartupMarker: WindowsSessionStartupMarker | null }>;
|
|
57
58
|
export type WindowsSessionRegistryPhaseObserver = (event: WindowsSessionRegistryPhaseEvent) => undefined;
|
|
59
|
+
const bootstrapDiagnosticCategories = ["compiler", "argument", "invalid-operation", "not-supported", "security", "assembly-load", "type-load", "other"] as const;
|
|
60
|
+
const bootstrapRejectionStages = ["volume-open", "ancestor-open", "routing-open", "transport-create-or-open", "transport-assert-owned", "presence-create-or-open", "presence-assert-owned", "unknown"] as const;
|
|
61
|
+
/** A fixed code derived from the helper's known bootstrap stderr markers; no stderr text, path, SID, or status crosses it. */
|
|
62
|
+
export type WindowsSessionBootstrapDiagnosticCode = `diagnostic-${typeof bootstrapDiagnosticCategories[number]}` | `rejection-${typeof bootstrapRejectionStages[number]}`;
|
|
63
|
+
export type WindowsSessionBootstrapDiagnosticObserver = (code: WindowsSessionBootstrapDiagnosticCode) => undefined;
|
|
64
|
+
const bootstrapDiagnosticCodes: ReadonlySet<string> = new Set([...bootstrapDiagnosticCategories.map((category) => `diagnostic-${category}`), ...bootstrapRejectionStages.map((stage) => `rejection-${stage}`)]);
|
|
65
|
+
export const isWindowsSessionBootstrapDiagnosticCode = (value: unknown): value is WindowsSessionBootstrapDiagnosticCode => typeof value === "string" && bootstrapDiagnosticCodes.has(value);
|
|
66
|
+
/** Classify one helper stderr line. Anything but an exact known marker is dropped. */
|
|
67
|
+
function classifyBootstrapStderr(line: string): WindowsSessionBootstrapDiagnosticCode | undefined {
|
|
68
|
+
let value: unknown;
|
|
69
|
+
try { value = JSON.parse(line); } catch { return undefined; }
|
|
70
|
+
if (!plainRecord(value) || Object.getPrototypeOf(value) !== Object.prototype) return undefined;
|
|
71
|
+
const keys = Object.keys(value).sort().join(",");
|
|
72
|
+
let code: string | undefined;
|
|
73
|
+
if (value.kind === "windows-session-bootstrap-diagnostic" && keys === "category,compilerCodes,kind,languageMode,reason") code = `diagnostic-${String(value.category)}`;
|
|
74
|
+
else if (value.kind === "windows-session-bootstrap-rejection" && keys === "kind,ntstatus,stage") code = `rejection-${String(value.stage)}`;
|
|
75
|
+
return isWindowsSessionBootstrapDiagnosticCode(code) ? code : undefined;
|
|
76
|
+
}
|
|
58
77
|
export type WindowsSessionRegistryObservation = Readonly<{
|
|
59
78
|
availability: "unavailable" | "observed";
|
|
60
79
|
provenance: "unavailable" | "ambiguous" | "owned-instance";
|
|
@@ -253,6 +272,10 @@ export class WindowsSessionTransportHost {
|
|
|
253
272
|
private started?: Promise<void>;
|
|
254
273
|
private startupMarker: WindowsSessionStartupMarker | null = null;
|
|
255
274
|
private startupReplyObserved = false;
|
|
275
|
+
private readonly onBootstrapDiagnostic?: WindowsSessionBootstrapDiagnosticObserver;
|
|
276
|
+
private bootstrapDiagnosticCode: WindowsSessionBootstrapDiagnosticCode | null = null;
|
|
277
|
+
private diagnosticOutput = Buffer.alloc(0);
|
|
278
|
+
private diagnosticOverflow = false;
|
|
256
279
|
private sequence = 0;
|
|
257
280
|
private output = Buffer.alloc(0);
|
|
258
281
|
private readonly pending = new Map<string, Pending>();
|
|
@@ -279,6 +302,7 @@ export class WindowsSessionTransportHost {
|
|
|
279
302
|
private readonly onStdoutError = () => this.abort("Windows transport host unavailable", true, "stream");
|
|
280
303
|
private readonly onStdinError = () => this.abort("Windows transport host unavailable", true, "stream");
|
|
281
304
|
private readonly onStderrError = () => this.abort("Windows transport host unavailable", true, "stream");
|
|
305
|
+
private readonly onStderrData = (chunk: Buffer) => this.onDiagnosticOutput(chunk);
|
|
282
306
|
private readonly onChildError = () => this.abort("Windows transport host unavailable", true, "process");
|
|
283
307
|
private readonly onChildExit = () => this.abort("Windows transport host exited", false, "exit");
|
|
284
308
|
private readonly onChildClose = () => this.handleChildClose();
|
|
@@ -291,11 +315,14 @@ export class WindowsSessionTransportHost {
|
|
|
291
315
|
this.callback = options.callback;
|
|
292
316
|
this.deadline = options.rpcDeadlineMs ?? RPC_DEADLINE_MS;
|
|
293
317
|
this.startupDeadline = options.startupDeadlineMs ?? STARTUP_DEADLINE_MS;
|
|
318
|
+
this.onBootstrapDiagnostic = options.onBootstrapDiagnostic;
|
|
294
319
|
if (!Number.isInteger(this.deadline) || this.deadline < 1 || this.deadline > RPC_DEADLINE_MS) throw new RangeError("invalid Windows transport deadline");
|
|
295
320
|
if (!Number.isInteger(this.startupDeadline) || this.startupDeadline < 1 || this.startupDeadline > STARTUP_DEADLINE_MS) throw new RangeError("invalid Windows transport startup deadline");
|
|
296
321
|
}
|
|
297
322
|
|
|
298
323
|
get lastStartupMarker() { return this.startupMarker; }
|
|
324
|
+
/** The first classified bootstrap stderr marker of this host, or null. */
|
|
325
|
+
get bootstrapDiagnostic() { return this.bootstrapDiagnosticCode; }
|
|
299
326
|
|
|
300
327
|
start(): Promise<void> {
|
|
301
328
|
if (this.started) return this.started;
|
|
@@ -307,6 +334,7 @@ export class WindowsSessionTransportHost {
|
|
|
307
334
|
this.child.stdout.on("error", this.onStdoutError);
|
|
308
335
|
this.child.stdin.on("error", this.onStdinError);
|
|
309
336
|
this.child.stderr.on("error", this.onStderrError);
|
|
337
|
+
this.child.stderr.on("data", this.onStderrData);
|
|
310
338
|
this.child.stderr.resume?.();
|
|
311
339
|
this.child.once("error", this.onChildError);
|
|
312
340
|
this.child.once("exit", this.onChildExit);
|
|
@@ -401,6 +429,27 @@ export class WindowsSessionTransportHost {
|
|
|
401
429
|
this.startupMarker = marker;
|
|
402
430
|
return true;
|
|
403
431
|
}
|
|
432
|
+
// stderr is always consumed. Only the first exact known bootstrap marker becomes a
|
|
433
|
+
// fixed code; unknown, malformed, or oversized lines are dropped unread.
|
|
434
|
+
private onDiagnosticOutput(chunk: Buffer) {
|
|
435
|
+
if (!Buffer.isBuffer(chunk)) return;
|
|
436
|
+
const output = this.diagnosticOutput.length === 0 ? chunk : Buffer.concat([this.diagnosticOutput, chunk]);
|
|
437
|
+
let offset = 0;
|
|
438
|
+
for (let newline = output.indexOf(10, offset); newline >= 0; newline = output.indexOf(10, offset)) {
|
|
439
|
+
const bytes = output.subarray(offset, newline);
|
|
440
|
+
offset = newline + 1;
|
|
441
|
+
const overflowed = this.diagnosticOverflow;
|
|
442
|
+
this.diagnosticOverflow = false;
|
|
443
|
+
if (overflowed || this.bootstrapDiagnosticCode !== null || bytes.length > MAX_CONTROL_BYTES) continue;
|
|
444
|
+
const code = classifyBootstrapStderr(bytes.toString("utf8").replace(/\r$/, ""));
|
|
445
|
+
if (!code) continue;
|
|
446
|
+
this.bootstrapDiagnosticCode = code;
|
|
447
|
+
try { this.onBootstrapDiagnostic?.(code); } catch { /* an observer never disturbs the helper */ }
|
|
448
|
+
}
|
|
449
|
+
const partial = output.subarray(offset);
|
|
450
|
+
if (partial.length > MAX_CONTROL_BYTES) { this.diagnosticOverflow = true; this.diagnosticOutput = Buffer.alloc(0); }
|
|
451
|
+
else this.diagnosticOutput = Buffer.from(partial);
|
|
452
|
+
}
|
|
404
453
|
private onOutput(chunk: Buffer) {
|
|
405
454
|
if (!Buffer.isBuffer(chunk)) { this.abort("Windows transport host unavailable", true, "protocol"); return; }
|
|
406
455
|
const output = this.output.length === 0 ? chunk : Buffer.concat([this.output, chunk]);
|
|
@@ -487,6 +536,7 @@ export class WindowsSessionTransportHost {
|
|
|
487
536
|
child.stdout.removeListener("error", this.onStdoutError);
|
|
488
537
|
child.stdin.removeListener("error", this.onStdinError);
|
|
489
538
|
child.stderr.removeListener("error", this.onStderrError);
|
|
539
|
+
child.stderr.removeListener("data", this.onStderrData);
|
|
490
540
|
child.removeListener("error", this.onChildError);
|
|
491
541
|
child.removeListener("exit", this.onChildExit);
|
|
492
542
|
if (!keepClose) child.removeListener("close", this.onChildClose);
|
|
@@ -511,6 +561,7 @@ export class WindowsSessionTransportHost {
|
|
|
511
561
|
this.rejectCleanup = undefined;
|
|
512
562
|
this.cleanup = undefined;
|
|
513
563
|
this.output = Buffer.alloc(0);
|
|
564
|
+
this.diagnosticOutput = Buffer.alloc(0);
|
|
514
565
|
this.child = undefined;
|
|
515
566
|
resolve?.();
|
|
516
567
|
}
|
|
@@ -643,11 +694,11 @@ export class WindowsSessionPresenceRegistry {
|
|
|
643
694
|
this.observer = observer;
|
|
644
695
|
this.host.setListenerFailure((generation) => this.listenerFailure?.(generation));
|
|
645
696
|
}
|
|
646
|
-
static async create(agentHome: string, observePhase?: WindowsSessionRegistryPhaseObserver) {
|
|
697
|
+
static async create(agentHome: string, observePhase?: WindowsSessionRegistryPhaseObserver, observeBootstrap?: WindowsSessionBootstrapDiagnosticObserver) {
|
|
647
698
|
if (process.platform !== "win32") throw new SessionPresenceError("io_error", "transport I/O failed");
|
|
648
699
|
if (typeof agentHome !== "string" || !/^[A-Za-z]:\\/.test(agentHome)) throw new SessionPresenceError("unsafe_path", "unsafe transport path");
|
|
649
700
|
let registry: WindowsSessionPresenceRegistry | undefined;
|
|
650
|
-
const host = new WindowsSessionTransportHost({ callback: async (notification) => registry?.notification?.(notification) ?? false });
|
|
701
|
+
const host = new WindowsSessionTransportHost({ callback: async (notification) => registry?.notification?.(notification) ?? false, onBootstrapDiagnostic: observeBootstrap });
|
|
651
702
|
const observer = observePhase === undefined ? undefined : new WindowsSessionRegistryObserver(observePhase, () => host.lastStartupMarker);
|
|
652
703
|
const run = <T>(phase: WindowsSessionRegistryPhase, operation: () => Promise<T>) => observer ? observer.run(phase, operation) : operation();
|
|
653
704
|
try {
|