Skip to content

fix(#244): restore role-aware initial result views for saved and shared queries - #251

Merged
BorisTyshkevich merged 1 commit into
mainfrom
fix/library-filter-launch-view-244
Jul 15, 2026
Merged

fix(#244): restore role-aware initial result views for saved and shared queries#251
BorisTyshkevich merged 1 commit into
mainfrom
fix/library-filter-launch-view-244

Conversation

@BorisTyshkevich

Copy link
Copy Markdown
Collaborator

What & why

Opening a Filter-role saved query from the Library, or via a share link/OAuth handoff, previously did not reliably start in the Filter preview:

  • Library-row activation (src/ui/saved-history.js): a Filter-role query with SQL restored whichever result view (Table/JSON/Panel) was already active, and could be overridden by a dormant persisted spec.view/Panel config. A Filter-role entry whose SQL can't auto-run (empty/DDL — reachable via an import or legacy localStorage entry that bypassed filterSqlDiagnostics) fell through to no view change at all — a real gap surfaced independently by 4 of 8 code-review finder angles during this PR's own review.
  • Share-link / OAuth-handoff bootstrap (src/main.js): resultView was only ever restored for a queryless Panel link (if (panel && panel.cfg) { if (!shared.sql) ... }). Any SQL-bearing shared Filter query, or a SQL-bearing shared Panel query with a persisted spec.view, always landed on the default Table view regardless of role or persisted view.

Both call sites now resolve the same precedence via one shared pure helper (rolePreviewView in src/core/result-choice.js):

role-owned transient preview (Filter) -> persisted spec.view -> queryless-Panel/default fallback

The Filter preview stays transient (no spec.view: "filter" is ever persisted), dormant Panel state is never touched, and ordinary reruns after a query is open continue to preserve the user's current Table/JSON/Filter selection.

Closes #244. Folds in #249 (closed as a duplicate) — that issue's narrower repro (empty-SQL Filter query) and the broader share-link restoration gap it pointed at are both covered here with one helper instead of two independent implementations that could diverge.

Verification

  • npm test: 2761/2761 passing, src/core/result-choice.js and src/main.js at 100/100/100/100, src/ui/saved-history.js above the branches floor.
  • Live-verified against a real ClickHouse demo cluster (otel):
    • Library-row activation for an auto-runnable Filter query, starting from Table/JSON/Panel views.
    • A non-auto-runnable Filter-role entry (injected via localStorage to simulate an unvalidated import) opening the Filter drawer instead of doing nothing.
    • The full OAuth sign-in round-trip restoring a Filter-role share link directly into the Filter preview.
  • /code-review (high effort, 8 finder angles + verify pass) run on the initial Library-only diff; the confirmed finding was fixed in this same PR before opening it, and the resulting broader share-link gap was triaged into this issue's scope per user direction rather than filed separately.

Checklist

🤖 Generated with Claude Code

https://claude.ai/code/session_01PQbDSVDUTUk1bA8891cX9y

…ed queries

Opening a Filter-role query from the Library, or via a share link/OAuth
handoff, now always starts in the Filter preview regardless of the
previously active result view or a dormant persisted spec.view. Both call
sites resolve the same rolePreviewView(spec) || queryView(query) precedence
so the invariant can't diverge between callers again. Folds in #249, whose
finding (a Filter-role query with non-auto-runnable SQL, and the broader
share-link bootstrap gap for any SQL-bearing shared query) is now covered
here instead of tracked separately.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PQbDSVDUTUk1bA8891cX9y
@BorisTyshkevich
BorisTyshkevich merged commit 377de42 into main Jul 15, 2026
6 checks passed
@BorisTyshkevich
BorisTyshkevich deleted the fix/library-filter-launch-view-244 branch August 6, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore role-aware initial result views when opening saved or shared queries

1 participant