Skip to content

fix(ssh): keep the IME confirmation Enter from submitting the port-forward dialog - #34126

Closed
seijikohara wants to merge 1 commit into
stablyai:mainfrom
seijikohara:fix/ssh-port-forward-ime-enter
Closed

seijikohara wants to merge 1 commit into
stablyai:mainfrom
seijikohara:fix/ssh-port-forward-ime-enter

Conversation

@seijikohara

Copy link
Copy Markdown
Contributor

ELI5

When you type Japanese or Chinese, the first Enter only confirms the converted word.

In the SSH "Forward a Port" dialog, some input methods made that same Enter submit the form, so Orca requested the forward with a half-typed label or host. Now the confirming Enter only confirms, and the next Enter submits.

What Changed

Before:

  • The dialog's four fields (Remote Port, Local Port, Remote Host, Label) are raw <input type="text"> elements inside a <form> with a submit button.
  • When an IME confirms a conversion and then sends an unmarked Enter/13 after compositionend, nothing intercepts that keydown, and the browser submits the form implicitly.

After:

  • The four fields render with ImeInput (src/renderer/src/lib/ime-text-field.tsx).
  • The confirmation and its redispatched Enter no longer submit the form. An ordinary Enter submits exactly once, as before.

Mechanism:

  • ImeInput applies useImeTextFieldProps, which uses the shared useImeEnterGestureOwnership tracker.
  • The tracker owns the confirming keydown and calls preventDefault() on the carried unmarked redispatch, so the browser never runs implicit submission for it.
  • Props and INPUT_CLASS are unchanged, so the dialog renders identically.

Why

Linked Issue

Fixes #34124

Visual Proof

