Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/pi-fff/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,15 @@ export default function fffExtension(pi: ExtensionAPI) {

function registerAutocompleteProvider(ctx: {
ui: {
addAutocompleteProvider: (
addAutocompleteProvider?: (
factory: (current: AutocompleteProvider) => AutocompleteProvider,
) => void;
};
}) {
// pi forks (e.g. omp) may not expose addAutocompleteProvider; skip UI wiring
// and let tools continue to work instead of failing session_start.
if (typeof ctx.ui.addAutocompleteProvider !== "function") return;

ctx.ui.addAutocompleteProvider((current) => {
const mentionProvider = createFffMentionProvider(getMentionItems);

Expand Down
18 changes: 18 additions & 0 deletions packages/pi-fff/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ describe("pi-fff autocomplete registration", () => {
]);
});

test("session_start survives hosts without addAutocompleteProvider", async () => {
const setup = createPi();
const ctx = {
cwd: "/tmp/workspace",
ui: {
notify: mock(() => undefined),
setEditorComponent: mock(() => undefined),
},
};
fffExtension(setup.pi as any);

const sessionStart = setup.events.get("session_start");
await sessionStart?.({ reason: "startup" }, ctx);

expect(ctx.ui.notify).not.toHaveBeenCalled();
expect(createCalls).toHaveLength(1);
});

test("delegates non-@ completions to the current provider", async () => {
const { ctx } = await start();
const factory = ctx.ui.addAutocompleteProvider.mock.calls[0][0];
Expand Down
Loading