Commit 0a7fc31
v1.27: eager screenshot pickup + lazy-compress + stale-clipboard overrides + payload telemetry
Five distinct user-reported failure modes from a single afternoon's
debugging session, each fixed once the live-state probes made the
root cause visible.
* Eager fresh-screenshot pickup on every paste (ipc.rs). GNOME's
screenshot tool atomically renames its tempfile into place but
KEEPS THE FD OPEN for 3–5 s while rendering its in-shell "saved"
toast, so inotify's CLOSE_WRITE doesn't fire until that fd
closes. A paste right after PrtScr saw the old staged_text and
dispatched the URL the user had on the clipboard before. Defence
in depth: every paste stats the screenshots dir for the newest
PNG/JPG; if its mtime beats staged_image.captured_at, read it
inline (~5–20 ms for a 500 KB PNG) and stage before dispatch.
Symptom journal entry: "staged screenshot from inotify" landing
4 s AFTER the file's mtime, with stale-text PASTED lines in
between. Helpers: `newest_image_in`, `mime_for_path`,
`now_unix_secs`.
* Lazy compression on the inotify path (inotify_watch.rs). The
synchronous `compress_for_attach_env` call re-encodes 4K PNGs to
WebP and was blocking the stage for 500–2000 ms on big screens.
Fix: read raw bytes and stage them right away (one fs::read,
~5–20 ms), then spawn a std::thread to compress in the
background; re-stage only if the compressed result actually wins
on bytes. The brief window where X11 serves the raw PNG is fine
— selection requests read from our in-memory buffer regardless
of size.
* 3 s freshness gate on the external-text override (ipc.rs). v1.26
added "if X11 advertises text-only, override staged image with
the live text" — correct in principle but fired on EVERY paste
right after a screenshot, because the daemon's X11 re-claim is
asynchronous (wakes x11.rs via stage_notifier_tx and re-issues
SetSelectionOwner ~100–300 ms later) and the probe saw the OLD
text targets in the meantime. Gate the probe behind `age >
Duration::from_secs(3)` on staged_image; any deliberate text-copy
after a screenshot takes at least ~1 s of human action, so 3 s
is comfortably above the X11 re-claim race window without being
above any real workflow.
* Stale-text override probe in the Text branch (ipc.rs). Symmetric
to v1.26's image-side override. When kitty's
copy_and_clear_or_interrupt fires (Ctrl+C with a live selection),
kitty writes the bytes straight to the X11 CLIPBOARD without
going through `flashpaste-trigger --stage-text`. The daemon's
in-memory staged_text stayed at whatever clipboard-set.sh last
set it to, so every paste delivered the old text. Probe live
X11; if it differs from the staged bytes, re-stage with the
live text. Companion: `~/.config/kitty/kitty.conf` got
`map ctrl+c copy_and_clear_or_interrupt` so the kitty side
actually copies on Ctrl+C with a selection.
* "What are we pasting?" payload telemetry (paste.rs +
flashpaste-shoot/src/main.rs). The previous `dispatched image
paste pane=%X` told you nothing about WHICH image. v1.27 emits
`PASTED image pane=%X kind=image payload_bytes=N
payload_mime=image/png payload_name=<basename> payload_path=…
ms_*` — every dispatch now self-describes. Same shape on the
shoot path: `ms_portal`, `ms_write`, `ms_annotate`, `ms_stage`
so the screenshot pipeline's latency is broken down per phase.
Companion shell-side improvements (already in main):
- `flashpaste-logs` got `[shot]`, `[clip]` (xclip-only by default
to avoid the dock flash on Mutter), `[kitty]`, `[claude]`
streams and `--all` shortcut.
- `bin/clipboard-set.sh` mirrors text to xclip when daemon
accepts a stage so the bash fallback dispatcher's `wl-paste
--list-types` probe sees text (was seeing image/png from a
stale prior screenshot).
No behaviour change for the existing fast paths. Daemon dispatch
latency stays at single-digit ms; the new pickup probe adds ~1 ms
when the screenshots dir is unchanged and ~5–20 ms when there's a
fresh file to read.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b70ac5c commit 0a7fc31
4 files changed
Lines changed: 372 additions & 616 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
557 | 570 | | |
558 | 571 | | |
559 | 572 | | |
560 | 573 | | |
561 | 574 | | |
562 | 575 | | |
563 | 576 | | |
564 | | - | |
| 577 | + | |
| 578 | + | |
565 | 579 | | |
566 | 580 | | |
567 | 581 | | |
| |||
573 | 587 | | |
574 | 588 | | |
575 | 589 | | |
| 590 | + | |
576 | 591 | | |
577 | 592 | | |
578 | 593 | | |
579 | 594 | | |
580 | 595 | | |
581 | | - | |
| 596 | + | |
| 597 | + | |
582 | 598 | | |
583 | 599 | | |
584 | 600 | | |
585 | 601 | | |
586 | 602 | | |
587 | | - | |
| 603 | + | |
588 | 604 | | |
589 | 605 | | |
590 | 606 | | |
591 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
592 | 611 | | |
593 | 612 | | |
594 | 613 | | |
595 | | - | |
| 614 | + | |
596 | 615 | | |
597 | 616 | | |
598 | 617 | | |
599 | 618 | | |
| 619 | + | |
600 | 620 | | |
601 | 621 | | |
602 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
603 | 639 | | |
604 | 640 | | |
605 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 140 | + | |
147 | 141 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
187 | 158 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 159 | + | |
| 160 | + | |
204 | 161 | | |
205 | 162 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
211 | 169 | | |
212 | 170 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
219 | 177 | | |
220 | 178 | | |
221 | | - | |
222 | | - | |
223 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
224 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
225 | 262 | | |
226 | 263 | | |
227 | 264 | | |
| |||
0 commit comments