gentle-pi 4.5.0 → 4.6.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 +9 -6
- package/assets/agents/gentle-ai-verify.md +4 -0
- package/assets/agents/gentle-ai-worker.md +1 -0
- package/assets/migrations/agent-body-history.json +147 -0
- package/assets/orchestrator-delegation-reference.md +3 -3
- package/assets/orchestrator-delegation.md +2 -2
- package/assets/orchestrator-verification.md +10 -6
- package/assets/orchestrator.md +8 -8
- package/bin/gentle-shell.mjs +61 -26
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +6 -0
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +8 -0
- package/docs/gentle-music.md +6 -3
- package/docs/gentle-shell.md +70 -20
- package/docs/install-wizard.md +1 -1
- package/docs/mcp-status.md +52 -0
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +82 -21
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/work-continuity.md +46 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agents.ts +477 -50
- package/extensions/gentle-ai.ts +1046 -191
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-music.ts +10 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +642 -97
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +42 -22
- package/extensions/history/store.ts +18 -12
- package/extensions/skill-registry.ts +35 -3
- package/extensions/startup-banner.ts +39 -7
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profiles.ts +1 -1
- package/lib/agents-config.ts +12 -3
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +105 -4
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/bridge-cost.ts +28 -0
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +21 -8
- package/lib/exploration-budget.ts +62 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-launcher.ts +4 -0
- package/lib/herdr-activity.ts +9 -3
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/inprocess-reviewer.ts +33 -13
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +10 -2
- package/lib/nan-provider.ts +3 -2
- package/lib/native-review-cli.ts +7 -2
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +121 -7
- package/lib/review-candidate-view-owner.ts +4 -0
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +22 -7
- package/lib/review-repository.ts +5 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +105 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +171 -56
- package/lib/shell-card.ts +26 -6
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +149 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +98 -25
- package/lib/shell-sidebar.ts +54 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +71 -0
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +41 -6
- package/lib/visual-customize-view.ts +164 -26
- package/lib/visual-layout-preview.ts +43 -0
- package/lib/yolo-session-policy.ts +28 -1
- package/package.json +1 -1
- package/runtime/gentle-shell-launcher.mjs +4 -0
- package/runtime/native-review-cli.mjs +7 -2
- package/runtime/review-integration-v2.mjs +22 -7
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/installer-preflight.mjs +1 -1
- package/scripts/pi-update.mjs +113 -3
- package/scripts/run-test-suite.mjs +17 -1
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +2 -0
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner.test.ts +168 -3
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bridge-cost.test.ts +32 -0
- package/tests/bundled-install.test.ts +6 -4
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +69 -0
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +16 -2
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +5 -4
- package/tests/design-canvas-server.test.ts +6 -2
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +18 -10
- package/tests/fixtures/session-profile-v1/replay.ts +125 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/gentle-agents.test.ts +416 -21
- package/tests/gentle-ai-exploration-budget.test.ts +135 -0
- package/tests/gentle-ai.test.ts +1011 -37
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +76 -2
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-music.test.ts +36 -1
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +49 -26
- package/tests/gentle-shell-launcher.test.ts +18 -2
- package/tests/gentle-shell.test.ts +1068 -37
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +50 -4
- package/tests/herdr-task-summary-policy.test.ts +128 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/inprocess-reviewer.test.ts +122 -0
- package/tests/installer-posix-bootstrap.test.ts +67 -5
- package/tests/installer-server.test.ts +2 -2
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/nan-provider.test.ts +4 -4
- package/tests/no-self-pause-contract.test.ts +19 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-prompt-budget.test.ts +131 -0
- package/tests/package-manifest.test.ts +160 -7
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/persona-reply-language.test.ts +61 -0
- package/tests/pi-update-launcher.test.ts +32 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-tier-footer.test.ts +79 -0
- package/tests/questionnaire-view.test.ts +150 -0
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-view.test.ts +51 -0
- package/tests/review-controller-native-routing.test.ts +120 -6
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/run-test-suite.test.ts +61 -5
- package/tests/sensitive-path-tools.test.ts +74 -0
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +15 -0
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +221 -0
- package/tests/shell-bar.test.ts +113 -55
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +332 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +12 -0
- package/tests/shell-sidebar-layout.test.ts +159 -27
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +68 -1
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +57 -1
- package/tests/task-size-routing-contract.test.ts +45 -1
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +56 -5
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +61 -7
- package/tests/visual-customize-view.test.ts +253 -8
- package/tests/visual-layout-preview.test.ts +28 -0
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/work-continuity-contract.test.ts +86 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +30 -11
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +16 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { execFileSync, execFile } from "node:child_process";
|
|
3
|
-
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import test, { after, afterEach, type TestContext } from "node:test";
|
|
8
8
|
import { initTheme, type ExtensionAPI, type ExtensionContext, type SlashCommandInfo, type SourceInfo } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
import { CURSOR_MARKER, matchesKey, stripTerminalSequences as stripAnsi, TuiMainScreen, visibleWidth, type TUI, type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
9
|
+
import { CURSOR_MARKER, matchesKey, stripTerminalSequences as stripAnsi, TuiAltScreen, TuiMainScreen, VStack, visibleWidth, type Terminal, type TUI, type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
10
10
|
import installGentleShell, { backgroundChangeRefreshesSettled, buildShellBarModel, createActiveProfileReader, changesShortcut, devBinaryCard, extractQueuedText, fetchCodexUsage, fetchNanUsage, loadFileDiff, shellGitRunner, openInExternalEditor, usageShortcut, GentlePromptEditor } from "../extensions/gentle-shell.ts";
|
|
11
11
|
import { CODEX_USAGE_URL, NAN_QUOTA_URL, USAGE_SOURCE_EVENT, USAGE_SOURCE_SCHEMA } from "../lib/shell-usage.ts";
|
|
12
12
|
import { bindSessionProfile, clearSessionProfileBinding, resetSessionProfileBindingsForTesting } from "../lib/session-profile-binding.ts";
|
|
@@ -19,6 +19,7 @@ afterEach(() => resetFrozenInheritedProfilesForTesting());
|
|
|
19
19
|
import { buildCommandPaletteGroups } from "../lib/command-palette-catalog.ts";
|
|
20
20
|
import { CHANGE_STATUS, DIFF_MAX_BYTES, DIFF_MAX_LINES, DIFF_TOO_LARGE } from "../lib/shell-changes.ts";
|
|
21
21
|
import { sidebarPart, sidebarState, type SidebarRail } from "../lib/shell-sidebar.ts";
|
|
22
|
+
import { installSidebar } from "../lib/shell-sidebar-layout.ts";
|
|
22
23
|
import { renderTodoCard } from "../lib/shell-todo.ts";
|
|
23
24
|
import type { ShellBarTheme } from "../lib/shell-bar.ts";
|
|
24
25
|
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
@@ -26,7 +27,7 @@ import { decodeReviewStatusV3 } from "../lib/review-integration-v2.ts";
|
|
|
26
27
|
import { REVIEW_SIDEBAR_EVENT } from "../lib/review-sidebar-state.ts";
|
|
27
28
|
import { isJobsSidebarSnapshot } from "../lib/jobs-sidebar-state.ts";
|
|
28
29
|
import type { NativeReviewCli } from "../lib/native-review-cli.ts";
|
|
29
|
-
import { resolveVisualSettings, writeVisualSettings } from "../lib/visual-customization-policy.ts";
|
|
30
|
+
import { DEFAULT_VISUAL_SETTINGS, DENSITY, VISUAL_PRESET, VISUAL_SCHEMA, resolveVisualSettings, visualPresetOf, writeVisualSettings } from "../lib/visual-customization-policy.ts";
|
|
30
31
|
import { resolveAnimationPolicy } from "../lib/animation-policy.ts";
|
|
31
32
|
import { resolveVimPolicy, writeVimPolicy } from "../lib/vim-policy.ts";
|
|
32
33
|
import { resolveHistoryCapturePolicy, writeHistoryCapturePolicy } from "../lib/history-capture-policy.ts";
|
|
@@ -372,6 +373,108 @@ test("gentleShell installs the footer on session_start when a UI exists", () =>
|
|
|
372
373
|
assert.match(lines[0], /main ⟡ gpt-5\.5 · medium/);
|
|
373
374
|
});
|
|
374
375
|
|
|
376
|
+
test("session shutdown detaches the footer before a queued fullscreen render and reload", async (t) => {
|
|
377
|
+
const intervals: Array<{ tick: () => void; delay: number; stopped: boolean }> = [];
|
|
378
|
+
t.mock.method(globalThis, "setInterval", (tick: () => void, delay: number) => {
|
|
379
|
+
const timer = { tick, delay, stopped: false };
|
|
380
|
+
intervals.push(timer);
|
|
381
|
+
return { unref() {}, timer };
|
|
382
|
+
});
|
|
383
|
+
t.mock.method(globalThis, "clearInterval", (handle: { timer: (typeof intervals)[number] }) => { handle.timer.stopped = true; });
|
|
384
|
+
const old = fakePi();
|
|
385
|
+
const first = fakeContext();
|
|
386
|
+
const oldUi = first.ctx.ui;
|
|
387
|
+
const oldSession = first.ctx.sessionManager;
|
|
388
|
+
let oldLive = true;
|
|
389
|
+
let staleReads = 0;
|
|
390
|
+
Object.defineProperty(first.ctx, "ui", { configurable: true, get() {
|
|
391
|
+
if (!oldLive) { staleReads++; throw new Error("old extension context is stale"); }
|
|
392
|
+
return oldUi;
|
|
393
|
+
} });
|
|
394
|
+
Object.defineProperty(first.ctx, "sessionManager", { configurable: true, get() {
|
|
395
|
+
if (!oldLive) { staleReads++; throw new Error("old session is stale"); }
|
|
396
|
+
return oldSession;
|
|
397
|
+
} });
|
|
398
|
+
const state = { appearance: "light" };
|
|
399
|
+
const foreground = "\x1b[38;2;64;66;72m";
|
|
400
|
+
const theme = { ...plainTheme, get appearance() { return state.appearance; }, getFgAnsi: () => foreground, getColorMode: () => "truecolor" };
|
|
401
|
+
(oldUi as unknown as { theme: typeof theme }).theme = theme;
|
|
402
|
+
// The provider is deliberately inert: this lifecycle test makes no network calls.
|
|
403
|
+
(first.ctx as unknown as { model: { provider: string } }).model.provider = "test";
|
|
404
|
+
const deps = { activeProfile: () => undefined };
|
|
405
|
+
gentleShell(old.pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, deps);
|
|
406
|
+
const frames: string[] = [];
|
|
407
|
+
let mounted: { render(width: number): string[]; dispose(): void } | undefined;
|
|
408
|
+
let mountedWidget: { render(width: number): string[] } | undefined;
|
|
409
|
+
const tui = {
|
|
410
|
+
mode: "fullscreen",
|
|
411
|
+
terminal: { rows: 40, columns: 160 },
|
|
412
|
+
requestRender() {},
|
|
413
|
+
applyLineResets: (lines: string[]) => lines.map((line) => `${line}\x1b[0m`),
|
|
414
|
+
doRender() { frames.push(this.applyLineResets(["hi"])[0]!); mounted?.render(160); mountedWidget?.render(160); },
|
|
415
|
+
};
|
|
416
|
+
let unsubscribed = 0;
|
|
417
|
+
const data = { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => { unsubscribed++; } };
|
|
418
|
+
const installFooter = (ui: FakeUi) => (ui.footerFactory as (host: unknown, theme: ShellBarTheme, data: unknown) => NonNullable<typeof mounted>)(tui, theme, data);
|
|
419
|
+
let oldFooter: NonNullable<typeof mounted> | undefined;
|
|
420
|
+
let fresh: ReturnType<typeof fakePi> | undefined;
|
|
421
|
+
let second: ReturnType<typeof fakeContext> | undefined;
|
|
422
|
+
let freshFooter: NonNullable<typeof mounted> | undefined;
|
|
423
|
+
let freshStopped = false;
|
|
424
|
+
try {
|
|
425
|
+
await fire(old.handlers, "session_start", first.ctx);
|
|
426
|
+
oldFooter = mounted = installFooter(first.ui);
|
|
427
|
+
mountedWidget = (first.ui.widgets.get("gentle-shell-below-input-header") as () => NonNullable<typeof mountedWidget>)();
|
|
428
|
+
const jobsTimer = intervals.find((timer) => timer.delay === 1000);
|
|
429
|
+
const sidebarTimer = intervals.find((timer) => timer.delay === 100);
|
|
430
|
+
assert.ok(jobsTimer);
|
|
431
|
+
assert.ok(sidebarTimer);
|
|
432
|
+
tui.doRender();
|
|
433
|
+
assert.ok(frames.at(-1)!.startsWith("\x1b[48;2;"), "the old fullscreen light theme paints");
|
|
434
|
+
const queuedRender = () => tui.doRender(); // The real scheduled callback resolves the host method when it runs.
|
|
435
|
+
await fire(old.handlers, "session_shutdown", first.ctx);
|
|
436
|
+
oldLive = false;
|
|
437
|
+
assert.doesNotThrow(queuedRender, "the queued frame cannot touch an invalidated context");
|
|
438
|
+
assert.equal(staleReads, 0);
|
|
439
|
+
assert.equal(frames.at(-1), "hi\x1b[0m", "the frame after shutdown is unpainted");
|
|
440
|
+
assert.equal(jobsTimer.stopped, true, "shutdown stops the footer's jobs interval");
|
|
441
|
+
assert.equal(sidebarTimer.stopped, true, "shutdown stops the sidebar attachment interval");
|
|
442
|
+
assert.equal(unsubscribed, 1, "shutdown disposes the native footer subscription once");
|
|
443
|
+
|
|
444
|
+
fresh = fakePi();
|
|
445
|
+
second = fakeContext();
|
|
446
|
+
(second.ctx as unknown as { model: { provider: string } }).model.provider = "test";
|
|
447
|
+
(second.ctx.ui as unknown as { theme: typeof theme }).theme = theme;
|
|
448
|
+
gentleShell(fresh.pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, deps);
|
|
449
|
+
await fire(fresh.handlers, "session_start", second.ctx);
|
|
450
|
+
freshFooter = mounted = installFooter(second.ui);
|
|
451
|
+
mountedWidget = (second.ui.widgets.get("gentle-shell-below-input-header") as () => NonNullable<typeof mountedWidget>)();
|
|
452
|
+
tui.mode = "regular";
|
|
453
|
+
tui.doRender();
|
|
454
|
+
assert.equal(frames.at(-1), "hi\x1b[0m", "regular mode keeps the terminal background");
|
|
455
|
+
tui.mode = "fullscreen";
|
|
456
|
+
tui.doRender();
|
|
457
|
+
assert.ok(frames.at(-1)!.startsWith(`\x1b[48;2;243;242;241m${foreground}`), "the replacement paints its own light theme");
|
|
458
|
+
oldFooter.dispose();
|
|
459
|
+
oldFooter.dispose();
|
|
460
|
+
state.appearance = "dark";
|
|
461
|
+
tui.doRender();
|
|
462
|
+
assert.equal(frames.at(-1), "hi\x1b[0m", "the replacement still follows a dark switch");
|
|
463
|
+
state.appearance = "light";
|
|
464
|
+
tui.doRender();
|
|
465
|
+
assert.ok(frames.at(-1)!.startsWith("\x1b[48;2;"), "late old disposal cannot remove the new paint");
|
|
466
|
+
assert.equal(staleReads, 0);
|
|
467
|
+
assert.equal(unsubscribed, 1);
|
|
468
|
+
await fire(fresh.handlers, "session_shutdown", second.ctx);
|
|
469
|
+
freshStopped = true;
|
|
470
|
+
} finally {
|
|
471
|
+
oldLive = true;
|
|
472
|
+
oldFooter?.dispose();
|
|
473
|
+
if (fresh && second && !freshStopped) await fire(fresh.handlers, "session_shutdown", second.ctx);
|
|
474
|
+
freshFooter?.dispose();
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
|
|
375
478
|
async function reviewSidebarHarness() {
|
|
376
479
|
const { pi, handlers, tools } = fakePi();
|
|
377
480
|
gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { activeProfile: () => undefined });
|
|
@@ -518,21 +621,24 @@ test("jobs snapshots feed their own rail card, keep one compact fallback, and re
|
|
|
518
621
|
const rail = state.parts.get("footer")!;
|
|
519
622
|
const jobs = state.parts.get("jobs")!;
|
|
520
623
|
const header = state.parts.get("header")!;
|
|
624
|
+
// Mobile keeps the running-job count in its status bar: no rail lists jobs there.
|
|
625
|
+
const statusbar = state.parts.get("statusbar")!;
|
|
626
|
+
state.layoutAttached = () => true; // installSidebar sets this on a real fullscreen root
|
|
521
627
|
const publish = (sessionId: string, jobs: unknown) => pi.events.emit("gentle-ai:jobs-sidebar", { sessionId, snapshot: { jobs } });
|
|
522
628
|
try {
|
|
523
629
|
publish("shell-session", [{ id: "job-1", label: "CI for PR 1860", startedAt: 1 }]);
|
|
524
630
|
assert.doesNotMatch(rail.render(46).join("\n"), /Jobs|CI for PR 1860/, "the Status card never prints jobs; the jobs card owns them");
|
|
525
631
|
assert.match(rail.render(46).join("\n"), /MCP: 3 servers/);
|
|
526
|
-
assert.match(jobs.render(46).join("\n"),
|
|
632
|
+
assert.match(jobs.render(46).join("\n"), /▾ JOBS[\s\S]*CI for PR 1860/);
|
|
527
633
|
publish("shell-session", [{ id: "job-1", label: "CI for PR 1860", startedAt: 1 }, { id: "job-0", label: "Build runtime", startedAt: 1, status: "exited", endedAt: Date.now(), exitCode: 0 }]);
|
|
528
634
|
assert.match(jobs.render(60).join("\n"), /1 running · 1 finished/, "finished tails ride the same snapshot");
|
|
529
|
-
assert.match(jobs.render(60).join("\n"),
|
|
635
|
+
assert.match(jobs.render(60).join("\n"), /✓ \S+ Build runtime/);
|
|
530
636
|
// The compact count is running-only: a finished tail still paints the
|
|
531
637
|
// card, but the header's ⧗ N jobs derives from running entries alone.
|
|
532
638
|
publish("shell-session", [{ id: "job-2", label: "Fresh tail", startedAt: 1, status: "exited", endedAt: Date.now(), exitCode: 0 }]);
|
|
533
639
|
tui.terminal.columns = 80;
|
|
534
640
|
assert.match(jobs.render(46).join("\n"), /Fresh tail/, "the finished tail still paints the card");
|
|
535
|
-
assert.doesNotMatch(
|
|
641
|
+
assert.doesNotMatch(statusbar.render(80).join("\n"), /⧗ 1 job/, "the compact count is running-only");
|
|
536
642
|
tui.terminal.columns = 160;
|
|
537
643
|
publish("shell-session", [{ id: "job-0", label: "Stale tail", startedAt: 1, status: "exited", endedAt: 5, exitCode: 0 }]);
|
|
538
644
|
assert.doesNotMatch(jobs.render(46).join("\n"), /Stale tail/, "a finished job past the TTL paints nothing");
|
|
@@ -540,23 +646,25 @@ test("jobs snapshots feed their own rail card, keep one compact fallback, and re
|
|
|
540
646
|
state.active = true;
|
|
541
647
|
state.ownsHost = () => true;
|
|
542
648
|
assert.doesNotMatch(header.render(160).join("\n"), /1 job/, "the visible rail owns job details");
|
|
649
|
+
assert.doesNotMatch(statusbar.render(160).join("\n"), /1 job/, "the wide status bar leaves jobs to the rail");
|
|
543
650
|
state.active = false;
|
|
544
651
|
tui.terminal.columns = 80;
|
|
545
652
|
publish("shell-session", [{ id: "job-1", label: "CI for PR 1860", startedAt: 1 }]);
|
|
546
|
-
assert.match(
|
|
653
|
+
assert.match(statusbar.render(80).join("\n"), /1 job/, "the mobile status bar preserves the count of a running job");
|
|
547
654
|
const before = jobs.render(46).join("\n");
|
|
548
655
|
publish("foreign", []);
|
|
549
656
|
publish("shell-session", [{ label: "invalid" }]);
|
|
550
657
|
assert.equal(jobs.render(46).join("\n"), before);
|
|
551
658
|
publish("shell-session", []);
|
|
552
659
|
assert.doesNotMatch(jobs.render(46).join("\n"), /Jobs|CI for PR/);
|
|
553
|
-
assert.doesNotMatch(
|
|
660
|
+
assert.doesNotMatch(statusbar.render(80).join("\n"), /1 job/);
|
|
554
661
|
publish("shell-session", [{ id: "job-2", label: "Build runtime", startedAt: 2 }]);
|
|
555
662
|
await fire(handlers, "session_start", ctx);
|
|
556
663
|
assert.doesNotMatch(state.parts.get("jobs")!.render(46).join("\n"), /Build runtime/);
|
|
557
664
|
await fire(handlers, "session_shutdown", ctx);
|
|
665
|
+
assert.equal(state.parts.has("jobs"), false, "shutdown removes the footer-owned jobs rail");
|
|
558
666
|
publish("shell-session", [{ id: "job-3", label: "late", startedAt: 3 }]);
|
|
559
|
-
assert.doesNotMatch(
|
|
667
|
+
assert.doesNotMatch(jobs.render(46).join("\n"), /late/, "shutdown also unsubscribes the jobs consumer");
|
|
560
668
|
} finally { component.dispose(); }
|
|
561
669
|
});
|
|
562
670
|
|
|
@@ -593,7 +701,7 @@ test("hidden Status leaves only a jobs count in regular bottom and fullscreen he
|
|
|
593
701
|
} finally { component.dispose(); await fire(handlers, "session_shutdown", ctx); }
|
|
594
702
|
});
|
|
595
703
|
|
|
596
|
-
test("the fullscreen Status rail
|
|
704
|
+
test("the fullscreen Status rail and header refresh the effective agent profile together", async () => {
|
|
597
705
|
const { pi, handlers } = fakePi();
|
|
598
706
|
let profile: string | undefined = "team";
|
|
599
707
|
gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { activeProfile: () => profile });
|
|
@@ -611,13 +719,20 @@ test("the fullscreen Status rail carries a live digest so a profile switch refre
|
|
|
611
719
|
assert.equal(typeof rail.digest, "function", "the Status card paints live state and must declare a digest");
|
|
612
720
|
assert.doesNotMatch(rail.render(46).join("\n"), /gpt-5\.5/, "model now lives in the header, not the Status card");
|
|
613
721
|
|
|
614
|
-
|
|
615
|
-
const
|
|
722
|
+
// Integrations exposes the same effective agent profile as the header.
|
|
723
|
+
const header = sidebarState(tui as unknown as TUI).parts.get("header") as SidebarRail;
|
|
724
|
+
assert.match(rail.render(46).join("\n"), /Agent profile: team/);
|
|
725
|
+
assert.match(header.render(160).join("\n"), /team/);
|
|
726
|
+
const beforeProfile = header.digest?.();
|
|
727
|
+
const beforeRailProfile = live();
|
|
616
728
|
profile = "other";
|
|
617
|
-
assert.notEqual(
|
|
618
|
-
assert.
|
|
729
|
+
assert.notEqual(header.digest?.(), beforeProfile, "a profile switch changes the header digest");
|
|
730
|
+
assert.notEqual(live(), beforeRailProfile, "a profile switch changes the Status digest");
|
|
731
|
+
assert.match(header.render(160).join("\n"), /other/);
|
|
732
|
+
assert.match(rail.render(46).join("\n"), /Agent profile: other/);
|
|
619
733
|
profile = undefined;
|
|
620
|
-
assert.doesNotMatch(
|
|
734
|
+
assert.doesNotMatch(header.render(160).join("\n"), /team|other/);
|
|
735
|
+
assert.doesNotMatch(rail.render(46).join("\n"), /Agent profile:/);
|
|
621
736
|
|
|
622
737
|
const beforeStatus = live();
|
|
623
738
|
statuses.set("mcp", "MCP: 3 servers enabled");
|
|
@@ -802,17 +917,17 @@ test("profile polling refreshes both fullscreen surfaces only on change and stop
|
|
|
802
917
|
try {
|
|
803
918
|
const timer = intervals.find((entry) => entry.delay === 2000);
|
|
804
919
|
assert.ok(timer, "UI session installs the 2000ms profile refresh");
|
|
805
|
-
assert.match(status(), /
|
|
920
|
+
assert.match(status(), /Agent profile: team/, "Integrations shows the effective agent profile");
|
|
806
921
|
assert.match(header(), /team/);
|
|
807
922
|
const before = tui.requestRender.mock.callCount();
|
|
808
923
|
timer.tick();
|
|
809
924
|
assert.equal(tui.requestRender.mock.callCount(), before, "unchanged poll does not render");
|
|
810
925
|
writeFileSync(local, JSON.stringify({ kind: "gentle-pi.agent_model_profile_pin", version: 1, profile: "other" }));
|
|
811
|
-
assert.match(
|
|
926
|
+
assert.match(header(), /team/, "external edits do not read during render");
|
|
812
927
|
timer.tick();
|
|
813
928
|
assert.equal(tui.requestRender.mock.callCount(), before + 1);
|
|
814
|
-
assert.match(status(), /Profile.*other \(local\)/);
|
|
815
929
|
assert.match(header(), /other \(local\)/);
|
|
930
|
+
assert.match(status(), /Agent profile: other \(local\)/, "profile polling also refreshes Integrations");
|
|
816
931
|
timer.tick();
|
|
817
932
|
assert.equal(tui.requestRender.mock.callCount(), before + 1);
|
|
818
933
|
const afterBind = resolutions;
|
|
@@ -828,8 +943,9 @@ test("profile polling refreshes both fullscreen surfaces only on change and stop
|
|
|
828
943
|
assert.equal(tui.requestRender.mock.callCount(), before + 1, "old session cannot repaint");
|
|
829
944
|
await fire(handlers, "session_shutdown", second.ctx);
|
|
830
945
|
assert.equal(replacement.stopped, true);
|
|
946
|
+
const afterShutdown = tui.requestRender.mock.callCount();
|
|
831
947
|
replacement.tick();
|
|
832
|
-
assert.equal(tui.requestRender.mock.callCount(),
|
|
948
|
+
assert.equal(tui.requestRender.mock.callCount(), afterShutdown, "a stopped poll cannot repaint after footer teardown");
|
|
833
949
|
} finally {
|
|
834
950
|
component.dispose();
|
|
835
951
|
}
|
|
@@ -852,6 +968,169 @@ const fakeTui = { terminal: { rows: 40, columns: 120 }, requestRender() {} };
|
|
|
852
968
|
const editorTheme = { borderColor: (text: string) => text, selectList: {} };
|
|
853
969
|
const fakeKeybindings = { matches: () => false };
|
|
854
970
|
|
|
971
|
+
test("panel control owns its rendered mouse cells across top rows and Vim modes", () => {
|
|
972
|
+
for (const vim of [false, true]) {
|
|
973
|
+
const tui = fakeTui;
|
|
974
|
+
let opens = 0;
|
|
975
|
+
const fg = (role: string, text: string) => `\x1b[38;5;${role === "warning" ? 208 : role === "accent" ? 30 : 245}m${text}\x1b[39m`;
|
|
976
|
+
const topRows = vim ? ["work", "alert"] : [];
|
|
977
|
+
const editor = new GentlePromptEditor(tui as never, editorTheme as never, fakeKeybindings as never, {
|
|
978
|
+
fg, bold: (text) => text, requestRender() {}, pending: () => false, now: () => 0,
|
|
979
|
+
doubleEscCancelEnabled: () => false, dispatchQueuedText() {}, tuiVersion: () => INSTALLED_PI,
|
|
980
|
+
panelChrome: () => true, topRows: () => topRows, onPanelClick: () => { opens++; },
|
|
981
|
+
});
|
|
982
|
+
try {
|
|
983
|
+
if (vim) editor.setVimPolicy("on");
|
|
984
|
+
editor.setText("draft");
|
|
985
|
+
const before = editor.getCursor();
|
|
986
|
+
const rule = topRows.length;
|
|
987
|
+
const initial = editor.render(80);
|
|
988
|
+
const start = stripAnsi(initial[rule]!).indexOf("[ Panel ]");
|
|
989
|
+
assert.ok(start >= 0, "the no-work prompt always shows a Panel control");
|
|
990
|
+
if (vim) assert.match(stripAnsi(initial[rule]!), /\[ Panel \].*INSERT/);
|
|
991
|
+
const event = (type: TuiMouseEvent["type"], button: TuiMouseEvent["button"], x: number, y = rule): TuiMouseEvent => ({ type, button, x, y, screenX: x + 10, screenY: y + 20, width: 80, height: initial.length, shift: false, alt: false, ctrl: false });
|
|
992
|
+
editor.handleMouse(event("click", "right", start));
|
|
993
|
+
editor.handleMouse(event("click", "left", start - 1));
|
|
994
|
+
editor.handleMouse({ ...event("click", "left", start), width: 79 });
|
|
995
|
+
assert.equal(opens, 0);
|
|
996
|
+
assert.deepEqual(editor.getCursor(), before, "non-button rule clicks never move the editor");
|
|
997
|
+
editor.handleMouse(event("move", "none", start));
|
|
998
|
+
assert.ok(editor.render(80)[rule]!.includes("\x1b[38;5;208m[ Panel ]\x1b[39m"));
|
|
999
|
+
editor.handleMouse(event("move", "none", start - 1));
|
|
1000
|
+
assert.ok(editor.render(80)[rule]!.includes("\x1b[38;5;30m[ Panel ]\x1b[39m"));
|
|
1001
|
+
editor.handleMouse(event("move", "none", start));
|
|
1002
|
+
editor.invalidate();
|
|
1003
|
+
assert.ok(editor.render(80)[rule]!.includes("\x1b[38;5;30m[ Panel ]\x1b[39m"), "invalidation clears hover");
|
|
1004
|
+
assert.equal(editor.handleMouse(event("press", "left", start))?.handled, true, "the native press owns the click gesture");
|
|
1005
|
+
for (const x of [start, start + "[ Panel ]".length - 1]) editor.handleMouse(event("click", "left", x));
|
|
1006
|
+
assert.equal(opens, 2, "both rendered bracket cells activate the control");
|
|
1007
|
+
assert.deepEqual(editor.getCursor(), before, "button clicks never move the editor");
|
|
1008
|
+
} finally { editor.dispose(); }
|
|
1009
|
+
}
|
|
1010
|
+
const regular = new GentlePromptEditor(fakeTui as never, editorTheme as never, fakeKeybindings as never, {
|
|
1011
|
+
fg: (_role, text) => text, bold: (text) => text, requestRender() {}, pending: () => false, now: () => 0,
|
|
1012
|
+
doubleEscCancelEnabled: () => false, dispatchQueuedText() {}, panelChrome: () => false, onPanelClick() { throw new Error("regular mode cannot open the button"); },
|
|
1013
|
+
});
|
|
1014
|
+
try { assert.doesNotMatch(regular.render(80).join("\n"), /\[ Panel \]/); }
|
|
1015
|
+
finally { regular.dispose(); }
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
test("editor hover reports rendering on entry but not repeated motion", () => {
|
|
1019
|
+
let renders = 0;
|
|
1020
|
+
const editor = new GentlePromptEditor(fakeTui as never, editorTheme as never, fakeKeybindings as never, {
|
|
1021
|
+
fg: (_role, text) => text, bold: (text) => text, requestRender() { renders++; }, pending: () => false, now: () => 0,
|
|
1022
|
+
doubleEscCancelEnabled: () => false, dispatchQueuedText() {}, panelChrome: () => true,
|
|
1023
|
+
topRows: () => ["work"], onPanelClick() {},
|
|
1024
|
+
});
|
|
1025
|
+
try {
|
|
1026
|
+
const rows = editor.render(80);
|
|
1027
|
+
const event = (x: number, y: number): TuiMouseEvent => ({ type: "move", button: "none", x, y, screenX: x, screenY: y, width: 80, height: rows.length, shift: false, alt: false, ctrl: false });
|
|
1028
|
+
assert.deepEqual(editor.handleMouse(event(3, 0)), { handled: true, render: true }, "first work-row hover requests a render");
|
|
1029
|
+
const afterWork = renders;
|
|
1030
|
+
assert.deepEqual(editor.handleMouse(event(3, 0)), { handled: true });
|
|
1031
|
+
assert.equal(renders, afterWork, "repeated work-row motion does not repaint");
|
|
1032
|
+
const x = stripAnsi(rows[1]!).indexOf("[ Panel ]");
|
|
1033
|
+
assert.deepEqual(editor.handleMouse(event(x, 1)), { handled: true, render: true }, "entering Panel requests a render");
|
|
1034
|
+
const afterPanel = renders;
|
|
1035
|
+
assert.deepEqual(editor.handleMouse(event(x, 1)), { handled: true });
|
|
1036
|
+
assert.equal(renders, afterPanel, "repeated Panel motion does not repaint");
|
|
1037
|
+
} finally { editor.dispose(); }
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
test("fullscreen mouse dispatch clears Panel hover after leaving the editor", () => {
|
|
1041
|
+
let input: ((data: string) => void) | undefined;
|
|
1042
|
+
const terminal: Terminal = {
|
|
1043
|
+
start(onInput) { input = onInput; }, stop() {}, async drainInput() {}, write() {}, columns: 80, rows: 24, kittyProtocolActive: false,
|
|
1044
|
+
moveBy() {}, hideCursor() {}, showCursor() {}, clearLine() {}, clearFromCursor() {}, clearScreen() {}, setTitle() {}, setProgress() {}, setProgramStatus() {},
|
|
1045
|
+
};
|
|
1046
|
+
const tui = new TuiAltScreen(terminal, false, undefined, { mouse: true });
|
|
1047
|
+
const fg = (role: string, text: string) => `\x1b[38;5;${role === "warning" ? 208 : role === "accent" ? 30 : 245}m${text}\x1b[39m`;
|
|
1048
|
+
let opens = 0;
|
|
1049
|
+
const editor = new GentlePromptEditor(tui, editorTheme as never, fakeKeybindings as never, {
|
|
1050
|
+
fg, bold: (text) => text, requestRender: () => tui.requestRender(), pending: () => false, now: () => 0,
|
|
1051
|
+
doubleEscCancelEnabled: () => false, dispatchQueuedText() {}, panelChrome: () => true, onPanelClick() { opens++; },
|
|
1052
|
+
});
|
|
1053
|
+
const outside = { render: () => ["outside"], invalidate() {} };
|
|
1054
|
+
tui.setLayoutRoot(new VStack([editor, outside]));
|
|
1055
|
+
const uninstall = installSidebar(tui, plainTheme);
|
|
1056
|
+
tui.start();
|
|
1057
|
+
try {
|
|
1058
|
+
tui.renderNow(true);
|
|
1059
|
+
const x = stripAnsi(editor.render(80)[0]!).indexOf("[ Panel ]");
|
|
1060
|
+
const cursor = editor.getCursor();
|
|
1061
|
+
input?.(`\x1b[<0;${x + 1};1M`);
|
|
1062
|
+
input?.(`\x1b[<0;${x + 1};1m`);
|
|
1063
|
+
assert.equal(opens, 1, "native primary press and release open the panel");
|
|
1064
|
+
assert.deepEqual(editor.getCursor(), cursor);
|
|
1065
|
+
input?.(`\x1b[<35;${x + 1};1M`);
|
|
1066
|
+
assert.ok(editor.render(80)[0]!.includes("\x1b[38;5;208m[ Panel ]\x1b[39m"), "native motion enters the control");
|
|
1067
|
+
input?.("\x1b[<35;1;4M");
|
|
1068
|
+
assert.ok(editor.render(80)[0]!.includes("\x1b[38;5;30m[ Panel ]\x1b[39m"), "native motion into a sibling clears hover");
|
|
1069
|
+
} finally { uninstall(); editor.dispose(); tui.stop(); }
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
test("installed sidebar clears mobile Panel hover on unhandled native transcript motion", () => {
|
|
1073
|
+
let input: ((data: string) => void) | undefined;
|
|
1074
|
+
const terminal: Terminal = {
|
|
1075
|
+
start(onInput) { input = onInput; }, stop() {}, async drainInput() {}, write() {}, columns: 80, rows: 24, kittyProtocolActive: false,
|
|
1076
|
+
moveBy() {}, hideCursor() {}, showCursor() {}, clearLine() {}, clearFromCursor() {}, clearScreen() {}, setTitle() {}, setProgress() {}, setProgramStatus() {},
|
|
1077
|
+
};
|
|
1078
|
+
const tui = new TuiAltScreen(terminal, false, undefined, { mouse: true });
|
|
1079
|
+
const fg = (role: string, text: string) => `\x1b[38;5;${role === "warning" ? 208 : role === "accent" ? 30 : 245}m${text}\x1b[39m`;
|
|
1080
|
+
const editor = new GentlePromptEditor(tui, editorTheme as never, fakeKeybindings as never, {
|
|
1081
|
+
fg, bold: (text) => text, requestRender: () => tui.requestRender(), pending: () => false, now: () => 0,
|
|
1082
|
+
doubleEscCancelEnabled: () => false, dispatchQueuedText() {}, panelChrome: () => true, onPanelClick() {},
|
|
1083
|
+
});
|
|
1084
|
+
const outside = { render: () => ["transcript"], invalidate() {} };
|
|
1085
|
+
tui.setLayoutRoot(new VStack([editor, outside]));
|
|
1086
|
+
const uninstall = installSidebar(tui, plainTheme);
|
|
1087
|
+
tui.start();
|
|
1088
|
+
try {
|
|
1089
|
+
tui.renderNow(true);
|
|
1090
|
+
const x = stripAnsi(editor.render(80)[0]!).indexOf("[ Panel ]");
|
|
1091
|
+
input?.(`\x1b[<35;${x + 1};1M`);
|
|
1092
|
+
assert.ok(editor.render(80)[0]!.includes("\x1b[38;5;208m[ Panel ]\x1b[39m"));
|
|
1093
|
+
input?.("\x1b[<35;1;4M");
|
|
1094
|
+
assert.ok(editor.render(80)[0]!.includes("\x1b[38;5;30m[ Panel ]\x1b[39m"), "unhandled transcript motion clears the hover");
|
|
1095
|
+
} finally { uninstall(); editor.dispose(); tui.stop(); }
|
|
1096
|
+
});
|
|
1097
|
+
|
|
1098
|
+
test("installed fullscreen Panel button opens the panel sheet with no live work", async () => {
|
|
1099
|
+
const previousStyle = cardStyle();
|
|
1100
|
+
const { pi, handlers } = fakePi();
|
|
1101
|
+
installGentleShell(pi, { GENTLE_PI_CONFIG_HOME: "/dev/null" }, {
|
|
1102
|
+
activeProfile: () => undefined, resolveWorktree: () => undefined, rootExists: () => false,
|
|
1103
|
+
gitRunner: () => async () => ({ stdout: "", stderr: "", code: 0 }),
|
|
1104
|
+
fetch: async () => { throw new Error("network forbidden in test"); },
|
|
1105
|
+
});
|
|
1106
|
+
const { ctx, ui } = fakeContext();
|
|
1107
|
+
const tui = { ...fakeTui, mode: "fullscreen", terminal: { rows: 24, columns: 80 } };
|
|
1108
|
+
try {
|
|
1109
|
+
await fire(handlers, "session_start", ctx);
|
|
1110
|
+
const state = sidebarState(tui as unknown as TUI);
|
|
1111
|
+
state.layoutAttached = () => true;
|
|
1112
|
+
const factory = ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor;
|
|
1113
|
+
const editor = factory(tui, editorTheme, fakeKeybindings);
|
|
1114
|
+
try {
|
|
1115
|
+
const rows = editor.render(80);
|
|
1116
|
+
const x = stripAnsi(rows[0]!).indexOf("[ Panel ]");
|
|
1117
|
+
assert.ok(x >= 0, "the button is visible without agents or todos");
|
|
1118
|
+
editor.handleMouse({ type: "click", button: "left", x, y: 0, screenX: x, screenY: 0, width: 80, height: rows.length, shift: false, alt: false, ctrl: false });
|
|
1119
|
+
assert.ok(ui.overlayView, "the click opens the panel sheet");
|
|
1120
|
+
assert.match(stripAnsi(ui.overlayView!.render(80).join("\n")), /PANEL/i);
|
|
1121
|
+
ui.closeOverlay?.();
|
|
1122
|
+
tui.terminal.columns = 160;
|
|
1123
|
+
state.active = true;
|
|
1124
|
+
state.ownsHost = () => true;
|
|
1125
|
+
const wide = editor.render(107);
|
|
1126
|
+
assert.doesNotMatch(stripAnsi(wide[0]!), /\[ Panel \]/, "desktop editor must not offer the mobile Panel control");
|
|
1127
|
+
} finally { editor.dispose(); }
|
|
1128
|
+
} finally {
|
|
1129
|
+
await fire(handlers, "session_shutdown", ctx);
|
|
1130
|
+
setCardStyle(previousStyle);
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
|
|
855
1134
|
function installedPrompt(
|
|
856
1135
|
ctx: ExtensionContext,
|
|
857
1136
|
ui: FakeUi,
|
|
@@ -2108,12 +2387,37 @@ test("visual customization and Vim register once and remain independently discov
|
|
|
2108
2387
|
await commands.get("gentle:vim")!.handler("enable", ctx);
|
|
2109
2388
|
const pending = commands.get("gentle:customize")!.handler("", ctx);
|
|
2110
2389
|
await overlayReady;
|
|
2111
|
-
assert.ok(ui.overlayView!.render(90).some((row) =>
|
|
2390
|
+
assert.ok(ui.overlayView!.render(90).some((row) => /Animations\s+● quality/.test(row)));
|
|
2112
2391
|
ui.overlayView!.handleInput("\x1b");
|
|
2113
2392
|
await pending;
|
|
2114
2393
|
assert.equal(JSON.parse(readFileSync(join(home, "vim.json"), "utf8")).policy, "on");
|
|
2115
2394
|
});
|
|
2116
2395
|
|
|
2396
|
+
test("/gentle:customize has a Keymaps category that saves a key and reloads on request", async () => {
|
|
2397
|
+
const home = mkdtempSync(join(tmpdir(), "gentle-shell-keymaps-"));
|
|
2398
|
+
isolatedConfigHomes.push(home);
|
|
2399
|
+
const { pi, commands } = fakePi();
|
|
2400
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
2401
|
+
const { ctx, ui, overlayReady } = fakeContext();
|
|
2402
|
+
let reloads = 0;
|
|
2403
|
+
(ctx as unknown as { reload(): Promise<void> }).reload = async () => { reloads += 1; };
|
|
2404
|
+
const pending = commands.get("gentle:customize")!.handler("", ctx);
|
|
2405
|
+
await overlayReady;
|
|
2406
|
+
const view = ui.overlayView as unknown as { render(width: number): string[]; handleInput(data: string): void; focus(label: string): boolean };
|
|
2407
|
+
assert.ok(view.focus("Command palette: alt+k"));
|
|
2408
|
+
assert.match(view.render(100).join("\n"), /Enter assign · ⌫ disable · r default · Esc close/);
|
|
2409
|
+
view.handleInput("\r");
|
|
2410
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2411
|
+
view.handleInput("\x1bj");
|
|
2412
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2413
|
+
assert.deepEqual(JSON.parse(readFileSync(join(home, "keymaps.json"), "utf8")).bindings, { commands: "alt+j" });
|
|
2414
|
+
assert.equal(ui.notices.at(-1), "Command palette: alt+j. Run /reload to apply it.");
|
|
2415
|
+
assert.ok(view.focus("Reload now to apply keymap changes"));
|
|
2416
|
+
view.handleInput("\r");
|
|
2417
|
+
await pending;
|
|
2418
|
+
assert.equal(reloads, 1, "the customize card closes, then Pi reloads");
|
|
2419
|
+
});
|
|
2420
|
+
|
|
2117
2421
|
test(`actual Pi ${INSTALLED_PI} enables a live prompt and enters NORMAL without a compatibility fallback`, async () => {
|
|
2118
2422
|
assert.ok(isAuditedPiEditorVersion(INSTALLED_PI), `actual installed Pi ${INSTALLED_PI} must be audited`);
|
|
2119
2423
|
const configHome = mkdtempSync(join(tmpdir(), "gentle-vim-shell-"));
|
|
@@ -3131,6 +3435,13 @@ function scopedDoubleEscCancelConfigHome(t: { after(callback: () => void): void
|
|
|
3131
3435
|
|
|
3132
3436
|
function findCustomizeRow(ui: FakeUi, label: string, width = 90): boolean {
|
|
3133
3437
|
const view = ui.overlayView!;
|
|
3438
|
+
// Choices of a setting apply on ←/→, so walking to one would apply it: focus selects without applying.
|
|
3439
|
+
const focus = (view as unknown as { focus?(label: string): boolean }).focus;
|
|
3440
|
+
if (typeof focus === "function") {
|
|
3441
|
+
const found = focus.call(view, label);
|
|
3442
|
+
view.render(width);
|
|
3443
|
+
return found;
|
|
3444
|
+
}
|
|
3134
3445
|
view.handleInput("\x1b[D");
|
|
3135
3446
|
for (let category = 0; category < 11; category++) {
|
|
3136
3447
|
view.handleInput("\x1b[C");
|
|
@@ -3183,12 +3494,15 @@ test("customize Notifications applies audio controls directly in the same overla
|
|
|
3183
3494
|
assert.equal(settled, false, "the overlay never closes to open a panel");
|
|
3184
3495
|
// Per-event exceptions stay folded until Advanced is expanded in the same overlay.
|
|
3185
3496
|
assert.ok(findCustomizeRow(ui, "Advanced:"), "Advanced toggle is a direct row");
|
|
3497
|
+
ui.overlayView!.handleInput("\x1b[C");
|
|
3186
3498
|
assert.doesNotMatch(ui.overlayView!.render(90).join("\n"), /agent\.failed:/, "per-event rows stay folded by default");
|
|
3187
3499
|
ui.overlayView!.handleInput("\r");
|
|
3188
3500
|
// Let the toggle's busy microtask settle before activating a revealed row.
|
|
3189
3501
|
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
3190
3502
|
const notices = ui.notices.length;
|
|
3191
3503
|
assert.ok(findCustomizeRow(ui, "agent.failed:"));
|
|
3504
|
+
for (let i = 0; i < 3; i++) ui.overlayView!.handleInput("\x1b[C");
|
|
3505
|
+
assert.equal(writes, 0, "navigation never saves a sound");
|
|
3192
3506
|
ui.overlayView!.handleInput("\r");
|
|
3193
3507
|
for (let attempt = 0; attempt < 100 && ui.notices.length === notices; attempt++) await new Promise<void>((resolve) => setTimeout(resolve, 5));
|
|
3194
3508
|
assert.ok(ui.notices.length > notices, "direct Enter action finished");
|
|
@@ -3236,7 +3550,7 @@ test("customize History rows persist prompt history capture and keep stored hist
|
|
|
3236
3550
|
const pending = commands.get("gentle:customize")!.handler("", ctx);
|
|
3237
3551
|
await overlayReady;
|
|
3238
3552
|
assert.ok(findCustomizeRow(ui, "Prompt history capture: enable"));
|
|
3239
|
-
assert.match(ui.overlayView!.render(90).join("\n"), /History · 1\/
|
|
3553
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /History · 1\/1/);
|
|
3240
3554
|
assert.match(ui.overlayView!.render(90).join("\n"), /Preview · Prompt history capture[\s\S]*preference: off · effective: off/i);
|
|
3241
3555
|
assert.equal(existsSync(join(home, "history-capture.json")), false, "highlighting never applies");
|
|
3242
3556
|
await customizeAction(ui, "Prompt history capture: enable");
|
|
@@ -3263,9 +3577,10 @@ test("customize Cards rows persist the card style and switch live conversation c
|
|
|
3263
3577
|
const pending = commands.get("gentle:customize")!.handler("", ctx);
|
|
3264
3578
|
await overlayReady;
|
|
3265
3579
|
assert.ok(findCustomizeRow(ui, "Card style: float (current)"));
|
|
3266
|
-
assert.match(ui.overlayView!.render(90).join("\n"), /Cards · 2
|
|
3580
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Cards · 1\/2/, "Card style and Card content are one line each");
|
|
3581
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Card style\s+○ neon\s+● float/);
|
|
3267
3582
|
assert.ok(findCustomizeRow(ui, "Card style: neon"));
|
|
3268
|
-
assert.ok(
|
|
3583
|
+
assert.ok(ui.overlayView!.render(90).some((line) => /Card style\s+› neon\s+● float/.test(line)), "the cursor is on neon, but float stays current without a saved preference");
|
|
3269
3584
|
assert.equal(existsSync(join(home, "card-style.json")), false, "highlighting never applies");
|
|
3270
3585
|
const requestRender = fakeTui.requestRender;
|
|
3271
3586
|
let renders = 0;
|
|
@@ -3313,7 +3628,7 @@ test("customize Cards rows persist the card content level and switch the live qu
|
|
|
3313
3628
|
ui.overlayView!.handleInput("\x1b"); await pending;
|
|
3314
3629
|
});
|
|
3315
3630
|
|
|
3316
|
-
test("T3 live style Cards action refreshes cached TODO
|
|
3631
|
+
test("T3 live style Cards action refreshes cached TODO and Status in both directions while the wide chrome stays", async (t) => {
|
|
3317
3632
|
const home = scopedDoubleEscCancelConfigHome(t);
|
|
3318
3633
|
const previous = cardStyle();
|
|
3319
3634
|
t.after(() => setCardStyle(previous));
|
|
@@ -3358,6 +3673,11 @@ test("T3 live style Cards action refreshes cached TODO, header, footer and promp
|
|
|
3358
3673
|
paint();
|
|
3359
3674
|
assert.equal(todoRenders, 1);
|
|
3360
3675
|
assert.match(frame.rail, /Cached task/);
|
|
3676
|
+
// The wide chrome: the title row on top and one status bar row as the last layout entry.
|
|
3677
|
+
const wide = root[node]() as unknown as { entries: { component: { render(width: number): string[] } }[] };
|
|
3678
|
+
assert.equal(wide.entries.length, 3, "title row, transcript with the rail, status bar");
|
|
3679
|
+
assert.match(stripAnsi(frame.header), /^ ✿ repo \/repo .*team $/);
|
|
3680
|
+
assert.match(stripAnsi(wide.entries[2]!.component.render(160).join("\n")), /^ main .*ctx .*usage/);
|
|
3361
3681
|
const neon = { ...frame };
|
|
3362
3682
|
paint();
|
|
3363
3683
|
assert.equal(todoRenders, 1, "unchanged frame uses cached TODO");
|
|
@@ -3378,7 +3698,10 @@ test("T3 live style Cards action refreshes cached TODO, header, footer and promp
|
|
|
3378
3698
|
assert.ok(overlayRenders > beforeOverlay, "customize redraws too");
|
|
3379
3699
|
assert.equal(todoRenders, beforeTodo + 1, "revision invalidation refreshes digest-less TODO");
|
|
3380
3700
|
assert.equal(statusRenders, beforeStatus + 1, "live style digest refreshes cached Status");
|
|
3381
|
-
|
|
3701
|
+
assert.notEqual(frame.rail, before.rail, "rail changes immediately");
|
|
3702
|
+
// The wide chrome's title row and panel editor are not cards: no card style changes them.
|
|
3703
|
+
assert.equal(frame.header, before.header, "the title row is the same in every card style");
|
|
3704
|
+
assert.equal(frame.prompt, before.prompt, "the panel editor is the same in every card style");
|
|
3382
3705
|
assert.match(ui.notices.at(-1)!, /Conversation cards and shell chrome redraw now/);
|
|
3383
3706
|
assert.match(ui.overlayView!.render(90).join("\n"), /prompt|shell chrome/i);
|
|
3384
3707
|
const rendered = { ...frame };
|
|
@@ -3598,18 +3921,18 @@ test("customize command updates displayed settings and applies layout immediatel
|
|
|
3598
3921
|
const { ctx, ui, overlayReady } = fakeContext();
|
|
3599
3922
|
const pending = commands.get("gentle:customize")!.handler("", ctx);
|
|
3600
3923
|
await overlayReady;
|
|
3601
|
-
assert.match(ui.overlayView!.render(90).join("\n"), /Animations
|
|
3924
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Animations\s+● quality/);
|
|
3602
3925
|
await customizeAction(ui, "Animations: performance");
|
|
3603
3926
|
assert.equal(resolveAnimationPolicy({ gentlePiConfigHome: home }).policy, "performance");
|
|
3604
|
-
assert.match(ui.overlayView!.render(90).join("\n"), /Animations
|
|
3927
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Animations\s+○ quality\s+● performance/);
|
|
3605
3928
|
assert.match(ui.notices.at(-1)!, /Prompt applies now.*banner.*next startup/i);
|
|
3606
|
-
await customizeAction(ui, "Banner rose");
|
|
3929
|
+
await customizeAction(ui, "Banner rose: off");
|
|
3607
3930
|
assert.equal((await readBannerConfig(home)).showRose, false);
|
|
3608
|
-
assert.match(ui.overlayView!.render(90).join("\n"), /Banner rose
|
|
3931
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Banner rose\s+○ on\s+● off/);
|
|
3609
3932
|
assert.match(ui.notices.at(-1)!, /next startup/i);
|
|
3610
3933
|
await customizeAction(ui, "Status placement: hidden");
|
|
3611
3934
|
assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.statusPlacement, "hidden");
|
|
3612
|
-
assert.match(ui.overlayView!.render(90).join("\n"), /Status
|
|
3935
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Status\s+○ auto\s+○ right\s+○ bottom\s+● hidden/);
|
|
3613
3936
|
assert.match(ui.notices.at(-1)!, /saved and applied/);
|
|
3614
3937
|
ui.overlayView!.handleInput("\x1b");
|
|
3615
3938
|
await pending;
|
|
@@ -3794,10 +4117,10 @@ test("T4d unified float footer uses one live owner and restores legacy Changes o
|
|
|
3794
4117
|
assert.deepEqual(footer.render(240), [""], "hidden float status retains exterior dock spacing");
|
|
3795
4118
|
assert.equal(header.render(240).length, 5);
|
|
3796
4119
|
assert.doesNotMatch(stripAnsi(header.render(240).join("\n")), /MCP updated/);
|
|
3797
|
-
await customizeAction(ui, "Section changes:
|
|
4120
|
+
await customizeAction(ui, "Section changes: hidden");
|
|
3798
4121
|
assert.equal(header.render(240).length, 4);
|
|
3799
4122
|
assert.equal(ui.widgets.has("gentle-shell-changes"), false);
|
|
3800
|
-
await customizeAction(ui, "Section changes:
|
|
4123
|
+
await customizeAction(ui, "Section changes: shown");
|
|
3801
4124
|
await customizeAction(ui, "Header placement: top");
|
|
3802
4125
|
assert.deepEqual(header.render(240), []);
|
|
3803
4126
|
assert.equal(widget("gentle-shell-changes").render(240).length, 1, "top placement restores standalone Changes");
|
|
@@ -4832,11 +5155,11 @@ test("Changes lists the session root's Git state at turn end, never at startup",
|
|
|
4832
5155
|
assert.match(renderFooter(ui),/main ±2/);
|
|
4833
5156
|
const rail = sidebarState(fakeTui as unknown as TUI).parts.get("footer")!;
|
|
4834
5157
|
const digest = rail.digest!();
|
|
4835
|
-
assert.match(rail.render(46).join("\n"), /2 files
|
|
5158
|
+
assert.match(rail.render(46).join("\n"), /2 files\n {2}\+2 −0/);
|
|
4836
5159
|
await fire(handlers,"agent_end",ctx);
|
|
4837
5160
|
await changesSettled();
|
|
4838
5161
|
assert.notEqual(rail.digest!(), digest, "same-count line changes invalidate the unified Status");
|
|
4839
|
-
assert.match(rail.render(46).join("\n"), /2 files
|
|
5162
|
+
assert.match(rail.render(46).join("\n"), /2 files\n {2}\+3 −0/);
|
|
4840
5163
|
assert.ok(gitStateOnly(git), JSON.stringify(git));
|
|
4841
5164
|
assert.ok(git.every((args) => args[1] === "/repo"), "only the session's own root is scanned");
|
|
4842
5165
|
await fire(handlers,"session_shutdown",ctx);
|
|
@@ -5522,6 +5845,81 @@ test("gentleShell records SSE rate-limit headers from provider responses", async
|
|
|
5522
5845
|
assert.doesNotMatch(renderFooter(ui), /codex/);
|
|
5523
5846
|
});
|
|
5524
5847
|
|
|
5848
|
+
test("gentleShell prices claude-bridge turns at the Anthropic list price and labels them as subscription", async () => {
|
|
5849
|
+
// pi-claude-bridge registers every model with a zero price, so without this
|
|
5850
|
+
// the footer and stats always read $0 on a Claude subscription.
|
|
5851
|
+
const { pi, handlers } = fakePi();
|
|
5852
|
+
gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fakeFetch({}, false).fetchFn, now: () => 0 });
|
|
5853
|
+
const entries: unknown[] = [];
|
|
5854
|
+
const { ctx, ui } = fakeContext({ entries, oauth: false });
|
|
5855
|
+
(ctx as unknown as { model: { provider: string; id: string } }).model = { ...ctx.model!, provider: "claude-bridge", id: "claude-opus-5-5" };
|
|
5856
|
+
(ctx.modelRegistry as unknown as { find: (provider: string, id: string) => unknown }).find = (provider, id) =>
|
|
5857
|
+
provider === "anthropic" && id === "claude-opus-5-5" ? { cost: { input: 4, output: 20, cacheRead: 0.2, cacheWrite: 5 } } : undefined;
|
|
5858
|
+
await fire(handlers, "session_start", ctx);
|
|
5859
|
+
|
|
5860
|
+
const message = { role: "assistant", provider: "claude-bridge", model: "claude-opus-5-5",
|
|
5861
|
+
usage: { input: 1_000_000, output: 100_000, cacheRead: 0, cacheWrite: 0, totalTokens: 1_100_000, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } } };
|
|
5862
|
+
const results = (handlers.get("message_end") ?? []).map((handler) => handler({ type: "message_end", message }, ctx));
|
|
5863
|
+
const replaced = results.find((result) => result !== undefined) as { message: typeof message } | undefined;
|
|
5864
|
+
assert.equal(replaced?.message.usage.cost.total, 6, "1M input at $4 plus 100k output at $20");
|
|
5865
|
+
|
|
5866
|
+
entries.push({ type: "message", message: replaced!.message });
|
|
5867
|
+
for (const handler of handlers.get("turn_end") ?? []) await handler({}, ctx);
|
|
5868
|
+
assert.match(renderFooter(ui), /\$6\.00 sub/);
|
|
5869
|
+
});
|
|
5870
|
+
|
|
5871
|
+
test("gentleShell prices claude-bridge turns inside a subagent child, where the shell UI is off", () => {
|
|
5872
|
+
// The parent sums each child's message_end cost over RPC, so a child that
|
|
5873
|
+
// skipped the pricing hook made the Stats `agents` row read $0.000.
|
|
5874
|
+
const { pi, handlers } = fakePi();
|
|
5875
|
+
gentleShell(pi, { GENTLE_PI_AGENTS_CHILD: "1" }, { fetch: fakeFetch({}, false).fetchFn, now: () => 0 });
|
|
5876
|
+
const { ctx } = fakeContext({ entries: [], oauth: false });
|
|
5877
|
+
(ctx.modelRegistry as unknown as { find: (provider: string, id: string) => unknown }).find = (provider, id) =>
|
|
5878
|
+
provider === "anthropic" && id === "claude-opus-5-5" ? { cost: { input: 4, output: 20, cacheRead: 0.2, cacheWrite: 5 } } : undefined;
|
|
5879
|
+
|
|
5880
|
+
const message = { role: "assistant", provider: "claude-bridge", model: "claude-opus-5-5",
|
|
5881
|
+
usage: { input: 1_000_000, output: 100_000, cacheRead: 0, cacheWrite: 0, totalTokens: 1_100_000, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } } };
|
|
5882
|
+
const results = (handlers.get("message_end") ?? []).map((handler) => handler({ type: "message_end", message }, ctx));
|
|
5883
|
+
const replaced = results.find((result) => result !== undefined) as { message: typeof message } | undefined;
|
|
5884
|
+
assert.equal(replaced?.message.usage.cost.total, 6, "1M input at $4 plus 100k output at $20");
|
|
5885
|
+
assert.equal(handlers.has("model_select"), false, "the child still renders no shell UI");
|
|
5886
|
+
});
|
|
5887
|
+
|
|
5888
|
+
test("gentleShell files header usage under the provider that served the response", async () => {
|
|
5889
|
+
// pi-claude-bridge forwards Claude Code's usage as the Anthropic unified
|
|
5890
|
+
// headers, so the headers alone name `anthropic` while the session runs on
|
|
5891
|
+
// `claude-bridge`.
|
|
5892
|
+
const { pi, handlers, commands } = fakePi();
|
|
5893
|
+
gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fakeFetch({}, false).fetchFn, now: () => 0 });
|
|
5894
|
+
const { ctx, ui } = fakeContext();
|
|
5895
|
+
(ctx as unknown as { model: { provider: string } }).model.provider = "claude-bridge";
|
|
5896
|
+
await fire(handlers, "session_start", ctx);
|
|
5897
|
+
for (const handler of handlers.get("after_provider_response") ?? []) {
|
|
5898
|
+
handler({ status: 200, headers: { "anthropic-ratelimit-unified-5h-utilization": "0.25", "anthropic-ratelimit-unified-7d-utilization": "0.9" } }, ctx);
|
|
5899
|
+
}
|
|
5900
|
+
assert.match(renderFooter(ui), /claude 5h ▰▰▱▱▱▱▱▱ 25% · week 90%/);
|
|
5901
|
+
|
|
5902
|
+
const opened = commands.get("gentle:usage")!.handler("", ctx);
|
|
5903
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
5904
|
+
const plain = ui.overlayView!.render(90).map(stripAnsi).join("\n");
|
|
5905
|
+
assert.match(plain, /✿ claude-bridge ·/);
|
|
5906
|
+
assert.doesNotMatch(plain, /no subscription usage for this provider/);
|
|
5907
|
+
ui.closeOverlay?.();
|
|
5908
|
+
await opened;
|
|
5909
|
+
});
|
|
5910
|
+
|
|
5911
|
+
test("gentleShell keeps the header provider when no model served the response", async () => {
|
|
5912
|
+
const { pi, handlers } = fakePi();
|
|
5913
|
+
gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fakeFetch({}, false).fetchFn, now: () => 0 });
|
|
5914
|
+
const { ctx, ui } = fakeContext();
|
|
5915
|
+
(ctx as unknown as { model: { provider: string } }).model.provider = "anthropic";
|
|
5916
|
+
await fire(handlers, "session_start", ctx);
|
|
5917
|
+
for (const handler of handlers.get("after_provider_response") ?? []) {
|
|
5918
|
+
handler({ status: 200, headers: { "anthropic-ratelimit-unified-5h-utilization": "0.25" } }, { ...ctx, model: undefined });
|
|
5919
|
+
}
|
|
5920
|
+
assert.match(renderFooter(ui), /claude 5h ▰▰▱▱▱▱▱▱ 25%/);
|
|
5921
|
+
});
|
|
5922
|
+
|
|
5525
5923
|
test("gentleShell ignores incomplete Codex headers and retains the last real quota without assuming 5h", async () => {
|
|
5526
5924
|
const { pi, handlers } = fakePi();
|
|
5527
5925
|
gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fakeFetch({}, false).fetchFn, now: () => 0 });
|
|
@@ -5680,6 +6078,40 @@ test("GENTLE_PI_COMMANDS_KEY=off registers no command-palette shortcut", () => {
|
|
|
5680
6078
|
assert.ok(shortcuts.has("alt+g"), "the unrelated changes shortcut still registers");
|
|
5681
6079
|
});
|
|
5682
6080
|
|
|
6081
|
+
test("saved keymaps replace the shell shortcuts, bind palette commands, and the environment still wins", async () => {
|
|
6082
|
+
const home = mkdtempSync(join(tmpdir(), "gentle-shell-keymaps-"));
|
|
6083
|
+
isolatedConfigHomes.push(home);
|
|
6084
|
+
writeFileSync(join(home, "keymaps.json"), JSON.stringify({ schema: 1, bindings: { commands: "alt+j", changes: null, usage: "alt+y", preset: "alt+p", "jobs.collapse": "alt+b", "command:gentle:profiles": "alt+o", "command:gentle:design": "alt+d" } }));
|
|
6085
|
+
const { pi, shortcuts, sentMessages } = fakePi();
|
|
6086
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
6087
|
+
for (const key of ["alt+j", "alt+y", "alt+p", "alt+b", "alt+o", "alt+d"]) assert.ok(shortcuts.has(key), key);
|
|
6088
|
+
for (const key of ["alt+k", "alt+g", "alt+u", "alt+l", "ctrl+shift+j"]) assert.equal(shortcuts.has(key), false, key);
|
|
6089
|
+
const { ctx, ui } = fakeContext();
|
|
6090
|
+
await shortcuts.get("alt+o")!.handler(ctx);
|
|
6091
|
+
assert.deepEqual(sentMessages.at(-1), { content: "/gentle:profiles", options: { expandPromptTemplates: true } });
|
|
6092
|
+
await shortcuts.get("alt+d")!.handler(ctx);
|
|
6093
|
+
assert.equal(sentMessages.length, 1, "a key bound to a command that is not registered runs nothing");
|
|
6094
|
+
assert.deepEqual(ui.notices.at(-1), "alt+d runs /gentle:design, which is not available in this session.");
|
|
6095
|
+
const envWins = fakePi();
|
|
6096
|
+
gentleShell(envWins.pi, { GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_COMMANDS_KEY: "ctrl+p" });
|
|
6097
|
+
assert.ok(envWins.shortcuts.has("ctrl+p"));
|
|
6098
|
+
assert.equal(envWins.shortcuts.has("alt+j"), false);
|
|
6099
|
+
});
|
|
6100
|
+
|
|
6101
|
+
test("a malformed keymaps.json keeps every default key and is reported once at startup", async () => {
|
|
6102
|
+
const home = mkdtempSync(join(tmpdir(), "gentle-shell-keymaps-"));
|
|
6103
|
+
isolatedConfigHomes.push(home);
|
|
6104
|
+
writeFileSync(join(home, "keymaps.json"), "{");
|
|
6105
|
+
const { pi, shortcuts, handlers } = fakePi();
|
|
6106
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
6107
|
+
assert.ok(shortcuts.has("alt+k") && shortcuts.has("alt+g"));
|
|
6108
|
+
const { ctx, ui } = fakeContext();
|
|
6109
|
+
for (const handler of handlers.get("session_start") ?? []) await handler({}, ctx);
|
|
6110
|
+
for (const handler of handlers.get("session_start") ?? []) await handler({}, ctx);
|
|
6111
|
+
assert.deepEqual(ui.notices.filter((notice) => notice.includes("keymaps.json")), [`Keymaps: ${join(home, "keymaps.json")} is unreadable or malformed; using the default keys.`]);
|
|
6112
|
+
assert.equal(readFileSync(join(home, "keymaps.json"), "utf8"), "{");
|
|
6113
|
+
});
|
|
6114
|
+
|
|
5683
6115
|
test("/gentle:commands shows only curated, registered commands, grouped, by their labels", async () => {
|
|
5684
6116
|
const { pi, commands } = fakePi();
|
|
5685
6117
|
gentleShell(pi, {});
|
|
@@ -5706,6 +6138,41 @@ test("/gentle:commands shows only curated, registered commands, grouped, by thei
|
|
|
5706
6138
|
await opened;
|
|
5707
6139
|
});
|
|
5708
6140
|
|
|
6141
|
+
test("the palette shows saved keys, marks ones waiting for a reload, and assigns a key with tab", async () => {
|
|
6142
|
+
const home = mkdtempSync(join(tmpdir(), "gentle-shell-keymaps-"));
|
|
6143
|
+
isolatedConfigHomes.push(home);
|
|
6144
|
+
const { pi, commands } = fakePi();
|
|
6145
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
6146
|
+
writeFileSync(join(home, "keymaps.json"), JSON.stringify({ schema: 1, bindings: { "command:gentle:profiles": "alt+o" } }));
|
|
6147
|
+
const { ctx, ui, overlayReady } = fakeContext();
|
|
6148
|
+
const opened = commands.get("gentle:commands")!.handler("", ctx);
|
|
6149
|
+
await overlayReady;
|
|
6150
|
+
const lines = ui.overlayView!.render(100);
|
|
6151
|
+
assert.match(lines.find((line) => line.includes("Models and profiles")) ?? "", /alt\+o \(reload\)/);
|
|
6152
|
+
assert.match(lines.find((line) => line.includes("Browse changes")) ?? "", /alt\+g/);
|
|
6153
|
+
for (const char of "Gentle AI status") ui.overlayView!.handleInput(char);
|
|
6154
|
+
ui.overlayView!.handleInput("\t");
|
|
6155
|
+
ui.overlayView!.handleInput("\x1bx");
|
|
6156
|
+
await opened;
|
|
6157
|
+
assert.deepEqual(JSON.parse(readFileSync(join(home, "keymaps.json"), "utf8")).bindings, { "command:gentle:profiles": "alt+o", "command:gentle:status": "alt+x" });
|
|
6158
|
+
assert.equal(ui.notices.at(-1), "/gentle:status: alt+x. Run /reload to apply it.");
|
|
6159
|
+
});
|
|
6160
|
+
|
|
6161
|
+
test("assigning a typing key from the palette is refused and saves nothing", async () => {
|
|
6162
|
+
const home = mkdtempSync(join(tmpdir(), "gentle-shell-keymaps-"));
|
|
6163
|
+
isolatedConfigHomes.push(home);
|
|
6164
|
+
const { pi, commands } = fakePi();
|
|
6165
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
6166
|
+
const { ctx, ui, overlayReady } = fakeContext();
|
|
6167
|
+
const opened = commands.get("gentle:commands")!.handler("", ctx);
|
|
6168
|
+
await overlayReady;
|
|
6169
|
+
ui.overlayView!.handleInput("\t");
|
|
6170
|
+
ui.overlayView!.handleInput("a");
|
|
6171
|
+
await opened;
|
|
6172
|
+
assert.equal(existsSync(join(home, "keymaps.json")), false);
|
|
6173
|
+
assert.match(ui.notices.at(-1) ?? "", /a is needed for typing/);
|
|
6174
|
+
});
|
|
6175
|
+
|
|
5709
6176
|
test("selecting a command from the palette by its label sends the underlying command as a slash message", async () => {
|
|
5710
6177
|
const { pi, commands, sentMessages } = fakePi();
|
|
5711
6178
|
gentleShell(pi, {});
|
|
@@ -6154,9 +6621,9 @@ test("an open session keeps its frozen profile in the status and Usage scope whe
|
|
|
6154
6621
|
const tui = { terminal: { rows: 40, columns: 160 }, requestRender() {} };
|
|
6155
6622
|
const component = factory(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
6156
6623
|
try {
|
|
6157
|
-
const
|
|
6158
|
-
assert.match(
|
|
6159
|
-
assert.doesNotMatch(
|
|
6624
|
+
const header = (sidebarState(tui as unknown as TUI).parts.get("header") as SidebarRail).render(160).join("\n");
|
|
6625
|
+
assert.match(header, /team/, "the header keeps the bare global name of the frozen profile");
|
|
6626
|
+
assert.doesNotMatch(header, /solo/);
|
|
6160
6627
|
} finally {
|
|
6161
6628
|
component.dispose();
|
|
6162
6629
|
}
|
|
@@ -6576,3 +7043,567 @@ test("pasted image chips warn instead of sending images a text-only model reject
|
|
|
6576
7043
|
});
|
|
6577
7044
|
assert.ok(ui.notices.some((notice) => /1 pasted image was not sent: the current model does not accept images/.test(notice)));
|
|
6578
7045
|
});
|
|
7046
|
+
|
|
7047
|
+
test("the installed editor draws the panel frame in the wide and mobile IDE chrome and the frame in regular mode", () => {
|
|
7048
|
+
const previous = cardStyle();
|
|
7049
|
+
const { pi, handlers } = fakePi();
|
|
7050
|
+
gentleShell(pi, {});
|
|
7051
|
+
const { ctx, ui } = fakeContext();
|
|
7052
|
+
const editor = installedPrompt(ctx, ui, handlers);
|
|
7053
|
+
const state = sidebarState(fakeTui as unknown as TUI);
|
|
7054
|
+
const owned = { active: state.active, ownsHost: state.ownsHost };
|
|
7055
|
+
const host = fakeTui as { mode?: string };
|
|
7056
|
+
try {
|
|
7057
|
+
setCardStyle(CARD_STYLE.NEON);
|
|
7058
|
+
host.mode = "fullscreen";
|
|
7059
|
+
state.active = true;
|
|
7060
|
+
state.ownsHost = () => true;
|
|
7061
|
+
const rows = editor.render(80).map(stripAnsi);
|
|
7062
|
+
assert.match(rows[0]!, /^─ ✿ waiting for input ─+─$/, "a titled rule replaces the frame");
|
|
7063
|
+
assert.match(rows[1]!, /^› /, "the input sits behind the prompt");
|
|
7064
|
+
assert.doesNotMatch(rows.join("\n"), /[╭╮╰╯│]/u);
|
|
7065
|
+
for (const row of rows) assert.equal(visibleWidth(row), 80);
|
|
7066
|
+
// An agent question sits right above the rule, inside the editor, so no widget can land between.
|
|
7067
|
+
const agents = sidebarPart(fakeTui as unknown as TUI, "agents", { render: (_width: number) => [], invalidate() {}, dispose() {} }, { render: () => [], alert: () => [" ? explore asked: Which file?"], invalidate() {} });
|
|
7068
|
+
const asked = editor.render(80).map(stripAnsi);
|
|
7069
|
+
assert.match(asked[0]!, /explore asked: Which file\?/);
|
|
7070
|
+
assert.match(asked[1]!, /^─ ✿ waiting for input/);
|
|
7071
|
+
assert.deepEqual(editor.handleMouse?.({ type: "move", button: "none", x: 2, y: 0, screenX: 2, screenY: 0, width: 80, height: asked.length, shift: false, alt: false, ctrl: false }), { handled: true, render: true }, "the shell owns the alert row's pointer events; they never reach Pi's editor");
|
|
7072
|
+
agents.dispose();
|
|
7073
|
+
state.active = false;
|
|
7074
|
+
state.layoutAttached = () => true;
|
|
7075
|
+
assert.match(stripAnsi(editor.render(80)[0]!), /^─ ✿ waiting for input/, "a narrow fullscreen terminal (mobile) keeps the panel editor");
|
|
7076
|
+
state.layoutAttached = undefined;
|
|
7077
|
+
assert.match(stripAnsi(editor.render(80)[0]!), /^╭/, "without the fullscreen layout installed the framed editor stays");
|
|
7078
|
+
delete host.mode;
|
|
7079
|
+
assert.match(stripAnsi(editor.render(80)[0]!), /^╭/, "regular mode keeps the framed editor");
|
|
7080
|
+
} finally {
|
|
7081
|
+
delete host.mode;
|
|
7082
|
+
state.active = owned.active;
|
|
7083
|
+
state.ownsHost = owned.ownsHost;
|
|
7084
|
+
setCardStyle(previous);
|
|
7085
|
+
editor.dispose();
|
|
7086
|
+
}
|
|
7087
|
+
});
|
|
7088
|
+
|
|
7089
|
+
test("mobile folds live work into one row above the editor that opens /gentle:panel as a sheet", async () => {
|
|
7090
|
+
const { pi, handlers, commands } = fakePi();
|
|
7091
|
+
gentleShell(pi, {});
|
|
7092
|
+
const { ctx, ui } = fakeContext();
|
|
7093
|
+
await fire(handlers, "session_start", ctx);
|
|
7094
|
+
const tui = { mode: "fullscreen", terminal: { rows: 34, columns: 56 }, requestRender() {} };
|
|
7095
|
+
const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void };
|
|
7096
|
+
const footer = factory(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7097
|
+
const state = sidebarState(tui as unknown as TUI);
|
|
7098
|
+
state.layoutAttached = () => true; // installSidebar sets this on a real fullscreen root
|
|
7099
|
+
const todoCard = sidebarPart(tui as unknown as TUI, "todo", { render: (_width: number) => ["TODO CARD"], invalidate() {}, dispose() {} }, {
|
|
7100
|
+
render: (width: number) => ["▾ TODOS".padEnd(width), " ◐ Run the suite".padEnd(width)],
|
|
7101
|
+
summary: () => ({ left: "◐ Run the suite", right: "1/3", rightLabel: "todos" }),
|
|
7102
|
+
invalidate() {},
|
|
7103
|
+
});
|
|
7104
|
+
try {
|
|
7105
|
+
assert.equal(state.compactWork?.(), true, "a narrow fullscreen terminal folds live work");
|
|
7106
|
+
assert.deepEqual(todoCard.render(56), [], "the Todos card steps aside for the work row");
|
|
7107
|
+
// The work row is part of the panel editor, right above its rule.
|
|
7108
|
+
assert.equal(ui.widgets.has("gentle-shell-work-row"), false, "no separate widget can land between the row and the editor");
|
|
7109
|
+
const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
|
|
7110
|
+
const editorRows = editor.render(56).map(stripAnsi);
|
|
7111
|
+
assert.match(editorRows[0]!, /^ ▸ ◐ Run the suite +1\/3 $/);
|
|
7112
|
+
assert.match(editorRows[1]!, /^─ ✿ waiting for input/, "the editor rule follows the work row directly");
|
|
7113
|
+
assert.equal(editor.handleMouse?.({ type: "click", button: "left", x: 3, y: 0, screenX: 3, screenY: 0, width: 56, height: editorRows.length, shift: false, alt: false, ctrl: false })?.handled, true, "a tap on the work row is handled");
|
|
7114
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
7115
|
+
assert.match(openPanelLines(ui)[0]!, /^ ✿ Panel/, "the tap opens the panel sheet");
|
|
7116
|
+
(ui.overlayView as unknown as { handleInput(data: string): void }).handleInput("\x1b");
|
|
7117
|
+
editor.dispose();
|
|
7118
|
+
const header = state.parts.get("header")!;
|
|
7119
|
+
assert.match(stripAnsi(header.render(56).join("\n")), /^ ✿ repo .*· /, "the mobile title row carries the model");
|
|
7120
|
+
assert.match(stripAnsi(state.parts.get("statusbar")!.render(56).join("\n")), /^ main/, "the mobile status bar leads with the branch");
|
|
7121
|
+
void commands.get("gentle:panel")!.handler("", ctx);
|
|
7122
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
7123
|
+
const sheet = openPanelLines(ui);
|
|
7124
|
+
assert.match(sheet[0]!, /^ ✿ Panel +esc back $/);
|
|
7125
|
+
assert.ok(sheet.some((line) => /▾ TODOS/.test(line)) && sheet.some((line) => /Run the suite/.test(line)), "the sheet shows the rail sections");
|
|
7126
|
+
(ui.overlayView as unknown as { handleInput(data: string): void }).handleInput("\x1b");
|
|
7127
|
+
tui.terminal.columns = 160;
|
|
7128
|
+
assert.equal(state.compactWork?.(), false, "a wide terminal keeps the rail and the cards' rules");
|
|
7129
|
+
} finally {
|
|
7130
|
+
todoCard.dispose();
|
|
7131
|
+
footer.dispose();
|
|
7132
|
+
}
|
|
7133
|
+
});
|
|
7134
|
+
|
|
7135
|
+
test("a tap on a mobile work row led by an agent opens /gentle:agents instead of the panel sheet", async () => {
|
|
7136
|
+
const { pi, handlers } = fakePi();
|
|
7137
|
+
gentleShell(pi, {});
|
|
7138
|
+
const { ctx, ui } = fakeContext();
|
|
7139
|
+
await fire(handlers, "session_start", ctx);
|
|
7140
|
+
const tui = { mode: "fullscreen", terminal: { rows: 34, columns: 56 }, requestRender() {} };
|
|
7141
|
+
const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void };
|
|
7142
|
+
const footer = factory(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7143
|
+
const state = sidebarState(tui as unknown as TUI);
|
|
7144
|
+
state.layoutAttached = () => true;
|
|
7145
|
+
let opened = 0;
|
|
7146
|
+
const agentsCard = sidebarPart(tui as unknown as TUI, "agents", { render: (_width: number) => ["AGENTS CARD"], invalidate() {}, dispose() {} }, {
|
|
7147
|
+
render: (width: number) => ["▾ AGENTS".padEnd(width), " ◐ map lib modules".padEnd(width)],
|
|
7148
|
+
summary: () => ({ left: "◐ map lib modules", right: "1", rightLabel: "running", priority: 1 }),
|
|
7149
|
+
open: () => { opened += 1; },
|
|
7150
|
+
invalidate() {},
|
|
7151
|
+
});
|
|
7152
|
+
try {
|
|
7153
|
+
assert.equal(state.compactWork?.(), true, "a narrow fullscreen terminal folds live work");
|
|
7154
|
+
const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
|
|
7155
|
+
const editorRows = editor.render(56).map(stripAnsi);
|
|
7156
|
+
assert.match(editorRows[0]!, /^ ▸ ◐ map lib modules +1 $/);
|
|
7157
|
+
assert.equal(editor.handleMouse?.({ type: "click", button: "left", x: 3, y: 0, screenX: 3, screenY: 0, width: 56, height: editorRows.length, shift: false, alt: false, ctrl: false })?.handled, true, "a tap on the work row is handled");
|
|
7158
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
7159
|
+
assert.equal(opened, 1, "the tap opens the agents view");
|
|
7160
|
+
assert.equal(ui.overlayView, undefined, "the tap never opens the panel sheet");
|
|
7161
|
+
editor.dispose();
|
|
7162
|
+
} finally {
|
|
7163
|
+
agentsCard.dispose();
|
|
7164
|
+
footer.dispose();
|
|
7165
|
+
}
|
|
7166
|
+
});
|
|
7167
|
+
|
|
7168
|
+
test("customize presets set density and visibility together, mark the current one, and keep the placements", async (t) => {
|
|
7169
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7170
|
+
const { pi, commands } = fakePi();
|
|
7171
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
7172
|
+
const { ctx, ui, overlayReady } = fakeContext();
|
|
7173
|
+
const pending = commands.get("gentle:customize")!.handler("", ctx);
|
|
7174
|
+
await overlayReady;
|
|
7175
|
+
await customizeAction(ui, "Header placement: below-input");
|
|
7176
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+● Neutral\s+○ Power user/, "the default density and visibility are the Neutral preset");
|
|
7177
|
+
await customizeAction(ui, "Preset: Light");
|
|
7178
|
+
const light = resolveVisualSettings({ gentlePiConfigHome: home }).settings;
|
|
7179
|
+
assert.equal(light.density, "minimal");
|
|
7180
|
+
assert.equal(light.visibility.todo, false);
|
|
7181
|
+
assert.equal(light.visibility.changes, false);
|
|
7182
|
+
assert.equal(light.headerPlacement, "below-input", "the preset keeps the chosen header placement");
|
|
7183
|
+
assert.equal(light.statusPlacement, "bottom", "Light is the minimal edition without the rail");
|
|
7184
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+● Light/);
|
|
7185
|
+
await customizeAction(ui, "Preset: Power user");
|
|
7186
|
+
assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.density, "comfortable", "Power user keeps Neutral's spacing");
|
|
7187
|
+
assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.visibility.stats, true, "and adds Stats");
|
|
7188
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+○ Neutral\s+● Power user/);
|
|
7189
|
+
await customizeAction(ui, "Section stats: hidden");
|
|
7190
|
+
assert.ok(findCustomizeRow(ui, "Preset: Neutral"));
|
|
7191
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+● Neutral/, "Power user without Stats is Neutral again");
|
|
7192
|
+
await customizeAction(ui, "Density: minimal");
|
|
7193
|
+
assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+○ Neutral\s+○ Power user/, "a hand-tuned mix matches no preset");
|
|
7194
|
+
ui.overlayView!.handleInput("\x1b");
|
|
7195
|
+
await pending;
|
|
7196
|
+
});
|
|
7197
|
+
|
|
7198
|
+
test("customize presets survive session switches and a fresh extension with the same config home", async (t) => {
|
|
7199
|
+
const shared = { ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input" as const };
|
|
7200
|
+
const cases = [
|
|
7201
|
+
{ name: "Light", actions: ["Preset: Light"], settings: { ...shared, statusPlacement: "bottom" as const, density: DENSITY.MINIMAL, visibility: { ...shared.visibility, changes: false, todo: false } }, marker: /Preset\s+● Light\s+○ Neutral\s+○ Power user/ },
|
|
7202
|
+
{ name: "Neutral after Light", actions: ["Preset: Light", "Preset: Neutral"], settings: { ...shared, visibility: { ...shared.visibility } }, marker: /Preset\s+○ Light\s+● Neutral\s+○ Power user/ },
|
|
7203
|
+
{ name: "Power user", actions: ["Preset: Power user"], settings: { ...shared, visibility: { ...shared.visibility, stats: true } }, marker: /Preset\s+○ Light\s+○ Neutral\s+● Power user/ },
|
|
7204
|
+
{ name: "Power user by arrow with launcher config home", actions: ["Preset: Power user"], settings: { ...shared, visibility: { ...shared.visibility, stats: true } }, marker: /Preset\s+○ Light\s+○ Neutral\s+● Power user/, launcher: true, move: true },
|
|
7205
|
+
{ name: "manual override", actions: ["Preset: Power user", "Section todo: hidden"], settings: { ...shared, visibility: { ...shared.visibility, todo: false, stats: true } }, marker: /Preset\s+○ Light\s+○ Neutral\s+○ Power user/ },
|
|
7206
|
+
];
|
|
7207
|
+
for (const scenario of cases) await t.test(scenario.name, async (t) => {
|
|
7208
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7209
|
+
// The helper treats an explicit empty override as isolated, while the
|
|
7210
|
+
// production resolver treats it as unset and uses the launcher marker.
|
|
7211
|
+
const launcher = "launcher" in scenario && scenario.launcher;
|
|
7212
|
+
const env = { GENTLE_PI_CONFIG_HOME: launcher ? "" : home, ...(launcher ? { GENTLE_SHELL_CONFIG_HOME: home } : {}), GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" };
|
|
7213
|
+
const session = (id: string) => {
|
|
7214
|
+
const result = fakeContext({ entries: [assistantEntry({ input: 1000, output: 200, cost: 0.5 })] });
|
|
7215
|
+
result.ctx.sessionManager.getSessionId = () => id;
|
|
7216
|
+
return result;
|
|
7217
|
+
};
|
|
7218
|
+
const checkSaved = () => {
|
|
7219
|
+
const resolved = resolveVisualSettings({ gentlePiConfigHome: home });
|
|
7220
|
+
assert.equal(resolved.source, "global_file");
|
|
7221
|
+
assert.equal(resolved.malformed, false);
|
|
7222
|
+
assert.equal(resolved.readError, false);
|
|
7223
|
+
assert.deepEqual(resolved.settings, scenario.settings);
|
|
7224
|
+
assert.deepEqual(JSON.parse(readFileSync(join(home, "visual-customization.json"), "utf8")), { schema: VISUAL_SCHEMA, ...scenario.settings });
|
|
7225
|
+
};
|
|
7226
|
+
const checkRestored = async (shell: ReturnType<typeof fakePi>, current: ReturnType<typeof fakeContext>) => {
|
|
7227
|
+
const { ctx, ui, overlayReady } = current;
|
|
7228
|
+
const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 180 }, requestRender() {} };
|
|
7229
|
+
const footer = (ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void })(tui, plainTheme, {
|
|
7230
|
+
getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {},
|
|
7231
|
+
});
|
|
7232
|
+
try {
|
|
7233
|
+
const state = sidebarState(tui as unknown as TUI);
|
|
7234
|
+
assert.equal(state.visibility?.todo, scenario.settings.visibility.todo, "the restored shell applies Todo visibility");
|
|
7235
|
+
const rail = state.parts.get("footer")!.render(46).map(stripAnsi).join("\n");
|
|
7236
|
+
assert.equal(/▾ STATS/.test(rail), scenario.settings.visibility.stats, "the restored shell applies Stats visibility");
|
|
7237
|
+
const header = ui.widgets.get("gentle-shell-below-input-header") as (tui: unknown, theme: ShellBarTheme) => { render(width: number): string[] };
|
|
7238
|
+
assert.match(stripAnsi(header(tui, plainTheme).render(180).join("\n")), /ctx.*45%/, "the restored shell keeps the below-input header");
|
|
7239
|
+
const pending = shell.commands.get("gentle:customize")!.handler("", ctx);
|
|
7240
|
+
await overlayReady;
|
|
7241
|
+
try {
|
|
7242
|
+
assert.ok(findCustomizeRow(ui, "Status placement: auto"));
|
|
7243
|
+
assert.match(ui.overlayView!.render(90).join("\n"), scenario.marker);
|
|
7244
|
+
checkSaved();
|
|
7245
|
+
} finally {
|
|
7246
|
+
ui.overlayView!.handleInput("\x1b");
|
|
7247
|
+
await pending;
|
|
7248
|
+
}
|
|
7249
|
+
} finally { footer.dispose(); }
|
|
7250
|
+
};
|
|
7251
|
+
const original = fakePi();
|
|
7252
|
+
gentleShell(original.pi, env);
|
|
7253
|
+
let active = session("selection");
|
|
7254
|
+
try {
|
|
7255
|
+
await fire(original.handlers, "session_start", active.ctx);
|
|
7256
|
+
const pending = original.commands.get("gentle:customize")!.handler("", active.ctx);
|
|
7257
|
+
await active.overlayReady;
|
|
7258
|
+
try {
|
|
7259
|
+
await customizeAction(active.ui, "Header placement: below-input");
|
|
7260
|
+
if ("move" in scenario && scenario.move) {
|
|
7261
|
+
assert.ok(findCustomizeRow(active.ui, "Preset: Neutral"));
|
|
7262
|
+
const notices = active.ui.notices.length;
|
|
7263
|
+
active.ui.overlayView!.handleInput("\x1b[C");
|
|
7264
|
+
for (let attempt = 0; attempt < 100 && active.ui.notices.length === notices; attempt++) await new Promise<void>((resolve) => setTimeout(resolve, 5));
|
|
7265
|
+
assert.ok(active.ui.notices.length > notices, "moving to Power user finished applying");
|
|
7266
|
+
} else {
|
|
7267
|
+
for (const action of scenario.actions) await customizeAction(active.ui, action);
|
|
7268
|
+
}
|
|
7269
|
+
} finally {
|
|
7270
|
+
active.ui.overlayView!.handleInput("\x1b");
|
|
7271
|
+
await pending;
|
|
7272
|
+
}
|
|
7273
|
+
checkSaved();
|
|
7274
|
+
active = session("switched");
|
|
7275
|
+
await fire(original.handlers, "session_start", active.ctx);
|
|
7276
|
+
await checkRestored(original, active);
|
|
7277
|
+
} finally { await fire(original.handlers, "session_shutdown", active.ctx); }
|
|
7278
|
+
const fresh = fakePi();
|
|
7279
|
+
gentleShell(fresh.pi, env);
|
|
7280
|
+
const restarted = session("restarted");
|
|
7281
|
+
try {
|
|
7282
|
+
await fire(fresh.handlers, "session_start", restarted.ctx);
|
|
7283
|
+
await checkRestored(fresh, restarted);
|
|
7284
|
+
} finally { await fire(fresh.handlers, "session_shutdown", restarted.ctx); }
|
|
7285
|
+
});
|
|
7286
|
+
});
|
|
7287
|
+
|
|
7288
|
+
// Verification blockers (odd/tasks/shell-ide-rework.md L22).
|
|
7289
|
+
test("without the top-header IDE chrome the rail keeps the permission mode and the session name", async () => {
|
|
7290
|
+
const { pi, handlers } = fakePi();
|
|
7291
|
+
gentleShell(pi, {});
|
|
7292
|
+
const { ctx, ui } = fakeContext();
|
|
7293
|
+
await fire(handlers, "session_start", ctx);
|
|
7294
|
+
const statuses = new Map([["gentle:mode", "Permissions: AUTO"], ["mcp", "MCP: 3 servers"]]);
|
|
7295
|
+
const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 180 }, requestRender() {} };
|
|
7296
|
+
const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void };
|
|
7297
|
+
const footer = factory(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => statuses, getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7298
|
+
try {
|
|
7299
|
+
// No layout owns the host here, so no title row or status bar draws: the rail must say it all.
|
|
7300
|
+
const rail = stripAnsi(sidebarState(tui as unknown as TUI).parts.get("footer")!.render(46).join("\n"));
|
|
7301
|
+
assert.match(rail, /Permissions: AUTO/, "the permission mode stays visible when no status bar shows it");
|
|
7302
|
+
assert.match(rail, /▾ SESSION[\s\S]*Release notes/, "the session name stays visible when no title row shows it");
|
|
7303
|
+
assert.match(rail, /MCP: 3 servers/);
|
|
7304
|
+
} finally {
|
|
7305
|
+
footer.dispose();
|
|
7306
|
+
}
|
|
7307
|
+
});
|
|
7308
|
+
|
|
7309
|
+
test("a hidden Todos section stays hidden in the mobile work row and the panel sheet, and the sheet leaves the editor visible", async () => {
|
|
7310
|
+
const { pi, handlers, commands } = fakePi();
|
|
7311
|
+
gentleShell(pi, {});
|
|
7312
|
+
const { ctx, ui } = fakeContext();
|
|
7313
|
+
await fire(handlers, "session_start", ctx);
|
|
7314
|
+
const tui = { mode: "fullscreen", terminal: { rows: 34, columns: 56 }, requestRender() {} };
|
|
7315
|
+
const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void };
|
|
7316
|
+
const footer = factory(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7317
|
+
const state = sidebarState(tui as unknown as TUI);
|
|
7318
|
+
state.layoutAttached = () => true; // installSidebar sets this on a real fullscreen root
|
|
7319
|
+
const todo = sidebarPart(tui as unknown as TUI, "todo", { render: (_width: number) => ["TODO CARD"], invalidate() {}, dispose() {} }, {
|
|
7320
|
+
render: (width: number) => ["▾ TODOS".padEnd(width), ...Array.from({ length: 40 }, (_, i) => ` ○ task ${i}`.padEnd(width))],
|
|
7321
|
+
summary: () => ({ left: "◐ Secret plan task", right: "1/3", rightLabel: "todos" }),
|
|
7322
|
+
invalidate() {},
|
|
7323
|
+
});
|
|
7324
|
+
const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
|
|
7325
|
+
try {
|
|
7326
|
+
const workRow = { render: (width: number) => editor.render(width).filter((row) => /▸/.test(stripAnsi(row))) };
|
|
7327
|
+
assert.match(stripAnsi(workRow.render(56)[0]!), /Secret plan task/);
|
|
7328
|
+
void commands.get("gentle:panel")!.handler("", ctx);
|
|
7329
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
7330
|
+
const sheet = ui.overlayView!.render(56);
|
|
7331
|
+
const options = ui.customOptions!.at(-1) as { overlayOptions?: { anchor?: string } };
|
|
7332
|
+
assert.equal(options.overlayOptions?.anchor, "top-center", "the sheet hangs from the top");
|
|
7333
|
+
assert.ok(sheet.length <= 34 - 6, `the editor, the work row and the status bar keep their rows: ${sheet.length}`);
|
|
7334
|
+
(ui.overlayView as unknown as { handleInput(data: string): void }).handleInput("\x1b");
|
|
7335
|
+
state.visibility = { todo: false };
|
|
7336
|
+
assert.deepEqual(workRow.render(56), [], "the work row honors the Todos switch");
|
|
7337
|
+
void commands.get("gentle:panel")!.handler("", ctx);
|
|
7338
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
7339
|
+
assert.doesNotMatch(stripAnsi(ui.overlayView!.render(56).join("\n")), /TODOS|Secret plan/, "the sheet honors the Todos switch");
|
|
7340
|
+
(ui.overlayView as unknown as { handleInput(data: string): void }).handleInput("\x1b");
|
|
7341
|
+
} finally {
|
|
7342
|
+
state.visibility = undefined;
|
|
7343
|
+
todo.dispose();
|
|
7344
|
+
footer.dispose();
|
|
7345
|
+
editor.dispose();
|
|
7346
|
+
}
|
|
7347
|
+
});
|
|
7348
|
+
|
|
7349
|
+
test("Status at the bottom with the header on top draws the minimal IDE chrome on a wide terminal, without the rail", async () => {
|
|
7350
|
+
const { pi, handlers } = fakePi();
|
|
7351
|
+
const home = mkdtempSync(join(tmpdir(), "shell-light-"));
|
|
7352
|
+
try {
|
|
7353
|
+
writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, statusPlacement: "bottom" }, { gentlePiConfigHome: home });
|
|
7354
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
7355
|
+
const { ctx, ui } = fakeContext();
|
|
7356
|
+
await fire(handlers, "session_start", ctx);
|
|
7357
|
+
const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 180 }, requestRender() {} };
|
|
7358
|
+
const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void };
|
|
7359
|
+
const footer = factory(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7360
|
+
const state = sidebarState(tui as unknown as TUI);
|
|
7361
|
+
state.layoutAttached = () => true; // installSidebar sets this on a real fullscreen root
|
|
7362
|
+
const todo = sidebarPart(tui as unknown as TUI, "todo", { render: (_width: number) => ["TODO CARD"], invalidate() {}, dispose() {} }, {
|
|
7363
|
+
render: (width: number) => ["▾ TODOS".padEnd(width)],
|
|
7364
|
+
summary: () => ({ left: "◐ Run the suite", right: "1/3", rightLabel: "todos" }),
|
|
7365
|
+
invalidate() {},
|
|
7366
|
+
});
|
|
7367
|
+
const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
|
|
7368
|
+
try {
|
|
7369
|
+
assert.equal(state.compactWork?.(), true, "the minimal edition folds live work like a phone");
|
|
7370
|
+
assert.deepEqual(footer.render(180), [], "the old compact bottom bar steps aside for the status bar");
|
|
7371
|
+
assert.deepEqual(todo.render(180), [], "the Todos card folds into the work row");
|
|
7372
|
+
assert.match(stripAnsi(state.parts.get("header")!.render(180).join("\n")), /^ ✿ repo /, "the title row draws");
|
|
7373
|
+
assert.match(stripAnsi(state.parts.get("statusbar")!.render(180).join("\n")), /^ main /, "the status bar draws");
|
|
7374
|
+
assert.match(stripAnsi(editor.render(180)[0]!), /▸ ◐ Run the suite/, "the work row sits right above the editor");
|
|
7375
|
+
} finally {
|
|
7376
|
+
editor.dispose();
|
|
7377
|
+
todo.dispose();
|
|
7378
|
+
footer.dispose();
|
|
7379
|
+
}
|
|
7380
|
+
} finally {
|
|
7381
|
+
rmSync(home, { recursive: true, force: true });
|
|
7382
|
+
}
|
|
7383
|
+
});
|
|
7384
|
+
|
|
7385
|
+
test("an agent question keeps its row above the framed editor while the rail hides the Agents card with the header below the input", async (t) => {
|
|
7386
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7387
|
+
writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input" }, { gentlePiConfigHome: home });
|
|
7388
|
+
const { pi, handlers } = fakePi();
|
|
7389
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
7390
|
+
const { ctx, ui } = fakeContext();
|
|
7391
|
+
const editor = installedPrompt(ctx, ui, handlers);
|
|
7392
|
+
const state = sidebarState(fakeTui as unknown as TUI);
|
|
7393
|
+
const owned = { active: state.active, ownsHost: state.ownsHost };
|
|
7394
|
+
const host = fakeTui as { mode?: string };
|
|
7395
|
+
const agents = sidebarPart(fakeTui as unknown as TUI, "agents", { render: (_width: number) => [], invalidate() {}, dispose() {} }, { render: () => [], alert: () => [" ? explore asked: Which file?"], invalidate() {} });
|
|
7396
|
+
try {
|
|
7397
|
+
host.mode = "fullscreen";
|
|
7398
|
+
state.active = true;
|
|
7399
|
+
state.ownsHost = () => true;
|
|
7400
|
+
const rows = editor.render(80).map(stripAnsi);
|
|
7401
|
+
assert.match(rows[0]!, /explore asked: Which file\?/, "the question sits right above the editor");
|
|
7402
|
+
assert.match(rows[1]!, /^╭/, "the below-input header keeps the framed editor");
|
|
7403
|
+
state.active = false;
|
|
7404
|
+
assert.doesNotMatch(editor.render(80).map(stripAnsi).join("\n"), /explore asked/, "without the rail the Agents card lists the question itself");
|
|
7405
|
+
} finally {
|
|
7406
|
+
agents.dispose();
|
|
7407
|
+
delete host.mode;
|
|
7408
|
+
state.active = owned.active;
|
|
7409
|
+
state.ownsHost = owned.ownsHost;
|
|
7410
|
+
editor.dispose();
|
|
7411
|
+
}
|
|
7412
|
+
});
|
|
7413
|
+
|
|
7414
|
+
test("rail Status sections fold on a header click and the Changes row opens /gentle:changes", async () => {
|
|
7415
|
+
const { pi, handlers } = fakePi();
|
|
7416
|
+
gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" });
|
|
7417
|
+
const { ctx, ui } = fakeContext();
|
|
7418
|
+
await fire(handlers, "session_start", ctx);
|
|
7419
|
+
const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 180 }, requestRender() {} };
|
|
7420
|
+
const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void };
|
|
7421
|
+
const footer = factory(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map([["mcp", "MCP: 3 servers"]]), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7422
|
+
try {
|
|
7423
|
+
const rail = sidebarState(tui as unknown as TUI).parts.get("footer")!;
|
|
7424
|
+
const rows = () => rail.render(46).map((line) => stripAnsi(line).trimEnd());
|
|
7425
|
+
const click = (y: number, type: "click" | "move" = "click") => rail.handleMouse?.({ type, button: type === "click" ? "left" : "none", x: 2, y, screenX: 2, screenY: y, width: 46, height: rows().length, shift: false, alt: false, ctrl: false });
|
|
7426
|
+
const header = rows().findIndex((line) => /^▾ INTEGRATIONS/.test(line));
|
|
7427
|
+
assert.ok(header >= 0);
|
|
7428
|
+
const before = rail.digest?.();
|
|
7429
|
+
assert.deepEqual(click(header, "move"), { handled: true, render: true }, "the header is hoverable");
|
|
7430
|
+
assert.notEqual(rail.digest?.(), before, "hover repaints the cached section");
|
|
7431
|
+
assert.equal(click(header)?.handled, true);
|
|
7432
|
+
assert.ok(rows().some((line) => /^▸ INTEGRATIONS/.test(line)) && !rows().some((line) => /MCP: 3 servers/.test(line)), "a click folds the section");
|
|
7433
|
+
click(rows().findIndex((line) => /^▸ INTEGRATIONS/.test(line)));
|
|
7434
|
+
assert.ok(rows().some((line) => /MCP: 3 servers/.test(line)), "a second click unfolds it");
|
|
7435
|
+
const changesRow = rows().findIndex((line) => /\/gentle:changes/.test(line));
|
|
7436
|
+
const notices = ui.notices.length;
|
|
7437
|
+
assert.equal(click(changesRow)?.handled, true, "the Changes row is clickable");
|
|
7438
|
+
for (let i = 0; i < 5 && !ui.overlayView && ui.notices.length === notices; i++) await new Promise((resolve) => setTimeout(resolve, 10));
|
|
7439
|
+
assert.ok(ui.overlayView || ui.notices.length > notices, "the click runs /gentle:changes (its view, or its note when nothing changed)");
|
|
7440
|
+
(ui.overlayView as unknown as { handleInput?(data: string): void } | undefined)?.handleInput?.("\x1b");
|
|
7441
|
+
} finally {
|
|
7442
|
+
footer.dispose();
|
|
7443
|
+
}
|
|
7444
|
+
});
|
|
7445
|
+
|
|
7446
|
+
test("the work row reacts to hover and the panel sheet closes from a click on esc back and scrolls with the wheel", async () => {
|
|
7447
|
+
const { pi, handlers, commands } = fakePi();
|
|
7448
|
+
gentleShell(pi, {});
|
|
7449
|
+
const { ctx, ui } = fakeContext();
|
|
7450
|
+
await fire(handlers, "session_start", ctx);
|
|
7451
|
+
const tui = { mode: "fullscreen", terminal: { rows: 20, columns: 56 }, requestRender() {} };
|
|
7452
|
+
const footer = (ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void })(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7453
|
+
const state = sidebarState(tui as unknown as TUI);
|
|
7454
|
+
state.layoutAttached = () => true;
|
|
7455
|
+
const todo = sidebarPart(tui as unknown as TUI, "todo", { render: (_width: number) => [], invalidate() {}, dispose() {} }, {
|
|
7456
|
+
render: (width: number) => ["▾ TODOS".padEnd(width), ...Array.from({ length: 30 }, (_, i) => ` ○ task ${i}`.padEnd(width))],
|
|
7457
|
+
summary: () => ({ left: "◐ Run the suite", right: "1/3", rightLabel: "todos" }),
|
|
7458
|
+
invalidate() {},
|
|
7459
|
+
});
|
|
7460
|
+
const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
|
|
7461
|
+
const pointer = (type: "move" | "click" | "wheel", x: number, y: number, extra: Record<string, unknown> = {}) => ({ type, button: type === "click" ? "left" : "none", x, y, screenX: x, screenY: y, width: 56, height: 6, shift: false, alt: false, ctrl: false, ...extra }) as never;
|
|
7462
|
+
try {
|
|
7463
|
+
editor.render(56);
|
|
7464
|
+
assert.deepEqual(editor.handleMouse?.(pointer("move", 3, 0)), { handled: true, render: true }, "hovering the work row repaints it as clickable");
|
|
7465
|
+
const opened = commands.get("gentle:panel")!.handler("", ctx);
|
|
7466
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
7467
|
+
const sheet = ui.overlayView as unknown as { render(width: number): string[]; handleMouse(event: unknown): unknown };
|
|
7468
|
+
const first = stripAnsi(sheet.render(56)[1]!);
|
|
7469
|
+
assert.deepEqual(sheet.handleMouse(pointer("wheel", 10, 5, { wheelDelta: 1 })), { handled: true, render: true });
|
|
7470
|
+
assert.notEqual(stripAnsi(sheet.render(56)[1]!), first, "the wheel scrolls the sheet");
|
|
7471
|
+
assert.deepEqual(sheet.handleMouse(pointer("move", 52, 0)), { handled: true, render: true }, "esc back is hoverable");
|
|
7472
|
+
assert.equal((sheet.handleMouse(pointer("click", 52, 0)) as { handled?: boolean }).handled, true);
|
|
7473
|
+
await opened;
|
|
7474
|
+
} finally {
|
|
7475
|
+
editor.dispose();
|
|
7476
|
+
todo.dispose();
|
|
7477
|
+
footer.dispose();
|
|
7478
|
+
}
|
|
7479
|
+
});
|
|
7480
|
+
|
|
7481
|
+
test("a render of the Status part at another width never moves the rail's click targets", async (t) => {
|
|
7482
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7483
|
+
// Below the input the rail keeps the Session section, whose row wraps at a narrow width.
|
|
7484
|
+
writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input" }, { gentlePiConfigHome: home });
|
|
7485
|
+
const { pi, handlers } = fakePi();
|
|
7486
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" });
|
|
7487
|
+
const { ctx, ui } = fakeContext();
|
|
7488
|
+
await fire(handlers, "session_start", ctx);
|
|
7489
|
+
const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 180 }, requestRender() {} };
|
|
7490
|
+
const footer = (ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void })(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7491
|
+
try {
|
|
7492
|
+
const rail = sidebarState(tui as unknown as TUI).parts.get("footer")!;
|
|
7493
|
+
const at = (width: number) => rail.render(width).map((line) => stripAnsi(line).trimEnd());
|
|
7494
|
+
const wide = at(46);
|
|
7495
|
+
const header = wide.findIndex((line) => /^▾ CHANGES/.test(line));
|
|
7496
|
+
assert.ok(header > 0, "the rail shows Session above Changes");
|
|
7497
|
+
const narrow = at(12);
|
|
7498
|
+
assert.notEqual(narrow.findIndex((line) => /^▾ CHANGES/.test(line)), header, "the narrow render moves the Changes header");
|
|
7499
|
+
// The click arrives at the rail's width with no render in between.
|
|
7500
|
+
const notices = ui.notices.length;
|
|
7501
|
+
const result = rail.handleMouse?.({ type: "click", button: "left", x: 2, y: header, screenX: 2, screenY: header, width: 46, height: wide.length, shift: false, alt: false, ctrl: false });
|
|
7502
|
+
assert.equal(result?.handled, true, "the click lands on the rail's own Changes header");
|
|
7503
|
+
assert.ok(at(46).some((line) => /^▸ CHANGES/.test(line)), "the click folds Changes");
|
|
7504
|
+
assert.equal(ui.notices.length, notices, "the click runs nothing else");
|
|
7505
|
+
} finally {
|
|
7506
|
+
footer.dispose();
|
|
7507
|
+
}
|
|
7508
|
+
});
|
|
7509
|
+
|
|
7510
|
+
test("alt+l cycles the visual presets Light → Neutral → Power user → Light and saves each pick", async (t) => {
|
|
7511
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7512
|
+
const { pi, handlers, shortcuts } = fakePi();
|
|
7513
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" });
|
|
7514
|
+
const { ctx, ui } = fakeContext();
|
|
7515
|
+
await fire(handlers, "session_start", ctx);
|
|
7516
|
+
const shortcut = shortcuts.get("alt+l");
|
|
7517
|
+
assert.ok(shortcut, "alt+l not registered");
|
|
7518
|
+
const preset = () => visualPresetOf(resolveVisualSettings({ gentlePiConfigHome: home }).settings);
|
|
7519
|
+
assert.equal(preset(), VISUAL_PRESET.NEUTRAL, "a fresh install starts on Neutral");
|
|
7520
|
+
const seen: (string | undefined)[] = [];
|
|
7521
|
+
for (let i = 0; i < 3; i++) {
|
|
7522
|
+
await shortcut.handler(ctx);
|
|
7523
|
+
seen.push(preset());
|
|
7524
|
+
}
|
|
7525
|
+
assert.deepEqual(seen, [VISUAL_PRESET.POWER_USER, VISUAL_PRESET.LIGHT, VISUAL_PRESET.NEUTRAL]);
|
|
7526
|
+
assert.match(ui.notices.at(-1) ?? "", /Preset: Neutral/);
|
|
7527
|
+
// A hand-tuned mix starts the cycle from Neutral.
|
|
7528
|
+
writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, density: DENSITY.MINIMAL }, { gentlePiConfigHome: home });
|
|
7529
|
+
await shortcut.handler(ctx);
|
|
7530
|
+
assert.equal(preset(), VISUAL_PRESET.NEUTRAL);
|
|
7531
|
+
|
|
7532
|
+
const silent = fakePi();
|
|
7533
|
+
gentleShell(silent.pi, { GENTLE_PI_SHELL_PRESET_KEY: "off" });
|
|
7534
|
+
assert.equal(silent.shortcuts.has("alt+l"), false, "GENTLE_PI_SHELL_PRESET_KEY=off drops the shortcut");
|
|
7535
|
+
const moved = fakePi();
|
|
7536
|
+
gentleShell(moved.pi, { GENTLE_PI_SHELL_PRESET_KEY: "alt+o" });
|
|
7537
|
+
assert.ok(moved.shortcuts.has("alt+o"));
|
|
7538
|
+
});
|
|
7539
|
+
|
|
7540
|
+
test("the Stats section (Power user) follows its visibility switch, at any density", async (t) => {
|
|
7541
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7542
|
+
const render = async (stats: boolean, density: (typeof DENSITY)[keyof typeof DENSITY] = DENSITY.COMFORTABLE) => {
|
|
7543
|
+
writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, density, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility, stats } }, { gentlePiConfigHome: home });
|
|
7544
|
+
const { pi, handlers } = fakePi();
|
|
7545
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" });
|
|
7546
|
+
const { ctx, ui } = fakeContext({ entries: [assistantEntry({ input: 1000, output: 200, cost: 0.5 }), assistantEntry({ input: 500, output: 100, cost: 0.25 })] });
|
|
7547
|
+
await fire(handlers, "session_start", ctx);
|
|
7548
|
+
const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 180 }, requestRender() {} };
|
|
7549
|
+
const footer = (ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void })(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7550
|
+
try {
|
|
7551
|
+
return sidebarState(tui as unknown as TUI).parts.get("footer")!.render(46).map((line) => stripAnsi(line).trimEnd()).join("\n");
|
|
7552
|
+
} finally {
|
|
7553
|
+
footer.dispose();
|
|
7554
|
+
}
|
|
7555
|
+
};
|
|
7556
|
+
const power = await render(true);
|
|
7557
|
+
assert.match(power, /▾ STATS\s+\$0\.750 sub/, "a subscription marks the cost like the status bar");
|
|
7558
|
+
assert.match(power, /spent\s+\$0\.750 sub\s+2 turns/);
|
|
7559
|
+
assert.doesNotMatch(await render(false), /STATS/, "Neutral leaves it off");
|
|
7560
|
+
assert.doesNotMatch(await render(false, DENSITY.COMPACT), /STATS/, "compact density alone no longer adds it");
|
|
7561
|
+
assert.match(await render(true, DENSITY.COMPACT), /▾ STATS/);
|
|
7562
|
+
});
|
|
7563
|
+
|
|
7564
|
+
test("Stats reads what subagents spent from the Agents rail section", async (t) => {
|
|
7565
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7566
|
+
writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility, stats: true } }, { gentlePiConfigHome: home });
|
|
7567
|
+
const { pi, handlers } = fakePi();
|
|
7568
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" });
|
|
7569
|
+
const { ctx, ui } = fakeContext({ entries: [assistantEntry({ input: 1000, output: 200, cost: 0.5 })] });
|
|
7570
|
+
await fire(handlers, "session_start", ctx);
|
|
7571
|
+
const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 180 }, requestRender() {} };
|
|
7572
|
+
const footer = (ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { dispose(): void })(tui, plainTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
|
|
7573
|
+
let spend: { runs: number; tokens: number; cost: number } | undefined = { runs: 2, tokens: 4200, cost: 0.3 };
|
|
7574
|
+
const agents = sidebarPart(tui as unknown as TUI, "agents", { render: (_width: number) => [], invalidate() {}, dispose() {} }, { surface: "panel", render: () => [], spend: () => spend, invalidate() {} });
|
|
7575
|
+
try {
|
|
7576
|
+
const rail = sidebarState(tui as unknown as TUI).parts.get("footer")!;
|
|
7577
|
+
const text = () => rail.render(46).map((line) => stripAnsi(line).trimEnd()).join("\n");
|
|
7578
|
+
const before = rail.digest?.();
|
|
7579
|
+
assert.match(text(), /agents\s+2 runs · 4\.2k · \$0\.300 sub/);
|
|
7580
|
+
spend = { runs: 3, tokens: 5000, cost: 0.4 };
|
|
7581
|
+
assert.notEqual(rail.digest?.(), before, "new subagent spend repaints the cached section");
|
|
7582
|
+
assert.match(text(), /agents\s+3 runs/);
|
|
7583
|
+
} finally {
|
|
7584
|
+
agents.dispose();
|
|
7585
|
+
footer.dispose();
|
|
7586
|
+
}
|
|
7587
|
+
});
|
|
7588
|
+
|
|
7589
|
+
|
|
7590
|
+
test("Customize groups every setting like Layout while navigation keeps stores unchanged", async (t) => {
|
|
7591
|
+
const home = scopedDoubleEscCancelConfigHome(t);
|
|
7592
|
+
const { pi, commands } = fakePi();
|
|
7593
|
+
gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
|
|
7594
|
+
const { ctx, ui, overlayReady } = fakeContext();
|
|
7595
|
+
const pending = commands.get("gentle:customize")!.handler("", ctx);
|
|
7596
|
+
await overlayReady;
|
|
7597
|
+
const snapshot = () => JSON.stringify(readdirSync(home).sort().map(name => [name, readFileSync(join(home, name), "utf8")]));
|
|
7598
|
+
const before = snapshot();
|
|
7599
|
+
for (const [label, setting] of [["Banner rose:", "Banner rose"], ["Banner text logo:", "Banner text logo"], ["Theme:", "Theme"], ["Vim:", "Vim"], ["YOLO:", "YOLO"], ["Session permissions:", "Session permissions"], ["Default permissions:", "Default permissions"], ["Prompt history capture:", "History capture"], ["Audio notifications:", "Enabled"], ["Success:", "Success"], ["Section changes:", "changes"]]) {
|
|
7600
|
+
assert.ok(findCustomizeRow(ui, label), label);
|
|
7601
|
+
const lines = ui.overlayView!.render(180);
|
|
7602
|
+
assert.equal(lines.filter(line => line.split("│").some(part => part.trimStart().replace(/^▸\s*/, "").startsWith(`${setting} `) && /[●○]/.test(part))).length, 1, `${setting} has one options line`);
|
|
7603
|
+
}
|
|
7604
|
+
assert.ok(findCustomizeRow(ui, "Prompt history capture: enable"));
|
|
7605
|
+
ui.overlayView!.render(120); ui.overlayView!.handleInput("\x1b[C");
|
|
7606
|
+
await new Promise<void>(resolve => setImmediate(resolve));
|
|
7607
|
+
assert.equal(snapshot(), before, "browsing an off/on option cannot write a preference");
|
|
7608
|
+
ui.overlayView!.handleInput("\x1b"); await pending;
|
|
7609
|
+
});
|