Skip to content

Retain a covering M4 overview during line refinement - #362

Merged
Alek99 merged 2 commits into
mainfrom
codex/clarify-decimated-tier-functionality
Jul 28, 2026
Merged

Retain a covering M4 overview during line refinement#362
Alek99 merged 2 commits into
mainfrom
codex/clarify-decimated-tier-functionality

Conversation

@FarhanAliRaza

@FarhanAliRaza FarhanAliRaza commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Fix the blank-area symptom observed during a fast zoom/decimation dance where the left third of the plot went empty because the decimated tier had no covering overview while a refined M4 window reply was in flight.
  • The repository spec's T1 invariant (never blank) described a density covering fallback but the decimated tier lacked an equivalent retained overview, creating a spec/implementation mismatch.
  • The change implements the safer behavior: decimated traces provide a covering home/overview until a reply that truly covers the current view is installed, matching the intent of T1/T8.

Description

  • Add x_range metadata to M4/tier replies in python/xy/interaction.py so the client knows the exact window each decimation reply served.
  • Make decimated line/area traces retain their initial (home/overview) GPU geometry on the client by introducing g._homeDecimated, g._decimatedWindow, and g._decimatedRefined in js/src/50_chartview.ts, and draw the retained overview whenever the active refined window does not cover the current view.
  • Allocate separate GPU buffers for refined replies in js/src/54_kernel.ts (so the initial covering geometry is not destroyed by the first refinement) and record the replied x_range on the client-side trace object.
  • Add lifecycle cleanup for the retained overview (_deleteVaos, _deleteBuffers, and _destroyTraceResources) and update the LOD design doc (spec/design/lod-architecture.md) to document the T1/T8 behavior for decimated traces.
  • Update the transport test in tests/test_channel.py to assert that decimation replies include the x_range field (transport contract change).

Testing

  • Ran node js/build.mjs, which completed successfully and produced the minified client bundles.
  • Ran uv run pytest tests/test_channel.py tests/test_figure.py -q, which completed successfully for the targeted tests.
  • Ran linters/format checks with uv run ruff check . and uv run ruff format --check ., both of which passed.
  • Pre-commit hooks (uv run --with pre-commit pre-commit run --all-files) could not be executed in this environment due to PyPI access being unavailable, but Ruff hooks were exercised directly and passed.
  • The render smoke (python3 scripts/smoke_render.py) could not be executed in this environment because no Chromium binary is available, so an end-to-end headless render probe was not run here.

Fixes #352

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved chart rendering during zooming and panning by retaining a stable “home/overview” representation for density decimated traces until refined coverage fully applies.
    • Prevented charts from showing blank or incomplete regions when the view extends outside the newly refined window.
  • New Features

    • Tier update messages now include the served horizontal x_range to support more reliable coverage checks.
  • Tests

    • Added assertions validating the expected normalized x_range in tier update payloads.
  • Documentation

    • Expanded smooth-transition spec with clarified fallback rules and coverage determination behavior.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8031a5b6-7e70-457c-b8d4-3c430a81788d

📥 Commits

Reviewing files that changed from the base of the PR and between 4b400c1 and e8acce7.

📒 Files selected for processing (2)
  • js/src/50_chartview.ts
  • spec/design/lod-architecture.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • spec/design/lod-architecture.md
  • js/src/50_chartview.ts

📝 Walkthrough

Walkthrough

decimate_view now includes the served x-range in tier updates. The client retains home decimated geometry, tracks refined coverage, falls back when panning exceeds that coverage, and cleans up retained WebGL resources.

Changes

Decimated coverage fallback

Layer / File(s) Summary
Decimation window contract
python/xy/interaction.py, tests/test_channel.py
Decimation replies include normalized x_range metadata, with a test asserting the returned range.
Retained decimated geometry
js/src/50_chartview.ts, js/src/54_kernel.ts
Decimated traces retain home geometry; first refinement allocates independent buffers and records the refined coverage window.
Coverage-aware drawing and teardown
js/src/50_chartview.ts, spec/design/lod-architecture.md
Rendering falls back to home geometry when the current view exceeds refined coverage, and teardown releases retained resources. The T1 design rule documents this behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant decimate_view
  participant tier_update
  participant ChartView
  decimate_view->>tier_update: include normalized x_range
  tier_update->>ChartView: install refined buffers and record coverage
  ChartView->>ChartView: compare current view with _decimatedWindow
  ChartView->>ChartView: draw home geometry when coverage is exceeded
Loading

Possibly related PRs

  • reflex-dev/xy#188: Both changes modify decimated-tier refinement and follow-up view behavior in 54_kernel.ts.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: retaining a covering M4 overview during line refinement.
Linked Issues check ✅ Passed The changes implement the requested decimated-trace fallback and metadata updates needed to prevent blank regions during M4 refinement for #352.
Out of Scope Changes check ✅ Passed The spec and test updates are directly tied to the decimated-trace fallback work and do not introduce unrelated changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/clarify-decimated-tier-functionality

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@js/src/50_chartview.ts`:
- Around line 4061-4072: Normalize the viewport bounds returned by
_axisRange(g.xAxis) before comparing them with the normalized _decimatedWindow
range. Update the refined-coverage check in the decimated rendering branch so
reversed views such as [100, 0] are evaluated using their lower and upper
bounds, preserving overview rendering whenever the normalized viewport extends
outside r.

In `@python/xy/interaction.py`:
- Around line 474-477: Transport the served x-range through the established
raw-f32 buffer-reference path instead of embedding [lo_x, hi_x] in JSON. Update
python/xy/interaction.py:474-477 to emit the buffer reference; update
tests/test_channel.py:44-44 to assert the decoded binary range; update
js/src/54_kernel.ts:779-781 to decode that buffer before assigning
_decimatedWindow; and document the binary served-window encoding and fallback
semantics in spec/design/lod-architecture.md:356-360.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 43920446-af50-41cc-bcc4-03e3be3a17c3

📥 Commits

Reviewing files that changed from the base of the PR and between d35a1b2 and 4b400c1.

📒 Files selected for processing (5)
  • js/src/50_chartview.ts
  • js/src/54_kernel.ts
  • python/xy/interaction.py
  • spec/design/lod-architecture.md
  • tests/test_channel.py

Comment thread js/src/50_chartview.ts
Comment thread python/xy/interaction.py
@codspeed-hq

codspeed-hq Bot commented Jul 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 103 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing codex/clarify-decimated-tier-functionality (e8acce7) with main (d35a1b2)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

_axisRange preserves axis direction while the served x_range arrives
normalized, so a reversed axis view compared raw hi-before-lo bounds
against the normalized window and treated a partial refinement as
covering. Compare normalized [lo, hi] on both sides; record the rule in
the LOD spec (T1).
@Alek99
Alek99 merged commit baec8d4 into main Jul 28, 2026
28 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.

Line charts blank the newly exposed region while an M4 refine is in flight (T1 "never blank" is density-only)

2 participants