Skip to content

feat: auto-load new namespaces when PromotionStrategies are added#1142

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/auto-refresh-promotions-namespaces
Draft

feat: auto-load new namespaces when PromotionStrategies are added#1142
Copilot wants to merge 3 commits intomainfrom
copilot/auto-refresh-promotions-namespaces

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

The namespace dropdown fetched namespaces only once on mount, requiring a page refresh to discover namespaces added after initial load.

Changes

  • NamespaceStore.ts: Added an addNamespace(ns: string) action that appends a namespace to the list only if it's not already present (no-op otherwise).

  • NamespaceDropdown.tsx: Subscribes to the existing SSE /watch?kind=PromotionStrategy endpoint (no namespace filter = all namespaces). On each event, the namespace is extracted directly from the event payload (metadata.namespace) and added to the store via addNamespace — no extra API calls are made. The /list?kind=namespace call happens only once on mount for the initial list. EventSource is closed on unmount.

fetch('/list?kind=namespace')
  .then(data => setNamespaces(...));  // initial load only

const eventSource = new EventSource('/watch?kind=PromotionStrategy');
eventSource.addEventListener('PromotionStrategy', (evt) => {
  const ns = JSON.parse(evt.data)?.metadata?.namespace;
  if (typeof ns === 'string' && ns) addNamespace(ns);  // no extra API calls
});
return () => eventSource.close();

Reuses the existing SSE infrastructure already in place for PromotionStrategy real-time updates — no backend changes required. New namespaces are discovered purely from the event stream regardless of how many PromotionStrategy events are received.

Original prompt

This section details on the original issue you should resolve

<issue_title>Auto-load new namespaces when PromotionStrategies are added</issue_title>
<issue_description>The dashboard currently requires a page refresh to load new namespaces when PromotionStrategies are added to those namespaces.

The list should auto-refresh as PromotionStragegies are added.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: crenshaw-dev <350466+crenshaw-dev@users.noreply.github.com>
Copilot AI changed the title [WIP] Auto-load new namespaces for PromotionStrategies feat: auto-load new namespaces when PromotionStrategies are added Mar 3, 2026
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.29%. Comparing base (eb875ff) to head (06e37af).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1142      +/-   ##
==========================================
+ Coverage   50.60%   51.29%   +0.69%     
==========================================
  Files          51       51              
  Lines        5501     5501              
==========================================
+ Hits         2784     2822      +38     
+ Misses       2417     2392      -25     
+ Partials      300      287      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@crenshaw-dev
Copy link
Contributor

@copilot if I have 100 PromotionStrategies that are fairly active (updating often), that'll be a lot of list operations on the namespaces. Can we just watch the namespaces instead of listing them?

… re-listing

Co-authored-by: crenshaw-dev <350466+crenshaw-dev@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot if I have 100 PromotionStrategies that are fairly active (updating often), that'll be a lot of list operations on the namespaces. Can we just watch the namespaces instead of...

Done in ec3c924. Instead of re-calling /list?kind=namespace on every event, I now extract metadata.namespace directly from the SSE event payload and append it to the store via a new addNamespace action (no-op if already present). The /list?kind=namespace call only happens once on mount for the initial list — no extra API calls regardless of how many PromotionStrategy events are received.

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.

Auto-load new namespaces when PromotionStrategies are added

3 participants