@ff-labs/pi-fff 0.9.5-nightly.ec57eb0 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +31 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ff-labs/pi-fff",
3
3
  "public": true,
4
- "version": "0.9.5-nightly.ec57eb0",
4
+ "version": "0.9.5",
5
5
  "description": "pi extension: FFF-powered fuzzy file and content search",
6
6
  "type": "module",
7
7
  "license": "MIT",
package/src/index.ts CHANGED
@@ -467,6 +467,30 @@ export default function fffExtension(pi: ExtensionAPI) {
467
467
  pi.on("session_start", async (_event, ctx) => {
468
468
  try {
469
469
  activeCwd = ctx.cwd;
470
+
471
+ // Restore persisted mode from session entries. This handles session
472
+ // resume after process restart where env vars are lost, and ensures
473
+ // the env var is set for the next /reload in the same session.
474
+ const entries = ctx.sessionManager?.getEntries();
475
+ if (entries) {
476
+ const modeEntry = [...entries]
477
+ .reverse()
478
+ .find(
479
+ (e: { type: string; customType?: string }) =>
480
+ e.type === "custom" && e.customType === "fff-mode",
481
+ );
482
+ if (
483
+ modeEntry &&
484
+ typeof (modeEntry as any).data?.mode === "string" &&
485
+ VALID_MODES.includes((modeEntry as any).data.mode as FffMode)
486
+ ) {
487
+ const restored = (modeEntry as any).data.mode as FffMode;
488
+ if (restored !== currentMode) {
489
+ currentMode = restored;
490
+ }
491
+ }
492
+ }
493
+
470
494
  registerAutocompleteProvider(ctx);
471
495
  await ensureFinder(activeCwd);
472
496
  } catch (e: unknown) {
@@ -920,8 +944,10 @@ export default function fffExtension(pi: ExtensionAPI) {
920
944
  if (!arg) {
921
945
  const mode = getMode();
922
946
  const flag = pi.getFlag("fff-mode") ?? "unset";
923
- const env = process.env.PI_FFF_MODE ?? "unset";
924
- ctx.ui.notify(`Current mode: '${mode}'\nFlag: ${flag}, Env: ${env}`, "info");
947
+ ctx.ui.notify(
948
+ `Current mode: '${mode}' (flag: ${flag})`,
949
+ "info",
950
+ );
925
951
  return;
926
952
  }
927
953
 
@@ -935,9 +961,11 @@ export default function fffExtension(pi: ExtensionAPI) {
935
961
  const oldMode = getMode();
936
962
  setMode(newMode);
937
963
 
964
+ pi.appendEntry("fff-mode", { mode: newMode });
965
+
938
966
  const note =
939
967
  (oldMode === "override") !== (newMode === "override")
940
- ? " (tool name change requires restart)"
968
+ ? " (tool name change requires /reload)"
941
969
  : "";
942
970
  ctx.ui.notify(`Mode changed: '${oldMode}' → '${newMode}'${note}`, "info");
943
971
  },