Skip to content

feat(ui): autocomplete namespace filter from displayed resources (refs #7405)#16087

Open
callmemorgan wants to merge 3 commits into
argoproj:mainfrom
callmemorgan:feat-namespace-filter-autocomplete-7405
Open

feat(ui): autocomplete namespace filter from displayed resources (refs #7405)#16087
callmemorgan wants to merge 3 commits into
argoproj:mainfrom
callmemorgan:feat-namespace-filter-autocomplete-7405

Conversation

@callmemorgan
Copy link
Copy Markdown

Fixes #7405

Motivation

The UI namespace filter (used on workflows, workflow templates, cron workflows, sensors, event sources, event bindings, event flow) is currently a free-text input backed only by a 5-entry localStorage history. Users with many namespaces have to retype namespace names from memory each time.

Issue #7405 has tracked this for 4+ years. In a comment on the dup #9140, @agilgur5 noted that one safe and proper way to provide namespace autocomplete is to derive suggestions from the namespaces of workflows the user has already loaded — since the user already has list permission on those namespaces, this leaks no information beyond k8s RBAC's existing answer.

That's what this PR does, generalized to every page that uses the shared NamespaceFilter.

Modifications

  • shared/components/input-filter.tsx gains an optional extraSuggestions?: string[] prop. Suggestions are merged with the existing localStorage cache (extras first, then history, deduped) and passed to Autocomplete.
  • shared/components/namespace-filter.tsx gains a matching extraNamespaces?: string[] prop and enables filterSuggestions so typing narrows the merged list. The managed-namespace short-circuit is unchanged.
  • shared/namespaces.ts gets a getUniqueNamespaces helper that extracts the unique sorted set of namespaces present on any list of namespaced k8s objects.
  • 7 callers of NamespaceFilter now pass extraNamespaces derived from the resource list each page already loads:
    • workflows list → props.workflows
    • workflow templates list → templates prop
    • cron workflows list → cronWorkflows prop
    • workflow event bindings → workflowEventBindings state
    • event sources list → eventSources state
    • sensors list → sensors state
    • event flow → combined eventSources + sensors + workflows
  • reports/reports-filters.tsx does not have a resource list in scope (it's a pure filter component), so it keeps the existing free-text + localStorage behavior. Its parent could be wired through in a follow-up, but it's intentionally out of scope here.
  • New unit test for InputFilter covers the merge/dedup/order/empty-state behavior.

No server, RBAC, or manifest changes — the data piped into autocomplete is data the page has already loaded under the user's existing list permissions. Cluster-wide list responses already include metadata.namespace per item (e.g., workflow-template-list.tsx:90), which is what populates the suggestions.

This is purposefully a small fix. Some honest limitations:

  • It does not surface empty namespaces (no resources visible).
  • It does not give first-paint suggestions before the first list request lands.
  • It does not change behavior in managed-namespace mode (filter still doesn't render at all).

Those limitations could be addressed by a future server-side ListNamespaces endpoint, which would be a separate design discussion involving manifest/RBAC changes — explicitly out of scope here. This PR aims to ship the maintainer-endorsed pragmatic improvement first.

Scope note: PR #13628 (open, @MasonM) adds a namespace input to the UserInfo page for SSO RBAC namespace delegation. That's a different page and a different concern — no overlap with this change.

Verification

  • yarn --cwd ui lint passes.
  • yarn --cwd ui test passes; new test cases in input-filter.test.tsx cover:
    1. extraSuggestions undefined → behavior identical to before (only the localStorage cache appears in Autocomplete.items).
    2. extraSuggestions present → suggestions appear first, then the localStorage cache, deduped.
    3. Empty extraSuggestions → empty items list.
  • Manual smoke: ran yarn --cwd ui start and confirmed that on /workflows, /workflow-templates, /cron-workflows, /sensors, /event-sources, /workflow-event-bindings, /event-flow the Namespace field's autocomplete now lists the namespaces of currently-visible resources and narrows them as you type. Confirmed --managed-namespace=foo still short-circuits to a plain foo label.

Documentation

No user-facing documentation change required — this is a UX improvement to an existing filter with no new configuration, flag, or API surface.

AI

Claude (Anthropic) was used to:

  • Survey existing NamespaceFilter callers and confirm what data each had in scope.
  • Verify existing helpers (util/auth.CanIArgo, server/auth.CanI) and their callers.
  • Audit the draft for technical accuracy against the actual codebase, including verifying the argo-server's default ClusterRole grants (which informed scoping this PR to a UI-only change and deferring server-side ListNamespaces to a separate design discussion).
  • Draft this PR description and the unit test.

All code in this PR was reviewed by the author before commit.

@callmemorgan callmemorgan marked this pull request as ready for review May 13, 2026 14:59
Refs argoproj#7405.

The shared NamespaceFilter used on workflows, workflow templates, cron
workflows, sensors, event sources, event bindings, and event flow was a
free-text input backed only by a 5-entry localStorage history. Users
with many namespaces had to retype namespace names from memory.

Each of those pages already loads a resource list whose items carry
metadata.namespace. Wire that list into the namespace filter so the
already-visible namespaces appear as autocomplete suggestions. This is
the workflow-derived approach endorsed on argoproj#9140:
suggestions never exceed what the user can already list, so no RBAC
boundary is crossed.

- InputFilter accepts an extraSuggestions prop; merges with localStorage
  history, dedups, passes the merged list to Autocomplete.
- NamespaceFilter accepts an extraNamespaces prop and enables
  filterSuggestions so typing narrows the merged list.
- shared/namespaces.ts gains getUniqueNamespaces<T>(items).
- 7 callers wire extraNamespaces from their resource list in scope.
- Reports filters has no resource list in scope and keeps existing
  free-text + localStorage behavior; can be wired through in a follow-up.
- New unit test in input-filter.test.tsx covers the merge, ordering,
  dedup, and empty cases.

Signed-off-by: Morgan Allen <[email protected]>
Required by the feature-pr-handling CI check for feat: PRs.

Signed-off-by: Morgan Allen <[email protected]>
@callmemorgan callmemorgan force-pushed the feat-namespace-filter-autocomplete-7405 branch from 9a91ca6 to bf195cf Compare May 18, 2026 15:08
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.

UI/API: Add autocomplete for namespace filter

1 participant