Skip to content

Run the FetchStats analysis once per selection - #417

Draft
CarsonDavis wants to merge 2 commits into
feature/351-draw-end-clicksfrom
feature/412-fetchstats-subscribes-once
Draft

Run the FetchStats analysis once per selection#417
CarsonDavis wants to merge 2 commits into
feature/351-draw-end-clicksfrom
feature/412-fetchstats-subscribes-once

Conversation

@CarsonDavis

@CarsonDavis CarsonDavis commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator
Category Lines added %
Tests 114 89.8%
Production code 13 10.2%

One AOI selection now makes one statistics request per layer, and unloading FetchStats mid-run silences it.

Closes #412

One selection, one request per layer

Previously, selecting an AOI queried every eligible visible layer twice, and the AOI progress readout counted doubled steps against a total it never cleanly reached.

The modern tool controller calls initialize() and then make(targetId), and initialize() itself already calls make(null), so the AOI subscription registered twice and every selection fired both listeners.

The fix: a made guard makes the second start a no-op, leaving one listener. Demo mission: yes, the demo is the modern layout and includes FetchStats.

Unloading the plugin mid-analysis goes quiet

Previously, a run in flight kept emitting progress, result, and skip messages onto the bus after teardown, so listeners heard from a plugin that no longer existed.

destroy() never dropped _api, and the four emit sites called it unconditionally.

The fix: destroy() nulls _api and the emits are optional-chained.

Classic Layout Stuff

The classic layout still answers a selection

Classic only calls initialize(), which is why the double query was modern-layout only and why the guard must not break the single start. It doesn't: one subscription there too, asserted by a test. Demo mission: no, only the test covers this.

AOI drives its progress readout off analysisProgress and only returns to idle on analysisReady, so tearing FetchStats down mid-run while AOI outlives it leaves AOI showing "running"; cancelling a run in flight is a separate issue.

The modern layout starts the plugin through initialize() and make(), and both subscribed to the AOI selection, so one selection ran the statistics round twice. The second start is now a no-op, and a run still in flight when the plugin is destroyed no longer reaches the bus.
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.

1 participant