fix: resolve empty resource tabs and missing peer component children#62
Merged
fix: resolve empty resource tabs and missing peer component children#62
Conversation
Fix two bugs that cause E2E test failures with aggregated peer gateways:
1. EntityResourceTabs: synchronously clear loadedTabsRef in the reset
effect so the load effect (same React commit) sees false instead of
stale true values from the previous entity.
2. loadChildren: when /components/{id}/hosts returns empty (peer-sourced
components), fall back to GET /apps filtered by x-medkit.component_id
or _links.is-located-on.
Extract filterAppsByComponent as a testable helper. Add 7 new tests
covering both fixes.
closes #61
There was a problem hiding this comment.
Pull request overview
Fixes two regressions in the entity browser when connected to aggregated/peer gateways: resource tabs going blank after switching entities, and peer-sourced components not showing child apps due to empty /hosts responses.
Changes:
- Update
EntityResourceTabsto synchronously resetloadedTabsRefon entity change to avoid a ref/state race. - Add
filterAppsByComponentand use it as a fallback when component hosts are empty by fetching/appsand filtering. - Add unit tests covering the tab-reset behavior and the new app-filter helper.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/components/EntityResourceTabs.tsx |
Fixes entity-switch race by resetting loadedTabsRef synchronously. |
src/lib/store.ts |
Adds /apps fallback to populate child apps for peer-sourced components and introduces filtering helper. |
src/lib/store-helpers.test.ts |
Adds unit tests for filterAppsByComponent. |
src/components/EntityResourceTabs.test.tsx |
Adds unit tests for EntityResourceTabs entity-switch behavior. |
- filterAppsByComponent now also matches `app.component_id` directly (not only `x-medkit.component_id` and `_links.is-located-on`) so the helper remains robust if future transforms lift component_id to the top level. - Add isPeerSourcedComponent helper and gate the /apps fallback on it, so legitimate empty manifest/plugin components do not trigger a full app-list fetch on every expand. Components with unknown source metadata still trigger the fallback to err on the side of completeness.
mfaferek93
reviewed
Apr 12, 2026
Addresses review feedback on PR #62: 1. EntityResourceTabs: propagate an AbortSignal to all resource fetches (data/operations/configurations/faults) and abort them whenever the entity changes or the component unmounts. Prevents stale responses from overwriting a newer entity's data on slow connections. Extend fetchEntityData, fetchEntityOperations, fetchConfigurations, listEntityFaults, and the underlying api-dispatch helpers to accept an optional signal parameter that threads through to openapi-fetch. 2. Deduplicate concurrent GET /apps requests when multiple peer-sourced components are expanded in quick succession. Extract the fallback into fetchAllAppsDeduped, which holds a module-level in-flight promise and shares it across concurrent callers. The promise is cleared on settlement so later expansions fetch fresh data. Add tests for both behaviors (stale-fetch discard + concurrent-request dedupe + dedupe-cache reset + fetch-failure fallback).
handleAction fires prepare/execute/automated/delete against the gateway without an abort signal. If the user navigates away while a mutation is in-flight, the promise resolves and fires toast.success + setBusyIds on an unmounted component. Add an AbortController created in a mount effect and aborted in its cleanup, thread its signal through the four mutation helpers, and short-circuit post-await side effects when the signal is aborted. The polling path in useUpdatesPolling already had this treatment; this brings mutations to parity. Tests assert (a) signal is an AbortSignal, (b) it becomes aborted on unmount, (c) a late-resolving mutation does not fire a success toast.
mfaferek93
approved these changes
Apr 12, 2026
bburda
added a commit
that referenced
this pull request
Apr 12, 2026
Addresses review feedback on PR #62: 1. EntityResourceTabs: propagate an AbortSignal to all resource fetches (data/operations/configurations/faults) and abort them whenever the entity changes or the component unmounts. Prevents stale responses from overwriting a newer entity's data on slow connections. Extend fetchEntityData, fetchEntityOperations, fetchConfigurations, listEntityFaults, and the underlying api-dispatch helpers to accept an optional signal parameter that threads through to openapi-fetch. 2. Deduplicate concurrent GET /apps requests when multiple peer-sourced components are expanded in quick succession. Extract the fallback into fetchAllAppsDeduped, which holds a module-level in-flight promise and shares it across concurrent callers. The promise is cleared on settlement so later expansions fetch fresh data. Add tests for both behaviors (stale-fetch discard + concurrent-request dedupe + dedupe-cache reset + fetch-failure fallback).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix two bugs that broke the entity browser when connected to a gateway aggregating peer ECUs:
loadedTabsvia batched setState but the load effect in the same React commit read a staleloadedTabsRefand returned early.GET /components/{id}/hostsreturns empty for them; the child apps actually reference the component viax-medkit.component_idor_links.is-located-on.Issue
Type
Testing
EntityResourceTabsentity-switch behavior, 5 for the newfilterAppsByComponenthelper (covering both match criteria, empty input, and the partial-ID edge case where a suffix of a longer component ID must not match).Checklist
npm run lint)npm run build)