Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/desktop
Steps to reproduce
- Open a page in the desktop preview that re-renders its DOM on a timer (for example a dashboard that polls data every few seconds and lets React replace the nodes).
- Start the annotation picker and click an element.
- Type or dictate a comment for ~10 seconds or longer, so a refresh happens while the editor is open.
- Click Attach or Send.
Expected behavior
The annotation is attached with a cropped screenshot of the area that was picked.
Actual behavior
The toast "Could not capture the picked element — The annotation was kept without the screenshot" appears. This happens often on pages that refresh while you write the comment, and rarely on static pages.
Desktop trace shows PreviewManager.capturePageWithRetry and PreviewManager.captureAnnotationScreenshot both exit with Success in 5–15 ms. So capturePage() works. The screenshot is dropped afterwards because cropAnnotationScreenshot returns null.
Cause, as far as I can see on main (009966d):
PickPreload.tsreads the element rect only at submit time:rect: rectFromDomRect(target.element.getBoundingClientRect())(around line 1726). It does not keep the rect from the moment of picking.- If the page replaced the node in the meantime,
target.elementis detached. A detached element returns a0×0rect at(0,0). cropAnnotationScreenshotinManager.ts(around line 300) then finds no target withrect.width > 0 || rect.height > 0and returnsnull. The caller mapsnulltoscreenshotFailed: true.
In my session the time between pick and submit was 8–48 seconds (desktop.ipc.preview.pickElement durations), which is enough for several refreshes.
Possible fix: store the last measured rect on SelectedElement when it is picked and whenever updateSelectedVisual runs, and use it at submit when !target.element.isConnected. Optionally try to re-resolve the element via its captured selector first.
Possibly related: #29664 (page panels close on Attach, which can also detach the picked element).
Impact
Minor bug or occasional failure
Version or commit
T3 Code (Beta) desktop 0.1.9. The same code is still on main at 009966d.
Environment
macOS, Apple Silicon, desktop app with a remote (SSH) server environment. Preview pages are local dev servers forwarded from the remote machine.
Logs or stack traces
PreviewManager.capturePageWithRetry Success 6 ms
PreviewManager.captureAnnotationScreenshot Success 7 ms
# no "preview annotation screenshot failed" warning is logged, because the failure is the null crop, not an Effect failureWorkaround
Drag a region instead of clicking an element. Region rects are stored at pick time, so the crop works.
Activity