Skip to content

fix(clipboard): preserve pinned state when editing entries - #3412

Merged
bbedward merged 9 commits into
duxlabs-dev:masterfrom
hthienloc:fix-clipboard-edit-pinned
Sep 12, 2026
Merged

bbedward merged 9 commits into
duxlabs-dev:masterfrom
hthienloc:fix-clipboard-edit-pinned

Conversation

@hthienloc

Copy link
Copy Markdown
Member

When saving edits to a pinned clipboard entry, the editor previously called clipboard.copy, which only created a new unpinned entry in recents while leaving the original pinned entry unchanged in the "Saved" tab.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

Approach is sound — the pinned state is preserved correctly and dedupe/trim are respected; three issues worth addressing, none blocking correctness of the happy path.

  • EditEntry takes the system selection before validating the entry, so a rejected edit still replaces the clipboard, core/internal/server/clipboard/manager.go:1977
  • Editor fallback fires on any editEntry error, not just an unknown method, so genuine failures silently copy + unpin/re-pin instead of toasting, quickshell/Modals/Clipboard/ClipboardEditor.qml:162
  • post() nil guard added to production code for the test manager; a mock wayland context already exists, core/internal/server/clipboard/manager.go:220
    Checked: EditEntry transaction against deduplicateInTx/trimLengthInTx/Pin/Unpin semantics, handler param validation, ClipboardService state reset and refresh paths, I18n usage, catalogs untouched. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

Previous round of feedback is addressed — SetClipboard now runs only after a successful commit, the post() nil guard is gone in favour of the wayland mock, and the editor picks its path by entry id instead of falling back on any error. One remaining gap.

  • EditEntry skips the empty/whitespace and MaxEntrySize guards CopyText applies, so a cleared editor silently replaces a saved entry with a blank one and an oversized edit reports success while the clipboard is untouched, core/internal/server/clipboard/manager.go:1971
    Checked: EditEntry transaction against deduplicateInTx/trimLengthInTx and Pin/Unpin hash semantics, pinned-duplicate merge path, handler param validation, ClipboardService.editEntry/reset/refresh state flow and pinnedCount consistency, editor save actions, I18n usage, catalogs untouched, test imports and mock wiring. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

Last round's finding is fixed — EditEntry now rejects empty/whitespace text and payloads over MaxEntrySize before touching the DB, and the tests cover both. One issue left, from the switch to a destructive edit path.

  • Saving before the async clipboard.getEntry fetch lands replaces the entry with its truncated/whitespace-collapsed preview, and the original row is now deleted, quickshell/Modals/Clipboard/ClipboardEditor.qml:156
    Checked: EditEntry transaction ordering, rollback on error, dedupe/trim and pinned-duplicate merge semantics vs Pin/Unpin, size and empty guards against CopyText, handler param validation and error mapping, ClipboardService.editEntry/reset/refresh and pinnedCount consistency, wayland mock wiring in the test helper, I18n usage, catalogs and IPC docs untouched. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

Last round's data-loss finding is fixed — a save before the full text arrives no longer replaces the entry with its preview. One follow-up on how that gate behaves.

  • The !textLoaded gate returns silently and textLoaded is never set on the getEntry error branches, so Save can look permanently broken with no feedback, quickshell/Modals/Clipboard/ClipboardEditor.qml:137
    Checked: EditEntry validation order and rollback, dedupe/trim and pinned-duplicate merge semantics vs Pin/Unpin, SetClipboard only after commit, handler param validation and error mapping, ClipboardService.editEntry/reset/refresh and pinnedEntries/pinnedCount consistency, editor save actions and stale-entry guards, wayland mock wiring in the test helper, I18n usage, catalogs untouched. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

Earlier rounds are addressed (SetClipboard moved after the commit, empty/size validation, wlCtx mock in tests); the new load-timeout fallback introduces one problem.

  • 5s timeout nulls entry, so Save silently copies the truncated 100-char preview and a late getEntry response is discarded, quickshell/Modals/Clipboard/ClipboardEditor.qml:19-29
  • New toast string has no translator context, quickshell/Modals/Clipboard/ClipboardEditor.qml:156

Checked: EditEntry dedup/pin/trim paths against storeEntry/PinEntry/UnpinEntry, handler param validation, ClipboardService.editEntry + reset() callers, and the new Go tests against the wlcontext mock. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

