@mariozechner/pi-coding-agent 0.37.5 → 0.37.7

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.
@@ -609,9 +609,9 @@ export class InteractiveMode {
609
609
  */
610
610
  createExtensionUIContext() {
611
611
  return {
612
- select: (title, options) => this.showExtensionSelector(title, options),
613
- confirm: (title, message) => this.showExtensionConfirm(title, message),
614
- input: (title, placeholder) => this.showExtensionInput(title, placeholder),
612
+ select: (title, options, opts) => this.showExtensionSelector(title, options, opts),
613
+ confirm: (title, message, opts) => this.showExtensionConfirm(title, message, opts),
614
+ input: (title, placeholder, opts) => this.showExtensionInput(title, placeholder, opts),
615
615
  notify: (message, type) => this.showExtensionNotify(message, type),
616
616
  setStatus: (key, text) => this.setExtensionStatus(key, text),
617
617
  setWidget: (key, content) => this.setExtensionWidget(key, content),
@@ -630,12 +630,23 @@ export class InteractiveMode {
630
630
  /**
631
631
  * Show a selector for extensions.
632
632
  */
633
- showExtensionSelector(title, options) {
633
+ showExtensionSelector(title, options, opts) {
634
634
  return new Promise((resolve) => {
635
+ if (opts?.signal?.aborted) {
636
+ resolve(undefined);
637
+ return;
638
+ }
639
+ const onAbort = () => {
640
+ this.hideExtensionSelector();
641
+ resolve(undefined);
642
+ };
643
+ opts?.signal?.addEventListener("abort", onAbort, { once: true });
635
644
  this.extensionSelector = new ExtensionSelectorComponent(title, options, (option) => {
645
+ opts?.signal?.removeEventListener("abort", onAbort);
636
646
  this.hideExtensionSelector();
637
647
  resolve(option);
638
648
  }, () => {
649
+ opts?.signal?.removeEventListener("abort", onAbort);
639
650
  this.hideExtensionSelector();
640
651
  resolve(undefined);
641
652
  });
@@ -658,19 +669,30 @@ export class InteractiveMode {
658
669
  /**
659
670
  * Show a confirmation dialog for extensions.
660
671
  */
661
- async showExtensionConfirm(title, message) {
662
- const result = await this.showExtensionSelector(`${title}\n${message}`, ["Yes", "No"]);
672
+ async showExtensionConfirm(title, message, opts) {
673
+ const result = await this.showExtensionSelector(`${title}\n${message}`, ["Yes", "No"], opts);
663
674
  return result === "Yes";
664
675
  }
665
676
  /**
666
677
  * Show a text input for extensions.
667
678
  */
668
- showExtensionInput(title, placeholder) {
679
+ showExtensionInput(title, placeholder, opts) {
669
680
  return new Promise((resolve) => {
681
+ if (opts?.signal?.aborted) {
682
+ resolve(undefined);
683
+ return;
684
+ }
685
+ const onAbort = () => {
686
+ this.hideExtensionInput();
687
+ resolve(undefined);
688
+ };
689
+ opts?.signal?.addEventListener("abort", onAbort, { once: true });
670
690
  this.extensionInput = new ExtensionInputComponent(title, placeholder, (value) => {
691
+ opts?.signal?.removeEventListener("abort", onAbort);
671
692
  this.hideExtensionInput();
672
693
  resolve(value);
673
694
  }, () => {
695
+ opts?.signal?.removeEventListener("abort", onAbort);
674
696
  this.hideExtensionInput();
675
697
  resolve(undefined);
676
698
  });
@@ -881,7 +903,7 @@ export class InteractiveMode {
881
903
  return;
882
904
  }
883
905
  if (text.startsWith("/export")) {
884
- this.handleExportCommand(text);
906
+ await this.handleExportCommand(text);
885
907
  this.editor.setText("");
886
908
  return;
887
909
  }
@@ -2095,11 +2117,11 @@ export class InteractiveMode {
2095
2117
  // =========================================================================
2096
2118
  // Command handlers
2097
2119
  // =========================================================================
2098
- handleExportCommand(text) {
2120
+ async handleExportCommand(text) {
2099
2121
  const parts = text.split(/\s+/);
2100
2122
  const outputPath = parts.length > 1 ? parts[1] : undefined;
2101
2123
  try {
2102
- const filePath = this.session.exportToHtml(outputPath);
2124
+ const filePath = await this.session.exportToHtml(outputPath);
2103
2125
  this.showStatus(`Session exported to: ${filePath}`);
2104
2126
  }
2105
2127
  catch (error) {
@@ -2122,7 +2144,7 @@ export class InteractiveMode {
2122
2144
  // Export to a temp file
2123
2145
  const tmpFile = path.join(os.tmpdir(), "session.html");
2124
2146
  try {
2125
- this.session.exportToHtml(tmpFile);
2147
+ await this.session.exportToHtml(tmpFile);
2126
2148
  }
2127
2149
  catch (error) {
2128
2150
  this.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);