Skip to content

fix(chat): only show copied checkmark after clipboard write succeeds - #5136

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/connect-desktop-clipboard-feedback-w3
Jul 23, 2026
Merged

fix(chat): only show copied checkmark after clipboard write succeeds#5136
pedrofrxncx merged 1 commit into
mainfrom
fix/connect-desktop-clipboard-feedback-w3

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Source: bug found while auditing desktop-linking UI (apps/mesh/src/web/components/chat/connect-desktop-dialog.tsx) for the desktop-launcher-resilience focus area. Note: the area hint pointed at apps/mesh/src/web/desktop/ (the Tauri launcher), but that directory doesn't exist on main yet — it's only introduced by the still-open PR #4178 — so I audited the existing desktop-linking surface that does live on main instead.

The bug: the install-snippet copy button called navigator.clipboard.writeText(...) and then immediately, synchronously, set copied = true (showing a checkmark) without waiting for the write to resolve. If the write rejects — document not focused, clipboard permission denied, etc. — the UI still claims success and the rejected promise is left unhandled (console warning). Every other clipboard-copy call site in apps/mesh/src/web (account-popover.tsx, markdown.tsx, preview.tsx, webhook-secret-dialog.tsx, ...) awaits or chains .then()/.catch() before touching UI state — this one didn't.

Fix: chain the state update inside .then() so the checkmark only appears once the write actually succeeds, matching the pattern used everywhere else in the codebase (e.g. account-popover.tsx).

Failure scenario: user clicks copy while the tab/window isn't focused (a plausible state right after switching to read the bunx decocms@latest link snippet) → writeText rejects → checkmark still shows, clipboard is actually empty, and the user pastes nothing into their terminal.

To confirm: cd apps/mesh && bunx tsc --noEmit (green); read the diff — it's a 1-line control-flow change with no type/behavior surface beyond the click handler.

Verified locally: bun run fmt (clean) and bunx tsc --noEmit in apps/mesh (no new errors introduced by this change — a pre-existing unrelated error in an untracked backfill-assets.test.ts file in this worktree is unaffected). Full CI validates the rest.


Summary by cubic

Fix copy button feedback in ConnectDesktopDialog: show the checkmark only after navigator.clipboard.writeText succeeds. Prevents false success when clipboard write fails (e.g., tab not focused or permission denied) and avoids unhandled promise rejections.

Written for commit 801a700. Summary will update on new commits.

Review in cubic

The install-snippet copy button in ConnectDesktopDialog set the
copied/checkmark state synchronously right after calling
navigator.clipboard.writeText, without waiting for the write to
resolve. If the write rejects (e.g. document not focused, clipboard
permission denied), the UI still claims success and the promise
rejection goes unhandled. Every other clipboard-copy call site in
apps/mesh/src/web (account-popover.tsx, markdown.tsx, preview.tsx,
etc.) awaits or chains .then() before updating UI state — this one
didn't.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 23, 2026 20:39
@pedrofrxncx
pedrofrxncx merged commit 321ea72 into main Jul 23, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/connect-desktop-clipboard-feedback-w3 branch July 23, 2026 20:46
decocms Bot pushed a commit that referenced this pull request Jul 23, 2026
PR: #5136 fix(chat): only show copied checkmark after clipboard write succeeds
Bump type: patch

- decocms (apps/mesh/package.json): 4.113.1 -> 4.113.2

Deploy-Scope: web
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