Skip to content

Add a refresh button to the database panel in the Web UI - #108958

Merged
alexey-milovidov merged 4 commits into
masterfrom
web-ui-database-refresh-button
Jul 1, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
web-ui-database-refresh-button

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

In the Web UI (play.html), when a database is expanded in the database panel, a refresh button (↻) is now shown to the right of the database name. Clicking it reloads the list of tables without collapsing the database.

The button reuses the same top-right slot as the loading hourglass (only one is shown at a time): the hourglass appears while tables load, and the refresh button is shown once the list is ready.

Changelog category (leave one):

  • Improvement

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

Web UI: show a refresh button next to an expanded database to reload its list of tables.

Version info

  • Merged into: 26.7.1.366 (included in 26.7 and later)

In the Web UI (`play.html`), when a database is expanded in the database
panel, show a refresh button (`↻`) to the right of the database name.
Clicking it reloads the list of tables without collapsing the database.

The button reuses the same top-right slot as the loading hourglass (only
one is shown at a time): the hourglass appears while tables are loading and
the refresh button is shown once the list is ready.

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

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [804009f]

Summary: ✅


AI Review

Summary

The PR adds a refresh button for expanded databases in play.html, reusing the existing loading slot and guarding stale table reloads with a per-row generation plus connectivity check. The previously reported stale-refresh paths are addressed in the current code, and I did not find new high-signal correctness issues in the final diff.

Final Verdict

✅ No findings to post.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 30, 2026
Comment thread programs/server/play.html Resolved
…lapsed database

The new database refresh button could repopulate the table list of a row
after the user had already collapsed it. Sequence: open a database, click the
refresh button, then click the database name (collapsing the row) before the
`loadTables` request returns. The collapse path deletes `dataset.opened`,
removes the refresh button and clears `.tables`, but it did not invalidate the
in-flight request, so when the promise resolved, `loadTables` still mutated the
same container and repopulated tables for a row that was no longer open.

The global `load_tables_request_num` does not help here: collapse issues no new
`loadTables`, so the counter stays equal, and bumping it on collapse would
wrongly cancel a concurrent open of a different row.

Add a per-row generation counter, bumped on every refresh and on collapse. An
in-flight load captures the generation and `loadTables` bails out (before
touching the DOM) if it is no longer current when its query returns. The
refresh button's visibility is also restored only when the load is still
current.

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

Copy link
Copy Markdown
Member Author

Addressed the AI review's "Request changes" (the only outstanding item) in d445bd2. The full pre-fix CI run on 73b82e93 was green (0 failed jobs).

What the bug was: the new refresh button could repopulate the table list of a database row after it had been collapsed — open a database, click ↻, then click the database name (collapsing it) before loadTables returned. The collapse path cleared .tables and removed the button but did not invalidate the in-flight request.

Fix: a per-row row_load_generation counter, bumped on every refresh and on collapse. loadTables now bails out before mutating the DOM if the row was collapsed or superseded by a newer refresh while its query was in flight (the global load_tables_request_num could not cover this, since collapse issues no new load and bumping the global would cancel a concurrent open of a different row). Diff is play.html-only (+22/-3). The inline <script> parses clean under node --check.

The review thread is resolved; CI should re-run on the new commit.

Comment thread programs/server/play.html Resolved
…nel is closed

A follow-up to the previous per-row generation guard. That guard invalidated
an in-flight refresh on collapse and on a newer refresh, but not when the whole
database panel is closed. Sequence: open a database, click the refresh button,
then hide the panel before `loadTables` returns. `toggleDatabases` (and a full
`loadDatabases` reload) removes all database row nodes without bumping
`row_load_generation`, so the row's generation is unchanged and the in-flight
load was still considered current. When its query returned, `loadTables` reached
`container.parentElement.querySelector('.current')` with `container.parentElement`
now `null`, raising a JavaScript exception instead of quietly dropping the stale
refresh.

Extend the `is_current` predicate with `database.isConnected`, so a load whose
row was detached from the document (panel closed, or database list reloaded)
bails out before touching the DOM, exactly like the collapse and supersession
cases. The check covers both the `loadTables` bail-out and the refresh button's
visibility restore, since both go through `is_current`.

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

