fix(terminal): forward mouse clicks to PTY and render underlines#251
fix(terminal): forward mouse clicks to PTY and render underlines#251forketyfork merged 3 commits intomainfrom
Conversation
Issue: Terminal apps like `fresh` that rely on mouse tracking show non-clickable menus and missing underlined mnemonics in Architect, despite working correctly in Ghostty. Solution: The input path already forwarded mouse scroll events but skipped button clicks entirely. Added mouse button press/release and motion encoding (SGR + X10 formats) to the input mapper, then wired the session interaction handler to check terminal mouse tracking modes before falling back to text selection. Also added per-cell underline rendering in the terminal renderer, which was processing bold, italic, and other SGR flags but had no underline support. Closes #250
There was a problem hiding this comment.
Pull request overview
Fixes terminal mouse tracking input forwarding (clicks + motion) and adds rendering support for SGR underlines in Architect’s terminal view.
Changes:
- Forward mouse button press/release and motion events to the PTY when terminal mouse tracking is enabled.
- Add input mapper support for encoding mouse button and motion events (SGR + X10 formats), with tests.
- Render underlined text by drawing a 1px underline at the bottom of the cell.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui/components/session_interaction.zig | Routes mouse events to PTY when mouse tracking is enabled; preserves selection/link behavior otherwise. |
| src/render/renderer.zig | Adds underline rendering for any non-.none underline style. |
| src/input/mapper.zig | Adds mouse button + motion encoders for SGR/X10 and corresponding unit tests. |
| src/c.zig | Exposes additional SDL mouse button constants/masks needed for motion/button handling. |
| script/setup | Changes setup behavior to run direnv allow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50db732925
ℹ️ 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".
…e rendering Move underline rendering after glyph flush so glyphs don't overwrite the underline line. Emit X10 button release events (button code 3) instead of silently dropping them, which fixes click/drag state in legacy mouse tracking mode. Fix inaccurate doc comment on encodeMouseMotion.
Summary
Terminal apps that enable mouse tracking (like
fresh) had two problems in Architect: mouse button clicks were never forwarded to the terminal PTY, and the SGR underline attribute wasn't rendered. Scroll wheel forwarding already worked correctly and served as the pattern for the button/motion fix.Closes #250
What changed
The input mapper gained two new encoding functions for mouse button press/release and motion events, supporting both SGR and X10 wire formats. The session interaction handler now checks whether the terminal has mouse tracking enabled before handling clicks — if tracking is on, events go to the PTY; otherwise the existing text selection and URL-opening behavior kicks in. Motion events are forwarded when
mouse_event_anyis active ormouse_event_buttonis active with a button held.On the rendering side, the terminal renderer now checks
style.flags.underlineand draws a 1px line at the cell bottom for any underline variant (single, double, curly, dotted, dashed). This uses the same SDL line-drawing approach already in place for link hover underlines.Test plan
fresh(or another mouse-aware TUI likehtop,mc, or any app that enables xterm mouse tracking) inside Architect and verify that clicking menu items works