[deep-review][duplication] D1: CopyTextToClipboard duplicated across 17 sites
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.
🤖 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 removedQuickSendDialog.cs— 2 calls + method definition removedOnboarding/Pages/ConnectionPage.cs— 1 call updated fromApp.CopyTextToClipboardtoClipboardHelper.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
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.