Skip to content

fix(cf): stop app-detail remount + env-var refetch on every tab (#5519) - #5526

Merged
norman-abramovitz merged 1 commit into
cloudfoundry:developfrom
nabramovitz:norm/fix/5519-app-tab-envvars
Jul 1, 2026
Merged

fix(cf): stop app-detail remount + env-var refetch on every tab (#5519)#5526
norman-abramovitz merged 1 commit into
cloudfoundry:developfrom
nabramovitz:norm/fix/5519-app-tab-envvars

Conversation

@nabramovitz

Copy link
Copy Markdown
Contributor

Closes #5519

Problem

Clicking between an application's side tabs (Summary, Log Stream, Revisions, Routes, Variables, Services, Events) triggers a fetch of /v3/apps/:guid/environment_variables every time, each emitting an audit.app.environment.show event and polluting the app's event feed. Env vars should only be fetched for the Variables tab.

Root cause

CustomReuseStrategy reuses a route only when a reuseRoute marker matches; the app-detail routes carried none, so every tab navigation tore down and rebuilt ApplicationBaseComponent. Its ngOnInit re-runs the eager data load (refresh('all')), which includes the env-vars fetch → an audit event per tab click.

A plain reuseRoute marker can't be used directly here: ApplicationBaseComponent derives its CF/app GUIDs from route params via construction-time DI factories, so reusing the instance across two different apps (A → B) would leave it pinned to app A's data.

Fix

Teach the component-keyed branch of shouldReuseRoute to also require the route node's own params to match:

  • same params (tab switch) → shell is reused, no remount, no env-vars refetch;
  • different params (different app) → shell rebuilds, GUIDs correct.

Then mark the app-detail shell (ApplicationBaseComponent) and tabs-base (ApplicationTabsBaseComponent) routes. Also fixes the same latent cross-resource staleness for the k8s helm-release shell, which uses the identical construction-time-guid pattern (verified). Adds route-reuse-stragegy.spec.ts covering param-aware reuse.

Verification

Strategy unit tests (4/4) cover reuse-on-same-params and rebuild-on-different-params. End-to-end live verification (clicking tabs, confirming the env-vars call no longer fires and the event feed stays clean) is pending an available CF endpoint and should be done before merge.

Clicking between an app's side tabs (Summary/Logs/Variables/...)
tore down and rebuilt ApplicationBaseComponent every time, because
CustomReuseStrategy reused a route only when a reuseRoute marker
matched — and the app-detail routes carried none. Each rebuild
re-ran the eager data load, including the env-vars fetch, which
emits an audit.app.environment.show event. Clicking around thus
spammed the app's event feed.

A plain reuseRoute marker can't be used here: ApplicationBaseComponent
derives its CF/app GUIDs from route params at construction, so
reusing it across two different apps (A -> B) would leave it pinned
to app A. So teach the component-keyed branch of shouldReuseRoute to
also require the route node's own params to match: same params (tab
switch) reuses the shell; different params (different app) rebuilds.
Then mark the app-detail shell + tabs-base routes.

This also fixes the same latent staleness for the k8s helm-release
shell, which uses the identical construction-time-guid pattern.

Adds route-reuse-stragegy.spec.ts covering the param-aware reuse.
@nabramovitz
nabramovitz force-pushed the norm/fix/5519-app-tab-envvars branch from 92f759a to 043b8a4 Compare July 1, 2026 13:44

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@norman-abramovitz
norman-abramovitz merged commit 41d4352 into cloudfoundry:develop Jul 1, 2026
13 checks passed
@nabramovitz
nabramovitz deleted the norm/fix/5519-app-tab-envvars branch July 1, 2026 22:52
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.

app environment_variables are invoked every time a new tap is chosen under the Application screens

2 participants