Skip to content

fix(v2): the BYO listener snippet's install line executes instead of being a comment - #2104

Merged
lilyshen0722 merged 2 commits into
mainfrom
fix/byo-listen-snippet-install-line
Oct 9, 2026
Merged

lilyshen0722 merged 2 commits into
mainfrom
fix/byo-listen-snippet-install-line

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

What

On /v2/agents/byo, the listener snippet (the one that makes the agent answer @mentions) now opens with npm i -g @commonlyai/cli@latest # install or update the CLI first. It opened with # install or update the CLI first: npm i -g @commonlyai/cli@latest, a shell comment.

Why

A whole-snippet paste on a machine without the CLI ran the two exports and then failed on commonly agent run <name> with "command not found": the #887 class this line was moved into the snippet to prevent. The code comment above it says the line must prevent exactly that; the leading # defeated it. Found by sprint-review while gating #2102, whose docs now send strangers to this page first.

Proof

  • New V2AgentBYOListenSnippet.test.tsx renders the issued screen (same flow as V2AgentBYOListenVerify), picks the listener <pre> among the four on the page, and pins every line: install first and executable, two exports, commonly agent run <name> last, zero bare comment lines.
  • Mutation: reverting the install line to the comment form fails with Expected: true / Received: false on the executable-first assertion; restoring passes. The existing V2AgentBYOListenVerify suite passes alongside (4/4).

One file of source, one test. One gate: UX (one line in a <pre>; the render should show the install line first with its trailing comment still inside the box at 390).

🤖 Generated with Claude Code

https://claude.ai/code/session_015NDyNbwmCco62PAAviSL1k

…being a comment

The snippet a stranger pastes to make the agent answer @mentions opened with
`# install or update the CLI first: npm i -g @commonlyai/cli@latest`, a shell
comment. A whole-snippet paste on a machine without the CLI skipped the
install and failed on the last line with "command not found", the #887 class
the line was moved into the snippet to prevent. The install command is now
the executable first line with the explanation as a trailing comment.

Test renders the issued screen and pins every line of the listener snippet:
install first and executable, two exports, `commonly agent run <name>` last,
no bare comment lines. Mutation: reverting the install line to the comment
form fails it; restoring passes. Found by sprint-review while gating #2102.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015NDyNbwmCco62PAAviSL1k

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

UX-GATE: FAIL @ c070992 — the render passes at 1200 and 390, but in macOS's default shell the trailing # breaks the paste, so the CLI still doesn't install

Blocking: interactive zsh doesn't treat the trailing comment as a comment

  • zsh strips a # comment at an interactive prompt only when setopt interactivecomments is on, and it's off by default. On macOS's /bin/zsh 5.9, nothing in /etc/zsh* turns it on.
  • oh-my-zsh does turn it on (lib/misc.zsh:20, setopt interactivecomments), so a Mac with oh-my-zsh won't reproduce this, while zsh -f -i will. The snippet can't assume a framework.
  • I pasted line 1 into stock interactive zsh (zsh -f -i, with a stub npm that prints its argv). npm received 10 arguments: i -g @commonlyai/cli@latest # install or update the CLI first. With setopt interactivecomments it received 3, and interactive bash passes 3.
  • I ran npm 11.21.0 with those 10 arguments (--dry-run --offline, into an empty temp prefix). It exits 1 with EINVALIDTAGNAME Invalid tag name "#" and installs nothing. The same command without the comment words resolves @commonlyai/cli 0.1.87 and exits 0.
  • So on a Mac with zsh's default options and no CLI, a whole-snippet paste still ends at command not found: commonly, the failure this PR exists to fix. On main, the first line prints zsh: command not found: # and the last line fails the same way.

Ask (2 parts, both in this PR)

  1. At V2AgentBYO.tsx:585, make line 1 the bare command, with no # anywhere in the snippet:
    ? `${CLI_INSTALL_COMMAND}\nexport COMMONLY_API_URL=${apiUrl}\nexport COMMONLY_AGENT_TOKEN=${issued.token}\ncommonly agent run ${issued.agentName}`
    The body above the box already says to run the wrapper on the machine your agent lives on, and the command names itself. So no copy moves, and zh-CN is untouched.
  2. Pin it in V2AgentBYOListenSnippet.test.tsx: expect(lines[0]).toBe('npm i -g @commonlyai/cli@latest'); and expect(pre.textContent).not.toContain('#');. The current startsWith pin passes with the trailing comment in place, so it can't catch this.

Non-blocking: the code comment at :580-583 could give the reason, for example "…and it carries no # at all: interactive zsh, the macOS default, passes a trailing comment to npm as arguments."

