Preserve Filter State When Navigating History
Description:
K9s currently supports navigating back ([) and forward (]) through view history. However, when switching between views (e.g., from Pods to Services) and then using the back command, K9s does not restore the previous filter state applied in the Pods view. Instead, it resets to an unfiltered view.
It would be helpful if K9s remembered and restored the filter state when navigating back/forward in history. This would allow users to seamlessly return to their previous context without needing to reapply filters manually.
Use Case:
1. A user filters the Pods view to show only a specific subset of pods.
2. They navigate to the Services view.
3. They press [ to go back to the Pods view.
4. Expected behavior: The filtered state is restored.
5. Current behavior: The filter is lost, and the Pods view resets.
@tyzbit
Hi, I like this idea!
When I implemented navigation, I considered but omitted this feature to keep complexity down and hopefully get the feature into hands quicker and also because I wasn't confident this would be functionality every user would want implemented this way. I'd prefer to give users choice or make intelligent, reasonable decisions for them and I wanted the project to have feedback like this to inform what's best for k9s for everyone.
As an aside, you don't need to ping me or other contributors on features they've added. I've only submitted a couple PRs to k9s as a hobbyist - others could come in and try to implement this feature without me, or if they had questions they could ask me then. Thank you!
Noted on the pinging. I just wanted to acknowledge your previous work, but I’ll keep that in mind going forward.
Since this seems like a great feature and no one else has picked it up to work on, I'll start working on it (especially since I would appreciate this feature too 😀)
I'll probably implement it as "preserve filter when paging back and forth by default" and if a further feature request comes for configurable behavior, I'll add that option to the config then to be conservative with adding config complexity.
Is this issue being worked on?
Yes, but I'm stuck. I need to access the filter history at a point in the code where accessing it requires doing stuff that doesn't seem right. I asked a question in the Slack about it but didn't get any response.
I took another crack at it and I'm still struggling. I've managed to get the filter when I need to but being able to set it seems to be missing or buried deep in the variables I have available in lastCommand() and others.
Opened a PR that adds this feature. I went down a lot of rabbit holes before finding the obvious, easy answer.
Nice, BTW this is also the case when you jump to the owner of the resource.
Let's say:
Pod -> ReplicaSet -> Deployment
And you Esc out of Deployment view, you will land back on Pod not ReplicaSet.
This seems like an issue with how k9s renders the views
Seems like a change recently that's causing all this, we should track back the PRs
It sounds like you're reporting an issue? This is a feature request regarding preserving filters while using history navigation. Can you open a new issue for that?
Submitted a PR https://github.com/derailed/k9s/pull/3519
This issue is stale because it has been open for 30 days with no activity.