Skip to content

fix(ui): copy chat content from its context menu - #146679

Merged
fuller-stack-dev merged 4 commits into
mainfrom
openclaw/chat-content-copy-20260913
Sep 13, 2026
Merged

fuller-stack-dev merged 4 commits into
mainfrom
openclaw/chat-content-copy-20260913

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes missing or wrong-scope copy actions when right-clicking chat content. Message copying depended on footer actions, while code, tables, and attachment cards offered no content-specific context action.

Related: #146618

User Impact

  • Copy user messages and grouped assistant commentary as Markdown, even without a footer.
  • Copy complete code, including collapsed lines and whitespace, or copy tables as tab-separated cells for spreadsheets.
  • Copy selected text in tool output and other transcript content.
  • Copy an attachment card's existing download link, or its file name when no download link is available.
  • Keep native browser menus for images, links, audio/video, embedded documents, and editable controls. Embedded widget image export remains with its existing Copy as image action; this does not turn arbitrary binary files or cross-origin embeds into clipboard objects.

Download links have the same access and lifetime as the existing download action. No configuration, state migration, or runtime restart is required by this source change.

Why This Change Was Made

The transcript menu now uses the clicked content's existing source and copy payload. Whole-message copy no longer requires a visible footer or truncates to the reply preview. Expanded-table menus stay inside their modal so they remain clickable. The legacy clipboard fallback also places its temporary text field inside the active modal, where browser focus and selection are permitted.

This reuses the code/table serializers and current clipboard feedback owner. The shared-feedback refactors proposed in #117430 and #122391 are not duplicated here.

Evidence

  • Before the fix, nine new context-copy cases fail because the action is missing. The same cases pass after the fix.
  • 424 chat/context-copy tests pass. Existing code, table, and message-source owner tests pass.
  • Production-bundle Chromium flow passes with actual right-clicks and clipboard readback for messages, collapsed code, inline and expanded tables, selection, and an attachment link. Trusted right-click events on image/link/video/input controls remain uncanceled.
  • Two real-browser regressions reproduce stale clipboard contents inside an expanded-table modal when the Clipboard API is unavailable or rejects. Both pass after the shared clipboard helper uses the existing modal registry. The three affected browser suites now pass all 15 tests.
  • Clipboard rejection stays visible and permits another attempt.
  • Browser-native menu items themselves are not OS-automated; the test verifies the event reaches the browser rather than our custom menu.

Final independent review of the complete staged candidate found no actionable P0-P2 issues. All changed-file repository checks passed, including typechecks, lint, formatting, i18n, assertion safety, and dead-export scans. Hosted CI remains required before landing.

CI follow-up

The first hosted run found two existing browser tests that expected the old menu: archived transcripts and oversized tool output. Both now assert the added Copy as markdown action and actual clipboard contents, preserving all archive/reply restrictions. Those assertions remain covered in the final 15-test browser pass. Production UI types, UI test types, typed lint, formatting, and 29 clipboard/context tests pass after the modal fix.

The unused-import blocker introduced by #146660 is fixed on main by #146689 at 4c47e8a06e5770afec242aff611a48c9ae798340. No security-owned source changes are needed in this PR.

The superseded run for 94214fa4 failed its required real-Gateway lane on two inherited cases:

Both prerequisite failures are now fixed on main: #146691 merged at a13a0105deaa6258ff2fd46eba4e4ab386b2d87b; #146677 was closed because #146667 merged the canonical cache-expectation repair at 2f663805b4c76be46199eb5b524bb1f3372f853d. Both commits are included in the refreshed base 52ea55b7b9367a5f7cf0a2ea0ae8513a5432d5ff.

The exact-head-guarded branch refresh published signed head 6034bc7e6b5c4f2c1f4517df994a2c46ed2ac6f9. Its complete copy patch is unchanged. All 13 changed production/test file blobs match the tested and reviewed candidate; only the shared assertion baseline incorporates other main changes. Fresh independent P0-P2 review is clean. Existing Chromium proof is retained, not described as rerun. Current-head CI must pass before native preparation and merge. The previous failed run remains recorded.

The recent ClawSweeper review of 94214fa4 has no remaining findings; the refreshed patch is identical. The separate browser-extension selected-tab bootstrap failure from the previous run did not recur in the final-head run. No assertions, timeout limits, or required checks were waived.

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 13, 2026 03:11
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: L maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 1:59 AM ET / 05:59 UTC (Revision 5).

ClawSweeper review

What this changes

Adds content-specific chat context-menu copying for messages, code, tables, and attachment links, and repairs clipboard fallback inside modal dialogs.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still lacks the broader context-copy behavior. Both earlier findings are addressed, and no new blocking defect was found.

