Skip to content

Conversation

@haefele
Copy link
Owner

@haefele haefele commented Jan 21, 2026

Handle printable characters directly in KeyDown using KeySymbol property instead of deferring to the TextInput event. This simplifies the input handling path while maintaining proper keyboard layout support.

Handle printable characters directly in KeyDown using KeySymbol property
instead of deferring to the TextInput event. This simplifies the input
handling path while maintaining proper keyboard layout support.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@haefele haefele enabled auto-merge (rebase) January 21, 2026 18:06
@greptile-apps
Copy link

greptile-apps bot commented Jan 21, 2026

Greptile Summary

Consolidated keyboard input handling by removing the separate TextInput event handler and processing all input through KeyDown using Avalonia's KeySymbol property. This simplifies the input path from two separate event handlers (KeyDown for special keys, TextInput for characters) to a single handler that branches based on whether KeySymbol contains a printable character.

Key changes:

  • Removed DisplayPanel_TextInput event handler and its registration in XAML
  • Removed ShouldDeferToTextInput helper method
  • Modified DisplayPanel_KeyDown to check KeySymbol and route printable single characters through SendTextInputAsync
  • Updated DisplayPanel_KeyUp to skip KeyUp events for printable characters
  • Changed IsInputEnabled check style to use is false pattern

Potential concerns:

  • The single-character length check (e.KeySymbol.Length == 1) may not support IME (Input Method Editor) composition for languages like Chinese, Japanese, and Korean, which could produce multi-character strings during composition
  • The previous TextInput handler supported up to 100 characters for IME and paste scenarios, which is now restricted to single characters

Confidence Score: 3/5

  • This PR simplifies input handling but may introduce a regression for IME users
  • The refactoring successfully consolidates the input handling path and maintains support for basic keyboard layouts. However, the single-character restriction in the new implementation could break IME support for Asian languages, which was previously handled by the TextInput event that could process multi-character composition strings up to 100 characters. This needs verification with IME testing before merge.
  • Pay close attention to src/RemoteViewer.Client/Views/Viewer/ViewerView.axaml.cs - verify IME functionality with Chinese/Japanese/Korean input

Important Files Changed

Filename Overview
src/RemoteViewer.Client/Views/Viewer/ViewerView.axaml Removed TextInput event handler registration from DisplayPanel
src/RemoteViewer.Client/Views/Viewer/ViewerView.axaml.cs Consolidated key input handling into KeyDown, removed TextInput handler and ShouldDeferToTextInput helper; potential IME support regression

Sequence Diagram

sequenceDiagram
    participant User
    participant DisplayPanel
    participant ViewerView
    participant ViewerService
    participant Connection
    participant PresenterService
    participant InputInjection

    Note over User,DisplayPanel: Before: Two-path approach
    User->>DisplayPanel: Press key
    alt Printable character
        DisplayPanel->>ViewerView: TextInput event (multi-char support)
        ViewerView->>ViewerService: SendTextInputAsync(text)
        ViewerService->>Connection: TextInputMessage
        Connection->>PresenterService: HandleTextInput(text)
        PresenterService->>InputInjection: InjectText(text)
    else Special key/shortcut
        DisplayPanel->>ViewerView: KeyDown event
        ViewerView->>ViewerService: SendKeyDownAsync(keyCode, modifiers)
        ViewerService->>Connection: KeyMessage
        Connection->>PresenterService: HandleKey(keyCode, modifiers, true)
        PresenterService->>InputInjection: InjectKey(keyCode, modifiers, true)
    end

    Note over User,DisplayPanel: After: Single-path approach
    User->>DisplayPanel: Press key
    DisplayPanel->>ViewerView: KeyDown event only
    alt KeySymbol is single printable char
        ViewerView->>ViewerService: SendTextInputAsync(KeySymbol)
        ViewerService->>Connection: TextInputMessage
        Connection->>PresenterService: HandleTextInput(text)
        PresenterService->>InputInjection: InjectText(text)
    else Non-printable key
        ViewerView->>ViewerService: SendKeyDownAsync(keyCode, modifiers)
        ViewerService->>Connection: KeyMessage
        Connection->>PresenterService: HandleKey(keyCode, modifiers, true)
        PresenterService->>InputInjection: InjectKey(keyCode, modifiers, true)
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +257 to +261
if (string.IsNullOrEmpty(e.KeySymbol) is false &&
e.KeySymbol.Length == 1 &&
char.IsControl(e.KeySymbol[0]) is false)
{
await this._viewModel.Connection.RequiredViewerService.SendTextInputAsync(e.KeySymbol);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The single-character check e.KeySymbol.Length == 1 may break IME (Input Method Editor) support for languages like Chinese, Japanese, and Korean. The previous TextInput event could receive multi-character strings from IME composition (up to 100 chars), but KeyDown.KeySymbol only provides single characters. IME users may not be able to input complex characters that require composition. Does Avalonia's KeyDown.KeySymbol handle IME composition, or should IME be handled separately through TextInput events?

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/RemoteViewer.Client/Views/Viewer/ViewerView.axaml.cs
Line: 257:261

Comment:
**logic:** The single-character check `e.KeySymbol.Length == 1` may break IME (Input Method Editor) support for languages like Chinese, Japanese, and Korean. The previous `TextInput` event could receive multi-character strings from IME composition (up to 100 chars), but `KeyDown.KeySymbol` only provides single characters. IME users may not be able to input complex characters that require composition. Does Avalonia's KeyDown.KeySymbol handle IME composition, or should IME be handled separately through TextInput events?

How can I resolve this? If you propose a fix, please make it concise.

@haefele haefele merged commit 580e8b4 into main Jan 21, 2026
2 checks passed
@haefele haefele deleted the consolidate-key-input-to-keydown branch January 21, 2026 18:10
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.

2 participants