Skip to content

fix(input): decode CSI R as F3 - #1133

Merged
gdamore merged 1 commit into
gdamore:mainfrom
kke:fix/add-csi-f3
Jul 19, 2026
Merged

gdamore merged 1 commit into
gdamore:mainfrom
kke:fix/add-csi-f3

Conversation

@kke

@kke kke commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Some terminals emit F3 as CSI R instead of SS3 R or CSI 13~.

The parser already recognizes neighboring CSI P/Q/S forms for F1, F2, and F4, but omitted R, causing F3 to be swallowed.

Only the no-parameter form is mapped, so cursor position reports like CSI row;col R should remain unaffected.

Tested to enable F3 using iTerm2 to connect to an Ubuntu 24.04 machine over Mosh+SSH+tmux without any obvious side-effects.

Summary by CodeRabbit

  • Bug Fixes
    • Improved special-key handling so an additional escape sequence is now recognized as F3.
    • This makes keyboard input more consistent for terminal-based interactions.
    • Added test coverage for the newly supported key sequence.

@kke
kke requested a review from gdamore as a code owner July 7, 2026 05:52
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97bdc001-27da-483f-807f-d06c99b09b00

📥 Commits

Reviewing files that changed from the base of the PR and between eb9a13e and fec5081.

📒 Files selected for processing (2)
  • input.go
  • input_test.go

📝 Walkthrough

Walkthrough

This change adds CSI R handling in the key mapping table and updates the special-key test to expect ESC [ R to produce KeyF3 with no modifier or payload.

Changes

CSI Key Mapping

Layer / File(s) Summary
Map CSI-R to F3
input.go, input_test.go
Adds csiParamMode{M: 'R'} to KeyF3 in the CSI mapping table and adds a TestSpecialKeys case for ESC [ R expecting KeyF3, ModNone, and an empty string.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested reviewers: gdamore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: decoding CSI R as F3 in input parsing.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
input.go (1)

225-225: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding an explicit CSI-R test case.

Test snippets show CSI-P, CSI-Q, CSI-S cases mirroring csiAllKeys entries for F1/F2/F4, but no bare CSI-R case for F3 exists alongside the new mapping (only SS3-F3 and Linux-F3 are covered).

✅ Suggested test addition (input_test.go)
 		{"CSI-P", []byte{'\x1b', '[', 'P'}, KeyF1, ModNone, ""},
 		{"CSI-Q", []byte{'\x1b', '[', 'Q'}, KeyF2, ModNone, ""},
+		{"CSI-R", []byte{'\x1b', '[', 'R'}, KeyF3, ModNone, ""},
 		{"CSI-S", []byte{'\x1b', '[', 'S'}, KeyF4, ModNone, ""},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@input.go` at line 225, Add an explicit CSI-R test case to cover the new F3
mapping in the key input tests. The current test table in input_test.go mirrors
csiAllKeys for F1/F2/F4 via CSI-P, CSI-Q, and CSI-S, but lacks a bare CSI-R
entry for KeyF3; update the relevant test fixture and assertions so CSI-R is
validated alongside the existing SS3-F3 and Linux-F3 coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@input.go`:
- Line 225: Add an explicit CSI-R test case to cover the new F3 mapping in the
key input tests. The current test table in input_test.go mirrors csiAllKeys for
F1/F2/F4 via CSI-P, CSI-Q, and CSI-S, but lacks a bare CSI-R entry for KeyF3;
update the relevant test fixture and assertions so CSI-R is validated alongside
the existing SS3-F3 and Linux-F3 coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6aa11091-a6f5-498d-a648-b9064da92a26

📥 Commits

Reviewing files that changed from the base of the PR and between d85b1fb and d33f64a.

📒 Files selected for processing (1)
  • input.go

@kke
kke force-pushed the fix/add-csi-f3 branch from d33f64a to eb9a13e Compare July 7, 2026 05:55
@codecov

codecov Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.34%. Comparing base (d85b1fb) to head (eb9a13e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1133      +/-   ##
==========================================
- Coverage   89.36%   89.34%   -0.02%     
==========================================
  Files          47       47              
  Lines        5718     5718              
==========================================
- Hits         5110     5109       -1     
- Misses        460      461       +1     
  Partials      148      148              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gdamore gdamore left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I thought I reviewed and merged this change (or one just like it) recently.

Some terminals emit F3 as CSI R instead of SS3 R or CSI 13~.
The parser already recognizes neighboring CSI P/Q/S forms for F1, F2,
and F4, but omitted R, causing F3 to be swallowed.

Only the no-parameter form is mapped, so cursor position reports like
CSI row;col R should remain unaffected.

Signed-off-by: Kimmo Lehto <kimmo.lehto@gmail.com>
@gdamore
gdamore merged commit 143d069 into gdamore:main Jul 19, 2026
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