@linxiraos/pi-tui 1.3.2 → 1.4.1

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 (116) hide show
  1. package/CHANGELOG.md +181 -181
  2. package/dist/types/apps/session-picker.d.ts +13 -1
  3. package/dist/types/autocomplete.d.ts +6 -0
  4. package/dist/types/components/sparkline.d.ts +34 -0
  5. package/dist/types/index.d.ts +1 -0
  6. package/dist/types/native/describe.d.ts +7 -1
  7. package/dist/types/native/overlay.d.ts +2 -0
  8. package/dist/types/native/tone.d.ts +2 -0
  9. package/dist/types/overlays/agent-hub.d.ts +3 -3
  10. package/dist/types/overlays/approval-dialog.d.ts +15 -1
  11. package/dist/types/overlays/jobs-panel.d.ts +3 -0
  12. package/dist/types/overlays/model-browser.d.ts +1 -1
  13. package/dist/types/overlays/resume-picker.d.ts +293 -0
  14. package/dist/types/overlays/resume-tree.d.ts +353 -0
  15. package/dist/types/overlays/session-selector.d.ts +22 -4
  16. package/dist/types/render/output-block.d.ts +2 -0
  17. package/dist/types/render/tool-card.d.ts +2 -0
  18. package/dist/types/sixel.d.ts +28 -0
  19. package/dist/types/status-line/host.d.ts +3 -0
  20. package/dist/types/terminal-capabilities.d.ts +6 -1
  21. package/dist/types/tools/bash.d.ts +2 -0
  22. package/dist/types/tools/default-renderer.d.ts +3 -0
  23. package/dist/types/tools/eval.d.ts +9 -8
  24. package/dist/types/tools/hub.d.ts +3 -1
  25. package/dist/types/tools/irc.d.ts +11 -1
  26. package/dist/types/tools/job-widget.d.ts +226 -0
  27. package/dist/types/tools/json-tree.d.ts +2 -0
  28. package/dist/types/tools/line-ranges.d.ts +8 -1
  29. package/dist/types/tools/mcp.d.ts +23 -0
  30. package/dist/types/tools/output-meta.d.ts +1 -1
  31. package/dist/types/tools/read.d.ts +8 -2
  32. package/dist/types/tools/renderer.d.ts +8 -2
  33. package/dist/types/tools/result-card.d.ts +1 -1
  34. package/dist/types/tools/streaming-output.d.ts +1 -0
  35. package/dist/types/tools/task.d.ts +12 -0
  36. package/dist/types/tools/wait.d.ts +11 -0
  37. package/package.json +9 -9
  38. package/src/apps/session-picker.ts +20 -2
  39. package/src/autocomplete.d.ts +6 -0
  40. package/src/autocomplete.ts +21 -6
  41. package/src/chat/skill-message.ts +16 -17
  42. package/src/chat/tool-execution.ts +35 -0
  43. package/src/chrome/transcript-container.ts +85 -13
  44. package/src/components/editor.ts +17 -7
  45. package/src/components/image.ts +5 -4
  46. package/src/components/markdown.ts +11 -3
  47. package/src/components/sparkline.d.ts +34 -0
  48. package/src/components/sparkline.ts +89 -0
  49. package/src/index.d.ts +1 -0
  50. package/src/index.ts +1 -0
  51. package/src/native/backend.ts +32 -6
  52. package/src/native/describe.d.ts +7 -1
  53. package/src/native/describe.ts +18 -1
  54. package/src/native/overlay.d.ts +2 -0
  55. package/src/native/overlay.ts +3 -0
  56. package/src/native/tone.d.ts +2 -0
  57. package/src/native/tone.ts +22 -0
  58. package/src/overlays/agent-hub.ts +14 -10
  59. package/src/overlays/agent-transcript-viewer.ts +2 -2
  60. package/src/overlays/agents-hub.ts +2 -1
  61. package/src/overlays/approval-dialog.ts +59 -13
  62. package/src/overlays/hub-frame.ts +2 -1
  63. package/src/overlays/jobs-panel.ts +24 -2
  64. package/src/overlays/model-browser.ts +3 -0
  65. package/src/overlays/model-hub.ts +2 -1
  66. package/src/overlays/resume-picker.ts +706 -0
  67. package/src/overlays/resume-tree.ts +1901 -0
  68. package/src/overlays/session-selector.ts +579 -39
  69. package/src/prompt/attachment-chips.ts +1 -1
  70. package/src/render/output-block.d.ts +2 -0
  71. package/src/render/output-block.ts +25 -12
  72. package/src/render/tool-card.d.ts +2 -0
  73. package/src/render/tool-card.ts +6 -0
  74. package/src/sixel.d.ts +28 -0
  75. package/src/sixel.ts +185 -0
  76. package/src/status-line/component.ts +19 -2
  77. package/src/status-line/host.ts +3 -0
  78. package/src/terminal-capabilities.d.ts +6 -1
  79. package/src/terminal-capabilities.ts +54 -3
  80. package/src/theme/symbols.ts +5 -3
  81. package/src/tools/bash.d.ts +2 -0
  82. package/src/tools/bash.ts +25 -9
  83. package/src/tools/default-renderer.d.ts +3 -0
  84. package/src/tools/default-renderer.ts +54 -17
  85. package/src/tools/eval.d.ts +9 -8
  86. package/src/tools/eval.ts +32 -14
  87. package/src/tools/find.ts +4 -5
  88. package/src/tools/glob.ts +4 -6
  89. package/src/tools/grep.ts +2 -4
  90. package/src/tools/hub.ts +4 -1
  91. package/src/tools/irc.d.ts +11 -1
  92. package/src/tools/irc.ts +11 -1
  93. package/src/tools/job-widget.d.ts +226 -0
  94. package/src/tools/job-widget.ts +1036 -0
  95. package/src/tools/json-tree.d.ts +2 -0
  96. package/src/tools/json-tree.ts +8 -0
  97. package/src/tools/line-ranges.d.ts +8 -1
  98. package/src/tools/line-ranges.ts +23 -13
  99. package/src/tools/mcp.d.ts +23 -0
  100. package/src/tools/mcp.ts +44 -1
  101. package/src/tools/output-meta.d.ts +1 -1
  102. package/src/tools/output-meta.ts +1 -1
  103. package/src/tools/proc-render.ts +1 -0
  104. package/src/tools/read.d.ts +8 -2
  105. package/src/tools/read.ts +64 -21
  106. package/src/tools/renderer.d.ts +8 -2
  107. package/src/tools/renderer.ts +8 -2
  108. package/src/tools/result-card.d.ts +1 -1
  109. package/src/tools/result-card.ts +1 -2
  110. package/src/tools/streaming-output.d.ts +1 -0
  111. package/src/tools/streaming-output.ts +11 -9
  112. package/src/tools/task.d.ts +12 -0
  113. package/src/tools/task.ts +25 -1
  114. package/src/tools/wait.d.ts +11 -0
  115. package/src/tools/wait.ts +296 -147
  116. package/src/tui.ts +45 -5
