fix(rust-term,rust-app): kitty キーボードプロトコルの残欠陥を修正(第17波)#153
Merged
Conversation
- 修飾つき矢印キーが全モードで無修飾と同一バイトだった問題を修正 (CSI 1;<m><letter> を disambiguate の有無に関係なく送信) - disambiguate 有効時、Esc が CSI 27u/27;<m>u を送るよう修正 (従来は legacy 0x1b のまま誤って除外扱いされていた) - disambiguate 有効時、Ctrl+<letter>(Ctrl+Alt 含む)が CSI <codepoint>;<m>u を送るよう修正(従来は C0 のまま) - 両バックエンドの kitty_disambiguate() を REPORT_ALL フラグ単独でも true を返すよう修正(kitty 仕様: flag 8 は flag 1 を含意する) - alacritty_terminal 0.26.0 をベンダリングし、push_keyboard_mode の コピペバグ(title_stack.remove(0) の誤呼び出しによる panic)を1行修正。kitty_keyboard:true化で到達可能になっていた - TERM_PROGRAM_VERSION を TERM_PROGRAM と対で設定し、呼び出し元 env による上書きを意図されたエスケープハッチとして明文化・テスト固定
sasagar
marked this pull request as ready for review
July 18, 2026 02:07
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.
Summary
第16波のコードレビューで CONFIRMED になった、kitty キーボードプロトコル(仕様)実装の残欠陥をまとめて修正。
keys.rs: 修飾つき矢印キー — Shift/Ctrl/Alt+矢印が全モードで無修飾と同一バイト(\x1b[A等)だった問題を修正。CSI 1;<m><letter>を disambiguate の有無に関係なく送信(legacy xterm の標準挙動であり kitty 固有ではないため)。keys.rs: disambiguate 時の Esc — 仕様上 Esc は disambiguate 有効時に例外なくCSI 27u/CSI 27;<m>uを要求されるが、従来コードは Enter/Tab/Backspace と同列に「out of scope」として legacy0x1bのまま誤って除外していた(コメントの仕様誤読)。修正し、コメントも仕様原文に合わせて書き直した。keys.rs: disambiguate 時の Ctrl+<letter>—CSI <codepoint>;<m>u(codepoint は小文字の Unicode 値、例 ctrl+c →CSI 99;5u)を送るよう修正。Ctrl+Alt の複合修飾も modifier ビットに反映。disambiguate 無効時は従来の C0 のまま非回帰。kitty_disambiguate()— kitty 仕様が明記する「flag 8(report all keys)は flag 1(disambiguate)を含意する」を反映し、intersectsに変更。alacritty_terminal0.26.0 のベンダリング — 上流のpush_keyboard_mode(term/mod.rs)が、キーボードモードスタックが上限(4096)に達した際のトリム対象をtitle_stack.remove(0)(コピペミス。正しくはkeyboard_mode_stack.remove(0))としているバグを発見。title_stackは空のままなのでVec::remove(0)が out-of-bounds panic を起こし、kitty_keyboard: trueにした本リポジトリで到達可能になっていた(panic はワーカースレッドを巻き込んで unwind し、ペインが恒久フリーズする)。1行のみ修正してベンダリング(rust/vendor/alacritty_terminal/、W14 のlibghostty-vt-sysと同じ前例に倣う)。上流への issue 報告は別途判断のため今回は行っていない。session.rs:TERM_PROGRAM_VERSION— 実 Ghostty が常にTERM_PROGRAMと対で設定することを踏まえ追加(値は libghostty-vt-sys のピン留めコミット・CI/開発手順が参照する vancluever フォーク双方のbuild.zig.zonから確認した1.3.2-dev)。呼び出し元envによる上書き(last-write-wins)を意図されたエスケープハッチとして明文化し、テストで固定。Test plan
cargo fmt --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspacecargo test -p labolabo-app(keys.rs のユニットテスト含む)cargo test -p labolabo-term --features backend-ghostty-vt(実 Zig/Ghostty ソースでビルド・実行)keyboard_mode_stack_survives_pushes_past_max_depth)が、パッチ適用前は実際にタイムアウトで red、適用後に green になることを確認(red-before-green 検証済み)未検証点:
backend-ghostty-vtのkitty_disambiguate()flag 8 対応はコード上 alacritty 側と対称的で spec 引用も同一だが、独立検証エージェント自身は Zig ツールチェイン未使用のためコンパイル未検証(自分自身では実際に Zig でビルドし全32テスト green を確認済み)。