Skip to content

fix(flights): compose the map at the width the ticker asked for - #304

Closed
ChuckBuilds wants to merge 1 commit into
mainfrom
fix/flights-honour-vegas-width
Closed

fix(flights): compose the map at the width the ticker asked for#304
ChuckBuilds wants to merge 1 commit into
mainfrom
fix/flights-honour-vegas-width

Conversation

@ChuckBuilds

Copy link
Copy Markdown
Owner

Follow-up to the observation that the flight map "is always a different size". It is — and which size you get depends on a code path the plugin cannot see.

What happens

Vegas asks a plugin for a narrower render so a full-panel layout doesn't read as sparse in the ticker. It normally delivers that by narrowing the shared canvas for the call, which a plugin sizing itself from matrix.width picks up for free.

But it cannot narrow the canvas in offscreen mode_render_at swaps the shared canvas, which is unsafe there — so it only sets the hint. Core's own comment says as much:

_vegas_render_width is set regardless: a plugin reading get_vegas_render_width() still gets its narrow size, and one that only reads matrix.width renders full width and is trimmed instead.

This plugin relied on the canvas being narrowed; its docstring said the projection scales "without any extra plumbing". Measured over two hours on the rig, that held 3 times out of 12:

Native: requesting 256px instead of 512px
Native: SUCCESS - 1 images, 512px total width      <- cropped afterwards
Native: SUCCESS - 1 images, 256px total width

So the map was composed at twice the needed width and most of it thrown away, on 9 of 12 requests.

The fix

The width property reads the hint. It covers both paths and falls back to the panel width outside a Vegas request, so the rotation is untouched.

The composite cache is already keyed by size, and its comment already says "Rotation and Vegas render the same map at different widths" — so this adds a cache entry rather than invalidating one. That was worth checking before changing anything, given a size-keyed cache is exactly where I found a thrash in the radar last time.

Wider finding

No plugin in the repo read get_vegas_render_width() before this, despite core providing and documenting it. Nine others currently render full-width frames the adapter then trims:

plugin rendered → kept discarded
countdown 5632 → 957 83%
clock-simple 4608 → 927 79%
of-the-day 6144 → 1365 77%
incoming-packages 5120 → 1160 77%
stock-news 4608 → 1998 56%

They're candidates for the same treatment, but each needs its own layout thought — a tighter arrangement, not just a smaller canvas. This fixes the one with a measured problem.

Verification

test_vegas_render_width.py: the width follows the request, returns to the panel width afterwards, falls back on a nonsense hint (0, -1, "wide", None), and the cache still keys on size. Mutation-checked — reverting to matrix.width fails it. All 9 flights suites pass.

One trap the test caught, worth recording: the harness must set both display_manager and _display_manager_ref. This plugin keeps the private name; BasePlugin stores the same object under the public one, and get_vegas_render_width()'s fallback reads the public one. A stub with only the private name makes the fallback miss the matrix and return its hard-coded 128 — which looks exactly like the property being broken, and briefly convinced me the fix was wrong.

🤖 Generated with Claude Code

https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW

Noticed on a live rig: the flight map came back at two different sizes.

Vegas asks a plugin for a narrower render so a layout built for the full panel
does not read as sparse in the ticker. It normally delivers that by narrowing
the shared canvas for the duration of the call, which a plugin sizing itself
from matrix.width picks up with no changes of its own. But it cannot narrow
the canvas in offscreen mode -- _render_at swaps the shared canvas, which is
unsafe there -- so it only sets the hint, and notes that a plugin reading
get_vegas_render_width() still gets the narrow size while one that reads only
matrix.width "renders full width and is trimmed instead".

This plugin relied on the canvas being narrowed; its own docstring said the
projection scales "without any extra plumbing". Measured over two hours on the
rig, that assumption held 3 times out of 12:

    Native: requesting 256px instead of 512px
    Native: SUCCESS - 1 images, 512px total width      <- cropped afterwards
    Native: SUCCESS - 1 images, 256px total width

so which width came back depended on a path the plugin cannot see, and the
full-width renders composed a map twice the needed width to have most of it
thrown away.

The width property now reads the hint. That covers both paths and falls back
to the panel width outside a Vegas request, so the rotation is unaffected. The
composite cache is already keyed by (width, height) and its comment already
says "Rotation and Vegas render the same map at different widths", so this
adds a cache entry rather than invalidating one.

No plugin in the repo read get_vegas_render_width() before this, despite core
providing and documenting it. Nine other plugins currently render full-width
frames that the adapter then trims by 56-83%; they are candidates for the same
treatment but each needs its own layout thought, so this fixes the one with a
measured problem.

test_vegas_render_width.py asserts the width follows the request, returns to
the panel width afterwards, and falls back on a nonsense hint, plus that the
cache still keys on size. Mutation-checked: reverting to matrix.width fails it.

The harness sets both display_manager and _display_manager_ref deliberately:
this plugin keeps the private name while BasePlugin stores the same object
under the public one, and get_vegas_render_width()'s fallback reads the public
one. A stub with only the private name makes the fallback miss the matrix and
return its hard-coded 128, which looks exactly like the property being broken.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a4652c3-39ec-43d6-95e9-90e9f6fe26aa


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity

Metric Results
Complexity 9

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@ChuckBuilds

Copy link
Copy Markdown
Owner Author

Superseded by #314, which combines the four ledmatrix-flights PRs into one version bump. Every change from this PR is verified present on that branch; the branch here is untouched if you want to compare.

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.

2 participants