pi-sdk-web 0.5.13 → 0.5.14
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.
- package/dist/server.js +26 -11
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -882,22 +882,37 @@ export class PiWebServer {
|
|
|
882
882
|
}
|
|
883
883
|
};
|
|
884
884
|
const unsubscribe = this.session.subscribe(listener);
|
|
885
|
-
// hasUI
|
|
886
|
-
//
|
|
887
|
-
//
|
|
888
|
-
//
|
|
889
|
-
// (
|
|
885
|
+
// hasUI per extension: extensions whose command handler draws a TUI
|
|
886
|
+
// panel via ctx.ui.custom() when hasUI=true need hasUI:false so they
|
|
887
|
+
// use their text fallback instead (pi-web can't render custom()).
|
|
888
|
+
// magic-context /ctx-status -> appendEntry (custom entry -> modal);
|
|
889
|
+
// aft-pi /aft-status (its only command) -> ui.notify(text).
|
|
890
|
+
// Everything else gets hasUI:true so notify-based output works.
|
|
890
891
|
const cmdPath = (cmd.sourceInfo && cmd.sourceInfo.path) || "";
|
|
891
|
-
const customOnly = /pi-magic-context|magic-context/.test(cmdPath);
|
|
892
|
+
const customOnly = /pi-magic-context|magic-context|aft-pi/.test(cmdPath);
|
|
893
|
+
// While a command runs, tag extension notify() broadcasts with the
|
|
894
|
+
// command name as title so the browser renders them as a titled,
|
|
895
|
+
// Markdown modal (e.g. /ctx-status, /aft-status) - the command's status
|
|
896
|
+
// report is a dialog, not a transient stream line. Restores the design
|
|
897
|
+
// in 68b56f1 (recorded in pi-web-design.md §14.9); 41112f5 had dropped
|
|
898
|
+
// the wrapping, so command notifies fell back to persistent status
|
|
899
|
+
// lines while custom-entry commands (/ctx-status) kept the modal.
|
|
900
|
+
const ui = this.uiContext;
|
|
901
|
+
const originalSink = ui.sink;
|
|
892
902
|
try {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
903
|
+
ui.sink = (obj) => {
|
|
904
|
+
const req = obj;
|
|
905
|
+
if (req && req.method === "notify") {
|
|
906
|
+
originalSink({ ...obj, title: `/${name}` });
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
originalSink(obj);
|
|
910
|
+
}
|
|
911
|
+
};
|
|
898
912
|
await cmd.handler(args, this.buildCommandContext(customOnly ? false : true));
|
|
899
913
|
}
|
|
900
914
|
finally {
|
|
915
|
+
ui.sink = originalSink;
|
|
901
916
|
unsubscribe();
|
|
902
917
|
}
|
|
903
918
|
// Show command output as a modal (TUI-like). The session entry remains
|