[Windows][CLI] Chinese IME breaks after exiting and relaunching Codex in the same PowerShell session
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
Summary
On Windows, Chinese IME input can work during the first Codex TUI launch, then stop working after exiting Codex and launching it again from the same PowerShell session.
This appears to be a related but distinct reproduction from #19501 and #35469. Those reports describe IME recovery after the terminal loses and regains focus or after switching tabs. In this case, the trigger appears to be the Codex TUI exit/re-entry cycle in the same pwsh.exe process, without running any intervening commands.
The initial Codex TUI appearance can also differ between the good and bad runs. I suspect the appearance difference and the IME failure may be two symptoms of a changed terminal/runtime detection or focus state, rather than a skin/configuration issue.
Environment
- OS: Windows 11
- PowerShell: 7.6.5
- Codex CLI: codex-cli 0.153.4
- Installation: npm
- Input method: Sogou Chinese IME
- Console input/output encoding: gb2312 / gb2312
- Launch context: Win+X / Explorer-launched PowerShell
- pwsh.exe parent process: explorer.exe
- WT_SESSION: absent
- WT_PROFILE_ID: absent
- TERM_PROGRAM: absent
- npm entry: %USERPROFILE%\AppData\Roaming\npm\codex.ps1
Because the process is launched directly from Explorer/Win+X and the Windows Terminal environment variables are absent, this may be a native console/ConHost path rather than a Windows Terminal profile session.
Initial observation
In the same Win+X PowerShell window:
- The first codex launch accepts Chinese IME input normally.
- I exit Codex with Ctrl+C.
- I launch codex again from the same PowerShell session.
- Chinese IME input is no longer accepted correctly, even though the shell and Codex otherwise remain usable.
The diagnostic commands used around this observation were read-only (Write-Host, reading environment variables, Get-Command, [Console]::InputEncoding, and querying the current code page). No terminal appearance or Codex configuration was changed by those commands.
Minimal reproduction
Please reproduce this with a fresh Win+X PowerShell window. Do not run any other commands between the two launches:
-
Open a new Win+X PowerShell window.
-
Run:
codex -
Immediately test Sogou Chinese input:
- switch between Chinese and English;
- type Pinyin;
- confirm a candidate;
- type a longer Chinese sentence.
-
Exit Codex with Ctrl+C.
-
Without running any other command, run codex again.
-
Repeat the same Chinese IME tests.
-
While the second Codex session is in the bad state, do not exit Codex:
- switch to Notepad or a browser with Alt+Tab;
- verify that Sogou Chinese input works there;
- switch back to Codex;
- try Chinese input again.
Expected behavior
Chinese IME input should work consistently across repeated Codex TUI launches from the same PowerShell session. Exiting and re-entering Codex should not leave the TUI with a stale or missing IME/TSF focus context.
Actual behavior
The first launch can accept Chinese input, while the second launch from the same pwsh.exe session can fail to accept Chinese IME composition. Switching focus to another application and back may restore input without restarting the PowerShell process.
If confirmed by the minimal reproduction above, the observed sequence is:
fresh Win+X pwsh
-> codex: Chinese IME works
-> Ctrl+C
-> codex again: Chinese IME fails
-> Alt+Tab away and back: input may recover
Additional observations
- WT_SESSION, WT_PROFILE_ID, and TERM_PROGRAM are empty in the affected shell.
- The affected shell is an Explorer child rather than a Windows Terminal profile child.
- gb2312 input/output code pages are present; changing the code page to UTF-8 has not been used as a workaround because it would introduce another variable.
- The TUI appearance may change between the good and bad launches. This may be related to terminal detection or lifecycle state; it should not be assumed to be a color/theme-only problem.
- The behavior is similar to the focus/IME recovery described in:
- #19501: Windows Chinese IME fails until the terminal loses and regains focus
- #35469: Windows Terminal Japanese IME recovers after switching tabs
- #37769: WT_SESSION changes Codex TUI rendering in the same Windows Terminal tab
Requested investigation
Please check whether the Windows TUI/ConPTY lifecycle leaves the console input mode, focus state, or Windows IME/TSF context in a stale state after Codex exits and starts again in the same shell. In particular, please verify that terminal modes and focus-related state are fully restored on TUI shutdown and reinitialized on the next launch.
I can provide a full sanitized codex doctor --json, repeated-run logs, and a screen recording of the first-launch/second-launch/focus-recovery sequence if needed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproduction in a fresh Win+X PowerShell window: launch Codex, exit with Ctrl+C, and relaunch without intervening commands. Investigate the Windows TUI/ConPTY lifecycle, including console input mode and focus-related state during shutdown and the next launch; done means Chinese IME input remains functional across both sessions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, rust
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100