pi-anycopy 0.2.5 → 0.2.6

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.
@@ -4,7 +4,7 @@ export type AnycopySummaryChoice = "No summary" | "Summarize" | "Summarize with
4
4
 
5
5
  export type AnycopyEnterNavigationDeps = {
6
6
  entryId: string;
7
- effectiveLeafIdForNoop: string | null;
7
+ currentLeafIdForNoop: string | null;
8
8
  skipSummaryPrompt: boolean;
9
9
  close: () => void;
10
10
  reopen: (options: { initialSelectedId: string }) => void;
@@ -21,12 +21,29 @@ export type AnycopyEnterNavigationDeps = {
21
21
  };
22
22
  };
23
23
 
24
+ export function createAnycopyEnterNavigationLauncher(
25
+ run: (entryId: string) => Promise<AnycopyEnterNavigationResult>,
26
+ ): (entryId: string) => void {
27
+ let navigationInFlight = false;
28
+
29
+ return (entryId: string) => {
30
+ if (navigationInFlight) {
31
+ return;
32
+ }
33
+
34
+ navigationInFlight = true;
35
+ void run(entryId).finally(() => {
36
+ navigationInFlight = false;
37
+ });
38
+ };
39
+ }
40
+
24
41
  export async function runAnycopyEnterNavigation(
25
42
  deps: AnycopyEnterNavigationDeps,
26
43
  ): Promise<AnycopyEnterNavigationResult> {
27
- const { entryId, effectiveLeafIdForNoop, skipSummaryPrompt, close, reopen, navigateTree, ui } = deps;
44
+ const { entryId, currentLeafIdForNoop, skipSummaryPrompt, close, reopen, navigateTree, ui } = deps;
28
45
 
29
- if (effectiveLeafIdForNoop !== null && entryId === effectiveLeafIdForNoop) {
46
+ if (currentLeafIdForNoop !== null && entryId === currentLeafIdForNoop) {
30
47
  close();
31
48
  ui.setStatus("anycopy", "Already at this point");
32
49
  return "closed";
@@ -31,7 +31,7 @@ import { homedir } from "os";
31
31
  import { dirname, join } from "path";
32
32
  import { fileURLToPath } from "url";
33
33
 
34
- import { runAnycopyEnterNavigation } from "./enter-navigation.ts";
34
+ import { createAnycopyEnterNavigationLauncher, runAnycopyEnterNavigation } from "./enter-navigation.ts";
35
35
  import {
36
36
  ANYCOPY_FOLD_STATE_CUSTOM_TYPE,
37
37
  createFoldStateEntryData,
@@ -799,30 +799,33 @@ export default function anycopyExtension(pi: ExtensionAPI) {
799
799
  : null;
800
800
  let durableFoldedNodeIds = restoredFoldState?.foldedNodeIds ?? [];
801
801
  let lastPersistedFoldedNodeIds = durableFoldedNodeIds;
802
+ const currentLeafIdForNoop = currentLeafId;
803
+
804
+ const startEnterNavigation = createAnycopyEnterNavigationLauncher(async (entryId) =>
805
+ runAnycopyEnterNavigation({
806
+ entryId,
807
+ currentLeafIdForNoop,
808
+ skipSummaryPrompt,
809
+ close: done,
810
+ reopen: (reopenOpts) => {
811
+ void openAnycopy(ctx, reopenOpts);
812
+ },
813
+ navigateTree: async (targetId, options) => ctx.navigateTree(targetId, options),
814
+ ui: {
815
+ select: (title, options) => ctx.ui.select(title, options),
816
+ editor: (title) => ctx.ui.editor(title),
817
+ setStatus: (source, message) => ctx.ui.setStatus(source, message),
818
+ setWorkingMessage: (message) => ctx.ui.setWorkingMessage(message),
819
+ notify: (message, level) => ctx.ui.notify(message, level),
820
+ },
821
+ }),
822
+ );
802
823
 
803
824
  const selector = new TreeSelectorComponent(
804
825
  initialTree,
805
826
  currentLeafId,
806
827
  treeTermHeight,
807
- (entryId) => {
808
- void runAnycopyEnterNavigation({
809
- entryId,
810
- effectiveLeafIdForNoop,
811
- skipSummaryPrompt,
812
- close: done,
813
- reopen: (reopenOpts) => {
814
- void openAnycopy(ctx, reopenOpts);
815
- },
816
- navigateTree: async (targetId, options) => ctx.navigateTree(targetId, options),
817
- ui: {
818
- select: (title, options) => ctx.ui.select(title, options),
819
- editor: (title) => ctx.ui.editor(title),
820
- setStatus: (source, message) => ctx.ui.setStatus(source, message),
821
- setWorkingMessage: (message) => ctx.ui.setWorkingMessage(message),
822
- notify: (message, level) => ctx.ui.notify(message, level),
823
- },
824
- });
825
- },
828
+ startEnterNavigation,
826
829
  () => done(),
827
830
  (entryId, label) => {
828
831
  pi.setLabel(entryId, label);
@@ -877,7 +880,6 @@ export default function anycopyExtension(pi: ExtensionAPI) {
877
880
  persistDurableFoldState(nextDurableFoldedNodeIds);
878
881
  };
879
882
 
880
- const effectiveLeafIdForNoop = selector.getTreeList().getSelectedNode()?.entry.id ?? currentLeafId;
881
883
  const overlay = new anycopyOverlay(
882
884
  selector,
883
885
  getTree,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-anycopy",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Pi's /tree with a live syntax-highlighted preview, ability to copy any node(s) to the clipboard, and persistence of folded branches",
5
5
  "keywords": ["pi-package", "pi", "pi-coding-agent"],
6
6
  "license": "MIT",