pi-spark 0.10.3 → 0.10.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.
@@ -17,17 +17,19 @@ export class BottomFiller implements Component {
17
17
  }
18
18
 
19
19
  render(width: number): string[] {
20
- // The TUI renders this component as part of its child tree, so measuring the
21
- // siblings re-enters this render. Guard against the recursion and count our
22
- // own contribution as zero lines while measuring.
20
+ // Guard against re-entrancy: measuring the siblings below renders this component again.
23
21
  if (this.measuring) return [];
24
22
  this.measuring = true;
25
23
 
24
+ // Re-assert `clearOnShrink` every render pass; the TUI reads it after `render()` returns,
25
+ // so this wins deterministically over pi's reset to the settings value on startup/reload.
26
+ this.tui.setClearOnShrink(true);
27
+
26
28
  const rows = this.tui.terminal.rows;
27
29
  let others = 0;
28
30
  for (const child of this.tui.children) {
29
31
  others += child.render(width).length;
30
- if (others >= rows) break; // content already fills the screen
32
+ if (others >= rows) break;
31
33
  }
32
34
 
33
35
  this.measuring = false;
@@ -37,7 +37,6 @@ export default function (pi: ExtensionAPI) {
37
37
  let tui: TUI | undefined;
38
38
  let enabled = false;
39
39
  let pendingClear = false;
40
- let previousClearOnShrink: boolean | undefined;
41
40
 
42
41
  pi.on("session_start", (_event, ctx) => {
43
42
  if (!ctx.hasUI) return;
@@ -54,18 +53,8 @@ export default function (pi: ExtensionAPI) {
54
53
  ctx.ui.setWidget(WIDGET_KEY, (capturedTui) => {
55
54
  tui = capturedTui;
56
55
 
57
- // Enable `clearOnShrink`, but defer it to a macrotask. On `/reload`, pi resets
58
- // `clearOnShrink` to the settings value right after `session_start`, inside the reload's
59
- // microtask continuation. A `setTimeout` callback runs only after that microtask queue
60
- // drains, so it lands last and sticks. `queueMicrotask` (or a synchronous call) would run
61
- // before the reset and get clobbered.
62
- previousClearOnShrink ??= capturedTui.getClearOnShrink();
63
- setTimeout(() => capturedTui.setClearOnShrink(true));
64
-
65
- // Clear the screen once on entry. `session_start` has no TUI to repaint with, and a
66
- // synchronous repaint here is too early (the filler isn't in the render tree until
67
- // `setWidget` returns), so defer to a microtask. `pendingClear` limits this to the
68
- // `session_start`-triggered mount rather than every widget rebuild.
56
+ // Defer the entry clear to a microtask: the filler isn't in the render tree until
57
+ // `setWidget` returns, and `session_start` has no TUI to repaint with yet.
69
58
  if (pendingClear) {
70
59
  pendingClear = false;
71
60
  queueMicrotask(() => capturedTui.requestRender(true));
@@ -78,19 +67,11 @@ export default function (pi: ExtensionAPI) {
78
67
  pi.on("session_shutdown", (event, ctx) => {
79
68
  if (!enabled) return;
80
69
 
81
- // Restore `clearOnShrink` to its pre-fullscreen value.
82
- if (previousClearOnShrink !== undefined) {
83
- tui?.setClearOnShrink(previousClearOnShrink);
84
- previousClearOnShrink = undefined;
85
- }
86
-
87
70
  if (event.reason === "quit" && tui) {
88
- // On normal interactive quit, shutdown handlers run after pi stops the TUI, so
89
- // `requestRender(true)` can no longer repaint. Write the clear sequence directly: clear
90
- // screen, move home, then clear scrollback.
71
+ // The TUI is already stopped here, so write the clear sequence directly instead of
72
+ // repainting: clear screen, home, clear scrollback.
91
73
  tui.terminal.write("\x1b[2J\x1b[H\x1b[3J");
92
74
 
93
- // Leave one concise line after the cleared session.
94
75
  const theme = ctx.ui.theme;
95
76
  const exitMessage = `${theme.bold(theme.fg("accent", "pi"))} ${theme.fg("dim", `v${VERSION} exited`)}`;
96
77
  const sessionText = getSessionDisplayText(ctx, theme);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spark",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "A small, opinionated collection of pi extensions",
5
5
  "keywords": [
6
6
  "pi-coding-agent",
@@ -11,6 +11,10 @@
11
11
  "url": "git+https://github.com/zlliang/pi-packages.git",
12
12
  "directory": "packages/pi-spark"
13
13
  },
14
+ "homepage": "https://github.com/zlliang/pi-packages/tree/main/packages/pi-spark#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/zlliang/pi-packages/issues"
17
+ },
14
18
  "license": "MIT",
15
19
  "type": "module",
16
20
  "files": [