Repository navigation
Conversation
|
I'm not 100% happy with the introduction of a new clipboard helper next to the existing one. Latter focuses more on formatting than actual interaction with the clipboard so this drove the implementation to consolidate the plugin vs. navigator handling into a dedicated file. Refactoring the clipboard handling in the entire project to unify the access to one implementation would be a much larger change I did shy away from. |
debba
left a comment
There was a problem hiding this comment.
Thanks for digging into this, and for the clear explanation of the Niri/Flatpak case where arboard falls back to X11 and times out. Keeping the plugin as the first choice and only falling back to navigator.clipboard is the right order, and the comment about the WebKitGTK paste confirmation explains why. The tests cover all the combinations, including HTML with and without ClipboardItem.
Unfortunately main moved under you with #676, and this needs to be redone rather than rebased:
- On main every clipboard call already goes through the platform layer (
platform.readClipboard/writeClipboard/writeClipboardHtml). The Tauri adapter inpackages/web-ui/src/platform/tauriCapabilities.tsmaps those straight to the plugin. The browser adapter (browserCapabilities.ts) already has thenavigator.clipboardcode,ClipboardItemfallback included. - A new util importing
@tauri-apps/plugin-clipboard-managerwould now fail lint: eslint restricts@tauri-apps/**imports inpackages/web-ui/srcto the adapter files. - Main also made the bug wider:
copyTextToClipboardnow goes throughplatform.writeClipboardtoo. On your setup, grid cell copy and Copy quoted name would hit the plugin as well, and this PR doesn't cover that path.
So the best place for the fallback is the Tauri adapter itself (defaultTauriOperations, or the clipboard methods in tauriCapabilities.ts). Then systemClipboard.ts and the call-site changes go away, every caller gets the fallback for free, and the tests can go in packages/web-ui/tests/platform/tauriCapabilities.test.ts.
Two smaller things while you're at it. On an affected system every copy or paste first waits for the X11 timeout before falling back; remembering the failure for the session would avoid that, and the repeated warning too. And in the tests, vi.unstubAllGlobals() at the end of the test body leaks the stub if an assertion fails, so afterEach would be safer. Also, did you get a chance to try paste (not just copy) on Niri? I'm curious whether WebKitGTK still treats navigator.clipboard.readText() as user-initiated after the timeout.
Since this is your first PR here, welcome! If you'd like to hang out with us, we'd be happy to see you on Discord: https://discord.com/invite/K2hmhfHRSt
Inside the Flatpak on compositors such as Niri, the clipboard plugin (arboard) cannot get the wlr/ext data-control protocols, falls back to X11 and fails after a timeout, so every copy, cut and paste breaks. TauriPlatformCapabilities now falls back to navigator.clipboard, which uses the window's own Wayland data device, so every platform clipboard caller, copyTextToClipboard included, is covered. Once the webview succeeds where the plugin failed, the window skips the plugin for the rest of the session and warns once. A failed read latches only when the webview returns text, since the plugin also rejects on an empty or non-text clipboard. The navigator.clipboard code moves from the browser adapter to platform/webClipboard.ts and is shared by both adapters. Fixes TabularisDB#1253 Assisted-by: Claude:claude-opus-5-5
9f345d4 to
d3bd2c3
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The PR now implements the webview-clipboard fallback inside the Tauri adapter, as requested in the earlier maintainer review. The Files Reviewed (5 files)
Reviewed by claude-sonnet-5.5 · Input: 242 · Output: 1.5K · Cached: 187.1K Review guidance: REVIEW.md from base branch |
|
@debba rebased, regenerated. tested on niri. |
debba
left a comment
There was a problem hiding this comment.
Thanks for redoing this on top of the platform layer. Moving the fallback into TauriPlatformCapabilities is what I had in mind, and I like that webClipboard.ts is just the browser adapter's code moved out, so both adapters share one copy. The session latch is a nice touch too, especially the detail that a failed read only latches when the webview actually returns text, since the plugin also rejects on an empty or non-text clipboard. The afterEach cleanup is in place as well.
I ran the platform tests locally (47 passing), lint on the changed files and a full build, and everything is green. I'm approving it. A few small things I'd like to follow up on, none of them blocking:
- When both the plugin and the webview fail,
withWebClipboardFallbackthrows the webview error and the plugin error is lost. On a system wherenavigator.clipboardis missing, the log would only say "Clipboard access is unavailable" and hide the real cause. LoggingpluginErrorin that branch too, or attaching it ascause, would make those reports easier to debug. - The read fallback now runs on every platform, not just Linux. On macOS or Windows with an image or nothing on the clipboard, the plugin rejects and we call
navigator.clipboard.readText()on every paste, since an empty result never latches. I want to make sure that doesn't pop up the system paste confirmation in WKWebView or WebKitGTK when the read happens after the plugin call has been awaited. - When you say tested on Niri, did that include paste in the SQL editor and in the grid, not only copy? That was the part I was most curious about.
I'll do some manual checks on my side, mainly paste on macOS with a non-text clipboard and on Linux, before merging.
debba
left a comment
There was a problem hiding this comment.
I tried this in the desktop app on macOS (debug build of this branch merged with current main), and I have to walk back my approval, sorry about that.
The good part first: copying a grid cell with Cmd+C lands in the system clipboard, and pasting text into the SQL editor works exactly as before, with no warnings in the console. Pasting with an empty clipboard does nothing, which is also fine.
The problem is the follow-up I mentioned about non-text clipboards. With only an image on the clipboard (I copied a PNG screenshot), every Cmd+V in the SQL editor opens the WKWebView "Paste" permission bubble. The plugin rejects because there's no text, withWebClipboardFallback then calls navigator.clipboard.readText(), and WebKit asks the user to confirm. Since the result is empty, the latch never kicks in, so the bubble comes back on every paste. While it's open the page script is waiting on it. On main the Tauri adapter only calls the plugin, so this is new behaviour on macOS, and anyone with a screenshot on the clipboard would hit it. I only tested the editor; the grid paste goes through the same platform.readClipboard(), so I'd expect the same there.
So the read fallback needs to be narrower. A couple of options:
- Only fall back for reads when the plugin error is a real backend failure (like the X11 timeout you saw on Niri), not when the clipboard simply has no text. That depends on whether the plugin's error message lets us tell the two apart reliably, so please check what it returns in both cases.
- Enable the read fallback only on Linux, where the arboard problem lives, and keep macOS and Windows on the plugin alone.
The write fallback doesn't have this problem, so it can stay as it is. A test that covers "plugin rejects on a non-text clipboard, no webview read on macOS" (or whatever the chosen rule is) would keep this from coming back.
Thanks again for sticking with this one, the overall shape in the adapter is right and it's close.

Inside the Flatpak on compositors such as Niri, the clipboard plugin (arboard) cannot get the wlr/ext data-control protocols, falls back to X11 and fails, so copy, cut and paste in the SQL editor, grid paste, HTML row copy and clipboard import all stop working.
Route these through new helpers in src/utils/systemClipboard.ts that try the plugin first and fall back to navigator.clipboard, which uses the window's own Wayland data device.
fixes: #1253
Assisted-by: Claude:claude-opus-5-5