Skip to content

TUI: cross-platform clipboard, inline images, and helper extraction - #74

Merged
ApiliumDevTeam merged 3 commits into
devfrom
chore/tui-close-roadmap
Jul 14, 2026
Merged

ApiliumDevTeam merged 3 commits into
devfrom
chore/tui-close-roadmap

Conversation

@ApiliumDevTeam

Copy link
Copy Markdown
Collaborator

Summary

Closes the remaining TUI roadmap items: cross-platform clipboard, inline image rendering, and the first pass of file-size reduction.

Cross-platform clipboard (P1-6)

  • /copy and /teleport export now use the shared copyToClipboard helper from infra/clipboard.ts, which has a fallback chain covering pbcopy, xclip, wl-copy (Wayland), clip.exe (Windows/WSL), and PowerShell. Previously hardcoded to pbcopy/xclip only.
  • Clipboard image capture now supports Windows (PowerShell + System.Windows.Forms) and Wayland (wl-paste), with xclip fallback for XWayland sessions.

Inline image rendering (P1-3)

  • Tool results containing image content blocks now render inline via the terminal image component when the terminal supports it (Kitty graphics or iTerm2 inline images). The Image component handles capability detection internally and falls back to a text placeholder on unsupported terminals.
  • Backend: image base64 data is no longer stripped in sanitizeToolResult — the omitted: true flag already prevents it from entering the model context, so retaining it does not inflate token usage.

File-size reduction (P2-16, partial)

  • Extracted 7 pure helper functions from tui.ts into tui-helpers.ts (228 LOC). Reduces tui.ts from 1087 to 883 LOC.
  • Further extraction of the state factory, status renderer, and connection handlers is tracked as a follow-up.

Test plan

  • pnpm tsgo — 0 errors
  • pnpm lint — 0 errors, 352 warnings
  • pnpm exec vitest run src/tui/ — 512 passed, 1 skipped, 0 failed

The /copy command and teleport export hardcoded pbcopy/xclip, so they
were broken on Windows (no pbcopy/xclip) and Wayland (no xclip under
pure Wayland). Replace the spawn and shell-pipeline approaches with the
existing cross-platform copyToClipboard helper from infra/clipboard.ts,
which has a fallback chain covering pbcopy, xclip, wl-copy, clip.exe,
and PowerShell Set-Clipboard.

Add Windows and Wayland support to clipboard image capture:
- Windows: PowerShell + System.Windows.Forms to read clipboard PNG.
- Wayland: wl-paste -t image/png when WAYLAND_DISPLAY is set, with
  xclip fallback for XWayland sessions.
Tool results that contain image content blocks now render inline using
the terminal image component when the terminal supports it (Kitty
graphics protocol or iTerm2 inline images). The Image component handles
capability detection internally and falls back to a text placeholder
([image/png 12kb]) when the terminal cannot display images, so no escape
sequences leak to unsupported terminals.

Backend change: stop stripping the base64 data from image content blocks
in sanitizeToolResult. The omitted: true flag already prevents the image
from entering the model context, so retaining data does not inflate
token usage — it only makes the base64 available for TUI rendering.
Move 7 standalone functions (createEditorSubmitHandler,
shouldEnableWindowsGitBashPasteFallback, createSubmitBurstCoalescer,
resolveTuiSessionKey, tryInlinePairingApproval,
resolveGatewayDisconnectState, createBackspaceDeduper) out of tui.ts
into a dedicated tui-helpers.ts module. These functions are pure
factories and resolvers with no dependency on the TUI instance or
mutable state, and are already covered by tui.test.ts.

Reduces tui.ts from 1087 to 883 LOC. Further extraction of the state
factory, status renderer, and connection handlers is tracked as a
follow-up — the remaining sections are tightly coupled to runTui's
closures and require more careful refactoring.
@ApiliumDevTeam
ApiliumDevTeam merged commit 583891e into dev Jul 14, 2026
7 of 8 checks passed
@ApiliumDevTeam
ApiliumDevTeam deleted the chore/tui-close-roadmap branch July 14, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant