Skip to content

fix(#198): commit-on-success streaming for the detached Data view#204

Merged
BorisTyshkevich merged 1 commit into
mainfrom
fix/detached-streaming-commit-on-success-198
Jul 13, 2026
Merged

fix(#198): commit-on-success streaming for the detached Data view#204
BorisTyshkevich merged 1 commit into
mainfrom
fix/detached-streaming-commit-on-success-198

Conversation

@BorisTyshkevich

Copy link
Copy Markdown
Collaborator

What & why

Fixes #198. In the detached Data view, changing a filter or clicking Refresh reran the captured query through the shared streaming seam and repainted the in-flight result on every network chunk. Two visible problems:

  1. Empty-result flash — a chunk can carry column metadata before any data rows (columns.length > 0, rows.length === 0), so the shared renderer momentarily showed Query returned 0 rows. even though rows arrived on the next chunk.
  2. Chart churn — on Panel, every chunk destroyed the current Chart.js instance and built a new one.

This adopts the same commit-on-success UI policy already used for dashboard tiles (#193).

Change (src/ui/results.js)

  • onChunk is now progress-only: Running… <n> rows read (else Running…). It never calls paint() and never touches current / statEl / view / sort / widths / panelState / chartInstance.
  • Start state shows Running… and disables Refresh.
  • After runReadInto() (current generation only): cancelled → settle(''), error → settle(err), else commit current = result, record bound params once, settle(''), paint() — exactly one repaint.
  • Removed the failure-time paint(current) restore: the in-flight result is never painted, so the committed result is already on screen on every non-success path.

Everything else (parameter analysis, prepared batch, token preflight, captured session, generation guard, AbortController, success-only recent recording) is unchanged. No generic "refreshable surface" abstraction introduced — detached and dashboard presentation semantics stay distinct, per the issue.

Tests (tests/unit/results.test.js)

New coverage via a controllable runReadInto seam: previous-result retention through a metadata-only chunk + a data chunk (no 0 rows flash, committed count unchanged, status text), commit-once Copy/recents targeting (old before, new after), no per-chunk chart churn (old chart destroyed once + one replacement on success), current-generation cancellation, and stale-chunk status suppression.

Verification

  • npm test — 2353 passed; src/ui/results.js holds the gate (br 95.04 / fn 97.26 / lines 100). npm run build clean.
  • Streaming policy is pinned deterministically by the new unit tests; I'll do a live confirmation on otel at deploy time (a slow rerun no longer flashes 0 rows / churns the chart).

Checklist

Closes #198

🤖 Generated with Claude Code

Changing a filter or clicking Refresh in the detached Data view repainted
the in-flight result on every network chunk. That flashed
"Query returned 0 rows." whenever a chunk carried column metadata before
any data rows, and it destroyed + recreated the Panel's Chart.js instance
per chunk.

Follow the same commit-on-success policy as dashboard tiles: onChunk now
updates a lightweight `Running… <n> rows read` status only — it never
paints the in-flight result and never touches current/stat/view/chart.
The previously committed Table/JSON/Panel (and its chart) stays on screen
untouched; the new result is committed and repainted exactly once after a
successful current-generation completion. Failure, cancellation,
supersession, and close all keep the previous committed result — and
because the in-flight result is never painted, the old failure-time
restore repaint (`paint(current)`) is removed. Winning bound params are
still recorded once; the committed toolbar row count no longer changes
mid-stream.

Adds tests for previous-result retention (incl. the metadata-only chunk),
commit-once Copy/recents targeting, no per-chunk chart churn, current-gen
cancellation, and stale-chunk status suppression. Dashboard and workbench
streaming behavior are unchanged; no new runtime dependency.

Closes #198

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVnHwXECf4dYtfLWy4wHcA
@BorisTyshkevich BorisTyshkevich mentioned this pull request Jul 12, 2026
46 tasks
@BorisTyshkevich BorisTyshkevich merged commit 84b59b6 into main Jul 13, 2026
6 checks passed
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.

Detached Data view: keep the committed result visible during streaming reruns

1 participant