Copy link
Copy Markdown
Member Author

Addressed the AI review's follow-up "Request changes" (the only outstanding item) in 4c4e2c9.

What the new finding was: closing the whole database panel while a refresh was in flight could crash the load. The previous per-row generation guard invalidated a refresh on collapse and on supersession, but not when the entire panel is closed. toggleDatabases (and a full loadDatabases reload) removes all database row nodes without bumping row_load_generation, so the in-flight load was still considered current; when its query returned, loadTables reached container.parentElement.querySelector(.current) with container.parentElement === null, raising a JavaScript exception instead of quietly dropping the stale refresh.

Fix: extend the is_current predicate with database.isConnected. A load whose row was detached from the document (panel closed, or database list reloaded) now bails out before touching the DOM, exactly like the collapse and supersession cases. The check covers both the loadTables bail-out and the refresh button visibility restore, since both go through is_current. Diff is play.html-only (+11/-5); the inline <script> parses clean under node --check.

The previous CI run on d445bd24 was fully green (0 failed jobs). The review thread is resolved; CI re-runs on the new commit.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged master into the branch (4c4e2c94690..804009fb137).

Why re-merge: master evolved programs/server/play.html in the exact region this PR touches — #108891 ("Show table count next to opened database", commit e45c45517e2) modifies the same collapse else branch in loadDatabases and adds a count-update block to loadTables. Merging validates the two Web UI features coexist and gives fresh CI on the integrated result, rather than leaving a green-but-stale CI on a state that would conflict.

Integration verified:

The net diff vs current master is exactly the refresh-button feature (+79/-8, play.html only); no other files differ. The inline <script> parses clean under node --check. The pre-merge CI on 4c4e2c94 was fully green (only CH Inc sync pending), and CI re-runs on the merge commit.

@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.

Cool, it works. I was able to create new tables and with the refresh button they appeared 👌

Image

@pamarcos pamarcos self-assigned this Jul 1, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 1, 2026
Merged via the queue into master with commit c81ae27 Jul 1, 2026
174 checks passed
@alexey-milovidov
alexey-milovidov deleted the web-ui-database-refresh-button branch July 1, 2026 17:54
alexey-milovidov added a commit that referenced this pull request Jul 1, 2026
…ed-databases

Resolve the `programs/server/play.html` conflict with the database refresh
button feature that landed on master (#108958).

Both features independently reworked the database-list loop body and the
6th parameter of `loadTables`: this PR added `openDatabase(set_current)`
plus the `opened_databases` restore set and a per-container `WeakMap`
staleness token with a `set_current`/`current_selection_num` highlight
guard, while master added `refreshTables`, the per-row `row_load_generation`
counter and the `is_current` predicate for the refresh button.

The merge keeps both: `refreshTables` now takes `set_current` (defaulting to
true, preserving master's refresh behaviour) and threads it into
`loadTables`; `openDatabase` wraps `refreshTables` to mark the row opened,
remember it in `opened_databases` and attach the refresh button; restore
calls `openDatabase(false)` so it never moves the current-database
highlight. `loadTables` keeps the per-container token, the `is_current`
predicate guard and the latest-selection highlight guard together.
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 1, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…refresh-button

Add a refresh button to the database panel in the Web UI
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ed-databases

Resolve the `programs/server/play.html` conflict with the database refresh
button feature that landed on master (ClickHouse#108958).

Both features independently reworked the database-list loop body and the
6th parameter of `loadTables`: this PR added `openDatabase(set_current)`
plus the `opened_databases` restore set and a per-container `WeakMap`
staleness token with a `set_current`/`current_selection_num` highlight
guard, while master added `refreshTables`, the per-row `row_load_generation`
counter and the `is_current` predicate for the refresh button.

The merge keeps both: `refreshTables` now takes `set_current` (defaulting to
true, preserving master's refresh behaviour) and threads it into
`loadTables`; `openDatabase` wraps `refreshTables` to mark the row opened,
remember it in `opened_databases` and attach the refresh button; restore
calls `openDatabase(false)` so it never moves the current-database
highlight. `loadTables` keeps the per-container token, the `is_current`
predicate guard and the latest-selection highlight guard together.
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.

3 participants