Skip to content

feat(demo): mouse-click DSL verb plus mouse_links subset GIF#543

Merged
fentas merged 3 commits into
masterfrom
feat-demo-mouse
Jun 30, 2026
Merged

feat(demo): mouse-click DSL verb plus mouse_links subset GIF#543
fentas merged 3 commits into
masterfrom
feat-demo-mouse

Conversation

@fentas

@fentas fentas commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Part of the per-feature subset GIFs. Adds a reusable click DSL verb to the e2e/ttysnap harness and uses it for the mouse_links docs GIF.

The click verb (reusable infra)

click <col> <row> sends an SGR-1006 left-button press+release (\x1b[<0;col;rowM then …m) at a 1-based col,row — atty parses it when config.mouse.enabled. This is the missing input primitive for testing/demoing atty's mouse features.

  • dsl.zig: Cmd.int_arg2 + Kind.click + parse; runner.zig emits the sequence; documented in the DSL header.
  • dsl_tests.zig: parse test + a missing-coordinate rejection.

mouse_links GIF

tests/demo/mouse_links/ — echo a src/main.zig:42 token, click it, and atty injects $EDITOR +42 'src/main.zig' into the prompt. EDITOR=echo so the GIF shows the resolved editor command running (rather than launching a real editor). Frame-verified; footer visible; OSC 7 stripped. Embedded on docs/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]/cancel trust banner (confirmed in the cast), but the banner — rendered via statusTextdoesn'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 after dispatchMouseClick) + verification, which I'm filing as a follow-up rather than rushing into a demo PR.

Not in CI — tests/demo runs only via zig build demo / make demo-gifs.

🤖 Generated with Claude Code

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 a click <col> <row> command and basic parsing tests.
  • Add tests/demo/mouse_links/ demo scenario + golden recording for clicking a path:line token and showing the injected editor command (EDITOR=echo).
  • Embed the generated mouse_links GIF in docs/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.

Comment thread src/test/e2e/runner.zig Outdated
Comment thread src/test/e2e/dsl.zig Outdated
Comment thread src/test/e2e/dsl.zig
Comment thread src/test/e2e/dsl_tests.zig
fentas and others added 2 commits June 30, 2026 19:39
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>
@fentas fentas merged commit d6abeb6 into master Jun 30, 2026
6 checks passed
@fentas fentas deleted the feat-demo-mouse branch June 30, 2026 17:49
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.

2 participants