pi-sdk-web 0.3.9 → 0.3.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/dist/server.js +18 -3
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -112,6 +112,13 @@ export class PiWebServer {
112
112
  // during teardown/dispose of the old session).
113
113
  this.unsubscribe?.();
114
114
  this.unsubscribe = null;
115
+ if (afterSwitch) {
116
+ // Drop stale extension dialogs/status from the PREVIOUS session BEFORE
117
+ // rebinding: bindExtensions emits session_start, whose handlers (e.g.
118
+ // magic-context's status line) call setStatus and populate statusMap.
119
+ // Clearing after bindExtensions would wipe the new session's values.
120
+ this.uiContext.clearSessionState();
121
+ }
115
122
  await session.bindExtensions({
116
123
  uiContext: this.uiContext,
117
124
  // "rpc" is the closest ExtensionMode: dialog-capable UI (hasUI=true),
@@ -135,10 +142,14 @@ export class PiWebServer {
135
142
  console.error(`Session cwd not found (${cwd}), keeping current directory`);
136
143
  }
137
144
  }
138
- // Stale extension dialogs/status from the previous session are dropped
139
- this.uiContext.clearSessionState();
140
145
  this.broadcastState();
141
146
  this.broadcastHistory();
147
+ // Push the (new) extension status snapshot: the frontend's
148
+ // clearContent() on history wipes ext-status and there is no other
149
+ // channel after switching, so plugin status lines (e.g. magic-context)
150
+ // would stay hidden until the new session's first turn event.
151
+ const extStatus = this.uiContext.getStatusSnapshot();
152
+ this.broadcast({ type: "ext_status", data: extStatus });
142
153
  }
143
154
  }
144
155
  async stop() {
@@ -390,7 +401,11 @@ export class PiWebServer {
390
401
  const message = typeof data.message === "string" ? data.message : "";
391
402
  if (!message)
392
403
  throw new Error("Missing 'message'");
393
- await this.session.prompt(message);
404
+ // Queue with steer when the agent is already running (matches TUI's
405
+ // default: user messages submitted mid-turn are steered, i.e. handled
406
+ // right after the current turn; without this Pi throws
407
+ // "Agent is already processing...").
408
+ await this.session.prompt(message, { streamingBehavior: "steer" });
394
409
  break;
395
410
  }
396
411
  case "abort":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-sdk-web",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "Browser Web access for Pi (AI coding agent) via the Pi SDK - standalone module, zero modification to Pi itself",
5
5
  "type": "module",
6
6
  "bin": {