Skip to content

fix(pi-fff): feature-detect ctx.ui.addAutocompleteProvider (#651)#653

Merged
dmtrKovalenko merged 1 commit into
mainfrom
triage-bot/issue-651
Jul 6, 2026
Merged

fix(pi-fff): feature-detect ctx.ui.addAutocompleteProvider (#651)#653
dmtrKovalenko merged 1 commit into
mainfrom
triage-bot/issue-651

Conversation

@gustav-fff

Copy link
Copy Markdown
Collaborator

Closes #651

Root cause

packages/pi-fff/src/index.ts:411 calls ctx.ui.addAutocompleteProvider unconditionally inside session_start. The type at :406 also declares it as required. On pi forks that do not expose this method (omp, reported in #651), the call throws and the catch in session_start (:496-501) surfaces FFF init failed: ctx.ui.addAutocompleteProvider is not a function — and, more importantly, tool registration for the session never completes.

Fix

Mark addAutocompleteProvider as optional in the accepted ctx shape and feature-detect it before calling. When absent, skip the UI wiring and return — tools (find/grep/multi_grep) still register normally.

Steps to reproduce

Pre-fix, on origin/main:

git checkout origin/main
cd packages/pi-fff
bun install

Add a repro test that mimics an omp-style host lacking addAutocompleteProvider:

// packages/pi-fff/test/repro.test.ts
import { test, expect, mock } from "bun:test";
import fffExtension from "../src/index";

test("host without addAutocompleteProvider", async () => {
  const events = new Map<string, any>();
  const pi = {
    getFlag: mock(() => undefined),
    on: mock((e: string, h: any) => { events.set(e, h); }),
    registerCommand: mock(() => undefined),
    registerFlag: mock(() => undefined),
    registerTool: mock(() => undefined),
    appendEntry: mock(() => undefined),
  };
  const ctx = {
    cwd: "/tmp/workspace",
    ui: { notify: mock(() => undefined), setEditorComponent: mock(() => undefined) },
    // NOTE: no addAutocompleteProvider — matches omp fork surface
  };
  fffExtension(pi as any);
  await events.get("session_start")({ reason: "startup" }, ctx);
  expect(ctx.ui.notify).not.toHaveBeenCalled();
});

Run:

bun test test/repro.test.ts

Expected: pass.
Actual on origin/main: fails — ctx.ui.notify is called with FFF init failed: ctx.ui.addAutocompleteProvider is not a function, matching the traceback in the issue.

How verified

cd packages/pi-fff
bun test test/extension.test.ts

Output: 8 pass, 0 fail — includes the new session_start survives hosts without addAutocompleteProvider regression test plus the existing 7 tests unchanged.

Automated triage via Gustav. Honk-Honk 🪿

pi forks (e.g. omp) do not expose addAutocompleteProvider, causing
session_start to throw "FFF init failed: ... is not a function" and
skipping tool registration entirely.

Skip UI wiring when the host lacks the method; tools still register.

Refs #651
@dmtrKovalenko dmtrKovalenko merged commit 960e689 into main Jul 6, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: @ff-labs/pi-fff@0.9.6 FFF init failed when used with omp

2 participants