Skip to content

fix(web): sandbox copy works on HTTP/intranet#67

Merged
cocofhu merged 1 commit into
mainfrom
fix/sandbox-clipboard-http-fallback
Jul 26, 2026
Merged

fix(web): sandbox copy works on HTTP/intranet#67
cocofhu merged 1 commit into
mainfrom
fix/sandbox-clipboard-http-fallback

Conversation

@cocofhu

@cocofhu cocofhu commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add reusable copyToClipboard helper: secure context prefers Clipboard API; non-secure (HTTP/intranet) skips API and uses textarea + execCommand('copy') in the same gesture stack; returns Promise<boolean> without throwing.
  • Wire SandboxListView (detail proxy URL / ENDPOINTS / copy ID) and SandboxConsoleView (copy password) to the helper: success keeps inline「已复制」; failure shows Toast common.toast.copyFailed(复制失败 / Copy failed)— no silent catch.
  • Colocated vitest covers secure success (no fallback), non-secure / API reject → fallback success, and dual failure → false.

Coverage (this PR only): SandboxListView + SandboxConsoleView. Out of scope (unchanged): ArtifactPreview, PmLeaderChat, WorkflowApiTab, AgentStudioView.

Test plan

  • npm test -- --run src/lib/copyToClipboard.test.ts (6 cases green)
  • Manual: open sandboxes over http://内网IP, click detail「复制」on proxy path and host:port — clipboard gets text, button shows「已复制」
  • Manual: HTTPS/localhost — Clipboard API path succeeds without unnecessary fallback
  • Force dual failure (if possible) — Toast「复制失败」/「Copy failed」, button does not enter「已复制」
  • Console copy password: success inline; failure Toast does not leak password plaintext

Made with Cursor

navigator.clipboard is unavailable in non-secure contexts; add
copyToClipboard with execCommand fallback and surface copy failures
via toast in SandboxListView and SandboxConsoleView.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cocofhu
cocofhu merged commit 910a5d9 into main Jul 26, 2026
10 checks passed
@cocofhu
cocofhu deleted the fix/sandbox-clipboard-http-fallback branch July 26, 2026 07:51
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