pi-dev-flow 0.86.1 → 0.86.2

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/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.86.2] - 2026-11-09
8
+
9
+ **Stale stage chips in pi-web clear themselves after a dropped connection.**
10
+
11
+ ### Fixed
12
+ - **pi-web no longer piles up old stage chips beside the current one.** dev-flow's chip in pi-web is labelled with the stage, so each stage change removes the old chip and adds a new one. If the browser's connection was down at that moment (a phone in the background, say), it missed the removal, and pi-web does not re-sync chips on reconnect, so one stale chip was left per missed stage change. Every repaint now re-sends the removal for the last few chips the session showed, so a missed one disappears at the next turn.
13
+
7
14
  ## [0.86.1] - 2026-11-08
8
15
 
9
16
  **A reply that stops mid-thought resumes on its own instead of stalling the flow.**
@@ -29,7 +29,7 @@ import { loadProject } from "../src/projectmd.ts";
29
29
  import { bashTimeout, requireTimeout, timeoutClass } from "../src/timeouts.ts";
30
30
  import { AGENT_MARK, operatorCommandAsks, operatorCommandCorrection, viewHeader, askLine, type GateView } from "../src/present.ts";
31
31
  import { Text } from "@earendil-works/pi-tui";
32
- import { CONTEXT_EMITTED, COPIES, GATE_HELP, SELF_BUILD, SKILL_DIR, type Ui, WEB_CHIP_KEYS, baseSeams, bindings, boundFeature, claimBlocker, claimFile, compacting, compactionTakeover, coreInjected, coreStale, currentBranch, dfDir, featDir, featureRefs, flowCompactInstructions, flowRoot, guardsAreMine, initiated, lastContext, loadedVersion, maybeCompactNow, noteFriction, now, readClaim, readReflections, readReflectionsText, readRoadmap, readState, registerCopy, releaseSession, sessionKey, sh, skillCore, unfinishedStates, worktreeAbs, writeClaim, writeState } from "../src/runtime/base.ts";
32
+ import { CONTEXT_EMITTED, COPIES, GATE_HELP, SELF_BUILD, SKILL_DIR, type Ui, WEB_CHIP_KEYS, LEGACY_CHIP_KEYS, nextChipKeys, baseSeams, bindings, boundFeature, claimBlocker, claimFile, compacting, compactionTakeover, coreInjected, coreStale, currentBranch, dfDir, featDir, featureRefs, flowCompactInstructions, flowRoot, guardsAreMine, initiated, lastContext, loadedVersion, maybeCompactNow, noteFriction, now, readClaim, readReflections, readReflectionsText, readRoadmap, readState, registerCopy, releaseSession, sessionKey, sh, skillCore, unfinishedStates, worktreeAbs, writeClaim, writeState } from "../src/runtime/base.ts";
33
33
  import { type Session, presentRun } from "../src/runtime/checks.ts";
34
34
  import { isSelfRepo } from "../src/runtime/setup.ts";
35
35
  import { foldView, pluginUpstream } from "../src/runtime/reflect.ts";
