feat(demo): mouse-click DSL verb plus mouse_links subset GIF#543
Merged
Conversation
Adds a reusable `click <col> <row>` verb to the e2e/ttysnap DSL (sends an SGR-1006 left-button press+release at a 1-based col,row, which atty parses when config.mouse.enabled) — then uses it for the mouse_links docs GIF. - src/test/e2e/dsl.zig: Cmd.int_arg2 + Kind.click + parse two ints; runner.zig emits `\x1b[<0;col;rowM` then `...m`. Documented in the dsl header. - dsl_tests.zig: parse test (col/row) + a missing-coordinate rejection. - tests/demo/mouse_links/ — config (mouse.enabled + mouse_links, EDITOR=echo so the click shows the resolved editor command instead of launching one) + scenario: echo a `src/main.zig:42` token, click it, atty injects `echo +42 'src/main.zig'`. docs/assets/atty-mouse-links.gif on the module page. mouse_urls is deferred: clicking a URL DOES arm the [y]/[a]/[t] trust banner, but the banner (rendered via statusText) doesn't repaint until the next output/ keystroke after the click — a real atty gap worth a dedicated fix (filed separately), not a demo-PR side change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new click verb to the e2e/ttysnap DSL so demo scenarios can synthesize SGR-1006 mouse events, and introduces a new mouse_links demo (scenario + golden recording) that’s embedded in the module docs.
Changes:
- Extend the e2e DSL (
dsl.zig+runner.zig) with aclick <col> <row>command and basic parsing tests. - Add
tests/demo/mouse_links/demo scenario + golden recording for clicking apath:linetoken and showing the injected editor command (EDITOR=echo). - Embed the generated
mouse_linksGIF indocs/modules/mouse_links.md.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/demo/mouse_links/scenario.e2e | New demo scenario that prints a src/main.zig:42 token and clicks it. |
| tests/demo/mouse_links/golden/env.toml | Captured environment metadata for the demo recording. |
| tests/demo/mouse_links/golden/cast.json | Golden asciinema recording for the demo scenario. |
| tests/demo/mouse_links/config.zig | Demo-specific atty config enabling mouse + statusbar and setting editor to echo. |
| src/test/e2e/runner.zig | Implements the runtime emission of the new .click command. |
| src/test/e2e/dsl.zig | Documents and parses the new click DSL directive. |
| src/test/e2e/dsl_tests.zig | Adds parser unit tests for click. |
| docs/modules/mouse_links.md | Embeds the new module-specific GIF in the docs page. |
Files not reviewed (1)
- tests/demo/mouse_links/golden/cast.json: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Subagent review of the click verb: give the SGR-1006 emit CI coverage (it was exercised only by the non-CI demo) and remove the tight-buffer nit. - dsl.zig: pure `clickBytes(col, row, buf)` sibling of `keyBytes`; runner.zig calls it with a [96]u8 buffer (covers any in-range terminal vs the prior [64]). - dsl_tests.zig: asserts the exact press+release bytes for `click 20 2`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…Copilot) Copilot review of the click verb: - Send only the SGR-1006 PRESS (not press+release). atty's intercept parses one mouse sequence per read; a trailing release in the same read would be parsed- past and leak to the shell. Modules' onMouseClick act on press only, so the press is sufficient + the whole read is consumed cleanly. (clickBytes + doc.) - Validate coordinates as 1-based u16 (1..65535) at parse time, so we never emit a sequence the mouse parser would discard. - dsl_tests: non-positive + overflow rejection; clickBytes asserts the press. - Re-recorded mouse_links (press-only): click still resolves, no stray bytes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the per-feature subset GIFs. Adds a reusable
clickDSL verb to the e2e/ttysnap harness and uses it for the mouse_links docs GIF.The
clickverb (reusable infra)click <col> <row>sends an SGR-1006 left-button press+release (\x1b[<0;col;rowMthen…m) at a 1-based col,row — atty parses it whenconfig.mouse.enabled. This is the missing input primitive for testing/demoing atty's mouse features.dsl.zig:Cmd.int_arg2+Kind.click+ parse;runner.zigemits the sequence; documented in the DSL header.dsl_tests.zig: parse test + a missing-coordinate rejection.mouse_links GIF
tests/demo/mouse_links/— echo asrc/main.zig:42token,clickit, and atty injects$EDITOR +42 'src/main.zig'into the prompt.EDITOR=echoso the GIF shows the resolved editor command running (rather than launching a real editor). Frame-verified; footer visible; OSC 7 stripped. Embedded ondocs/modules/mouse_links.md.mouse_urls — deferred (with a real finding)
I prototyped mouse_urls too. Clicking a URL does arm the
[y]/[a]/[t]/canceltrust banner (confirmed in the cast), but the banner — rendered viastatusText— doesn't repaint until the next output/keystroke after the click, so a user clicking a URL sees nothing until they type. That's a genuine atty UX gap (the status bar isn't repainted after a consumed mouse click). It needs a dedicated fix (immediate status repaint afterdispatchMouseClick) + verification, which I'm filing as a follow-up rather than rushing into a demo PR.Not in CI —
tests/demoruns only viazig build demo/make demo-gifs.🤖 Generated with Claude Code