Skip to content

[deep-review][duplication] D1: CopyTextToClipboard duplicated across 17 sites #364

Closed

Description

@codemonkeychris

Summary

Two byte-identical CopyTextToClipboard methods plus 15 other sites that inline the same new DataPackage(); SetText; SetContent ritual. Total: 17 call sites doing the same three operations.

Where

  • src/OpenClaw.Tray.WinUI/App.xaml.cs:4395 — CopyTextToClipboard (one of two byte-identical implementations)
  • src/OpenClaw.Tray.WinUI/Dialogs/QuickSendDialog.cs:344 — CopyTextToClipboard (the other byte-identical implementation)
  • 15 other call sites where the three-line pattern new DataPackage(), .SetText(...), Clipboard.SetContent(...) is inlined directly. Easiest find: grep -rn "Clipboard.SetContent" src/.

PR #336 (refactor/extract-copy-diagnostic-helper) already established a sibling seam — CopyDiagnosticHelper — for the redacted-diagnostic copy operations. The same seam can absorb plain text copy.

Why it matters

  • Three-line patterns are exactly where AI-assisted edits introduce subtle behavior differences. E.g., one site forgets try { } catch (COMException) { } to guard against the clipboard being held by another process; another adds it. Drift accumulates.
  • New developers can't find the canonical helper because there isn't one.

Proposed fix

Extend the helper introduced in PR #336:

public static class ClipboardHelper
{
    public static void CopyText(string text);          // existing pattern
    public static void CopyDiagnostic(string text);    // already exists from #336
}

Migrate all 17 sites in one PR. Delete the two CopyTextToClipboard methods.

Severity

Low (cosmetic) — but a fast win that demonstrates the pattern for the larger refactors.

Activity

  1. added a commit that references this issue on May 16, 2026
    1758b28
  2. github-actions commented on May 16, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I've opened a draft PR that removes the two CopyTextToClipboard wrapper methods and points all 7 call sites directly to ClipboardHelper.CopyText.

    ClipboardHelper.CopyText was already the canonical helper — both wrappers were thin delegates that did nothing but forward to it. The PR deletes them and updates:

    • App.xaml.cs — 4 internal calls + method definition removed
    • QuickSendDialog.cs — 2 calls + method definition removed
    • Onboarding/Pages/ConnectionPage.cs — 1 call updated from App.CopyTextToClipboard to ClipboardHelper.CopyText

    No behaviour change.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a
    
  3. shanselman commented on May 18, 2026

    @shanselman
    Collaborator

    Closing during the post-refactor deep-review cleanup. Clipboard duplication is much smaller in the current tree and is consolidated into #372 as a scoped cleanup item. This keeps the signal while reducing stale one-off issue noise.

  4. locked as resolved and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions