Skip to content

launch: simple file dialog, monaco-paste helper, parallel session pattern#318488

Merged
roblourens merged 2 commits into
mainfrom
agents/vsckb-explore-i-d-like-you-to-do-14f3e7c5
May 27, 2026
Merged

launch: simple file dialog, monaco-paste helper, parallel session pattern#318488
roblourens merged 2 commits into
mainfrom
agents/vsckb-explore-i-d-like-you-to-do-14f3e7c5

Conversation

@roblourens
Copy link
Copy Markdown
Member

Surfaced while running a bug bash over the Agents window terminal tool — the launch skill needed three improvements before subagents could drive multiple Code OSS instances cleanly.

1. launch.sh: force files.simpleDialog.enable: true in the launched profile

Native macOS file dialogs cannot be driven via @playwright/cli over CDP / SSH; the simple (quick-input style) dialog can. Without this, the new-session workspace picker's Select... button is a dead end for automation on a fresh slim-copied UDD.

2. New scripts/monaco-paste.sh helper

Inserts text into the focused Code OSS chat-input Monaco editor by dispatching a synthetic ClipboardEvent('paste') with a DataTransfer payload. Why a helper instead of just docs:

  • Avoids pbcopy's system-wide NSPasteboard collision — any other process touching the clipboard during the paste window can stomp the prompt. The synthetic event stays inside the CDP connection.
  • Handles unicode / emoji / backticks / quotes / newlines including the case where the input has embedded \" and \` .
  • Waits two requestAnimationFrames before read-back — Monaco updates its view-line DOM asynchronously after a paste event; a same-tick read returns stale state.
  • Normalizes U+00A0 (NBSP) → ASCII space when verifying — Monaco renders regular spaces as NBSP in the view-line DOM for visual fidelity, which breaks naive startsWith checks.
  • Honors --session NAME or $PW_SESSION so it stays in the same @playwright/cli session as the rest of the agent's calls.

Tested across 20+ pastes with all the awkward characters and parallel multi-instance runs (-s=sessA / -s=sessB) — no cross-contamination.

3. SKILL.md updates

  • Documents the new simpleDialog default and the monaco-paste.sh helper.
  • Makes -s=$PW_SESSION the default convention on every @playwright/cli example. The skill is built around per-instance isolation (UDD, ports, shared-data-dir), and this pattern extends that isolation to the Playwright-driving layer. Without -s=, parallel shells share the implicit "default" session daemon and the most-recently-attached CDP wins for every subsequent command from either shell.
  • New "Parallel multi-instance pattern" subsection showing the full attach / paste / cleanup loop with per-session names.
  • Notes that PLAYWRIGHT_CLI_SESSION env var works for open-style workflows but interacts poorly with attach --cdp= due to an upstream behavior in playwright-core/cli-client/session.ts:142-143 (the env var is pushed as --endpoint=… even when --cdp=… is already set, and the daemon ends up trying to connect to the env var value as a socket path). Explicit -s= is safe in all modes.

Test plan

  • Sequential 20+ pastes with varied content (unicode, emoji, backticks, ampersands, embedded quotes, newlines) — all verified.
  • Parallel 2-instance run with -s=sessA / -s=sessB; pastes landed in their respective windows with no cross-contamination.
  • Used as the test infra for an end-to-end bug bash across 10 scenarios on the Agents window terminal tool.

Not in this PR

  • The underlying @playwright/cli attach --cdp= + PLAYWRIGHT_CLI_SESSION interaction. Worth a separate issue against microsoft/playwright; the -s= flag is a clean workaround for now.

🤖 Generated with Copilot CLI

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

…tern

Surfaced while running a bug bash over the Agents window terminal tool —
the launch skill needed three improvements before subagents could drive
multiple Code OSS instances cleanly.

1. launch.sh now forces `files.simpleDialog.enable: true` in the launched
   profile. Native macOS file dialogs cannot be driven via @playwright/cli
   over CDP/SSH; the simple (quick-input style) dialog can. Without this,
   the new-session workspace picker's `Select...` button is a dead end
   for automation on a fresh slim-copied UDD.

2. New scripts/monaco-paste.sh helper inserts text into the focused
   Code OSS chat-input Monaco editor by dispatching a synthetic
   ClipboardEvent('paste') with a DataTransfer payload. Avoids pbcopy's
   system-wide NSPasteboard collision (which fights any other process
   touching the clipboard), supports unicode/emoji/backticks/quotes/
   newlines, and waits two requestAnimationFrames before read-back
   because Monaco updates its view-line DOM asynchronously after paste.
   Honors `--session NAME` arg or `$PW_SESSION` env. Verified across
   20+ pastes including all the awkward characters and parallel
   multi-instance runs.