The latest commit removes the entry = null fallback, so the truncated-preview save is gone; two items remain, plus one earlier comment that is only half addressed.

  • EditEntry hardcodes text/plain;charset=utf-8 and deletes the original, so editing a text/uri-list (multi-file / file) entry destroys it and it stops pasting as files, core/internal/server/clipboard/manager.go:1972
  • New Failed to load clipboard entry string has no translator context (3 call sites), quickshell/Modals/Clipboard/ClipboardEditor.qml:112
  • Still open from the earlier round: textLoaded is never set on the getEntry failure branches, so after the error toast Save is permanently blocked and only repeats Loading full text, please wait... (fix(clipboard): preserve pinned state when editing entries #3412 (comment) context comment also still applies to that string).
    Checked: EditEntry validation order, rollback, dedupe/trim and pinned-duplicate merge against Pin/Unpin and MaxPinned, SetClipboard only after commit, alt-mime entries (unreachable, image-only), handler param validation, ClipboardService.editEntry/reset/refresh and pinnedEntries/pinnedCount, editor load/save paths and timer lifecycle, test mock wiring, catalogs untouched. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

Translator contexts are in and the uri-list destruction is fixed; the new mime gate is a bit too tight, and one earlier item is still open.

  • text/plain-only gate rejects UTF8_STRING/STRING/TEXT entries that selectMimeType stores for plain text, so Edit silently disappears for them, core/internal/server/clipboard/manager.go:2007 (same check in ClipboardContextMenu.qml:31 and ClipboardHistoryContent.qml:184)
  • Still open from earlier rounds: textLoaded is never set on the getEntry failure/timeout branches, so after the error toast Save stays blocked and only repeats Loading full text, please wait... (fix(clipboard): preserve pinned state when editing entries #3412 (comment))
    Checked: EditEntry validation order and rollback, dedupe/trim and pinned-duplicate merge against Pin/Unpin, SetClipboard only after commit and no self-store loop (isOwner), alt-mime entries (image-only), handler param validation, ClipboardService.editEntry/reset/refresh and pinnedEntries/pinnedCount, editor load/save paths and timer lifecycle, test mock wiring, catalogs untouched. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

The alt-mime fix lands correctly — isTextMimeType now matches what selectMimeType stores, and the QML guards all route through the single ClipboardService.canEditEntry helper. No new issues found in this round.

  • Still open from earlier rounds: textLoaded is only ever set to true on the one success branch of the clipboard.getEntry callback (ClipboardEditor.qml:130). After the error toast at L112/L127, or the 5s timeout at L25, it stays false, so Save is permanently blocked and only repeats Loading full text, please wait... (fix(clipboard): preserve pinned state when editing entries #3412 (comment))

Checked: isTextMimeType against selectMimeType/altTextMimeTypes and storeClipboardEntry, EditEntry validation order, rollback, dedupe/trim and pinned-duplicate merge vs PinEntry/UnpinEntry, SetClipboard only after commit, handler param validation, ClipboardService.canEditEntry/editEntry/reset and pinnedEntries/pinnedCount consistency, editor load/save paths and timer lifecycle, imports and mock wiring in the new tests, I18n contexts, catalogs untouched. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found. The last open item is resolved: ClipboardHistoryContent.editEntry now pre-fetches the full text before switching to the editor, so setEntry always gets a text string and textLoaded is true on open, and saveEntry retries the fetch instead of blocking forever after a failure.

Checked: EditEntry validation order (empty/whitespace, MaxEntrySize), rollback, b.Delete + deduplicateInTx + pinned-duplicate merge and trimLengthInTx against storeEntry/PinEntry/UnpinEntry semantics, SetClipboard only after a successful commit, isTextMimeType vs selectMimeType/altTextMimeTypes and its QML twin in ClipboardService, handler param validation and error mapping, ClipboardService.editEntry/canEditEntry/reset and pinnedEntries/pinnedCount flow, editor load/save/retry paths and timer lifecycle, stale-entry guards, test imports and wlcontext mock wiring, I18n contexts, catalogs untouched. Model: claude-opus-5.

@bbedward
bbedward merged commit 4141089 into duxlabs-dev:master Sep 12, 2026
4 checks passed
deepfriedret pushed a commit to deepfriedret/DankMaterialShell that referenced this pull request Sep 14, 2026
…ev#3412)

* fix(clipboard): preserve pinned state when editing entries

* fix(clipboard): address PR review feedback on editEntry

* fix(clipboard): validate empty text and entry size in EditEntry

* fix(clipboard): gate saving entry on full text load completion

* fix(clipboard): add user feedback and error fallback for entry loading

* fix(clipboard): keep entry and gate save with error toast on load failure

* fix(clipboard): reject non-text edits and add translator contexts

* fix(clipboard): support alt text mime types in EditEntry and UI guards

* fix(clipboard): pre-fetch entry before opening editor and allow retry on load failure
bbedward pushed a commit that referenced this pull request Sep 15, 2026
* fix(clipboard): preserve pinned state when editing entries

* fix(clipboard): address PR review feedback on editEntry

* fix(clipboard): validate empty text and entry size in EditEntry

* fix(clipboard): gate saving entry on full text load completion

* fix(clipboard): add user feedback and error fallback for entry loading

* fix(clipboard): keep entry and gate save with error toast on load failure

* fix(clipboard): reject non-text edits and add translator contexts

* fix(clipboard): support alt text mime types in EditEntry and UI guards

* fix(clipboard): pre-fetch entry before opening editor and allow retry on load failure

(cherry picked from commit 4141089)
@hthienloc
hthienloc deleted the fix-clipboard-edit-pinned branch November 15, 2026 15:38
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.

2 participants