waveterm icon indicating copy to clipboard operation
waveterm copied to clipboard

feat(term): add sixel rendering and propagate terminal pixel size to PTY

Open zouyonghe opened this issue 9 months ago • 4 comments

Summary

This PR adds Sixel support in Wave terminal rendering and propagates terminal pixel dimensions (xpixel/ypixel) end-to-end so image tools relying on TIOCGWINSZ.ws_xpixel/ws_ypixel can place images correctly.

Fixes https://github.com/wavetermdev/waveterm/issues/2172

Changes

  • Frontend:

    • Enable Sixel via @xterm/addon-image (sixelSupport: true, enableSizeReports: true).
    • Add terminal pixel-size capture (xpixel/ypixel) from terminal viewport.
    • Send pixel size together with rows/cols on resize, resync, restart, and terminal-state cache paths.
  • Shared types:

    • Extend TermSize with optional xpixel / ypixel.
  • Backend:

    • Propagate xpixel/ypixel into PTY winsize (pty.Winsize{Rows, Cols, X, Y}) for start + resize paths.
    • Update shell/job resize flows to compare and apply pixel-size changes.
    • Keep SSH behavior char-based (WindowChange(rows, cols)), unchanged.

Why

Some image clients (e.g. PixelTerm-C) depend on PTY pixel metrics for cell geometry. Previously Wave only updated rows/cols, which could cause image positioning offsets.

Validation

  • Built backend/frontend successfully.
  • Verified wavesrv startup with updated build.
  • Verified related Go packages compile/test cleanly.

Compatibility

  • xpixel/ypixel are optional; existing behavior remains when pixel size is not provided.

zouyonghe avatar Feb 26 '26 01:02 zouyonghe

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 26 '26 01:02 CLAassistant

[!NOTE]

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • [ ] ▶️ Resume reviews
  • [ ] 🔍 Trigger review

Walkthrough

This PR adds pixel dimensions to TermSize (xpixel/ypixel in frontend types; XPixel/YPixel in Go) and propagates TermSize usage across frontend and backend. Frontend: termwrap loads an optional sixel ImageAddon, introduces getTermSize(), replaces direct rows/cols access with TermSize, updates types, and adds sharp and @xterm/addon-image deps. Backend: waveobj.TermSize gains pixel fields; ConnInterface.SetSize signatures changed to accept a TermSize; a new ptyutil.WinsizeFromTermSize helper converts TermSize to pty.Winsize and is used in jobmanager, shellexec, blockcontroller, and conn implementations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main changes: adding Sixel rendering support and propagating terminal pixel dimensions to the PTY.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, covering frontend Sixel support, terminal pixel-size capture, shared type extensions, and backend PTY propagation.
Linked Issues check ✅ Passed The PR successfully implements graphics protocol support (Sixel) as requested in issue #2172, enabling improved image previews in the terminal with proper pixel-size handling for image positioning.
Out of Scope Changes check ✅ Passed All code changes are directly related to implementing Sixel support and propagating terminal pixel dimensions, with no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Feb 26 '26 01:02 coderabbitai[bot]

Code Review Summary

Status: No New Issues | Recommendation: Merge

Overview

The PR adds sixel image rendering support and propagates terminal pixel dimensions to the PTY. The implementation is solid with proper error handling for the ImageAddon loading.

Previously Identified Issues (Already Addressed)

Severity File Line Issue
WARNING pkg/jobmanager/jobcmd.go N/A Code duplication - helper functions defined in multiple files
CRITICAL pkg/shellexec/conninterface.go 223 SSH WindowChange - noted as x/crypto API limitation
MAJOR frontend/app/view/term/termwrap.ts 602 Pixel-only resizes may be skipped in handleResize

Files Reviewed (7 files)

  • frontend/app/view/term/term-model.ts - Refactored to use getTermSize()
  • frontend/app/view/term/term.tsx - Updated xterm options (overviewRuler → scrollbar)
  • frontend/app/view/term/termwrap.test.ts - New test file for sixel addon
  • frontend/app/view/term/termwrap.ts - Added sixel support, getTermSize(), viewport scroll tracking
  • frontend/types/gotypes.d.ts - Added xpixel/ypixel to TermSize
  • package.json - Added @xterm/addon-image dependency
  • package-lock.json - Dependency updates

Code review completed. No new issues found in this revision.


Reviewed by minimax-m2.5-20260211 · 284,204 tokens

kilo-code-bot[bot] avatar Feb 26 '26 01:02 kilo-code-bot[bot]

image

Current support image output by sixel.

zouyonghe avatar Feb 26 '26 02:02 zouyonghe