3. SKILL.md updated to:
   - document the new simpleDialog default
   - recommend monaco-paste.sh as the primary typing path; keeps per-key
     `press` and `pbcopy` as fallbacks with the pasteboard-collision
     caveat called out explicitly
   - make `-s=$PW_SESSION` the default convention on every
     @playwright/cli example so the skill's per-instance isolation
     extends to the Playwright-driving layer. Without `-s=`, parallel
     shells share the implicit "default" session daemon and the most-
     recently-attached CDP wins for every subsequent command
   - add a "Parallel multi-instance pattern" subsection showing the
     full attach/paste/cleanup loop with per-session names
   - note that PLAYWRIGHT_CLI_SESSION env var works for `open`-style
     workflows but interacts poorly with `attach --cdp=` due to a
     playwright-core bug (cli-client/session.ts:142-143) — explicit
     `-s=` works in all modes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 27, 2026 01:56
Copy link
Copy Markdown
Contributor

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

This PR enhances the .agents/skills/launch skill to make multi-instance Code OSS automation more reliable, particularly for subagents driving UI via @playwright/cli in parallel.

Changes:

  • Force files.simpleDialog.enable: true in the launched throwaway profile to ensure file/folder picking is automation-friendly.
  • Add scripts/monaco-paste.sh to paste into Monaco-based chat input via a synthetic ClipboardEvent('paste'), avoiding system clipboard collisions.
  • Update SKILL.md with a consistent -s=$PW_SESSION pattern and documentation for the new paste helper and parallel workflows.
Show a summary per file
File Description
.agents/skills/launch/SKILL.md Documents the simpleDialog override, introduces the -s=$PW_SESSION convention, and adds parallel multi-instance guidance.
.agents/skills/launch/scripts/monaco-paste.sh New helper script to paste text into Monaco via CDP/Playwright CLI without using the system clipboard.
.agents/skills/launch/scripts/launch.sh Applies a per-launch setting override to force the simple file dialog in the cloned profile.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 5

Comment thread .agents/skills/launch/scripts/launch.sh
Comment thread .agents/skills/launch/scripts/monaco-paste.sh
Comment thread .agents/skills/launch/scripts/monaco-paste.sh Outdated
Comment thread .agents/skills/launch/scripts/monaco-paste.sh
Comment thread .agents/skills/launch/SKILL.md Outdated
Five inline comments from the Copilot reviewer on #318488, all addressed:

- launch.sh: replace the regex-strip-then-JSON.parse settings overlay
  with a data-preserving text-based insert. The previous version could
  silently drop user settings on parse failure and would incorrectly
  strip `//` inside string values (e.g. URLs). The new version:
    * detects when the key is already present (any value) and updates
      its value via a targeted regex on the value slot only;
    * otherwise inserts the key before the last `}`, preserving all
      comments and formatting;
    * fails loudly (non-zero exit) if the file is structurally bad
      rather than silently overwriting with `{}`;
    * is idempotent (T6: byte-identical when key is already `true`).
  Verified across 7 scenarios incl. JSONC comments + URLs containing
  `//` + malformed input.

- monaco-paste.sh: detect platform and pick `Meta+a` (macOS) or
  `Control+a` (Linux/Windows) for the clear-before-paste select-all,
  so the default (non-`--append`) path actually clears the editor on
  non-mac.

- monaco-paste.sh: validate node + jq up-front in addition to npx, so
  missing tools fail with a clear actionable message and exit 2 rather
  than crashing later.

- monaco-paste.sh: header docs now correctly list the three exit codes
  (0 success, 1 paste/eval failure, 2 argument/tooling error) and the
  required tools on PATH.

- monaco-paste.sh: fix `set -u` unbound-variable error when no
  PW_SESSION/--session is set — `"${PW_ARGS[@]}"` on an empty array
  trips set -u, so use the `${PW_ARGS[@]+"${PW_ARGS[@]}"}` idiom at
  every call site.

- SKILL.md: fix "Macros-Mach-ports" → "macOS Mach-ports" typo.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens marked this pull request as ready for review May 27, 2026 03:07
@roblourens roblourens enabled auto-merge (squash) May 27, 2026 03:07
@roblourens roblourens merged commit a9a3df6 into main May 27, 2026
25 checks passed
@roblourens roblourens deleted the agents/vsckb-explore-i-d-like-you-to-do-14f3e7c5 branch May 27, 2026 03:31
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 27, 2026
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.

3 participants