mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
* fix(coding-agent): keep selector status markers visible - place status markers before labels - strike unavailable scoped models and update tests * fix(coding-agent): align scoped model toggle behavior - show checks for the all-enabled state - toggle individual models consistently and add coverage * docs(coding-agent): add changelog entry * fix(coding-agent): keep trust marker visible while browsing - move the saved marker before the trust option - update tests and changelog * fix(coding-agent): mark per-model thinking overrides - add the leading level marker - update tests and changelog
91 lines
2.7 KiB
TypeScript
91 lines
2.7 KiB
TypeScript
import { setKeybindings } from "@earendil-works/pi-tui";
|
|
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { KeybindingsManager } from "../src/core/keybindings.ts";
|
|
import { TrustSelectorComponent } from "../src/modes/interactive/components/trust-selector.ts";
|
|
import { initTheme } from "../src/modes/interactive/theme/theme.ts";
|
|
import { stripAnsi } from "../src/utils/ansi.ts";
|
|
|
|
describe("TrustSelectorComponent", () => {
|
|
beforeAll(() => {
|
|
initTheme("dark");
|
|
});
|
|
|
|
beforeEach(() => {
|
|
setKeybindings(new KeybindingsManager());
|
|
});
|
|
|
|
it("keeps the saved trusted decision marked while browsing", () => {
|
|
const selector = new TrustSelectorComponent({
|
|
cwd: "/project",
|
|
savedDecision: { path: "/project", decision: true },
|
|
projectTrusted: true,
|
|
onSelect: () => {},
|
|
onCancel: () => {},
|
|
});
|
|
|
|
let output = stripAnsi(selector.render(120).join("\n"));
|
|
expect(output).toContain("Saved decision: trusted (/project)");
|
|
expect(output).toContain("Current session: trusted");
|
|
expect(output).toContain("→ ✓ Trust");
|
|
|
|
selector.handleInput("\x1b[B");
|
|
output = stripAnsi(selector.render(120).join("\n"));
|
|
expect(output).toContain("✓ Trust");
|
|
expect(output).toContain("→ Trust parent folder (/)");
|
|
expect(output).not.toContain("✓ Do not trust");
|
|
});
|
|
|
|
it("selects a trust decision", () => {
|
|
const onSelect = vi.fn();
|
|
const selector = new TrustSelectorComponent({
|
|
cwd: "/project",
|
|
savedDecision: null,
|
|
projectTrusted: false,
|
|
onSelect,
|
|
onCancel: () => {},
|
|
});
|
|
|
|
selector.handleInput("\n");
|
|
|
|
expect(onSelect).toHaveBeenCalledWith({ trusted: true, updates: [{ path: "/project", decision: true }] });
|
|
});
|
|
|
|
it("labels saved ancestor decisions as inherited", () => {
|
|
const selector = new TrustSelectorComponent({
|
|
cwd: "/parent/project/nested",
|
|
savedDecision: { path: "/parent", decision: true },
|
|
projectTrusted: true,
|
|
onSelect: () => {},
|
|
onCancel: () => {},
|
|
});
|
|
|
|
const output = stripAnsi(selector.render(120).join("\n"));
|
|
|
|
expect(output).toContain("Saved decision: trusted (inherited from /parent)");
|
|
});
|
|
|
|
it("adds a trust parent option", () => {
|
|
const onSelect = vi.fn();
|
|
const selector = new TrustSelectorComponent({
|
|
cwd: "/parent/project",
|
|
savedDecision: { path: "/parent", decision: true },
|
|
projectTrusted: true,
|
|
onSelect,
|
|
onCancel: () => {},
|
|
});
|
|
|
|
const output = stripAnsi(selector.render(120).join("\n"));
|
|
expect(output).toContain("Saved decision: trusted (inherited from /parent)");
|
|
expect(output).toContain("✓ Trust parent folder (/parent)");
|
|
|
|
selector.handleInput("\n");
|
|
|
|
expect(onSelect).toHaveBeenCalledWith({
|
|
trusted: true,
|
|
updates: [
|
|
{ path: "/parent", decision: true },
|
|
{ path: "/parent/project", decision: null },
|
|
],
|
|
});
|
|
});
|
|
});
|