Update Pi packages to 0.79.9 and align pi-ask with current TUI/RPC behavior. - guard custom ask/settings flows to TUI mode with a clear non-TUI fallback - reset config cache on extension reload so edited settings are picked up - clean up remote ask flow listeners on session shutdown - forward editor focus/invalidation and keep @ file autocomplete explicit - document the non-TUI contract and cover the compatibility fixes with tests
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { registerAnswerCommands } from "../src/answer-commands.ts";
|
|
|
|
function registerCommands() {
|
|
const commands = new Map<
|
|
string,
|
|
{ handler: (args: string, ctx: any) => Promise<void> }
|
|
>();
|
|
registerAnswerCommands({
|
|
registerCommand(
|
|
name: string,
|
|
command: { handler: (args: string, ctx: any) => Promise<void> }
|
|
) {
|
|
commands.set(name, command);
|
|
},
|
|
} as never);
|
|
return commands;
|
|
}
|
|
|
|
test("answer commands do not open custom UI outside TUI mode", async () => {
|
|
const commands = registerCommands();
|
|
const notifications: Array<{ message: string; type: string }> = [];
|
|
let customOpened = false;
|
|
const ctx = {
|
|
mode: "rpc",
|
|
ui: {
|
|
custom() {
|
|
customOpened = true;
|
|
},
|
|
notify(message: string, type: string) {
|
|
notifications.push({ message, type });
|
|
},
|
|
},
|
|
};
|
|
|
|
await commands.get("answer")?.handler("", ctx);
|
|
await commands.get("answer:again")?.handler("", ctx);
|
|
await commands.get("ask:replay")?.handler("", ctx);
|
|
|
|
assert.equal(customOpened, false);
|
|
assert.deepEqual(notifications, [
|
|
{ message: "/answer requires interactive TUI mode.", type: "error" },
|
|
{ message: "Ask replay requires interactive TUI mode.", type: "error" },
|
|
{ message: "Ask replay requires interactive TUI mode.", type: "error" },
|
|
]);
|
|
});
|