Repository navigation
Web UI prototype for framing formats - #110210
Conversation
Rework the query progress display in the Web UI to consume the `EventStream` framing format over HTTP, so it works regardless of the output format (including `FORMAT Pretty`, binary formats via base64, and images). - Stream every query with `framing_output_format=EventStream` and `send_logs_level=trace`, decoding data/progress/log/profile_events/ exception packets as they arrive. - Show realtime CPU, memory, and disk usage like `clickhouse-client`, aggregated per host (total and max/host), switching to peak RAM when the query finishes. - Merge elapsed time and realtime metrics into a single element rendered on top of the progress bar; keep the text readable with a background-clip gradient that darkens the glyphs only over the colored fill (per-theme peak color and fraction). - Display server logs in real time, colored like the client, with a Logs button available even on exception; keep the view fast for 100k+ lines via batched appends and content-visibility while preserving native browser search. - Render inline images for image output formats, and base64-decode binary payloads signalled by the `payload=base64` content type. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Iterate on the query progress display: - Merge the elapsed time, realtime resource metrics, and rows/bytes read stats into a single progress area so the progress-bar gradient renders behind all of them; the read stats stay right-aligned and wrap when long, the elapsed/metrics text keeps its natural width. - Draw the colored bar only one text line tall, so when the read stats wrap and grow the area the fill stays a single-line strip. - Tint every glyph (left metrics and right stats alike) with a text mask clipped from the same full-width `--progress` gradient as the bar, so the two correspond exactly and the text stays readable over the fill. Light theme uses a plain gray to black; dark theme uses a steep gray to white (first quarter) then a jump to black. - Use a 10pt font for the progress area. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [c0da97c] Summary: ✅
AI ReviewSummaryThis PR turns the Web UI prototype into a framing-aware client with substantial new request-shaping, replay, and tab-state logic in Findings
Tests
Final VerdictLLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 681/730 (93.29%) · Uncovered code |
- Replace the Result/Logs button pair with a single "Logs" toggle at the front of the progress line (just before the elapsed/metrics text). It switches the result element(s) between the query result and the streamed server logs, shows a dotted underline, uses the monospace font, and gets a yellow background while the logs view is active. - Show the toggle only when the query produced at least one log line, so it stays hidden when a query has not started or produced no logs. - Drop the now-meaningless leading `NN.N%, ` from the read stats once the query finishes (the percentage only matters while progressing to 100%). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…m snapshot Address review (#110210): the history/tab replay path only distinguished the default (table) output from `rawText`; it never recorded whether the saved `EventStream` response used `payload=base64` (a binary or raw output format such as `Native` or `RawBLOB`). A restored snapshot of such a result was therefore replayed as literal base64 text, whereas the live `readEventStream` path decodes the payload to bytes and renders it as an image or raw text. Persist an `is_base64` bit with the result snapshot (single-query, multi-query, and the `saveHistory` / flat-entry serialization) and have `renderEventStreamText` decode the base64 `data`/`totals`/`extremes` payloads and hand them to `renderBinaryPayload`, exactly like the live path. A base64 snapshot is rendered as an image or raw text and is never finished as a table. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Keep the Web UI prototype current with master and clear the reported conflict with the base branch. The only conflict was a single hunk in `programs/server/play.html`, in the non-OK response branch of `postImpl`: master added query-error highlighting (`highlightQueryError`, guarded by `editorInteractionGen === runEditorInteraction`) while this branch added the `is_base64` field to the returned result and reworked the image `else if` condition to exclude framed (`text/event-stream`) responses. Resolved by keeping both: master's error-highlighting block, followed by this branch's `is_base64` return and framing-aware image branch. The `queryStart` argument that master threads into `postImpl` is already present (auto-merged), so the highlight call is in scope. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…o read-only queries Two fixes to the framing `EventStream` consumer in `play.html`, addressing the AI review of the PR: - `profile_events`: `EventStream` serializes each `profile_events` packet as a single JSON array of event objects in one `data:` field, but the client pushed every parsed line as one element, producing `[[...]]`. `feedProfileEvents` then saw the whole batch as a single element with no `thread_id` / `name`, so the realtime CPU / RAM / disk meters stopped updating for framed queries. Flatten the parsed batch into individual events (a bare object is tolerated too, for older one-per-line servers). - No-framing retry: the Web UI enables framing for every query, and a non-pulling pipeline (`INSERT`, DDL) never creates a framing stream, so such a statement can return a plain-HTTP error after it has already run. The previous code retried the whole request on any non-event-stream error, which could duplicate the side effect. Gate the retry to read-only queries (`queryIsReadOnly`, the same read-only kinds treated as parallelizable), so a side-effecting statement is never blindly resubmitted. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ed but rejected When a query requested framing and the output format was rejected by `IOutputFormat::setFraming` on the data path (a format that defers totals and extremes to finalization, such as `Template`, or writes progress in-band, such as `JSONEachRowWithProgress`), the rejection was thrown after `output_format` had already been assigned. The exception-recovery path in `executeQuery` only recreated the format when `output_format` was null, so it treated the leftover format as usable - but it is not framed, and it writes to the payload buffer of a framing format that was already destroyed during stack unwinding. The error therefore fell back to a plain HTTP error body instead of a framed `exception` packet. Recovery now also recreates the format when framing is requested by the effective settings but the existing format is not framed. In addition, the framed exception path uses a `Null` carrier format instead of the query's own format: with a framing format the exception packet is written by the framing itself and the output format writes nothing in exception-only mode (`framing_exception_only`), while the real format may not even be constructible on the exception path - for example `Template` referencing header columns when the header is empty. This also frames exceptions raised before the output format existed for such formats. Extends `04512_framing_formats` with regressions for all three cases: the deferred-totals rejection and the in-band-progress rejection are delivered as framed exception packets, and a pre-format exception with `Template` is framed too. Addresses an AI review finding on #110210 (which carries this PR's commits): #110210 (comment)
The "Run all" snapshot mapper stored `data: null` for every statement with `is_image`, on the assumption that images stream as a blob and cannot be re-rendered from text. That is only true for non-framed image responses; a framed image (`FORMAT PNG` over the `EventStream` framing) has a replayable `reply` - the full event stream whose base64 payload `renderEventStreamText` decodes back into the picture on restore. Such statements were lost on tab switch / reload in multi-query mode, while the single-query history path kept them. Persist the `reply` for framed (`is_base64`) images and store `data: null` only for non-framed blob images, whose `reply` is empty anyway. Addresses an AI review finding: #110210 (comment)
Add a "Metrics" toggle next to "Logs" in the progress line that shows an extended profile-event metrics table, mirroring the clickhouse-client progress table shown on Space: - Live table of profile events (thread_id 0, aggregated per host), with Event name, Value, per-second rate, and a realtime sparkline; rows reorder by freshness then magnitude while the query runs, and switch to totals / query-average rates when it finishes. - Value type inferred from the metric name (`*Bytes`/`*Chars` and the memory trackers are sizes, `*Microseconds`/`*Milliseconds`/ `*Nanoseconds` are durations); the rate is tinted by magnitude with the client's escalating palette (per-theme variables). - Sparklines: one sample per pixel, grow left-to-right, scroll (latest window) on overflow, and compress to the cell on finish; zero samples are skipped; each fragment is colored by its own sample's tier; unbounded, lock-step history so all sparklines stay time-aligned. - Each CamelCase word of the metric name is hash-colored; hovering a word highlights every row sharing it; hovering or clicking a row highlights it, and a clicked (or hovered) row is pinned in place while the others reorder; metric-name text stays selectable. - Header removed; horizontal row lines only; K/M/G/T suffixes for counts. Also: - Fix the result table collapsing to zero-width columns when returning from the logs/metrics view: defer the fixed-layout measurement while the table is hidden and run it when the result view is shown again. - Reset the progress-line metric-width debouncing for every new query. - Harden formatReadable against unit overflow (no more "undefined/s"). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts: # programs/server/play.html
|
🕵 Added the remaining executable |
Do not treat immediately after as a query-level clause. This avoids incorrectly disabling the Web UI framing path for a select-list column named . Add fallback-tokenizer coverage for the real production path. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110210&sha=2da21a1f9edfcde825b7e651313d6548766543d8&name_0=PR PR: #110210
…w-feedback Fix remaining Web UI review feedback from ClickHouse#110210
Prototype changes to the Web UI (
programs/server/play.html) to test and showcase the framing formats feature. This is a draft for experimentation and review of the client-side experience, not intended to merge as-is.It builds on the framing-formats server work in #110127 (this branch is based on that PR, so the diff includes those commits until it merges into
master).What the prototype does:
EventStreamframing format over HTTP (framing_output_format=EventStream,send_logs_level=trace), decoding data / progress / log / profile_events / exception packets as they arrive - so progress and logs work regardless of the output format (includingFORMAT Pretty, binary formats via base64, and images).clickhouse-client, aggregated per host (total and max/host), switching to peak RAM when the query finishes. The meter state is owned by each tab: the CPU counters inprofile_eventspackets are per-packet increments, so a query running in a background tab keeps accumulating them, and reopening the tab continues the meter from its live values (rather than restarting near zero).event: exceptionblock, the{"packet":"exception",...}line, or the plain{"exception":...}line, captured at stream-read time since the capped text stops growing before the terminal exception arrives), so reopening or reloading a failed tab still shows the error reason.data/totals/extremespayload (theEventStreamwire encodes each block as a single base64data:field and theContent-Typecarriespayload=base64), deciding the rendering by the output format: the default format is reassembled into the table, an image format (or bytes carrying an image signature) is rendered as an inline image once the stream completes, and any other format is decoded and shown incrementally as raw text.FORMATclause: the framed request asks forJSONCompactStringsEachRowWithNamesAndTypes(the framing rejects the in-band-progressJSONStringsEachRowWithProgress) and the client reassembles the compact rows into the table renderer's shapes; on the server side (Framing formats: multiplex data, totals, extremes, progress, logs, and profile events in the HTTP response stream #110127) the compact family emits totals and extremes under framing, soWITH TOTALSand extremes-based column coloring keep working on the default path. When such a format is shown as raw text instead (an explicitFORMAT JSONCompactEachRow), only thedatapackets are concatenated, so the rendered text is exactly the plain output of that format rather than one carrying the totals and extremes rows the format itself drops.exceptionpacket as a query failure even when the HTTP status was already 200 (soRun allstops at the failed statement) - and, when a query chooses its ownJSONEachPacket*framing that fails before the 200 OK header (coming back as a non-200application/x-ndjsonpacket stream ending with a{"packet":"exception",...}line), shows those packets verbatim and recordsframing_kind = 'ndjson_packets'for replay rather than rendering the whole stream as one opaque error string; retries framing-incompatible explicit formats (e.g.FORMAT JSONEachRowWithProgress,FORMAT Template) once without framing for read-only queries (read-only-ness is resolved with a CTE-aware lexer walk -WITH y AS (SELECT 1) INSERT INTO t SELECT * FROM yis a write - shared withRun all's grouping, so such a statement is also a barrier there and never runs in parallel with the reads that follow it; the port with regression coverage lives insrc/Parsers/tests/gtest_play_query_is_read_only.cpp); a retriedJSON*EachRowWithProgressformat that itself reports a failure in-band - a trailing{"exception":...}object while the HTTP status stays 200 (http_write_exception_in_output_format) - is detected as a failure too, keyed off the output format rather than only a user-chosenJSONEachPacket*framing, soRun allstops after such a retried query fails; and does not add its own framing to a query that sets its ownframing_output_formatto a real framing choice (the response is then dispatched by content type, so the requested packets are shown verbatim); a query that setsframing_output_format = 'None'is refused client-side instead, since this page's rendering depends on framing (values the page cannot know upfront -= DEFAULT, a reset to the session/server default, and query-parameter placeholders like= {fmt:String}- are classified conservatively the same way and refused, rather than sent with a request shape the response might not match); likewise a standaloneSET framing_output_format = ...is refused, because it would change the setting for the whole session (with asession_id) while the page keeps adding its own framing per request - a query-levelSETTINGS framing_output_format = ...clause is the supported way to choose framing for one query. A query that carries its ownframing_output_formatis also refused for download (the setting would override the download's chosendefault_format, so the file would be the framing packet stream), and if such a query fails, its history snapshot - the rawJSONEachPacket*packet stream - is replayed as raw text on tab-switch/reload rather than as one opaque error string.framing_output_format=Noneon every request that expects an unframed response (the plain/chart request, the compatibility retry, the download, and the panel/server-status/completion queries), rather than only omitting the setting - otherwise a framing carried by the connection URL or by the HTTP session behind it would frame those responses too. A query-levelSETTINGS framing_output_format = ...clause is applied after the URL parameters, so a query that intentionally chooses a framing still overrides the pin.event_stream/ndjson_packets/ none) with each result snapshot and keys the history/tab replay off it, instead of guessing from the payload's first bytes - so a raw result whose text happens to start withevent:(e.g.SELECT 'event: data' FORMAT RawBLOB) or{"packet":is not reparsed as a framing stream after a tab switch or reload. A snapshot recorded asndjson_packetsis replayed as raw text regardless of whether the run succeeded and of its underlying output format, matching the live path - so a successful user-framedJSONEachPacket*result whose format has its own restore path (a table or aJSONCompactColumnschart) is not reparsed as that format's JSON. The snapshot also records whether the framed stream was truncated, so replay keeps the live fail-closed behavior for images: a cut-off framedFORMAT PNGresponse that showed only its error live reopens from history / Back / Forward as that error too, never as a partially decoded picture (a failed but complete stream - a terminalexceptionpacket after the payload - still renders its collected image, as live).FORMATclause and itsframing_output_formatsetting with the WASM lexer rather than a raw text match, so a mention inside a string literal or a comment - e.g.SELECT 'FORMAT JSONCompactColumns'- does not make the page silently opt out of its own framing. The detection is positional, not keyword-adjacent: a settings context is recognized by itsname = valuelist grammar (a column merely namedsettingsdoes not open one), and aFORMATclause candidate must follow a token that ends an expression (so inWITH 1 AS format SELECT format JSONCompactColumns SETTINGS max_threads = 1bothformatwords are identifiers, not a clause). The download reuses the sameFORMAT-clause detection (now returning the clause span) to strip only a real trailingFORMATclause from the download query, leaving text or ordinary SQL likeSELECT 'FORMAT TSV' AS suntouched. Both detectors also accept a quoted spelling of the name - the server parses setting names andFORMATnames with identifier parsers, so a backquotedframing_output_formator format name is real - comparing by the unquoted name. Regression coverage for both lives insrc/Parsers/tests/gtest_play_detect_explicit_format.cppandgtest_play_detect_framing_setting.cpp(ports of the token walking onto the realDB::Lexer).FormatFactorylooks them up by their lowercased name), whileX-ClickHouse-Formatechoes the identifier exactly as theFORMATclause spelled it, soFORMAT jsoncompactcolumnsused to lose the chart renderer, a lowercased default format lost the table renderer, and the late in-band exception probes did not recognizeFORMAT xml/FORMAT json/FORMAT jsoneachrowwithprogress- a query failing after its200 OKheader was then reported as a success andRun allcontinued past it. Every dispatch now compares a lowercased copy of the format name.SELECTqueries now also end with the documented finalprogresspacket carryingresult_rows/result_bytes/memory_usage, matching the native protocol and the no-result path.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Prototype Web UI changes to test framing formats (draft).
Related: #110127
Version info
26.8.1.1518(included in26.8and later)