oira666_pi-subagent 0.2.9 → 0.2.11

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/index.ts +22 -1
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -373,6 +373,7 @@ const RESUME_PROVIDER = "pi-subagent-resume";
373
373
  const RESUME_MODEL_ID = "synthetic-tool-call";
374
374
  const RESUME_STATE_KEY = "__piSubagentResumeState";
375
375
  const SUBAGENT_FALLBACK_MODEL_ENV = "PI_SUBAGENT_FALLBACK_MODEL";
376
+ const RESUME_INTERACTIVE_DELAY_MS = 50;
376
377
 
377
378
  type SyntheticResumeState = {
378
379
  plan: ResumableSubagentCall | null;
@@ -471,6 +472,7 @@ function getRestorableModel(ctx: any): any | undefined {
471
472
  export default function (pi: ExtensionAPI) {
472
473
  let resumeModelRegistry: any | undefined;
473
474
  let lastRestorableModel: any | undefined;
475
+ let pendingInteractiveResumePrompt: string | null = null;
474
476
 
475
477
  async function streamWithRealModelFallback(context: any, options: any, fallback: any) {
476
478
  if (!fallback) return null;
@@ -684,7 +686,12 @@ export default function (pi: ExtensionAPI) {
684
686
  if (hasCliInitialPrompt(process.argv)) {
685
687
  if (ctx.hasUI) ctx.ui.notify(`Resuming ${plan.tasks.length} subagents...`, "info");
686
688
  } else {
687
- pi.sendUserMessage(`Resuming ${plan.tasks.length} subagents...`);
689
+ // Do not start the synthetic resume turn from session_start. Pi renders
690
+ // the resumed chat only after session_start/resources_discover complete;
691
+ // starting now lets that render wipe out the live tool component, so no
692
+ // real-time updates appear. Queue it for resources_discover instead,
693
+ // which is the last extension hook before the initial chat render.
694
+ pendingInteractiveResumePrompt = `Resuming ${plan.tasks.length} subagents...`;
688
695
  }
689
696
  } catch (err) {
690
697
  console.error("[pi-subagent] Error in session_start:", err);
@@ -696,6 +703,20 @@ export default function (pi: ExtensionAPI) {
696
703
  await restoreModelAfterResumeFailure();
697
704
  });
698
705
 
706
+ pi.on("resources_discover", (_event, ctx) => {
707
+ const prompt = pendingInteractiveResumePrompt;
708
+ if (!prompt) return;
709
+ pendingInteractiveResumePrompt = null;
710
+ setTimeout(() => {
711
+ try {
712
+ pi.sendUserMessage(prompt);
713
+ } catch (err) {
714
+ console.error("[pi-subagent] Failed to start deferred resume turn:", err);
715
+ void restoreModelAfterResumeFailure(ctx);
716
+ }
717
+ }, RESUME_INTERACTIVE_DELAY_MS);
718
+ });
719
+
699
720
  // Inject available agents into the system prompt
700
721
  pi.on("before_agent_start", async (event) => {
701
722
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oira666_pi-subagent",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Subagent extension for Pi coding agent. Delegate tasks to specialized agents.",
5
5
  "type": "module",
6
6
  "main": "index.ts",