Priority: P2
Reviewed head: 6034bc7e6b5c4f2c1f4517df994a2c46ed2ac6f9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful browser coverage, resolved prior findings, and no remaining actionable defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Supplied Chromium observations cover transcript copying and modal fallback with clipboard readback; inspected screenshots concern unrelated sidebar work, and no execution is claimed by this review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Supplied Chromium observations cover transcript copying and modal fallback with clipboard readback; inspected screenshots concern unrelated sidebar work, and no execution is claimed by this review.
Evidence reviewed 10 items Current main still needs the repair: At fetched main, context-menu copying still depends on a matching footer copy button, and the legacy clipboard helper still appends its textarea to document.body. These do not cover footerless messages or modal fallback.
Release boundary: Inspection of v2026.9.4 also shows the legacy clipboard textarea appended to document.body; the modal correction is not present in that release.
Introduced behavior and ownership: The introduced resolver reuses the existing code decoder and table serializer. Message copying uses prepared source text, while footer delegation remains available; native links, media, and editable controls retain their browser menus.
Findings None None.
Security None None.

How this fits together

The Control UI renders conversation messages and attachments received from the Gateway. Its transcript context menu selects the clicked content’s existing copy payload and sends it through the shared browser clipboard helper.

flowchart TD
  A[Rendered chat content] --> B[Right-click handler]
  B --> C{Native browser control?}
  C -->|Yes| D[Browser context menu]
  C -->|No| E[Existing message or content payload]
  E --> F[Chat copy menu]
  F --> G[Shared clipboard helper]
  G --> H[Clipboard result and feedback]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +70, Tests +444, Other 0. Total +514 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 8 123 53 +70
Tests 5 453 9 +444
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 14 577 63 +514

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +70 net lines; tests +444 net lines The production growth supplies content selection and modal handling while reusing existing serializers; most growth covers observable copying and preserved sibling behavior.

Technical review

Best possible solution:

Keep context-copy actions connected to existing content serializers and the shared clipboard lifecycle, including modal-safe fallback.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main source exposes the footer dependency and body-mounted fallback, and the supplied browser cases exercise footerless copying and modal clipboard failure. This review did not execute them.

Is this the best way to solve the issue?

Yes: the patch extends the existing transcript handler, reuses canonical payload serializers, and fixes modal fallback in the shared clipboard owner without introducing competing state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 47e4150c30ee.

Labels

Label justifications:

  • P2: Repairs a bounded chat copying workflow without changing configuration, persisted state, or message delivery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Supplied Chromium observations cover transcript copying and modal fallback with clipboard readback; inspected screenshots concern unrelated sidebar work, and no execution is claimed by this review.

Evidence

What I checked:

  • Current main still needs the repair: At fetched main, context-menu copying still depends on a matching footer copy button, and the legacy clipboard helper still appends its textarea to document.body. These do not cover footerless messages or modal fallback. (ui/src/pages/chat/components/chat-thread-interactions.ts:500, 47e4150c30ee)
  • Release boundary: Inspection of v2026.9.4 also shows the legacy clipboard textarea appended to document.body; the modal correction is not present in that release. (ui/src/lib/clipboard.ts:47, 3a9d69db306c)
  • Introduced behavior and ownership: The introduced resolver reuses the existing code decoder and table serializer. Message copying uses prepared source text, while footer delegation remains available; native links, media, and editable controls retain their browser menus. (ui/src/pages/chat/components/chat-context-copy.ts:18, 6034bc7e6b5c)
  • Earlier findings resolved: The fallback textarea now uses the last connected modal layer. Browser coverage exercises unavailable and rejecting Clipboard API writes with real execCommand and clipboard readback; archive and oversized-tool expectations now include the added copy action without removing their original restrictions. (ui/src/lib/clipboard.ts:48, 6034bc7e6b5c)
  • Review continuity: GitHub REST blob identities for the previously reviewed interaction handler, clipboard helper, and context-copy browser suite match the current checkout. The broader local earlier-head comparison encountered unavailable Git objects; no complete local comparison is claimed. (ui/src/pages/chat/components/chat-thread-interactions.ts:465, 6034bc7e6b5c)
  • Browser evidence scope: The captured PR body and contributor comment report production-bundle Chromium right-clicks, clipboard readback, uncanceled native-control events, and 15 passing affected browser cases. The inspected test exercises those paths with a mocked Gateway. All three prepared images instead depict sidebar behavior from fix(agents): recover yielded subagents and preserve sidebar nesting #146667 and were excluded as copy proof. No runtime tests were executed during this read-only review. (ui/src/e2e/chat-content-copy.e2e.test.ts:42, 6034bc7e6b5c)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-13T03:21:39.223Z sha c9e90d3 :: blocked before merge. :: [P2] Keep the clipboard fallback inside the active modal | [P2] Update sibling E2E expectations for the added copy action
  • reviewed 2026-09-13T03:29:20.838Z sha 2ff61a1 :: blocked before merge. :: [P2] Keep the clipboard fallback inside the active modal
  • reviewed 2026-09-13T03:35:58.533Z sha 94214fa :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T04:21:43.764Z sha 94214fa :: needs maintainer review before merge. :: none

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Both findings from the earlier review are addressed at 94214fa4fe6b7353099f83c23bdb66baaaa83645:

  • The legacy clipboard helper now puts its temporary textarea in the last connected layer from the existing modal registry, rather than the inert document body. Two real-browser tests failed on the original helper with unchanged clipboard contents, then passed with navigator.clipboard.writeText unavailable and rejecting. They use real execCommand, trusted pointer input, and clipboard readback.
  • Archived-transcript and oversized-tool tests now assert the added menu action and actual copied content. Archive restrictions, original Reply behavior, full-message fetch assertions, and timeouts are unchanged.

