Skip to content

[0.0.28] fix(input): preserve negotiated Shift+Enter distinction - #2628

Merged
Xuepoo merged 7 commits into
mainfrom
ctx-1505/fix-shift-enter
Oct 24, 2026
Merged

Xuepoo merged 7 commits into
mainfrom
ctx-1505/fix-shift-enter

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Priority: P1 | Area: area:term | Labels: fix,P1,area:term | Milestone: v0.0.28 | RFC: OQ-004 | Task: CTX-1505

Closes #1665 (related Kitty keyboard protocol contract).

Summary

Some TUIs use Shift+Enter as an inserted newline. This patch makes the Kitty encoder's bare-key fallback explicit and pins the routing contract:

  • ordinary Enter remains CR (0d);
  • without negotiated Kitty enhancement, Shift+Enter fails closed to legacy CR;
  • with Kitty disambiguation (CSI > 1 u / CSI = 1 u), Shift+Enter is CSI 13;2u (1b 5b 31 33 3b 32 75);
  • with report-events, repeat/release are CSI 13;2:2u / CSI 13;2:3u;
  • unrelated alternate-key-only negotiation does not guess a CSI-u frame;
  • the real ModifiersChanged platform route is covered.

The legacy exception remains for bare Enter/Tab/Backspace/Delete so a crashed application can still type reset. No modifyOtherKeys path exists in Core; this change does not invent one or alter chrome keymaps/shell routing.

Verification

  • cargo fmt --all -- --check
  • cargo clippy -p bitty-platform -p bitty-runtime --all-targets --locked -- -D warnings
  • focused bitty-platform keyboard tests: 34 passed
  • bitty-runtime enhanced keyboard protocol tests: 42 passed
  • docs parity PR: bitty-terminal-docs#305 (just check)

Security/performance impact: bounded existing CSI-u frames only; no new authority or unbounded input.

Follow-up: independent review and required CI; do not merge as part of this task.

Summary by CodeRabbit

  • Bug Fixes
    • Pressing unmodified Enter to confirm a pending paste no longer sends extra input from that key’s repeat or release events. Later Enter presses work normally.
    • Modified Enter, including Shift+Enter, no longer confirms a pending paste. Losing window focus clears the pending Enter handling.
  • Documentation
    • Clarified keyboard behavior: Shift+Enter sends a carriage return in legacy mode and uses the Kitty protocol’s modified-key sequence when negotiated. Plain Enter continues to send a carriage return.

@Xuepoo Xuepoo added this to the v0.0.28 milestone Oct 24, 2026
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:term Area: terminal state / VT labels Oct 24, 2026
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30fc6659-3b71-4cb8-b9e6-574375c24c5f
Commits

Reviewing files that changed from the base of the PR and between be33946 and d5ca01d.

Files selected for processing: 6
  • crates/bitty-runtime/src/runtime.rs
  • crates/bitty-runtime/src/runtime/input.rs
  • crates/bitty-runtime/src/runtime/selection.rs
  • crates/bitty-runtime/tests/enhanced_keyboard_protocol.rs
  • crates/bitty-runtime/tests/suspicious_paste.rs
  • crates/bitty-terminal/src/chrome_keys.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change documents and tests Kitty encoding for modified functional keys. Pending-paste confirmation now requires an unmodified Enter press and consumes that key’s repeat and release. Focus loss clears the associated swallow state.

Changes: Keyboard Input and Pending Paste

