@wierdbytes/pi-facelift 0.6.4 → 0.6.5

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 (3) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/index.ts +15 -2
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.5
4
+
5
+ - **Fix:** pi crashing with "extension ctx is stale" when the session was replaced or reloaded while the working timer was ticking.
6
+
3
7
  ## 0.6.4
4
8
 
5
9
  - **Fix:** declare `shiki` as a runtime dependency instead of a dev-only one.
package/index.ts CHANGED
@@ -1180,11 +1180,24 @@ export default function piFaceliftExtension(pi: PiFaceliftApi, deps?: PiFacelift
1180
1180
  };
1181
1181
 
1182
1182
  const renderWorkingMessage = (ctx: SessionContextLike): void => {
1183
- if (ctx.hasUI) {
1184
- ctx.ui.setWorkingMessage(workingMessageText(workingTracker.elapsedMs(), workingTracker.liveTps()));
1183
+ // The ticker captures `ctx`; after session replacement / reload any
1184
+ // access to it throws (stale ctx). Inside a timer that would be an
1185
+ // uncaughtException and kill pi, so swallow and stop ticking.
1186
+ try {
1187
+ if (ctx.hasUI) {
1188
+ ctx.ui.setWorkingMessage(workingMessageText(workingTracker.elapsedMs(), workingTracker.liveTps()));
1189
+ }
1190
+ } catch {
1191
+ stopWorkingTick();
1185
1192
  }
1186
1193
  };
1187
1194
 
1195
+ // Session replaced / reloaded / exiting mid-stream: message_end and
1196
+ // agent_settled may never arrive, so kill the ticker here.
1197
+ pi.on("session_shutdown", () => {
1198
+ stopWorkingTick();
1199
+ });
1200
+
1188
1201
  // `before_agent_start` fires right after the user submits the prompt,
1189
1202
  // so it anchors the wall-clock `total` (retries + tools + overhead).
1190
1203
  pi.on("before_agent_start", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wierdbytes/pi-facelift",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Cosmetic facelift for built-in pi tool output — open-right rounded frames, syntax-highlighted reads, status-aware bash summaries, find/grep.",
5
5
  "type": "module",
6
6
  "files": [