All 15 tests in the three affected browser suites pass, as do 29 clipboard/context tests, production UI types, UI test types, typed lint, and formatting. The earlier 424-test chat/context pass is retained. Final independent P0-P2 review of the complete staged candidate is clean; the published source tree matches it.

The previous type/lint failures are from #146660 leaving isValidEnvSecretRefId unused at src/config/types.secrets.ts:10. The exact minimal upstream repair was sent to the existing owner; this UI PR does not modify the security-owned file.

The second run's browser-extension bootstrap failure is unrelated: the complete extension tree, runner, and dependencies match its base and tested merge, and that exact-base main job passed. Required new-head CI still must pass; no gate waiver or automerge is requested.

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 13, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 13, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Ready for native landing at reviewed head 6034bc7e6b5c4f2c1f4517df994a2c46ed2ac6f9.

  • Exact-head CI, attempt 1, completed successfully. All 101 jobs are terminal, with 88 successful and 13 skipped. Required openclaw/ci-gate passed.
  • Fresh independent P0-P2 review found no actionable issues. The main refresh preserves the complete copy patch and all production/test blobs.
  • Retained proof includes 424 chat cases, 29 clipboard/context cases, and 15 production-bundle browser cases. Browser proof used mocked Gateway responses with trusted Chromium events and actual clipboard readback. Native OS menu execution is not automated, and retained browser proof was not rerun on the main-refresh commit.
  • Contextual copy reuses existing serializers, context-menu handling, copy feedback, and modal lifecycle. It copies selected text, full message Markdown, code, TSV tables, and existing attachment references while preserving native browser menus.
  • Both prerequisite corrections are landed. No runtime deployment is part of this task.

@fuller-stack-dev
fuller-stack-dev merged commit d7111df into main Sep 13, 2026
131 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/chat-content-copy-20260913 branch September 13, 2026 08:02
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '2acbeee461474b6ba41f5186ae1a4e0e80f4087a': (117 commits)
  fix(ui): import the shared deferred helper in sidebar scope tests (#146862)
  fix(ui): copy chat content from its context menu (#146679)
  perf(memory): defer legacy sidecar writer imports (#146815)
  fix(e2e): accept expected Kitchen Sink worker rejection (#146681)
  fix(ui): distinguish absolute and relative file links (#146572)
  feat(ui): keep file previews in tabs and render HTML (#146672)
  refactor: reuse shared deferred promises in UI tests (#146670)
  fix: gateway stop/restart refuses a healthy gateway when the Windows process snapshot misses (#146387)
  improve(crabbox): keep healthy cloud desktops warm on resume (#146816)
  fix: report blocked SQLite WAL checkpoints in status and doctor (#146775)
  feat: share browser dashboards with agents (#146702)
  fix(doctor): continue repairs after legacy agent directory collisions (#146092)
  feat(agents): retry cyber-refused embedded turns on Daybreak (#145291)
  fix: restore media uploads through protected egress (#144902)
  refactor(qa): share capture filter rendering (#146696)
  fix(cli): keep running stream jobs visible as running (#146793)
  refactor(parallels): share gateway readiness loop (#146694)
  fix(sessions): avoid rewriting already-consumed input on release (#146795)
  fix: preserve scheduled conversation delivery after Doctor (#146794)
  perf(ui): avoid redundant session-row provenance work (#146797)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
* fix(ui): copy chat content from its context menu

* test(ui): verify copying archived and oversized content

* fix(ui): copy text from active modal dialogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant