Skip to content

fix(explorer): clear quick filter when goto jumps between resource types - #541

Merged
janosmiko merged 2 commits into
mainfrom
task/TASK-839
Jul 17, 2026
Merged

fix(explorer): clear quick filter when goto jumps between resource types#541
janosmiko merged 2 commits into
mainfrom
task/TASK-839

Conversation

@janosmiko

@janosmiko janosmiko commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • A quick filter committed on one resource list stayed active after switching to a different resource list, silently hiding every row in the destination.
  • All type-switch paths now share resetFilterForTypeSwitch: save the origin's filter for back-nav restore, then clear filter text/input, broad mode, preset state, and search highlight. Covered paths: regular descend, g-prefix goto chords (gd, gv, ...), the security-finding teleport, the per-resource findings view, and the port-forwards list. The last three previously leaked.
  • Deliberately no destination-filter restore: a type switch is a fresh start; only back-nav (navigateParent) recalls a saved filter. Bookmark jumps and session restore keep applying their own saved filters by design.

Test plan

  • TestGotoResourceType_ClearsQuickFilter (red before fix) + TestGotoResourceType_DoesNotRestoreDestinationFilter
  • filter_typeswitch_test.go: regular-nav pin + red-first leak tests for the finding teleport, findings view, and port-forwards paths
  • Broad-mode clear + save asserted (CodeRabbit review comments addressed)
  • go test -race ./... clean, golangci-lint run ./... 0 issues, go vet ./... clean

Tracked as Backlog TASK-839; also implements TASK-840 (jumpToFindingResource leak).

A committed quick filter stayed in m.filterText across a g-prefix goto
(e.g. gd from pods to deployments), silently hiding every row in the
destination list. gotoResourceType now mirrors the descend path's filter
bookkeeping: save the old level's filter for back-nav restore, then
start the destination clean (filter, preset, search highlight).

Closes TASK-839
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Navigation between resource types, security views, and the port-forwards pseudo-list now clears live quick-filter and search state while preserving the source filter for back-navigation. gotoResourceType also avoids restoring a saved destination filter. Added tests cover filter and input clearing, filter-state reset, pseudo-resource transitions, and saved-filter behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description has Summary and Testing, but it misses required template sections like Type of change, Related issue, Changes, Checklist, and Screenshots. Add the missing template sections, especially Type of change, Related issue, Changes, Checklist, and optional Screenshots/recordings, while keeping the Testing details.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: clearing quick filters when switching resource types.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/app/whichkey_test.go`:
- Around line 307-333: Extend the gotoResourceType test around the existing
filter-state assertions to set filterBroadMode before the jump, then verify it
is cleared on the destination model and preserved in filterMemory[oldKey] for
back-navigation restoration. Keep the existing checks for the other filter
fields unchanged.

In `@internal/app/whichkey.go`:
- Around line 103-115: Update the manual filter reset in gotoResourceType to
also set m.filterBroadMode to false, ensuring broad-mode state does not carry
into the destination resource type alongside the other cleared filter fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8943678e-2c58-44ba-b903-9b28a07ab9cd

📥 Commits

Reviewing files that changed from the base of the PR and between 15c4b51 and 539d8b8.

📒 Files selected for processing (2)
  • internal/app/whichkey.go
  • internal/app/whichkey_test.go

Comment thread internal/app/whichkey_test.go
Comment thread internal/app/whichkey.go Outdated
Comment on lines +103 to +115
// Mirror the descend path's filter bookkeeping: remember this level's
// committed filter for back-nav restore, then start the destination list
// clean so the old type's quick filter doesn't silently hide every row
// (TASK-839). Deliberately no restoreLevelFilter here — like a descend, a
// goto is a fresh start; only back-nav (navigateParent) recalls a saved
// filter.
m.saveLevelFilter()
m.filterText = ""
m.filterInput.Clear()
m.filterActive = false
m.activeFilterPreset = nil
m.unfilteredMiddleItems = nil
m.searchInput.Clear()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear filterBroadMode to fully reset the quick filter state.

Since gotoResourceType manually clears the filtering state to provide a fresh start (deliberately skipping restoreLevelFilter), it should also explicitly reset m.filterBroadMode = false. Otherwise, if the broad filter mode (e.g., the Tab toggle) was active on the old resource type, it will leak to the destination level and unexpectedly apply when the user types a new filter.

🐛 Proposed fix
 	m.saveLevelFilter()
 	m.filterText = ""
 	m.filterInput.Clear()
 	m.filterActive = false
+	m.filterBroadMode = false
 	m.activeFilterPreset = nil
 	m.unfilteredMiddleItems = nil
 	m.searchInput.Clear()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Mirror the descend path's filter bookkeeping: remember this level's
// committed filter for back-nav restore, then start the destination list
// clean so the old type's quick filter doesn't silently hide every row
// (TASK-839). Deliberately no restoreLevelFilter here — like a descend, a
// goto is a fresh start; only back-nav (navigateParent) recalls a saved
// filter.
m.saveLevelFilter()
m.filterText = ""
m.filterInput.Clear()
m.filterActive = false
m.activeFilterPreset = nil
m.unfilteredMiddleItems = nil
m.searchInput.Clear()
// Mirror the descend path's filter bookkeeping: remember this level's
// committed filter for back-nav restore, then start the destination list
// clean so the old type's quick filter doesn't silently hide every row
// (TASK-839). Deliberately no restoreLevelFilter here — like a descend, a
// goto is a fresh start; only back-nav (navigateParent) recalls a saved
// filter.
m.saveLevelFilter()
m.filterText = ""
m.filterInput.Clear()
m.filterActive = false
m.filterBroadMode = false
m.activeFilterPreset = nil
m.unfilteredMiddleItems = nil
m.searchInput.Clear()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/app/whichkey.go` around lines 103 - 115, Update the manual filter
reset in gotoResourceType to also set m.filterBroadMode to false, ensuring
broad-mode state does not carry into the destination resource type alongside the
other cleared filter fields.

UAT feedback on the goto fix: the filter must start clean on any path
that lands on a different resource list, not just g-prefix chords.

Extract the save-then-clear bookkeeping into resetFilterForTypeSwitch
and use it on every type-switch path: regular descend (navigateChild),
goto chords, the security-finding teleport, the per-resource findings
view, and the port-forwards list. The last three previously leaked the
origin list's filter. Broad-match mode now also clears (and is saved
for back-nav restore), per CodeRabbit review.

Bookmark jumps and session restore intentionally keep applying their
own saved filters.
@janosmiko

Copy link
Copy Markdown
Owner Author

@coderabbitai Both review comments are addressed in e1d74ac: the filter reset (now the shared resetFilterForTypeSwitch helper) clears filterBroadMode, and the goto test asserts broad mode is cleared on the destination and preserved in filterMemory for back-nav restore.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@janosmiko Thanks for addressing both points. Clearing filterBroadMode in resetFilterForTypeSwitch and covering both destination reset and back-navigation preservation in the goto test resolves the concerns.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@janosmiko
janosmiko merged commit 4222cbf into main Jul 17, 2026
9 checks passed
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.

1 participant