Fixes #4809 - Kitty Keyboard Protocol Phase 2: Rich keyboard event model#4816
Merged
tig merged 13 commits intogui-cs:v2_developfrom Mar 10, 2026
Merged
Fixes #4809 - Kitty Keyboard Protocol Phase 2: Rich keyboard event model#4816tig merged 13 commits intogui-cs:v2_developfrom
tig merged 13 commits intogui-cs:v2_developfrom
Conversation
Mark Phase 2 as in-progress in the kitty keyboard protocol plan. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…d ModifierKey - Add KeyEventType enum (Press/Repeat/Release) and ModifierKey enum for standalone modifier identity - Extend Key with EventType, ModifierKey, and IsModifierOnly properties (additive, non-breaking) - Add KeyUp event pipeline: IInputProcessor → IDriver → IKeyboard → Application → View - Enable kitty flag 2 (report event types) alongside flag 1 (disambiguate escape codes) - Extract shared ApplyModifiersAndEventType helper in AnsiKeyboardParserPattern base class - Update CsiKeyPattern and CsiCursorPattern regexes to accept kitty modifiers:event_type format - Map kitty modifier key codepoints (57358-57451) to ModifierKey enum in KittyKeyboardPattern - Rename KittyKeyboardPhase1Flags → KittyKeyboardRequestedFlags - Update Keys scenario to display event type, modifier key identity, and KeyUp events - Update keyboard.md and drivers.md documentation - Add 44 new tests (KeyEventTypeTests + KittyKeyboardPhase2Tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9 tasks
Fix two bugs that broke InputInjectionMode.Pipeline: 1. InputProcessorImpl used DateTime.Now instead of _timeProvider.Now for stale escape detection, causing immediate release with VirtualTimeProvider 2. AnsiInputProcessor.InjectKeyDownEvent/InjectMouseEvent routed through the background input thread; now enqueues directly to InputQueue Simplify InputInjector.ProcessQueue() by removing the VirtualTimeProvider 60ms-advance workaround (no longer needed with bug #1 fixed). Un-skip two Pipeline tests and add 27 kitty protocol pipeline tests covering event types, modifiers, functional keys, standalone modifier keys, CSI ~/cursor variants, full press-repeat-release cycles, and negative cases (invalid event types, malformed sequences, recovery). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BDisp
reviewed
Mar 9, 2026
BDisp
reviewed
Mar 9, 2026
Previously, input bytes from the Windows console were always decoded as UTF-8, but ReadFile returns bytes in the console's input code page (e.g., Windows-1252). This caused accented and non-ASCII characters to be misread. This commit introduces a ConsoleInputEncoding property in WindowsVTInputHelper to dynamically use the correct encoding, and updates AnsiInput to use it. Adds unit tests to verify correct decoding of accented characters. Also includes minor test cleanups and improved naming.
BDisp
reviewed
Mar 9, 2026
Include kitty flag 8 to enable reporting of standalone modifier key events (e.g., Shift, Ctrl, Alt) as escape codes. Update tests to verify correct handling of modifier-only key press and release events, and assert that the requested kitty flags include "report all keys as escape codes." This improves compatibility with terminals supporting the kitty keyboard protocol.
BDisp
approved these changes
Mar 10, 2026
Collaborator
BDisp
left a comment
There was a problem hiding this comment.
This is fantastic. It provides a much wider range of key manipulation, allowing for complete control. Thank you for getting involved and committing to this.
I just asked a question.
… coding conventions - Replaced .github/copilot-instructions.md stub with full reference covering build/test commands, architecture overview, code style, terminology, and testing conventions - Added early return/guard clause convention across all AI instruction files - Added one-type-per-file convention for public and internal types - Updated CONTRIBUTING.md (source of truth), CLAUDE.md, and AGENTS.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replaces raw int usage with strongly-typed KittyKeyboardFlags enum for kitty keyboard protocol flags throughout the codebase. Adds KittyKeyboardFlags.cs and moves KittyKeyboardProtocolResult to its own file, updating it to use the new enum. Updates all related logic, methods, and tests for improved type safety, clarity, and maintainability.
Adds full support for kitty keyboard protocol "alternate key reporting" (flag 4) in Terminal.Gui. The Key model now exposes ShiftedKeyCode and BaseLayoutKeyCode, populated by the kitty parser for each key event. Updates the parser, documentation, and tests to cover alternate key fields, international layouts, and end-to-end propagation. Replaces old phase 2 tests with new, comprehensive suites for parsing, pipeline, and Key object behavior. Improves operator and parsing logic in Key, and updates docs to guide usage of new features.
Two threads (test + AppTestHelper background) could race into Dispose() → ResetState() concurrently. Thread A nulls Driver between Thread B's null-check and Driver.Dispose(), causing NullReferenceException. Fix: capture Driver to local, null the property, then unsubscribe and dispose using the captured local. Concurrent callers see null and skip cleanup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 1, 2026
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.
Fixes
Summary
Phase 2 of the Kitty Keyboard Protocol implementation (#4809). Builds on Phase 1 (merged in #4810) to extend
Keyand the keyboard event pipeline with richer semantics.Planned work
Key.EventType— Add Press/Release/Repeat event type toKeyKeyUppipeline — AddKeyUpevent through driver → keyboard → application → viewKeyUp—View.OnKeyUp/View.KeyUpevent routingSee
plans/kitty-keyboard-protocol-plan.mdfor detailed implementation steps.Test plan
dotnet build --no-restorepassesdotnet test --project Tests/UnitTestsParallelizable --no-build— all passdotnet test --project Tests/UnitTests --no-build— all passKeyDown-based code continues to work without modification🤖 Generated with Claude Code