Layer / File(s) Summary
Kitty encoding policy and coverage
crates/bitty-platform/src/keyboard.rs, crates/bitty-runtime/tests/enhanced_keyboard_protocol.rs
Documentation distinguishes legacy and negotiated encoding for modified functional keys. Tests cover Enter, Tab, Backspace, Delete, and numpad Enter across modifier, repeat, release, and report-all cases.
Pending-paste Enter handling
crates/bitty-runtime/src/runtime.rs, crates/bitty-runtime/src/runtime/input.rs, crates/bitty-runtime/src/runtime/selection.rs, crates/bitty-runtime/tests/suspicious_paste.rs, crates/bitty-terminal/src/chrome_keys.rs
Only an unmodified Enter press confirms a pending paste. The runtime consumes the confirming Enter’s repeat and release, and clears its swallow state on focus loss. Tests cover later Enter input and modified Enter behavior.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant EnterEvent
  participant confirm_pending_paste_on_enter
  participant PendingPaste
  EnterEvent->>confirm_pending_paste_on_enter: unmodified Enter press
  confirm_pending_paste_on_enter->>PendingPaste: confirm pending paste
  EnterEvent->>confirm_pending_paste_on_enter: repeat and release
  confirm_pending_paste_on_enter->>confirm_pending_paste_on_enter: consume through release
Loading

Possibly related issues

  • bitty-terminal/bitty#2632 — The changes cover Enter press, repeat, release, and Shift+Enter behavior with pending paste, but the issue describes a broader contract and is identified as a separate follow-up.

Suggested labels: area:runtime

Merge Risk: Minimal · up to d5ca0

No specific regression is established. Complete the required checks and resolve the reported test failures before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change, the scope, and the type of fix: it preserves the negotiated Shift+Enter distinction in the input path. The PR changes Kitty keyboard encoding and routing for Shift+Enter, s…
Linked Issues check Passed Issue #1665 is closed and supplies historical context only. No active directly linked issue remains. No linked-issue coding requirements apply.
Out of Scope Changes check Passed The changes cover Shift+Enter encoding, Kitty negotiation, repeat and release handling, and the real modifier routing path. The paste-confirmation and focus-loss changes prevent modified Enter from co…
Full details: Title check

Explanation

The title names the change, the scope, and the type of fix: it preserves the negotiated Shift+Enter distinction in the input path. The PR changes Kitty keyboard encoding and routing for Shift+Enter, so the title matches the main change. The title's "[0.0.28]" version tag and the commit-style prefix are noise but do not make the title unrelated or vague.

Full details: Out of Scope Changes check

Explanation

The changes cover Shift+Enter encoding, Kitty negotiation, repeat and release handling, and the real modifier routing path. The paste-confirmation and focus-loss changes prevent modified Enter from confirming or leaking across focus changes. The added tests verify these behaviors. The reported changes have a direct connection to the stated keyboard contract. No unrelated change is demonstrated.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@Xuepoo

Xuepoo commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

[guard 2026-10-24 20:15] Forensics (from job steps + annotations, NOT a rerunnable flake): nextest fails on ALL OS legs — Quality gates shard 1/2 (exit 100), Windows/Linux-X11/Linux-Wayland/macOS all fail at Run tests, so both Tier-1 aggregates read stale leaves. Branch-specific test failures (sibling PRs 2630/2631/2567 green in the same window). NEEDS-FIX in-branch; do not merge past red.

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Guard independent review 2026-10-24 ([guard], cron):

Checks (verified green on head): Quality gates (1) pass, Quality gates (2) pass, Linux X11 (xvfb) pass, Linux Wayland pass, Windows check and test pass, macOS ARM64 pass, MSRV 1.85 pass, Supply chain pass, VM tier pass, Extension pin drift pass.

Diff read: encode_key_event_kitty_protocol narrows the bare Enter/Tab/Backspace/Delete legacy exception to modifiers == 0 (bare_legacy_exception), so Shift+Enter under the negotiated Kitty protocol now emits CSI 13;2u while bare Enter keeps CR; legacy path docs explicitly state Shift+Enter stays CR. Tests added in enhanced_keyboard_protocol.rs cover both paths. Legacy-path behavior is unchanged (UX reference rule satisfied). Approving; branch is behind main — updating branch before merge.

@Xuepoo
Xuepoo merged commit 447071b into main Oct 24, 2026
20 checks passed
@Xuepoo
Xuepoo deleted the ctx-1505/fix-shift-enter branch October 24, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:term Area: terminal state / VT fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] Implement Kitty Keyboard Protocol progressive enhancement encoding (CSI > u)

1 participant