@@ -51,14 +51,20 @@ function refreshStatus(ctx: ExtensionContext, root: string): void {
51
51
  if (!ctx.hasUI) return;
52
52
  const web = ctx.mode !== "tui";
53
53
  const sk = sessionKey(ctx);
54
+ // Old keys are cleared on EVERY repaint, not once — a clear the browser missed while its event stream
55
+ // was down (pi-web never re-syncs widgets on reconnect) is re-sent until the history ages it out.
54
56
  const setChip = (key: string | undefined, lines?: string[]) => {
55
- const prev = WEB_CHIP_KEYS.get(sk);
56
- if (prev !== undefined && prev !== key) ctx.ui.setWidget(prev, undefined);
57
- if (key === undefined) WEB_CHIP_KEYS.delete(sk);
58
- else {
59
- WEB_CHIP_KEYS.set(sk, key);
60
- ctx.ui.setWidget(key, lines);
57
+ let prev = WEB_CHIP_KEYS.get(sk);
58
+ if (prev === undefined) {
59
+ const legacy = LEGACY_CHIP_KEYS?.get(sk);
60
+ LEGACY_CHIP_KEYS?.delete(sk);
61
+ prev = legacy === undefined ? [] : [legacy];
61
62
  }
63
+ const next = nextChipKeys(prev, key);
64
+ for (const k of next.clear) ctx.ui.setWidget(k, undefined);
65
+ if (next.keys.length) WEB_CHIP_KEYS.set(sk, next.keys);
66
+ else WEB_CHIP_KEYS.delete(sk);
67
+ if (key !== undefined) ctx.ui.setWidget(key, lines);
62
68
  };
63
69
  if (!initiated(root)) {
64
70
  ctx.ui.setStatus("dev-flow", undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.86.1",
3
+ "version": "0.86.2",
4
4
  "description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -546,9 +546,24 @@ export function tail(out: string, n = 15): string {
546
546
 
547
547
  // ------------------------------------------------------------------ extension
548
548
 
549
- /** The pi-web chip's current key, per session: the chip's label IS the widget key, so it changes with the
550
- * footer text and the previous one must be cleared on every repaint. Per session, not per process — one
551
- * pi-web server repaints many sessions (drivers, chats, workers), and a single shared slot let session B's
552
- * repaint overwrite A's key, so A's next repaint cleared a key A never had and left its old chip beside
553
- * the new one. On globalThis so a /reload or a duplicate copy still knows the chip already painted. */
554
- export const WEB_CHIP_KEYS: Map<string, string> = ((globalThis as { __piDevFlowChipKeys?: Map<string, string> }).__piDevFlowChipKeys ??= new Map());
549
+ /** The pi-web chip keys a session has painted, oldest first, the current one last: the chip's label IS the
550
+ * widget key, so it changes with the footer text and the old ones must be cleared. Every repaint re-sends
551
+ * the clear for each old key, not just once: pi-web delivers a clear to the browser only over a live
552
+ * event stream and does not re-sync widgets on reconnect, so a phone that was backgrounded across a stage
553
+ * change kept the old chip beside the new one (one per missed stage). Clearing a key the browser no
554
+ * longer has is a no-op, and the next repaint after reconnect retracts what was missed. Bounded to
555
+ * CHIP_KEY_HISTORY keys. Per session, not per process — one pi-web server repaints many sessions, and a
556
+ * shared slot let session B's repaint overwrite A's key. On globalThis so a /reload or a duplicate copy
557
+ * still knows what was painted (a new name: older copies kept a single string per session there). */
558
+ export const WEB_CHIP_KEYS: Map<string, string[]> = ((globalThis as { __piDevFlowChipKeyHistory?: Map<string, string[]> }).__piDevFlowChipKeyHistory ??= new Map());
559
+ export const CHIP_KEY_HISTORY = 8;
560
+ /** The previous copy's single-key slot, read once per session so the first repaint after an upgrade still
561
+ * retracts the chip that copy painted. */
562
+ export const LEGACY_CHIP_KEYS: Map<string, string> | undefined = (globalThis as { __piDevFlowChipKeys?: Map<string, string> }).__piDevFlowChipKeys;
563
+
564
+ /** Next chip-key history for a repaint: every key except the current one is to be cleared (again), and
565
+ * the current key moves to the end. `key` undefined (uninitiated folder) clears them all. Pure. */
566
+ export function nextChipKeys(prev: readonly string[], key: string | undefined): { clear: string[]; keys: string[] } {
567
+ const clear = prev.filter((k) => k !== key);
568
+ return { clear, keys: key === undefined ? clear.slice(-CHIP_KEY_HISTORY) : [...clear, key].slice(-CHIP_KEY_HISTORY) };
569
+ }