package/src/tui.ts CHANGED
@@ -28,6 +28,7 @@ import { assumedTspHello, NativeBackend, type NativeHost } from "./native/backen
28
28
  import { col } from "./native/describe";
29
29
  import { TSP_PREFIX, type TspHello } from "./native/encode";
30
30
  import type { DescribeContext, NativeNode, NativeScreen, NativeSurfaceProvider, NativeUiEvent } from "./native/node";
31
+ import { cropSixelTop } from "./sixel";
31
32
  import { STDOUT_BACKLOG_CLEAR_BYTES, setAltScreenActive, type Terminal } from "./terminal";
32
33
  import { classifyTerminalMultiplexerModule, terminalMultiplexerSessions } from "./terminal-multiplexer";
33
34
  import {
@@ -36,6 +37,7 @@ import {
36
37
  encodeKittyDeleteImage,
37
38
  encodeKittyDeletePlacement,
38
39
  encodeKittyPlacementLine,
40
+ getCellDimensions,
39
41
  getTerminalBackgroundColor,
40
42
  ImageProtocol,
41
43
  isImageProtocolForced,
@@ -1022,6 +1024,8 @@ export class TUI extends Container {
1022
1024
  #screenImagePlacements = new Map<number, LiveImagePlacement>();
1023
1025
  #altImagePlacements = new Map<number, LiveImagePlacement>();
1024
1026
  #nextImagePlacementId = 1;
1027
+ /** Last top-clipped SIXEL crop; only the block straddling row 0 is ever cropped. */
1028
+ #sixelCrop: { source: string; pixels: number; maxHeightPixels: number; output: string } | undefined;
1025
1029
  #ghosttyInitialImageDelayDone = false;
1026
1030
  #ghosttyInitialImageDelayTimer: RenderTimer | undefined;
1027
1031
  #ghosttyImageReadyAtMs = 0;
@@ -3386,10 +3390,11 @@ export class TUI extends Container {
3386
3390
  }
3387
3391
 
3388
3392
  /**
3389
- * Clip a Kitty direct placement and record its live owner; history
3390
- * placements have no mutable owner. Other direct placements (SIXEL,
3391
- * iTerm2) have no delete command and composite over whatever pixels they
3392
- * land on, so the rows they paint above `screenRow` are erased first.
3393
+ * Clip direct placements to the visible source slice: Kitty tracks a live
3394
+ * placement owner, while SIXEL crops the encoded raster (iTerm2 images are
3395
+ * not cropped). SIXEL and iTerm2 have no delete command and composite over
3396
+ * existing pixels, so erase the visible rows they paint above `screenRow`
3397
+ * before repainting.
3393
3398
  */
3394
3399
  #imageLineSequence(
3395
3400
  line: string,
@@ -3400,7 +3405,16 @@ export class TUI extends Container {
3400
3405
  if (screenRow < 0) return line;
3401
3406
  const parsed = parseKittyDirectPlacementLine(line);
3402
3407
  if (!parsed) {
3403
- const lift = Math.min(directPlacementLift(line), screenRow);
3408
+ const requestedLift = directPlacementLift(line);
3409
+ const lift = Math.min(requestedLift, screenRow);
3410
+ if (requestedLift > lift) {
3411
+ const cellHeight = getCellDimensions().heightPx;
3412
+ const cropPixels = Math.round((requestedLift - lift) * cellHeight);
3413
+ const maxHeightPixels = Math.floor((screenRow + 1) * cellHeight);
3414
+ line = line.replace(/\x1bP[0-9;]*q[\s\S]*?\x1b\\/g, sequence =>
3415
+ this.#cropSixel(sequence, cropPixels, maxHeightPixels),
3416
+ );
3417
+ }
3404
3418
  return lift > 0 ? `\x1b[${lift}A${`${ERASE_LINE}\x1b[B`.repeat(lift)}${line}` : line;
3405
3419
  }
3406
3420
  const previous = placements?.get(placementRow);
@@ -3420,6 +3434,32 @@ export class TUI extends Container {
3420
3434
  );
3421
3435
  }
3422
3436
 
3437
+ /**
3438
+ * Crop a SIXEL raster whose top rows lie above the viewport. A raster the
3439
+ * cropper cannot parse is dropped: painting it whole would overwrite the
3440
+ * rows below the visible slice.
3441
+ */
3442
+ #cropSixel(source: string, pixels: number, maxHeightPixels: number): string {
3443
+ const cached = this.#sixelCrop;
3444
+ if (
3445
+ cached !== undefined &&
3446
+ cached.pixels === pixels &&
3447
+ cached.maxHeightPixels === maxHeightPixels &&
3448
+ cached.source === source
3449
+ ) {
3450
+ return cached.output;
3451
+ }
3452
+ let output: string;
3453
+ try {
3454
+ output = cropSixelTop(source, pixels, maxHeightPixels);
3455
+ } catch (err) {
3456
+ logger.warn("Dropping top-clipped SIXEL image that cannot be cropped", { err });
3457
+ output = "";
3458
+ }
3459
+ this.#sixelCrop = { source, pixels, maxHeightPixels, output };
3460
+ return output;
3461
+ }
3462
+
3423
3463
  #terminalLine(line: PreparedLine): string {
3424
3464
  if (line.hasOsc8) return line.terminalContent + LINE_TERMINATOR;
3425
3465
  return line.terminalContent.endsWith(SEGMENT_RESET) ? line.terminalContent : line.terminalContent + SEGMENT_RESET;