# fix\(web\): surround selected text with dead-key quotes · PR \#21360 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/21360)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: Unavailable fork

Source branch: fix/composer-dead-key-quotes

Target branch: main

Head commit: 18e33fb223ed2994ec0a5a5001e240155f46a958

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/21360)

[Commits](https://git.cafe/pingdotgg/t3code/pull/21360/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/21360/diffs?format=markdown)

## Description

---

With US-International input, selecting `word` and pressing apostrophe then Space replaces the word with `'` on Linux and macOS. This restores the existing selection-surround behavior for dead keys after #20350. Related: [the maintainer's request to verify selection wrapping](https://github.com/pingdotgg/t3code/issues/16859#issuecomment-6040638741).

Keep eligible selected text in place while the dead key resolves, then surround it when a delimiter commits. Accented letters still replace the selection. Handle both native composition and Windows' direct text commits, preserve one-step undo, and discard stale selections.

Verification:

- 32 focused browser tests pass across the input, navigation, and citation-draft tests. They cover preedit replacement, wrapping, accents, cancellation, undo/redo, and stale selections.
- Web typecheck, targeted lint, and formatting pass. The shared web/desktop editor is covered in rich and plain modes; mobile uses a separate native input.
- Native Electron 44.4.5: 16 cases pass per target across rich and plain modes on Windows, macOS, Linux X11, and native Linux Wayland. OS layout probes precede the composer tests. Selected words stay present throughout wrapping, with one-step undo and redo.
- Linux automation uses Ubuntu 24.04 with Xvfb/Openbox for X11 and isolated Sway for Wayland. Wayland has XWayland disabled and no X11 display, and the test verifies an Electron `xdg_shell` surface. The reporter also verified the isolated desktop build on CachyOS/Wayland.

Reproduce the focused browser checks with:

```sh
cd apps/web
../../node_modules/.bin/vp test run --project browser src/components/ComposerPromptEditorTiptap.{input,navigation,citationDraft}.browser.test.tsx
```

macOS before the fix: apostrophe + Space replaces the selected `word` with `'`.

![macOS before the fix: only an apostrophe remains](https://github.com/user-attachments/assets/f3696d42-8e06-4ea6-abeb-7a4747cc1dfa)

https://github.com/user-attachments/assets/347b0a56-e70f-40c6-b759-b2eeb7a47f17

macOS after the fix: apostrophe + Space produces `'word'` and keeps `word` selected.

![macOS after the fix: the selected word is surrounded by apostrophes](https://github.com/user-attachments/assets/dfb71541-08ac-4d02-bebe-355ccd7a25ed)

https://github.com/user-attachments/assets/1b873d6a-44cd-4495-8ebd-bf5cb7001c75

<details>
<summary>Windows native verification</summary>

All 16 cases pass in rich and plain modes, including accents, selection wrapping, and undo/redo.

![Windows after the fix: the selected word is surrounded by apostrophes](https://github.com/user-attachments/assets/a50b49ee-b21a-47a5-bdf8-5b37808c13e2)

https://github.com/user-attachments/assets/7f3fddf9-8796-4dbf-b31f-8bb0adecba39

</details>

<details>
<summary>Linux X11 and native Wayland verification</summary>

X11: all 16 native cases pass under Xvfb/Openbox.

![Linux X11: the selected word remains surrounded by apostrophes](https://github.com/user-attachments/assets/73afa5ae-9578-40fc-baf7-23b47c76f844)

https://github.com/user-attachments/assets/b5244c8a-701e-4ac1-8a1a-1f66837333f0

Native Wayland: all 16 cases pass under Sway, with XWayland disabled. The selected word remains in every recorded transaction and frame.

![Native Linux Wayland: the selected word remains surrounded by apostrophes](https://github.com/user-attachments/assets/4d93cb3f-4c2e-4c77-b371-e94d76435a30)

https://github.com/user-attachments/assets/f3e76c64-4c75-4967-90a3-038ef7309c0c

[Passing Linux run](https://github.com/Gustav0ar/t3code/actions/runs/39182903189), [X11 environment and event traces](https://github.com/Gustav0ar/t3code/actions/runs/39182903189/artifacts/12157055936), and [Wayland environment, surface, and event traces](https://github.com/Gustav0ar/t3code/actions/runs/39182903189/artifacts/12157036077).

</details>

The recordings include layout probes and native keyboard cases. [Passing Windows and macOS native run](https://github.com/Gustav0ar/t3code/actions/runs/39182903195), [macOS event traces](https://github.com/Gustav0ar/t3code/actions/runs/39182903195/artifacts/12156639269), and [Windows event traces](https://github.com/Gustav0ar/t3code/actions/runs/39182903195/artifacts/12156672555). The test code stays on the fork's [test branch](https://github.com/Gustav0ar/t3code/tree/test/composer-input-simplified).

Implemented with GPT-6.1-sol in Codex.


