Files
pi-skill/extensions/agent-nav.ts
2026-05-25 16:41:08 +07:00

29 lines
973 B
TypeScript

// ABOUTME: Shared F-key navigation for agent widgets (chain, team)
// ABOUTME: Dispatches F1-F4 to the first active NavProvider on globalThis
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
export default function (pi: ExtensionAPI) {
function getActiveProvider() {
const providers = (globalThis as any).__piNavProviders || [];
return providers.find((p: any) => p.isActive());
}
pi.registerShortcut("f1", {
description: "Select previous item",
handler: async (ctx) => { getActiveProvider()?.selectPrev(ctx); },
});
pi.registerShortcut("f2", {
description: "Select next item",
handler: async (ctx) => { getActiveProvider()?.selectNext(ctx); },
});
pi.registerShortcut("f3", {
description: "Open detail view",
handler: async (ctx) => { await getActiveProvider()?.showDetail(ctx); },
});
pi.registerShortcut("f4", {
description: "Exit selection",
handler: async (ctx) => { getActiveProvider()?.exitSelection(ctx); },
});
}