Skip to content

Fix side menu height on play.html when web terminal is open - #105087

Merged
alexey-milovidov merged 8 commits into
masterfrom
play-menu-height-with-terminal
May 23, 2026
Merged

alexey-milovidov merged 8 commits into
masterfrom
play-menu-height-with-terminal

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 15, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix the left panel height on the play.html page when the web terminal is open, so the terminal toggle button at the bottom stays visible.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Description

The side menu on play.html had a fixed height: 100vh, so opening the web terminal panel above it pushed its bottom (the terminal toggle and GitHub icons) below the viewport.

This change tracks the panel's height via a --terminal-height CSS variable and sizes the menu as calc(100vh - var(--terminal-height, 0px)). The variable is updated whenever the terminal is activated, hidden, or drag-resized, so the menu's bottom icons stay visible at all times.

Version info

  • Merged into: 26.6.1.111

The left panel had a fixed `height: 100vh`, so opening the web terminal
pushed its bottom (with the terminal/GitHub icons) below the viewport.
Track the panel height via a `--terminal-height` CSS variable and size
the menu as `100vh - terminal_height`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6982670]

Summary: ✅


AI Review

Summary

This PR adjusts play.html so the left menu height tracks terminal panel height, and also reworks web terminal URL resolution/messaging for locally opened playground pages. The layout part is fine, but two behavior contracts are still violated in the current head: terminal availability probing is CORS-gated in the cross-origin/local scenario the PR explicitly targets, and credential handoff from local parents is blocked by the iframe-side origin policy. These need to be fixed before merge.

Findings

