Skip to content

fix(terminal): forward mouse clicks to PTY and render underlines#251

Merged
forketyfork merged 3 commits intomainfrom
forketyfork/implement-250
Mar 4, 2026
Merged

fix(terminal): forward mouse clicks to PTY and render underlines#251
forketyfork merged 3 commits intomainfrom
forketyfork/implement-250

Conversation

@forketyfork
Copy link
Owner

@forketyfork forketyfork commented Mar 4, 2026

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_any is active or mouse_event_button is active with a button held.

On the rendering side, the terminal renderer now checks style.flags.underline and 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

  • Run fresh (or another mouse-aware TUI like htop, mc, or any app that enables xterm mouse tracking) inside Architect and verify that clicking menu items works
  • Confirm underlined text (mnemonics, SGR underline sequences) renders with visible underlines
  • Verify that normal text selection still works when mouse tracking is not enabled by the terminal app
  • Verify Cmd+click to open URLs still works
  • Verify mouse scroll forwarding still works in mouse-tracking apps

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
@forketyfork forketyfork requested a review from Copilot March 4, 2026 10:30
@forketyfork forketyfork marked this pull request as ready for review March 4, 2026 10:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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.
@forketyfork forketyfork merged commit 5d763d8 into main Mar 4, 2026
4 checks passed
@forketyfork forketyfork deleted the forketyfork/implement-250 branch March 4, 2026 10: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.

[Bug]: fresh menu is not clickable in Architect (works in Ghostty)

2 participants