Skip to content

fix: Korean/CJK IME input and rendering in Sidebar Terminal#1297

Open
realcarsonterry wants to merge 1 commit intogarrytan:mainfrom
realcarsonterry:fix/cjk-terminal-input-output
Open

fix: Korean/CJK IME input and rendering in Sidebar Terminal#1297
realcarsonterry wants to merge 1 commit intogarrytan:mainfrom
realcarsonterry:fix/cjk-terminal-input-output

Conversation

@realcarsonterry
Copy link
Copy Markdown

@realcarsonterry realcarsonterry commented May 2, 2026

Summary

Fixes #1272 - Korean/CJK IME input and rendering issues in Sidebar Terminal

Special thanks to @ldybob for the excellent root cause analysis and proposed solutions.

Problem

The Sidebar Terminal had three separate Korean/CJK bugs:

  1. IME Input: Korean text typed via IME composition was not reaching the PTY correctly
  2. Font Rendering: Korean characters appeared fragmented or overlapping due to missing CJK font fallbacks
  3. UTF-8 Splitting: Multi-byte UTF-8 characters were being split across WebSocket chunks, causing garbled output

Changes

Bug 1: IME Composition Handling

  • Added compositionstart/compositionend event listeners in extension/sidepanel-terminal.js
  • Suppresses partial jamo fragments during composition
  • Only sends the final composed string on compositionend
  • Prevents doubled or fragmented input

Bug 2a: CJK Font Fallback

  • Updated fontFamily in extension/sidepanel-terminal.js to include "Noto Sans Mono CJK KR" and "Malgun Gothic"
  • Updated --font-mono CSS variable in extension/sidepanel.css with the same fonts
  • Ensures consistent cell-width calculations for Korean characters
  • Prevents character overlap and cursor misalignment

Bug 2b: UTF-8 Boundary Detection

Testing

✅ Korean input via IME now works correctly
✅ Korean output renders without garbled characters
✅ English input/output still works as expected
✅ Cursor positioning is correct for mixed English/Korean text

Impact

This fix enables Korean and other CJK developers using gstack on WSL2/Windows to fully use the Sidebar Terminal in their native language. Both input and output now work correctly.

Fixes garrytan#1272

This commit addresses three separate Korean/CJK bugs in the Sidebar Terminal:

**Bug 1 - IME Input**: Korean text typed via IME composition was not
reaching the PTY correctly. Added compositionstart/compositionend event
listeners to suppress partial jamo fragments and only send the final
composed string.

**Bug 2a - Font Rendering**: Added CJK monospace font fallbacks
("Noto Sans Mono CJK KR", "Malgun Gothic") to both the xterm.js
fontFamily config and the CSS --font-mono variable. This ensures
consistent cell-width calculations for Korean characters.

**Bug 2b - UTF-8 Boundary Detection**: Added buffering logic to prevent
multi-byte UTF-8 characters (Korean is 3 bytes) from being split across
WebSocket chunks. This follows the same pattern as PR garrytan#1007 which fixed
the sidebar-agent path, but extends it to the terminal-agent path.

Special thanks to @ldybob for the excellent root cause analysis and
proposed solutions in issue garrytan#1272.

Tested on WSL2 + Windows 11 with Korean IME.
@realcarsonterry realcarsonterry force-pushed the fix/cjk-terminal-input-output branch from 908ce92 to 4bd6359 Compare May 2, 2026 07:44
@realcarsonterry
Copy link
Copy Markdown
Author

Hey! I've been using gstack on WSL2 and ran into this issue where Korean input was completely broken in the sidebar terminal. Spent some time debugging and found it was actually three separate bugs working together.

The UTF-8 splitting issue was interesting - looks like PR #1007 fixed it for sidebar-agent but terminal-agent was still affected. Applied the same buffering pattern here.

Let me know if you'd like me to add any additional test cases or documentation. Thanks for building this tool btw, it's been super helpful for my workflow!

@realcarsonterry
Copy link
Copy Markdown
Author

Heads up - it looks like the CI workflows aren't running because I'm a first-time contributor to this repo. GitHub's security policy blocks automatic workflow runs for external contributors.

Would a maintainer be able to approve the workflow run so the tests can execute? The changes are pretty straightforward (IME handling + font fallbacks + UTF-8 buffering), but I'd love to see the CI results to make sure everything passes. Thanks!

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.

Sidebar Terminal: Korean (CJK) IME input not delivered to PTY

1 participant