add persisted pi workflow extension
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
createChildResources,
|
||||
resolveStandaloneChildProjectTrust,
|
||||
shutdownAndDisposeChildSession,
|
||||
waitForChildOperation,
|
||||
type DisposableChildSession,
|
||||
} from "./child-session.ts";
|
||||
|
||||
@@ -105,6 +106,7 @@ test("child denylist keeps extension and workflow structured tools available", a
|
||||
"subagent_check",
|
||||
"subagent_list",
|
||||
"workflow",
|
||||
"pi_workflow",
|
||||
"ask_user",
|
||||
],
|
||||
);
|
||||
@@ -253,6 +255,12 @@ test("shutdown helper balances hooks and disposal despite errors", async () => {
|
||||
assert.equal(disposals, 1);
|
||||
});
|
||||
|
||||
test("child operations are bounded independently of teardown", async () => {
|
||||
const startedAt = Date.now();
|
||||
await waitForChildOperation(new Promise(() => {}), 5);
|
||||
assert.ok(Date.now() - startedAt < 100);
|
||||
});
|
||||
|
||||
test("shutdown helper bounds a stuck hook before disposal", async () => {
|
||||
let disposals = 0;
|
||||
const session: DisposableChildSession = {
|
||||
|
||||
@@ -18,6 +18,7 @@ export const CHILD_EXCLUDED_TOOL_NAMES = [
|
||||
"subagent_check",
|
||||
"subagent_list",
|
||||
"workflow",
|
||||
"pi_workflow",
|
||||
"ask_user",
|
||||
] as const;
|
||||
|
||||
@@ -92,7 +93,10 @@ export interface DisposableChildSession {
|
||||
|
||||
const childShutdowns = new WeakMap<object, Promise<void>>();
|
||||
|
||||
function waitBounded(operation: Promise<unknown>, timeoutMs: number) {
|
||||
export function waitForChildOperation(
|
||||
operation: Promise<unknown>,
|
||||
timeoutMs = CHILD_SHUTDOWN_TIMEOUT_MS,
|
||||
) {
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
const timeout = new Promise<void>((resolve) => {
|
||||
timer = setTimeout(resolve, timeoutMs);
|
||||
@@ -124,7 +128,7 @@ export function shutdownAndDisposeChildSession(
|
||||
const shutdown = (async () => {
|
||||
try {
|
||||
if (session.extensionRunner.hasHandlers("session_shutdown")) {
|
||||
await waitBounded(
|
||||
await waitForChildOperation(
|
||||
session.extensionRunner.emit({
|
||||
type: "session_shutdown",
|
||||
reason: "quit",
|
||||
|
||||
Reference in New Issue
Block a user