pi-interactive-shell 0.3.1 → 0.3.3

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
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to the `pi-interactive-shell` extension will be documented in this file.
4
4
 
5
+ ## [0.3.3] - 2026-01-17
6
+
7
+ ### Fixed
8
+ - Handoff preview now uses raw output stream instead of xterm buffer. TUI apps using alternate screen buffer (like Codex, Claude, etc.) would show misleading/stale content in the preview.
9
+
5
10
  ## [0.3.0] - 2026-01-17
6
11
 
7
12
  ### Added
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Interactive Shell Extension
1
+ # Pi Interactive Shell Overlay
2
2
 
3
- Run AI coding agents (Claude Code, Gemini CLI, Codex, Aider, etc.) as **foreground subagents** inside a pi TUI overlay. The user sees the agent working in real-time and can take over control at any time.
3
+ An extension for [pi-coding-agent](https://github.com/badlogic/pi-mono/) that runs AI coding agents (Claude Code, Gemini CLI, Codex, Aider, etc.) as **foreground subagents** inside a TUI overlay. The user sees the agent working in real-time and can take over control at any time.
4
4
 
5
5
  This is distinct from **background subagents** (the `subagent` tool) which run pi instances invisibly.
6
6
 
@@ -438,11 +438,20 @@ export class InteractiveShellOverlay implements Component, Focusable {
438
438
  const maxChars = this.options.handoffPreviewMaxChars ?? this.config.handoffPreviewMaxChars;
439
439
  if (lines <= 0 || maxChars <= 0) return undefined;
440
440
 
441
- const tail = this.session.getTailLines({
442
- lines,
443
- ansi: false,
444
- maxChars,
445
- });
441
+ // Use raw output stream instead of xterm buffer - TUI apps using alternate
442
+ // screen buffer can have misleading content in getTailLines()
443
+ const rawOutput = this.session.getRawStream({ stripAnsi: true });
444
+ const outputLines = rawOutput.split("\n");
445
+
446
+ // Get last N lines, respecting maxChars
447
+ let tail: string[] = [];
448
+ let charCount = 0;
449
+ for (let i = outputLines.length - 1; i >= 0 && tail.length < lines; i--) {
450
+ const line = outputLines[i];
451
+ if (charCount + line.length > maxChars && tail.length > 0) break;
452
+ tail.unshift(line);
453
+ charCount += line.length + 1; // +1 for newline
454
+ }
446
455
 
447
456
  return { type: "tail", when, lines: tail };
448
457
  }
@@ -907,11 +916,20 @@ export class ReattachOverlay implements Component, Focusable {
907
916
  const maxChars = this.config.handoffPreviewMaxChars;
908
917
  if (lines <= 0 || maxChars <= 0) return undefined;
909
918
 
910
- const tail = this.session.getTailLines({
911
- lines,
912
- ansi: false,
913
- maxChars,
914
- });
919
+ // Use raw output stream instead of xterm buffer - TUI apps using alternate
920
+ // screen buffer can have misleading content in getTailLines()
921
+ const rawOutput = this.session.getRawStream({ stripAnsi: true });
922
+ const outputLines = rawOutput.split("\n");
923
+
924
+ // Get last N lines, respecting maxChars
925
+ let tail: string[] = [];
926
+ let charCount = 0;
927
+ for (let i = outputLines.length - 1; i >= 0 && tail.length < lines; i--) {
928
+ const line = outputLines[i];
929
+ if (charCount + line.length > maxChars && tail.length > 0) break;
930
+ tail.unshift(line);
931
+ charCount += line.length + 1; // +1 for newline
932
+ }
915
933
 
916
934
  return { type: "tail", when, lines: tail };
917
935
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-interactive-shell",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Run AI coding agents as foreground subagents in pi TUI overlays with hands-free monitoring",
5
5
  "type": "module",
6
6
  "bin": {