tmux DCS passthrough 対応#22
Closed
flexphere wants to merge 3 commits into
Closed
Conversation
Wrap all Kitty APC sequences in tmux DCS passthrough (\x1bPtmux;...\x1b\\) when running inside tmux. This allows the outer terminal to receive and render Kitty graphics directly as overlays, bypassing tmux's cell buffer. - Add Option pattern with WithTmuxMode to KittyRenderer - Add wrapDCSPassthrough function that doubles ESC chars for DCS encoding - Convert buildUploadSequence/buildRGBAUploadSequence to methods for per-chunk wrapping - Auto-detect tmux via TMUX environment variable in main.go Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add TestWrapDCSPassthrough for ESC doubling and DCS format - Add TestKittyRenderer_TmuxMode_Display for wrapped placement output - Add TestKittyRenderer_TmuxMode_DisplayMinimap for upload+placement wrapping - Add TestKittyRenderer_TmuxMode_DisplayMinimap_CacheHit for cached placement - Add TestKittyRenderer_TmuxMode_BuildRGBAUploadSequence for chunk wrapping - Update existing buildRGBAUploadSequence tests for method syntax Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
tmux 環境下で Kitty Graphics Protocol の画像が表示できない問題に対し、Kitty の APC シーケンスを tmux の DCS passthrough でラップして外側ターミナルへ透過させることで表示を可能にする PR です。レンダラ側の出力生成に tmux 対応を組み込み、CLI 側で tmux 環境を自動検出して有効化します。
Changes:
KittyRendererに Option パターン(WithTmuxMode)を導入し、tmux モード時に Kitty シーケンスを DCS passthrough でラップ- 画像アップロード/配置/削除の各 APC 出力箇所にラッピングを適用し、アップロードはチャンク単位でラップ
$TMUX検出による自動有効化と、README に tmux 設定手順を追記(加えて tmux 対応のテストを追加)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/adapter/renderer/kitty_renderer.go | tmux DCS passthrough ラッピングと Option パターン導入、各 APC 出力のラップ適用 |
| internal/adapter/renderer/kitty_renderer_test.go | tmux ラップの単体テスト追加、RGBA upload シーケンス生成の呼び出しをメソッド化に追従 |
| cmd/gaze/main.go | $TMUX に応じて WithTmuxMode(true) を自動適用 |
| README.md | tmux での利用手順(allow-passthrough on)を追記 |
Comment on lines
+558
to
+559
| // In wrapped form, \x1b_ becomes \x1b\x1b_ inside the DCS payload | ||
| if strings.Contains(output, "\x1b_G") && !strings.Contains(output, "\x1b\x1b_G") { |
There was a problem hiding this comment.
TestKittyRenderer_TmuxMode_BuildRGBAUploadSequence の「unwrapped APC が含まれない」検証が弱く、出力に wrapped と unwrapped が混在しても検知できません(wrapped 形式自体が "\x1b_G" 部分文字列を含むため)。"\x1bPtmux;" の回数と対応付けて各チャンクが必ず DCS で始まることを確認する、または "\x1b\x1b_G" を除去した残りに "\x1b_G" が現れないことを確認する等、混在を確実に落とせる形にしてください。
Suggested change
| // In wrapped form, \x1b_ becomes \x1b\x1b_ inside the DCS payload | |
| if strings.Contains(output, "\x1b_G") && !strings.Contains(output, "\x1b\x1b_G") { | |
| // In wrapped form, \x1b_ becomes \x1b\x1b_ inside the DCS payload. | |
| // wrapped 由来の \x1b\x1b_G をすべて除去した残りに \x1b_G が含まれていないことを検証することで、 | |
| // wrapped/unwrapped の混在も確実に検出する。 | |
| clean := strings.ReplaceAll(output, "\x1b\x1b_G", "") | |
| if strings.Contains(clean, "\x1b_G") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
tmux 環境で Kitty Graphics Protocol の画像が表示されない問題を修正。すべての Kitty APC シーケンスを tmux DCS passthrough (
\x1bPtmux;...\x1b\\) でラップし、外側のターミナル(WezTerm/Kitty/Ghostty等)に直接転送することで画像表示を実現する。変更内容
KittyRendererに Option パターン (WithTmuxMode) を導入wrapDCSPassthrough関数で ESC 文字を二重化し DCS passthrough 形式にラップbuildUploadSequence/buildRGBAUploadSequenceをメソッド化し、各チャンクを個別にラップDisplay,Clear,UploadMinimap,DisplayMinimap,ClearMinimapの全 APC 出力箇所でラッピングを適用\x1b[H) は CSI シーケンスのため tmux が処理し、DCS で包まないcmd/gaze/main.goで$TMUX環境変数を検出し自動的に tmux モードを有効化set -g allow-passthrough on) を追記テスト計画
make ci)internal/adapter/renderer/kitty_renderer_test.goTestWrapDCSPassthrough: ESC 二重化と DCS フォーマットの検証TestKittyRenderer_TmuxMode_Display: placement APC のラッピングTestKittyRenderer_TmuxMode_DisplayMinimap: upload + placement の複数ラッピングTestKittyRenderer_TmuxMode_DisplayMinimap_CacheHit: キャッシュヒット時もラッピングTestKittyRenderer_TmuxMode_BuildRGBAUploadSequence: チャンク単位のラッピングgaze <image>を実行し画像が表示されることを確認備考
tmuxMode=false(デフォルト)時は従来と完全同一動作のため、既存ユーザーに影響なしRendererPortインターフェースの変更なし(内部実装のみ)🤖 Generated with Claude Code