How the images were made

  • A hidden Electron launch on macOS (ORCA_BACKGROUND_LAUNCH=1, the repository's E2E harness, Playwright CDP).
  • A seeded SSH workspace whose host is unreachable. Its connection state is set to connected, so the Ports panel offers "Forward a Port".
  • In the Label field, these events are sent through CDP:
    1. Input.imeSetComposition: かいはつ, then 開発
    2. a Process/229 keydown
    3. Input.insertText
    4. a trusted Enter/13 keydown with text: "\r": the unmarked redispatch, in Windows/Linux order
    5. keyup
  • No native OS IME and no real SSH connection were used.
  • The red line is how this dialog reports a submission to an unreachable host.
Before (main @ b759a95) After (this branch)
before after

After the fix, a deliberate Enter still submits:

after-deliberate-enter

Testing

Tested on macOS (Apple silicon) only. The change has no platform-specific code.

  • Manual: I ran the Visual Proof flow above in hidden launches of main @ b759a95 and of this branch.

  • New test: ssh-port-forward-dialog.ime-enter.test.tsx covers each of the four fields.

    • It replays the marked confirmation (Process/229) and the unmarked redispatch, and asserts that the redispatch keydown is default-prevented and nothing is submitted.
    • It then asserts that an ordinary Enter submits once, with the confirmed value in the request.
    • All four cases fail when the raw inputs are restored.
  • Existing tests: the right-sidebar Ports suites (PortsPanel.test.tsx, PortsPanel.folder-workspace.test.tsx, ssh-forwarded-ports-section.test.tsx, ports-panel-host.test.ts, local-workspace-port-sections.test.ts) and ime-text-field.test.tsx pass. With the new test, that is 7 files and 110 tests.

  • pnpm typecheck passes.

  • check:code-quality:changed and check:react-doctor:changed against main @ b759a95 report 0 new findings.

  • pnpm lint: every step passes except check:flaky-test-pattern-ratchet, which cannot run as configured here.

    • It diffs against this fork's outdated origin/main, and the diff output overflows (spawnSync git ENOBUFS).
    • With ORCA_FLAKY_TEST_RATCHET_ALL=1 it checks every file instead. It then reports findings in four src/main/ipc/filesystem/watchers/*.test.ts files, and unmodified main @ b759a95 reports the same findings.
    • Its test-* rules report no finding in this PR's two files.
  • pnpm test fails locally in 83 of 13,503 test files. None of the failing files covers a module this PR changes:

    • 73 of them also fail on unmodified main @ b759a95 in the same environment. The causes are local: release tags the cross-version harness cannot resolve in this clone, macOS bash 3.2, /var versus /private/var temp paths, zsh prompt and PTY timeouts, and a self-signed certificate in the TLS chain.
    • The other 10 pass when rerun outside the full run. The full run shared the machine with other work, and they hit timeouts there.
  • pnpm build:

    • build:desktop passes, including the mobile web bundle. Before that, I installed the mobile/ dependencies with pnpm install --frozen-lockfile, as the install-mobile-dependencies action does.
    • build:native fails to link the x86_64 slice of notification-status-macos: this machine's Command Line Tools ship the Swift compatibility libraries for arm64 only. Unmodified main @ b759a95 fails the same way, and this PR changes no native code.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Implemented with Claude Code (Claude Opus 5.5) under my direction.

Review

AI review with Claude Code (Claude Opus 5.5), in a separate pass over the diff. It found no blocking issue and checked these points:

  • The redispatched Enter is default-prevented, so the browser runs no implicit submission for it.
  • ImeInput passes every prop through and adds only onKeyDown, onKeyUp, onCompositionStart, onCompositionEnd and onBlur. The dialog's onChange handlers are untouched.
  • Escape, Tab and the disabled submit button behave as before.
  • A search of the renderer's 29 files that render a <form>, following their imports two levels deep, found no other raw text input inside a submitting form.

Its two test suggestions are applied: the test no longer advances timers between the two Enters, and it asserts that the submitted request carries the confirmed value.

Compatibility and risk:

  • Cross-platform: No platform-specific code. The fix matters for Windows/Linux IMEs that send the unmarked Enter. macOS behaviour is unchanged.
  • SSH/remote/local: Renderer-only. The add/update port-forward RPC and its parameters are unchanged.
  • Agents and integrations: None touched.
  • Performance: One keydown handler per field, the same tracker every other text field uses.
  • UI quality: Identical rendering; the same className is passed through.
  • Security: None. No new data flow.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Author

X handle: none.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…rward dialog

The SSH port-forward dialog renders its four fields as raw inputs inside a
form with a submit button. IMEs that redispatch an unmarked Enter after
compositionend therefore trigger implicit submission with the half-typed
value. The pre-revert ImeEnterGuardedForm covered this form; #25480 moved
the guard into shared fields but did not reach these raw inputs, and the
#28609 lint rule only inspects Enter handlers, which these fields lack.

Render the fields with ImeInput so the shared gesture tracker swallows the
confirmation and its redispatch while ordinary Enter still submits.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

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
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76f099fd-cda3-4d43-9bbd-580d82161ed2
Commits

Reviewing files that changed from the base of the PR and between 0fef4a8 and ebba240.

Files selected for processing: 2
  • src/renderer/src/components/right-sidebar/ssh-port-forward-dialog.ime-enter.test.tsx
  • src/renderer/src/components/right-sidebar/ssh-port-forward-dialog.tsx

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

Walkthrough

The SSH port-forward dialog now uses ImeInput for the remote port, local port, remote host, and optional label fields. Tests verify that the first Enter after composition ends does not submit the form, and that a subsequent Enter submits once with the expected field value.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to ebba2

The IME handling change is ready to merge based on the available evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the SSH port-forward dialog fix and the IME confirmation Enter behavior. It is concise and directly matches the main change.
Description check Passed The description is complete and follows the repository template. It explains the user impact, implementation, rationale, linked issue, visual proof, testing, limitations, compatibility considerations,…
Linked Issues check Passed The PR addresses active issue #34124. It replaces the four SSH port-forward dialog text inputs with ImeInput and preserves their existing props and INPUT_CLASS styling. The added test covers all f…
Out of Scope Changes check Passed The reported changes are limited to the four fields in SshPortForwardDialog and one focused IME test file. The component change and test directly support issue #34124. No unrelated product, RPC, nat…
Full details: Description check

Explanation

The description is complete and follows the repository template. It explains the user impact, implementation, rationale, linked issue, visual proof, testing, limitations, compatibility considerations, and checklist status.

Full details: Linked Issues check

Explanation

The PR addresses active issue #34124. It replaces the four SSH port-forward dialog text inputs with ImeInput and preserves their existing props and INPUT_CLASS styling. The added test covers all four fields, prevents submission from the IME redispatch, and verifies that a later ordinary Enter submits once with the confirmed value. The reported typecheck and focused test results support the required behavior.

Full details: Out of Scope Changes check

Explanation

The reported changes are limited to the four fields in SshPortForwardDialog and one focused IME test file. The component change and test directly support issue #34124. No unrelated product, RPC, native, or data-flow changes are reported.

  • 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.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @seijikohara! Your fix landed with your authorship preserved in #34315 (we run CI only on in-repo branches, so we carried your commit over). Closing this one in favor of it. Fixes #34124.

@nwparker nwparker closed this Oct 27, 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.

[Bug]: IME confirmation Enter can submit the SSH port-forward dialog

3 participants