⚠️ Majors

  • [programs/server/play.html:4508] The terminal availability contract is broken for cross-origin/local usage (file://.../play.html?url=...): fetch(terminalProbeURL, {method: 'HEAD'}) is CORS-restricted, while /webterminal responses are not CORS-enabled, so the probe fails and the terminal icon remains hidden even when the endpoint exists. Suggested fix: remove this cross-origin fetch probe and use an availability strategy that does not depend on CORS (for example optimistic icon display with runtime fallback when iframe session setup fails).
  • [programs/server/play.html:4515] The credentials handoff contract is broken for locally opened parent pages: play.html posts webterminal-credentials, but webterminal.html only accepts parent origins that are same-origin or *.clickhouse.com / *.clickhouse.cloud. A file:// parent has origin "null", so credentials are dropped, and after initial auth failure the iframe can stay stuck waiting for parent credentials. Suggested fix: align the parent-origin trust/handshake with the local embedding flow (or fall back to interactive credential prompt instead of waiting indefinitely when parent credentials cannot be accepted).
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  1. Replace the current CORS-dependent terminal availability probe so terminal visibility works in the cross-origin/local scenario described by the PR.
  2. Make parent-to-iframe credential flow robust for local embedding, or ensure a guaranteed interactive fallback path when parent credentials are not accepted.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 15, 2026
When `play.html` is opened locally with a `?url=...` query parameter
overriding the server, the HEAD check for `/webterminal` was still
issued against the page's own URL (e.g. `file:///webterminal`) and
always failed. Resolve it against the configured server instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 2 commits May 17, 2026 02:51
… server URL

The availability probe was updated in cdd5e96 to resolve `/webterminal`
against `url_elem.value`, but `getTerminalURL` still returned the relative
path `/webterminal`, which the iframe resolves against the page's own origin.
When the page is opened locally with `?url=...`, the probe would succeed on
the configured server while the iframe loaded a non-existent endpoint on the
page origin.

Make `getTerminalURL` resolve against `url_elem.value` so the probe and the
iframe use the same URL source. Capture the iframe origin at creation time
and use it as the target origin for `postMessage`, so credential and refit
messages still reach the iframe when it is cross-origin.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

This was fixed by #105146. Let's update the branch.

Comment thread programs/server/play.html Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, please fix this error:

Stress test (arm_release) FAIL
Logical error: Can't extract iceberg table state from storage snapshot for table location A (STID: 2606-44c0)

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov — STID: 2606-44c0 (Can't extract iceberg table state from storage snapshot) is part of our chronic Iceberg LOGICAL_ERROR family, already tracked.

Existing fix in flight: PR #102033 — "Fix Can't extract iceberg table state from storage snapshot for table location in StorageObjectStorageStableTaskDistributor". OPEN, MERGEABLE, last CI run on 2026-04-28 had Style/Code Review/builds SUCCESS. It has been awaiting re-review for ~12 days. Could you (or a comp-datalake reviewer — @alesapin / @Michicosun / @scanhex12 / @kssenii) take another pass? That'll unblock this sighting and the other 14 PR hits in the family.

Family evidence (CIDB, last 30 days): STID 2606-* family has 19 total failures — 4 on master + 14 across 15 distinct PRs — confirming this is a chronic trunk bug, not anything specific to PR #105087's play.html change.

The single 2606-44c0 hit in CIDB right now is exactly the one you flagged here on f34a44b (Stress test arm_release). PR #105087's diff is play.html UI only — completely unrelated to Iceberg storage snapshots.

Closing the loop on the directive: tracked, fix exists, waiting on review.

— @groeneai (session cron:clickhouse-ci-task-worker:20260517-234500)

`getTerminalURL` resolved `/webterminal` against `url_elem.value` without
validation. If the value is not an absolute URL (e.g. `?url=localhost:8123`
or a temporarily invalid value while the user is editing), `new URL(...)`
threw synchronously, and because the probe runs at module initialization
the exception could abort the rest of `play.html` initialization.

Catch the parse failure, return `null`, and treat that as "terminal
unavailable" - skip the probe and bail out of `activateTerminal` before
mutating any state.

Addresses review feedback on PR #105087.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The only failing CI check is Stress test (arm_release) with a Logical error: Can't extract iceberg table state from storage snapshot for table location A. This is unrelated to this PR (which only touches programs/server/play.html) and matches the open issue #102037.

@groeneai, please investigate and fix in a separate PR if it is not yet covered.

Comment thread programs/server/play.html Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov — confirming this STID is already covered. Quick rundown:

STID 2606-44c0 ⊆ same chronic family as STID 2606-4a47 / issue #102037. Identical error message (Can't extract iceberg table state from storage snapshot for table location A) — same code path (IcebergMetadata::iterate() at IcebergMetadata.cpp:1037 throwing LOGICAL_ERROR when datalake_table_state is missing from the storage snapshot). Only the stack hash differs because the surrounding call chain in stress varies (e.g. mutation path vs select path). CIDB confirms: 2606-44c0 has exactly 1 hit in 30 days, and it's the exact one you flagged here on f34a44b; 2606-4a47 has 17 hits (5 master, 13 PRs) over the same window.

Existing fix-in-flight: PR #102033 — "Fix LOGICAL_ERROR crash in IcebergMetadata::iterate when datalake_table_state is missing". Same file, same line 1037. Body explicitly cites STID 2606-4a47 evidence. Defense-in-depth: falls back to getRelevantState() instead of throwing, matching the existing pattern in getColumnMapperForCurrentSchema() (same file, line ~1260). Covers the cluster-function nullptr path, the schema-inference nullptr path, and the TOCTOU race between updateExternalDynamicMetadataIfExists() and getInMemoryMetadataPtr().

Why it hasn't merged yet: PR #102033 is stale — last activity 2026-04-28, 8714 commits behind master, only review was @alesapin's dismissal on day-of-open (2026-04-08) with no comments. It's been sitting awaiting a fresh look from comp-datalake for ~5 weeks. So this is a review-stall, not a "fix not yet written" situation.

Next action on my side: I'll rebase #102033 onto current master and re-request review. Tagging the comp-datalake owners again so this finally moves:

cc @alesapin @Michicosun @scanhex12 @kssenii — could one of you re-check #102033? Same fix unblocks all 18+ hits across this PR and the other 13 PRs hitting the family in CIDB.

— @groeneai (session cron:clickhouse-ci-task-worker:20260518-144500)

@pamarcos pamarcos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix seems to work.

Before

Image

Now

Image

However, apart of the typo, GPT-5.5 reports the following:

⚠️ Major: cross-origin terminal path still won’t work.

programs/server/play.html:4305-4309 now probes http://server/webterminal from the page origin. When play.html is opened from file:// or another host/port, this fetch needs CORS headers, but /webterminal does not add them, so the probe is blocked and the terminal icon stays hidden.

programs/server/play.html:4313-4318 posts credentials to the remote iframe, but programs/server/webterminal.html:320-322 rejects messages unless e.origin === window.location.origin. For a local/static play.html, the parent origin differs from the iframe origin, so credentials/refit messages are dropped even if the iframe is forced open.

Suggested fix: either scope this PR back to same-origin layout only, or define a safe explicit cross-origin embedding contract. Don’t just accept * in webterminal.html; that same-origin check is currently the main guard against arbitrary pages embedding /webterminal and sending credentials.

`codespell` flagged the comment word `unparseable` in `getTerminalURL`'s
guard clause. Replace with `unparsable` so the `Style check` passes.

Addresses the only unresolved review thread on #105087.
Comment thread programs/server/play.html
terminalIcon.style.display = 'none';
const terminalProbeURL = getTerminalURL();
if (terminalProbeURL) {
fetch(terminalProbeURL, {method: 'HEAD'}).then(function(resp) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch(terminalProbeURL, {method: 'HEAD'}) requires CORS whenever url_elem.value points to a different origin (for example file://.../play.html?url=http://host:8123). The /webterminal HTML response path does not add CORS headers, so this probe is rejected by the browser and the terminal icon stays hidden even when the endpoint exists.

Can we avoid a cross-origin fetch as the availability check (for example, optimistic show + lazy fallback on iframe load failure)?

Comment thread programs/server/play.html
function sendCredentialsToTerminal() {
if (terminalIframe && terminalIframe.contentWindow) {
if (terminalIframe && terminalIframe.contentWindow && terminalOrigin) {
terminalIframe.contentWindow.postMessage({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now posts webterminal-credentials to terminalOrigin, but programs/server/webterminal.html accepts parent messages only from same-origin or *.clickhouse.com / *.clickhouse.cloud. For local/static play.html (origin = "null"), credentials/refit messages are dropped.

With auth enabled, webterminal.html then waits for parent credentials after initial auth fails, so the embedded terminal cannot recover. If local embedding is intended here, this needs a compatible handshake/allowlist contract.

@pamarcos

Copy link
Copy Markdown
Member

GPT-5.5 found the same as Opus:

Findings
⚠️ Majors

  • programs/server/play.html:4307: the terminal availability probe uses fetch(terminalProbeURL, {method: 'HEAD'}). For play.html?url=... opened from file:// or another origin, this becomes a CORS-gated request to /webterminal, but WebTerminalRequestHandler::serveHTML does not add CORS headers. Result: the probe is blocked and the terminal icon remains hidden even when /webterminal exists.
  • programs/server/play.html:4314: play.html sends credentials to the remote iframe, but local/static parent origins still are not accepted by current webterminal.html origin checks. With non-empty credentials required, the iframe can wait for credentials that it rejects. This is especially relevant because the PR comments explicitly describe locally opened play.html?url=....

@alexey-milovidov alexey-milovidov self-assigned this May 23, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

This nitpick is secondary to this PR.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 23, 2026
Merged via the queue into master with commit be122a9 May 23, 2026
326 of 328 checks passed
@alexey-milovidov
alexey-milovidov deleted the play-menu-height-with-terminal branch May 23, 2026 21:38
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 23, 2026
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
`getTerminalURL` resolved `/webterminal` against `url_elem.value` without
validation. If the value is not an absolute URL (e.g. `?url=localhost:8123`
or a temporarily invalid value while the user is editing), `new URL(...)`
threw synchronously, and because the probe runs at module initialization
the exception could abort the rest of `play.html` initialization.

Catch the parse failure, return `null`, and treat that as "terminal
unavailable" - skip the probe and bail out of `activateTerminal` before
mutating any state.

Addresses review feedback on PR ClickHouse#105087.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
`codespell` flagged the comment word `unparseable` in `getTerminalURL`'s
guard clause. Replace with `unparsable` so the `Style check` passes.

Addresses the only unresolved review thread on ClickHouse#105087.
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
…-with-terminal

Fix side menu height on play.html when web terminal is open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants