Skip to content

Studio: guard project chat rename against IME composition keys - #7246

Merged
danielhanchen merged 1 commit into
mainfrom
studio-project-rename-ime-escape
Jul 23, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio-project-rename-ime-escape

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Follow-up to #7005. The project chat rename input guarded only the Enter that confirms an IME candidate, so on WebKit an Escape that cancels a candidate mid-composition also cancelled the rename. Composing a CJK title and pressing Escape to drop a candidate would lose the edit.

Fix

Move the composition guard ahead of the key branch so both Enter and Escape are ignored while a candidate is being composed (isComposing on WebKit, keyCode 229 on Chromium). Non-IME input is unchanged: a real Enter still commits and a real Escape still cancels.

Verification

Checked against the rename state machine: while composing, neither Enter nor Escape commits or cancels; outside composition both behave as before. Frontend only, scoped to the rename input.

Compatibility

No behaviour change for non-IME input; only reorders where the existing composition check runs.

The rename input only ignored the composition-confirming Enter, so on WebKit an
Escape that cancels an IME candidate also cancelled the rename. Move the
composition guard ahead of the key branch so both Enter and Escape are ignored
while a CJK candidate is being composed.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the onKeyDown handler in the chat page component to guard against keydown events fired during IME composition before checking specific keys like "Enter". This prevents candidate-confirming or candidate-cancelling actions from prematurely committing or cancelling a rename. The reviewer suggested using React's synthetic event.isComposing directly instead of accessing event.nativeEvent.isComposing to simplify the code and avoid potential runtime errors in test environments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +1119 to +1123
if (
event.nativeEvent.isComposing ||
event.keyCode === 229
)
return;

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.

medium

In React, the isComposing property is directly available on the Synthetic KeyboardEvent (i.e., event.isComposing). Reaching into event.nativeEvent is unnecessary and can occasionally lead to runtime errors in testing environments where nativeEvent might not be fully mocked. Additionally, simplifying this to a single-line conditional matches the existing codebase style for guard clauses.

                              if (event.isComposing || event.keyCode === 229) return;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

isComposing is not exposed on React's SyntheticKeyboardEvent (react/react#13104), so event.isComposing is undefined at runtime. event.nativeEvent.isComposing is the required access and is what guards WebKit here; switching would drop the Safari IME guard and leave only the Chromium keyCode 229 path. Keeping as is.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: b31f34c096

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 127c69b into main Jul 23, 2026
41 checks passed
@danielhanchen
danielhanchen deleted the studio-project-rename-ime-escape branch July 23, 2026 07:45
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.

1 participant