Repository navigation
Web UI: preview image URLs on Ctrl/Cmd + hover - #109347
Conversation
In `play.html`, when a table cell holds a URL ending in `.jpg`, `.jpeg`, `.png`, `.gif`, or `.webp` (optionally followed by a query or fragment), hovering over the link shows a floating preview of the image that follows the cursor. The preview is capped to half the viewport in each dimension (`max-width: 50vw`, `max-height: 50vh`) while preserving aspect ratio; smaller images keep their natural size. A single reused element serves every hovered link, and the preview hides itself if the image fails to load. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Previously the preview element's `display` was set to `block` synchronously on `mouseenter`, so the previously loaded image stayed visible while the new one was still loading. Now the preview is kept hidden until the new image's `load` event fires, and that handler ignores loads the cursor has already moved away from or superseded, so a late load cannot reveal a stale preview. Re-entering a link whose image is still loaded shows it immediately, since no `load` event fires for an unchanged `src`. Also remove the popup's inner padding and border-radius so the image sits flush against the frame. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [00ac0e5] Summary: ✅
AI ReviewSummaryThis PR adds Final VerdictStatus: ✅ Approve |
Address review feedback: the floating image preview uses `position: fixed`, so scrolling while the cursor stays still can move the hovered link out from under the pointer without delivering a mouse event, leaving the preview pinned on screen after the cell it previews has scrolled away. This is the same scroll-driven hover edge case the file already handles for the table balloons via the global capture-phase `scroll` handler. Factor the hide logic into `hideImagePreview` (reused by `mouseleave`) and call it from the global `scroll` handler. Clearing `image_preview_hovered_url` there also suppresses an in-flight `load` that would otherwise reveal a stale preview after the scroll. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Feedback from GPT-5.5: |
|
This is on point, but hard to avoid. Maybe preview only when the user holds Ctrl. And/or display a confirmation on the first time. |
|
The hypothetical attack scenario sounds far-fetched. |
The floating `position: fixed` image preview was hidden only on `mouseleave` and `scroll`. Rerunning a query (`Ctrl+Enter`) tears down the hovered result cell through `clear` (called from `postSingle`, `postMulti`, and history restore) without delivering either event, so the preview could stay pinned over the next result until some later scroll. Call `hideImagePreview` from `clear` so the preview cannot outlive the cell it was anchored to, regardless of how the result is torn down. Addresses review feedback on #109347 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Feedback from GPT-5.6 Sol Pro The preview currently turns untrusted result data into browser requests without an explicit user action:
Please add a browser/network test proving that no request occurs before opt-in, fragment/query suffixes are rejected, and every hide/teardown path releases the image request. |
A query string or fragment ending in an image extension passed the check, e.g. `https://internal.example/admin/restart#preview.png`, while the browser strips the fragment and requests the non-image path. Parse the URL and test the extension only on its `pathname`, so query-string or fragment suffixes cannot establish that the target is an image. Addresses review feedback: #109347 (comment) Co-Authored-By: Claude Fable 5 <[email protected]>
`hideImagePreview` only flipped `display`, so a slow or large image kept downloading invisibly after the preview was dismissed by `mouseleave`, scroll, or result teardown. Detach `src` (which aborts the fetch) and clear the `load`/`error` handlers and the cached URL state on hide. Addresses review feedback: #109347 (comment) Co-Authored-By: Claude Fable 5 <[email protected]>
|
Points 2 and 3 are addressed:
1 (opt-in before any hover fetch) is the same open question as the unresolved review thread and stays with that design discussion. On the test: |
|
Feedback from GPT-5.6 Sol Pro The fragment/query extension bypass and hidden-resource cleanup from the previous round are fixed. The security concern in the unresolved thread remains: Merely moving the pointer over untrusted query data therefore makes the operator's browser issue a GET to an attacker-controlled or browser-reachable internal endpoint. Pathname validation does not close this because a valid |
Address the recurring security Blocker on this PR (reviewer feedback from `clickhouse-gh`/`pamarcos`, repeated across multiple rounds including a redirect-bypass variant that pathname validation cannot close): merely hovering a table cell whose value is an image URL previously made the browser issue a `GET` to that URL immediately, i.e. to arbitrary attacker-controlled or internal hosts present in untrusted query results. Implement the modifier-gated opt-in mitigation floated earlier in the PR discussion: the preview now only loads and displays while the user holds Ctrl (`Meta`/Cmd on Mac) over the link, tracked via `image_preview_modifier_held`. Hovering without the modifier only records the candidate URL (`image_preview_candidate_url`); no `src` is assigned and no request is made until the modifier is pressed. Releasing the modifier hides the preview (quick-look/peek semantics), and `blur` also releases it so a stuck "held" state cannot survive the window losing focus without a `keyup`. A `title` attribute on the link advertises the gesture. Verified with a standalone state-machine harness (`node`) that plain hover never triggers a fetch, that the modifier gates both directions, and that holding the modifier before entering the link fetches immediately.
Address the AI review Major at `programs/server/play.html`: the modifier-gated image preview is supposed to fetch only for the link currently under the cursor, but `hideImagePreview` deliberately keeps `image_preview_candidate_url` so that releasing and re-pressing the modifier while still hovering the same link re-previews it. The `scroll` handler and the result `clear` path called `hideImagePreview` directly, so after a link scrolled out from under a stationary cursor (which fires no `mouseleave`), or after a query rerun tore the result cell down, a later `Ctrl`/`Cmd` press still fetched the now-stale candidate URL - an unexpected outbound request for a link no longer under the pointer. Add `dismissImagePreview`, which forgets `image_preview_candidate_url` and then hides, and use it from `mouseleave`, `scroll`, and `clear` - every teardown path where the cursor is no longer over the link. Plain `hideImagePreview` (which keeps the candidate) is now used only on modifier release, preserving the re-press-to-re-preview behavior.
Address review: the previous gate fetched from the raw `Control`/`Meta` `keydown` handler via the latched `image_preview_candidate_url`, so an unrelated shortcut such as `Ctrl+Enter` (rerun) or `Cmd+C` while the cursor happened to rest on an image link still assigned `img.src` and made the browser contact an untrusted URL. Now pressing the modifier only arms the preview; the fetch happens exclusively from `mouseenter` and `mousemove` on the link with the modifier already held, a gesture that cannot piggyback on ordinary shortcuts. This also removes the candidate-URL latch and `dismissImagePreview`, since the pointer handlers always carry the correct URL.
|
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109347&sha=82d90b3a59093fdbdc9d2d2f097c79579b32001b&name_0=PR&name_1=AST%20fuzzer%20%28amd_msan%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.
SELECT number FROM remote('127.0.0.{1,2,3}', numbers_mt(1)) ORDER BY number ASC WITH FILL TO 1This PR only touches |
…roll in the image-preview test The image-preview regression harness added earlier wired a hand-built `<a>` straight into `attachImagePreview` and fired `scroll` on `document` directly, so it never ran the two production paths that were actually fixed during review: the URL-qualification gate in `QueryResultElement._renderCell` (`^https?://\S+$` plus the image-extension test on `new URL(text).pathname`) and the capture-phase `this.shadowRoot` scroll listener that dismisses the preview on a scroll inside the `query-result` shadow tree. The suite would therefore stay green if the fragment/query bypass were reintroduced, a non-`http(s)` URL were previewed, the shadow-root dismissal were deleted, or its capture phase were lost. Make the fake DOM able to construct a real `QueryResultElement` (a functional `HTMLElement` base with `attachShadow`/`getElementById`) and give `dispatchEvent` real capture -> target -> bubble propagation up the `parentNode` chain, then: - add a `url-gate` scenario that runs `_renderCell` for image paths, image extensions hidden in a query/fragment, a non-`http(s)` scheme, and plain text, asserting which cells become previewable via an actual `Ctrl`+hover; - add a `shadow-scroll` scenario that puts the rendered cell in a real shadow root and fires `scroll` from the inner `.cell-content` scroller, so the event routes through the capture phase to the shadow-root listener. Verified standalone against `programs/server/play.html` (39 checks pass) and verified non-vacuous: the harness fails when the pathname gate is replaced by a full-string match, when the shadow-root scroll listener is deleted, and when that listener loses its capture phase. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…image-preview # Conflicts: # programs/server/play.html
|
Feedback from GPT-5-6 Sol The Ctrl/Cmd plus pointer-movement opt-in fixes the unsolicited request concern, and pathname validation/resource cleanup remain correct. The cleanup is still attached to the wrong lifecycle, however.
The current integration test calls that wrapper, so its Please move teardown into the active result/panel lifecycle, while ensuring a background tab clear cannot dismiss an unrelated active preview. Add coverage for a real rerun through |
Address review (pamarcos / `clickhouse-gh`): after the tabs rework, the production result teardown goes through `clearPanel` (called from `postSingle`/`postMulti`/`materializeResult`/`beginFlight`), panel switching (`setActivePanel`), and tab removal (`panel.remove`) - none of which called `hideImagePreview`. Only the auxiliary global `clear` wrapper did, so rerunning a query, switching tabs, or closing a tab could remove the hovered image link while leaving the floating `position: fixed` preview, its request, and its late-load handler alive. Anchor the single global preview to the `query-result` whose cell owns it (`image_preview_owner`, set in `showImagePreview`, cleared in `hideImagePreview`). Dismiss it from the real result lifecycle: `QueryResultElement.clear` and `disconnectedCallback` call `hideImagePreviewOwnedBy(this)` (which hides only if the preview is anchored to that result), and `setActivePanel` dismisses a preview whose owner is not in the newly active panel. This tears the preview down on rerun / panel switch / tab close, while a background tab's teardown cannot dismiss a preview owned by another, still-hovered result. Extend `tests/integration/test_play_image_preview/image_preview_harness.js` to drive the real production paths: the harness DOM now supports a working `contains` and fires `connectedCallback`/`disconnectedCallback`, so new scenarios build genuine `QueryResultElement`s in real tabs and exercise `clearPanel` (rerun), `setActivePanel` (switch), and `panel.remove` (tab close), including the negative cases where a background/unrelated teardown must not dismiss the active preview. Verified non-vacuous: each check fails when the corresponding teardown or the ownership scoping is removed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Thanks @pamarcos — good catch. Fixed in
Dismissal is owner-scoped ( Coverage added to the integration harness for a real rerun through |
|
Both failures on
Re-merged master ( |
|
Once #110048 lands, the |
|
Both red checks on
Review state: zero unresolved threads, AI review verdict is Approve. |
|
Merged The remaining red, |
|
Merged The remaining red — Stress test (amd_debug), logical error |
| @@ -0,0 +1,992 @@ | |||
| #!/usr/bin/env node | |||
There was a problem hiding this comment.
LOL - I've often said that Web UI does not have tests (because I'm afraid that the ratio of test LOC to code LOC will be around 100x), but it just found a way to add them anyway.
Accepted.
|
We need discoverability - when the mouse is over the image link, the title should say "Ctrl/Cmd for preview". |
The floating `position: fixed` image preview was hidden only on `mouseleave` and `scroll`. Rerunning a query (`Ctrl+Enter`) tears down the hovered result cell through `clear` (called from `postSingle`, `postMulti`, and history restore) without delivering either event, so the preview could stay pinned over the next result until some later scroll. Call `hideImagePreview` from `clear` so the preview cannot outlive the cell it was anchored to, regardless of how the result is torn down. Addresses review feedback on ClickHouse#109347 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A query string or fragment ending in an image extension passed the check, e.g. `https://internal.example/admin/restart#preview.png`, while the browser strips the fragment and requests the non-image path. Parse the URL and test the extension only on its `pathname`, so query-string or fragment suffixes cannot establish that the target is an image. Addresses review feedback: ClickHouse#109347 (comment) Co-Authored-By: Claude Fable 5 <[email protected]>
`hideImagePreview` only flipped `display`, so a slow or large image kept downloading invisibly after the preview was dismissed by `mouseleave`, scroll, or result teardown. Detach `src` (which aborts the fetch) and clear the `load`/`error` handlers and the cached URL state on hide. Addresses review feedback: ClickHouse#109347 (comment) Co-Authored-By: Claude Fable 5 <[email protected]>
…ge-preview Web UI: preview image URLs on Ctrl/Cmd + hover
Preview image URLs in the Web UI (
play.html) by holdingCtrl(orCmdon macOS) while hovering.When a table cell holds a URL ending in
.jpg,.jpeg,.png,.gif, or.webp(optionally followed by a query string or fragment), holdingCtrl/Cmdwhile hovering over the link shows a floating preview of the image that follows the cursor. A plain hover does nothing: the preview only loads while the modifier is held, so untrusted result data never triggers an outbound request without an explicit user gesture. The link's tooltip advertises the gesture.The preview is capped to half the viewport in each dimension (
max-width: 50vw,max-height: 50vh) while preserving aspect ratio; smaller images keep their natural size. A single reused element serves every previewed link. The preview stays hidden until the new image finishes loading, and it is torn down onmouseleave,scroll,blur, and when the result is cleared. When hidden, it detachessrcso an in-flight download is aborted. Onlyhttp/httpsURLs qualify, and the extension is checked against the URL's path only (not its query or fragment).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
In the Web UI (Play), holding
Ctrl(Cmdon Mac) while hovering over a table cell whose value is a URL ending in.jpg,.jpeg,.png,.gif, or.webpnow shows a preview of the image.Documentation entry for user-facing changes
Version info
26.8.1.128(included in26.8and later)