← Back to Pull requests

frontend: ResourceTable: Ignore namespace filter when disabled #7468

Merged
dlanov merged 11 files (363 lines) on Nov 26, 2026 21:53 UTC
View on GitHub
dlanov dlanov commented on Aug 24, 2026 22:45 UTC
Author

Summary

This PR fixes namespace-scoped resource tables being hidden by a stale global
namespace filter.

When a namespace filter was selected elsewhere in Headlamp, namespace-scoped
views could still apply that global filter at the table row-filtering layer even
though the namespace selector was hidden. This caused resources from the
currently viewed namespace to disappear.

Rather than restoring the global filter reset from #5157, which was reverted by
#5271 due to crashes, this change makes ResourceTable respect
noNamespaceFilter without modifying the global namespace selection.

Related Issue

Fixes #7467

Changes

  • Allow the default resource row filter to ignore the global namespace filter

  • when namespace filtering is disabled for the view.
  • Compute one effective noNamespaceFilter value in ResourceListView and use

  • it for both SectionFilterHeader and ResourceTable, while preserving
    existing caller override semantics.
  • Preserve the existing global namespace selection instead of clearing Redux or

  • persisted state.
  • Prevent Project Access Role/RoleBinding tables from being further restricted

  • by an unrelated global namespace filter.
  • Prevent Advanced Search results from being silently filtered after the result

  • count is computed.
  • Add regression tests for row filtering, ResourceListView wiring, and the

  • Project Access tables.

    Steps to Test

    1. In Workloads, select a namespace filter such as namespace A.
    2. Navigate to Clusters -> Namespaces and open a different namespace B.
    3. Scroll to the Pods section.
    4. Verify that pods from namespace B are displayed.
    5. Return to a normal namespace-filtered resource list and verify that the
    original global namespace filter still applies.
    6. Open a Project Access tab whose namespaces do not overlap the global
    selection and verify its Role/RoleBinding rows remain visible.
    7. In Advanced Search, verify the displayed rows remain consistent with the
    reported result count regardless of the global namespace selection.

    Automated validation:

  • Focused tests: 30 passed

  • Full frontend suite: 235/235 files, 3120/3120 tests passed

  • npm run tsc

  • npm run lint

  • npm run format-check

  • git diff --check
  • Screenshots (if applicable)

    Not applicable.

    Notes for the Reviewer

  • This does not restore the namespace-filter reset approach from #5157.

  • The global namespace filter is not mutated or cleared.

  • ResourceListView now keeps the header and table aligned on the same effective

  • namespace-filter behavior, including callers that explicitly pass an
    undefined override value.
  • A custom ResourceTable.filterFunction continues to replace the default

  • filter exactly as before and owns its filtering semantics.
  • Textual/search filtering remains active when namespace filtering is bypassed.
  • Diff: 363 lines (+347 / -16) across 11 files Reviewer: illume Review duration: 135308m
    All Vouch review confidence checks passed
    Residual risk 0.13 = Change Risk (0.53) × (1 − Review Confidence (0.76)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.53 · 363 lines diff across 11 files
    0.53
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.52 · 5 substantive comment(s)
    0.52
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    75%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.353
    Real PR Conversation Timeline
    26 items
    kubernetes-prow[bot] kubernetes-prow[bot] commented on Aug 24, 2026 22:46 UTC
    Bot

    Welcome @dlanov! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes-sigs/headlamp'>kubernetes-sigs/headlamp</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation. <br><br>You can also check if kubernetes-sigs/headlamp has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs! <br><br>Thank you, and welcome to Kubernetes. :smiley:

    unlikelyzero unlikelyzero requested changes on Aug 24, 2026 23:29 UTC
    Changes Requested Reviewer

    A few things worth fixing before merge:

    1. ResourceListView.tsx:66 vs :80 — the table's namespace-filter bypass doesn't match the header's. The header uses noNamespaceFilter={!withNamespaceFilter} (falls back to a derived default based on resourceClass.isNamespaced), but the table only gets headerProps?.noNamespaceFilter === true, dropping that derived default entirely. For any ResourceListView used without a resourceClass (the plain data+columns overload) and no explicit headerProps.noNamespaceFilter, the namespace selector ends up hidden while the table still applies the stale global namespace filter to rows — reproducing the exact bug this PR is fixing, just for a different set of callers. Suggest computing the effective value once (headerProps?.noNamespaceFilter ?? !withNamespaceFilter) and using it for both the header and the table.

    2. ProjectDetails.tsx:378-390 — the Access tab's Role/RoleBinding tables have the same problem. They fetch with an explicit namespaces={project.namespaces} and render no namespace selector, but never pass noNamespaceFilter, so the global namespace filter still silently drops project-scoped rows if the global selection doesn't overlap the project's namespaces.

    3. ResourceSearch.tsx:269 — advanced search's result count can disagree with the table. The "Found N results" banner is computed before namespace filtering is applied to the table, so a stale global namespace selection can hide rows the banner says were found, with no selector on the page to explain why.

    4. Lower confidence: Resource.tsx:1828 — noSearch (previously purely cosmetic) now also feeds hideNamespaceFilter, giving it a real effect on which rows are shown. Today's only caller is safe, but it's an easy footgun for a future caller.

    5. Design note: a caller-supplied filterFunction fully bypasses noNamespaceFilter (ResourceTable.tsx:345), so any namespace-scoped view built with a custom filter function silently keeps the old (buggy) namespace-filtering behavior.

    dlanov dlanov commented on Aug 25, 2026 00:46 UTC
    Author

    Thanks for the review. Addressed the feedback in 053043b61:

    1. ResourceListView now computes one effective noNamespaceFilter value and passes the same value to both SectionFilterHeader and ResourceTable. I preserved the existing behavior for callers that explicitly pass a noNamespaceFilter key with an undefined value.
    2. Added noNamespaceFilter to the Project Access Role and RoleBinding tables so the project namespace scope is not further restricted by the global namespace filter.
    3. Added noNamespaceFilter to Advanced Search so the displayed rows remain consistent with the reported search-result count.
    4. I left the OwnedPodsSection noSearch behavior unchanged. Its current caller is namespace-scoped, and when the namespace selector is hidden, bypassing an unrelated global namespace filter is intentional here.
    5. I left custom filterFunction semantics unchanged: a caller-supplied filter continues to replace the default filter and owns its filtering behavior.

    Validation: focused tests 30/30; full frontend suite 235/235 files, 3120/3120 tests; tsc, lint, format-check, and git diff --check all pass.

    illume illume requested changes on Aug 29, 2026 05:43 UTC
    Changes Requested Reviewer

    <!-- prch:feedback -->
    Thanks for the contribution.

    <!-- prch:commit-guidelines -->
    Could you take a look at the commit messages in this PR? We follow a Linux kernel style for git commits — see the contributing guide and git log for examples.

    <details>
    <summary>Commits that need attention</summary>

  • frontend: address namespace filter review feedback — Description must start with a capital letter — e.g. frontend: HomeButton: Fix the button not frontend: HomeButton: fix the button.
  • </details>

    <details>
    <summary>Commit guidelines</summary>

  • Use atomic commits focused on a single change.

  • Use the title format <area>: <Description of changes> — description must start with a capital letter.

  • Keep the title under 72 characters (soft requirement).

  • Explain the intention and why the change is needed.

  • Make commit titles meaningful and describe what changed.

  • Do not add code that a later commit rewrites; squash or reorder commits instead.

  • Do not include Fixes #NN in commit messages.
  • Good examples:

  • frontend: HomeButton: Fix so it navigates to home

  • backend: config: Add enable-dynamic-clusters flag
  • </details>

    Copilot Copilot commented on code on Aug 29, 2026 05:46 UTC
    Code Review
    frontend/src/components/common/Resource/ResourceListView.tsx:1
    @@ -53,6 +55,17 @@ export default function ResourceListView(
       const withNamespaceFilter = 'resourceClass' in props && props.resourceClass?.isNamespaced;
       const resourceClass = (props as ResourceListViewWithResourceClassProps<any>)
         .resourceClass as KubeObjectClass;
    +  // A headerProps object with the noNamespaceFilter key present (even set to undefined,
    +  // as several renderers like Pod/Job do via `{ noNamespaceFilter, ...}` with an
    +  // undefined local variable) is an explicit override, matching how {...headerProps}
    +  // used to win over the derived header prop. Otherwise fall back to the resourceClass
    +  // signal, matching the header's previous default.
    +  const hasNoNamespaceFilterOverride =
    +    headerProps !== undefined &&
    +    Object.prototype.hasOwnProperty.call(headerProps, 'noNamespaceFilter');
    +  const noNamespaceFilter = hasNoNamespaceFilterOverride
    +    ? headerProps?.noNamespaceFilter === true
    +    : !withNamespaceFilter;

    Please clean up the commit history before merge. The second commit, frontend: address namespace filter review feedback, substantially rewrites the ResourceListView implementation/tests introduced by the first commit and has a vague, lowercase description. Squash the corrective work into the original commit (or otherwise reorder it) and use a meaningful <area>: <Description> title that explains the resulting change.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Aug 29, 2026 05:46 UTC
    Reviewer

    Pull request overview

    Fixes stale global namespace filters hiding rows in namespace-scoped tables without mutating global state.

    Changes:

  • Adds namespace-filter bypass support to default resource filtering.

  • Aligns ResourceListView header and table filtering behavior.

  • Covers Project Access and Advanced Search with regression tests.
  • CI build/lint checks passed; several test and platform checks remain in progress. Commit history cleanup is required.

    Reviewed changes

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

    <details>
    <summary>Show a summary per file</summary>

    | File | Description |
    | ---- | ----------- |
    | frontend/src/redux/filterSlice.ts | Supports bypassing namespace matching. |
    | frontend/src/redux/filterSlice.test.ts | Tests bypass and text filtering. |
    | frontend/src/lib/util.ts | Forwards the bypass option. |
    | frontend/src/components/project/ProjectDetails.tsx | Bypasses unrelated filters in Access tables. |
    | frontend/src/components/project/ProjectDetails.test.tsx | Verifies Access table configuration. |
    | frontend/src/components/common/Resource/ResourceTable.tsx | Exposes and applies noNamespaceFilter. |
    | frontend/src/components/common/Resource/ResourceTable.test.tsx | Tests table filtering and state preservation. |
    | frontend/src/components/common/Resource/ResourceListView.tsx | Shares effective filtering behavior. |
    | frontend/src/components/common/Resource/ResourceListView.test.tsx | Tests override semantics and wiring. |
    | frontend/src/components/advancedSearch/ResourceSearch.tsx | Prevents result-count filtering discrepancies. |
    </details>

    ---

    💡 <a href="/kubernetes-sigs/headlamp/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

    dlanov dlanov commented on code on Aug 29, 2026 12:41 UTC
    Code Review
    frontend/src/components/common/Resource/ResourceListView.tsx:1
    @@ -53,6 +55,17 @@ export default function ResourceListView(
       const withNamespaceFilter = 'resourceClass' in props && props.resourceClass?.isNamespaced;
       const resourceClass = (props as ResourceListViewWithResourceClassProps<any>)
         .resourceClass as KubeObjectClass;
    +  // A headerProps object with the noNamespaceFilter key present (even set to undefined,
    +  // as several renderers like Pod/Job do via `{ noNamespaceFilter, ...}` with an
    +  // undefined local variable) is an explicit override, matching how {...headerProps}
    +  // used to win over the derived header prop. Otherwise fall back to the resourceClass
    +  // signal, matching the header's previous default.
    +  const hasNoNamespaceFilterOverride =
    +    headerProps !== undefined &&
    +    Object.prototype.hasOwnProperty.call(headerProps, 'noNamespaceFilter');
    +  const noNamespaceFilter = hasNoNamespaceFilterOverride
    +    ? headerProps?.noNamespaceFilter === true
    +    : !withNamespaceFilter;

    Updated. I squashed the corrective commit into the original change, rebased onto the current main branch, and renamed the resulting single commit to frontend: ResourceTable: Ignore namespace filter when disabled. The PR now contains one commit.

    dlanov dlanov commented on Aug 29, 2026 12:41 UTC
    Author

    @illume Updated the commit history as requested. The PR is now a single commit, frontend: ResourceTable: Ignore namespace filter when disabled, rebased onto current main.

    Post-rebase validation: focused tests 30/30, tsc, lint, format-check, and git diff --check all pass.

    Copilot Copilot commented on code on Aug 29, 2026 15:37 UTC
    Code Review
    frontend/src/lib/util.ts:1
    @@ -315,17 +315,25 @@ export function getResourceMetrics(
      *
      * @returns A filter function that can be used to filter a list of items.
      * @param matchCriteria - The JSONPath criteria to match.
    + * @param ignoreNamespaceFilter - When true, the returned function ignores the global
    + *                                 namespace filter (textual/search filtering still applies).
      */
     export function useFilterFunc<
       T extends { [key: string]: any } | KubeObjectInterface | KubeEvent =
         | KubeObjectInterface
         | KubeEvent
    ->(matchCriteria?: string[]) {
    +>(matchCriteria?: string[], ignoreNamespaceFilter?: boolean) {

    The exported useFilterFunc API now accepts ignoreNamespaceFilter, but the committed generated page still documents only useFilterFunc(matchCriteria?) (docs/development/api/modules/lib_util.md:382-399). Repository guidance requires API-affecting changes to include regenerated output (docs/development/frontend.md:82-86). Please run npm run docs and commit the resulting API documentation updates so consumers can discover this parameter.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Aug 29, 2026 15:37 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

    illume illume requested changes on Aug 29, 2026 15:42 UTC
    Changes Requested Reviewer

    <!-- prch:feedback -->
    Thanks for the contribution.

    <!-- prch:copilot-comments -->
    There are some open Copilot review comments — could you take a look at them? Please mark each one as resolved once you've addressed it.

    dlanov dlanov commented on code on Aug 29, 2026 23:57 UTC
    Code Review
    frontend/src/lib/util.ts:1
    @@ -315,17 +315,25 @@ export function getResourceMetrics(
      *
      * @returns A filter function that can be used to filter a list of items.
      * @param matchCriteria - The JSONPath criteria to match.
    + * @param ignoreNamespaceFilter - When true, the returned function ignores the global
    + *                                 namespace filter (textual/search filtering still applies).
      */
     export function useFilterFunc<
       T extends { [key: string]: any } | KubeObjectInterface | KubeEvent =
         | KubeObjectInterface
         | KubeEvent
    ->(matchCriteria?: string[]) {
    +>(matchCriteria?: string[], ignoreNamespaceFilter?: boolean) {

    Addressed in 11aa0657d. I ran npm run docs, but the currently pinned TypeDoc toolchain attempts a repository-wide generated-docs layout migration (201 tracked files plus a new directory structure), while the checked-in API pages still use the legacy layout. To keep this PR scoped, I updated the existing generated lib_util.md page with the new ignoreNamespaceFilter parameter for both useFilterFunc and the re-exported filterResource API. git diff --check is clean.

    dlanov dlanov commented on Aug 29, 2026 23:59 UTC
    Author

    @illume Addressed the remaining Copilot API-doc feedback in 11aa0657d and resolved both addressed Copilot threads.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Sep 28, 2026 18:51 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟢 Approval recommended

    The implementation is coherent, regression-tested, documented, and all current-head CI checks pass.

    Review effort: Balanced
    Findings: None

    <details>
    <summary><strong>Resolved since last review (2)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> [The exported useFilterFunc API now accepts ignoreNamespaceFilter, but the committed generated…](#discussion_r3886970685)

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> [Please clean up the commit history before merge. The second commit, \`frontend: address namespace…](#discussion_r3885732954)

  • </details>

    illume illume requested changes on Oct 22, 2026 18:27 UTC
    Changes Requested Reviewer

    <!-- prch:feedback -->
    Thanks for working on this.

    <!-- prch:git-conflicts -->
    Looks like there are git conflicts in this PR. Can you fix them up?

    <details>
    <summary>How to resolve conflicts</summary>

    Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.

    </details>

    dlanov dlanov commented on Oct 23, 2026 18:16 UTC
    Author

    @illume Rebased onto current main (317ccc200) and resolved the conflicts, preserving the upstream changes. Local validation passed: 38 focused tests, TypeScript, lint, and formatting. CI is running on the updated commit.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 05, 2026 10:53 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟢 Approval recommended

    No active review issues are recorded for the namespace-filtering changes, although CI status was not available in the supplied context.

    No open issues 🎉

    <sub>Review effort: Balanced</sub>

    illume illume requested changes on Nov 23, 2026 23:32 UTC
    Changes Requested Reviewer

    <!-- prch:feedback -->
    Thanks for the contribution.

    <!-- prch:git-conflicts -->
    This PR has git conflicts — could you resolve them?

    <details>
    <summary>How to resolve conflicts</summary>

    Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.

    </details>

    dlanov dlanov commented on Nov 24, 2026 01:19 UTC
    Author

    @illume Rebased onto current main (24dffcd52) and resolved the ResourceListView conflicts while preserving both the newer upstream empty-state behavior and this PR's namespace-filter fix. Local validation passed: 61 focused tests, TypeScript, lint, formatting, and diff checks.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 25, 2026 14:58 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟢 Approval recommended

    No active review issues are identified for the namespace-filtering fix.

    No open issues 🎉

    <sub>Review effort: Balanced</sub>

    illume illume requested changes on Nov 25, 2026 18:28 UTC
    Changes Requested Reviewer

    <!-- prch:feedback -->
    Thanks for this PR.

    <!-- prch:git-conflicts -->
    There are git conflicts in this PR that need to be resolved.

    <details>
    <summary>How to resolve conflicts</summary>

    Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.

    </details>

    dlanov dlanov commented on Nov 26, 2026 14:16 UTC
    Author

    @illume Rebased again onto current main (b49841fcb) and resolved the ResourceListView test conflict, preserving the newer upstream empty-state tests and this PR's namespace-filter regression coverage. Local validation passed: 66 focused tests, TypeScript, lint, formatting, and diff checks.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 26, 2026 15:41 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟢 Approval recommended

    No active review issues are blocking approval of the namespace-filtering changes.

    No open issues 🎉

    <sub>Review effort: Balanced</sub>

    illume illume approved these changes on Nov 26, 2026 21:53 UTC
    Approved Reviewer

    🎉 thanks!

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Nov 26, 2026 21:53 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/headlamp/pull/7468#" title="Author self-approved">dlanov</a>, <a href="https://github.com/kubernetes-sigs/headlamp/pull/7468#pullrequestreview-6080893499" title="Approved">illume</a>

    The full list of commands accepted by this bot can be found here.

    The pull request process is described here

    <details >
    Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [illume]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Reviewers
    Assignees
    dlanov dlanov
    Labels
    risk: low confidence: 75.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.9% (MEDIUM) · Higher = larger blast radius
    52.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 75.6% · Lower = rushed or shallow review
    75.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 12.9% · Safe to merge
    12.9%