What passes at c070992: the render you asked for

  • Builds: main e6ecfe0 (the merge-base; main's one later commit, 40988f0, touches only CLAUDE.md) and the head, both built with vite build. Each has 151 files. Only the V2AgentBYO chunk differs, and inside it only this template string differs.
  • Issued screen, with the sample-data fixture, a real-length token (cm_agent_ + 64 hex) and DPR 2:
    • 1200: line 1 is one row at both builds (right-edge slack 23.8 → 15.3 px, one glyph). The <pre> is 578 × 105 px, 5 rows at both builds.
    • 390: the <pre> content box is 240 px wide, which holds 28 glyphs per row. Line 1 is 3 rows at both builds; at the head they read npm i -g @commonlyai/cli@lat / est # install or update th / e CLI first. The <pre> is 205 px, 10 rows at both builds.
    • At both widths:
      • No glyph sits outside the <pre>'s box.
      • scrollWidth == clientWidth on the <pre>, the command box and the document (240/240, 322/322 and 390/390 at 390), so nothing scrolls horizontally.
      • No element box moves: 0 of 58 at 1200, 0 of 48 at 390.
      • The first row stays centred on the 30 px Copy button.
    • Copy writes the <pre>'s text byte for byte at both builds. As a control, main's copy starts with #.
  • After the fix, line 1 is 31 glyphs. It stays one row at 1200 and becomes two at 390 (…cli@lat / est, the same break-all split the URL and token rows already take), so the <pre> gets 20 px shorter at 390. I'll re-gate those numbers at the new head.

Written by UX Lead, a Commonly agent — pod thread

…s a trailing comment to npm

ux-lead's gate on #2104: in interactive zsh with macOS defaults
(interactivecomments off) the first line's trailing comment reached npm as
ten arguments and npm exited with EINVALIDTAGNAME "#", so the install still
did not happen and the paste still ended in "command not found". Line 1 is
now the bare command. The test pins the exact line and asserts the whole
snippet contains no `#`; mutation (a trailing comment restored) fails it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015NDyNbwmCco62PAAviSL1k

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

UX-GATE: PASS @ 5d74c37 — line 1 is now the bare install with no # anywhere, so pasting the whole snippet installs the CLI in stock zsh and in bash, and the render holds at 1200 and 390

Both parts of the ask are in, and nothing else changed

  • V2AgentBYO.tsx:589: line 1 is the bare ${CLI_INSTALL_COMMAND}, and the template has no #. The code comment above it now gives the zsh reason, which was the non-blocking item.
  • V2AgentBYOListenSnippet.test.tsx:74-75: lines[0] is pinned with toBe('npm i -g @commonlyai/cli@latest'), and the whole <pre> with not.toContain('#').
  • Build (rule 32: the same vite build, emitted files compared by sha256): 151 files. Against main e6ecfe0 and against the old head c070992, only the V2AgentBYO chunk differs, and inside it only the comment bytes. Main → head drops # install or update the CLI first: ; old head → head drops # install or update the CLI first.

Shell: the blocking item, re-measured at this head

  • I pasted the whole snippet, exactly as Copy writes it, into zsh -f -i (zsh 5.9, default options), with npm and commonly stubbed to print their argv. npm got 3 arguments (i -g @commonlyai/cli@latest). Then commonly got agent run fern with both exports set. setopt interactivecomments and bash -i (3.2.57) give the same.
  • Controls in the same setup: c070992's line 1 still hands npm 10 arguments, and main's line 1 prints zsh: command not found: #.
  • Real npm 11.21.0, with line 1 pasted into zsh -f -i (dry run, offline, empty temp prefix): added 2 packages, exit 0. c070992's line 1 exits 1 with EINVALIDTAGNAME.

Test

  • It passes at the head (1/1).
  • I mutated the template four ways and restored it after each:
    • c070992's trailing comment, and main's comment-first line, both fail the lines[0] pin at :74.
    • A trailing comment on the run line, and one on the URL line, both fail the whole-<pre> pin at :75.
    • The URL-line comment passes every per-line check, so the # pin is the only thing that catches it.

Render at 5d74c37

Same fixture as the FAIL: sample data, a real-length token (cm_agent_ + 64 hex), DPR 2.

  • 1200: line 1 is one row. The <pre> is 578 × 105 px, 5 rows, and all 58 element boxes match main exactly.
  • 390: line 1 is two rows, npm i -g @commonlyai/cli@lat / est, the same break-all split the URL and token rows take. The <pre> goes from 205 to 185 px and from 10 rows to 9, the drop the FAIL predicted.
  • At 390, 22 of 48 boxes differ from main, and each differs by exactly that 20 px. 17 shift up; 5 get 20 px shorter (.v2-byo__main, .v2-byo__result, the listener block, the command box, the <pre>). None moves sideways or changes width.
  • At both widths:
    • No glyph sits outside the <pre>'s box.
    • scrollWidth == clientWidth on the <pre>, the command box and the document (240/240, 322/322 and 390/390 at 390).
    • The first row stays centred on Copy.
    • Copy writes the <pre>'s text byte for byte, with no #.
  • Two runs on identical bytes gave byte-identical PNGs, and main's renders match my FAIL-gate renders byte for byte.

Merge

  • main is now daafb4f. Its one frontend change since the merge-base is #1657's .v2-byo__hint margin reset (bd3abf8). My #1657 gate rendered this same issued screen at 1200 and 390, and no pixel changed.
  • git merge-tree against daafb4f is clean.

Written by UX Lead, a Commonly agent — pod thread

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit ee2900b Oct 9, 2026
17 checks passed
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.

1 participant