Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): add history navigation with [ and ], most recent command with - #2799

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tyzbit
Copy link
Contributor

@tyzbit tyzbit commented Jul 19, 2024

Go Back walks back through the history until at the oldest saved view

Last View switches between the current and previous views like how "cd -" works

EDIT: New description for the features

  • Use square brackets [ and ] to navigate the command history back [ and forward ].
  • Use the minus/dash key - to switch between the current screen and the last one.

Example
While on the pod screen, type :service and enter. Hitting [ then brings you back to the pod screen. Hitting ] brings you forward in your history to the service screen. Type :ingress and hit enter (you are taken to the Ingresses screen), then hit -, you will go back to the service screen. Hit - again and you will go back to the Ingresses screen.

@tyzbit tyzbit changed the title feat(app): add Previous View and Go Back feat(app): add Go Back and Last View Jul 19, 2024
@tyzbit tyzbit force-pushed the tyzbit/quick-return branch 2 times, most recently from be13aa3 to f6bff90 Compare July 19, 2024 04:07
@tyzbit tyzbit marked this pull request as draft July 19, 2024 15:33
@tyzbit tyzbit marked this pull request as ready for review July 19, 2024 15:49
@tyzbit tyzbit marked this pull request as draft July 19, 2024 18:28
@tyzbit tyzbit marked this pull request as ready for review July 19, 2024 20:31
@tyzbit
Copy link
Contributor Author

tyzbit commented Aug 5, 2024

Closes #1786 and #869

Features from these requests not included are:

  • It is not possible to go forward again through the history. If you go back, the very last view you were on is removed from the history. - doesn't remove anything from history, just rearranges it. This is no longer true, the history now retains previous commands.
  • There is no overview to let you see the history and pick a specific view from it.

This PR implements the most powerful parts of the feature requests. Better navigation and richer history could be added later while keeping this functionality intact.

Supersedes #1090

internal/view/app.go Outdated Show resolved Hide resolved
internal/view/app.go Outdated Show resolved Hide resolved
@KevinGimbel
Copy link

Tested the feature locally and I have some questions:

  • When I look at containers (Select Pod -> Enter) I cannot go back to the pods with - or b
  • Same when using Describe (d)

Is this intended? I assume these "views" are somehow different from the generic Object views (Pod, StatefulSet, Deployment, ...)?

In general I really like this feature! Especially - seems useful! Thank you @tyzbit!

@tyzbit
Copy link
Contributor Author

tyzbit commented Aug 7, 2024

I would defer to someone more familiar with the codebase but Views seem to correlate mostly with Kubernetes resources (with the exception of contexts). Maybe the most accurate way to define them is the screens you get when you use a command (e.g. :pods).

When you dive into a resource, you get a trail of breadcrumbs at the bottom.

image

For demonstration, I went to pods, namespaces and then deployments and then selected a Deployment and hit Enter to go to the Pod, then hit enter again to go to the container, then I checked the cmdHistory:

image

k9s doesn't add breadcrumb-related navigation to the command history at the present time.

In terms of addressing the difference in expectations, maybe I could update the documentation and help to clarify that Go Back and Last View only work with k8s resources and contexts?

@KevinGimbel
Copy link

In terms of addressing the difference in expectations, maybe I could update the documentation and help to clarify that Go Back and Last View only work with k8s resources and contexts?

I think that's a good idea, just to make it clear what to expect from the feature 👍

@tyzbit
Copy link
Contributor Author

tyzbit commented Aug 9, 2024

I updated the README.

@KevinGimbel
Copy link

Thanks!

One tiny remark:

Your commit changed all * to - for lists - I assume some plugin or editor configuration on your side is making these changes? It makes reviewing the actual code changes hard, and I wonder if future changes will revert this due to different editor configs.

My 2ct would be to revert these style-changes so only the new documentation is added, but I guess @derailed has the final call here :)

Go Back walks back through the history until at the oldest saved view

Last View switches between the current and previous views like how "cd -" works
@tyzbit
Copy link
Contributor Author

tyzbit commented Aug 12, 2024

@KevinGimbel those formatting changes were not intentional, I've changed my settings so it doesn't happen again. While I was at it, I squashed my commits.

@KevinGimbel
Copy link

@tyzbit thank you! Looks good to me now. @derailed in my opinion this could be added to the next released :)

Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

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

@tyzbit Nice work! Good concept. Just a few items to clean up and simplify.

README.md Outdated Show resolved Hide resolved
internal/view/app.go Outdated Show resolved Hide resolved
internal/view/app.go Outdated Show resolved Hide resolved
internal/view/app.go Outdated Show resolved Hide resolved
internal/model/history.go Outdated Show resolved Hide resolved
@derailed derailed added enhancement New feature or request question Further information is requested labels Aug 15, 2024
@tyzbit
Copy link
Contributor Author

tyzbit commented Sep 13, 2024

Thank you for the great feedback. I'm working on addressing the comments; some planned changes:

  • Navigate history with [ and ] instead of B (I prefer this over < and > because it is not necessary to hold shift)
  • Add a view to see your history visually and pick a specific point in the history to go to. I think this will aid greatly in training users in using the new features.
  • cmdHistory will keep a more accurate history of your commands such as saving the last command used as well as the current command (therefore duplicates are possible and the assumption that history[0] is the current command will be broken, requiring some other updates)

@tyzbit tyzbit changed the title feat(app): add Go Back and Last View feat(app): add history navigation with [ and ], most recent command with - Sep 24, 2024
@tyzbit
Copy link
Contributor Author

tyzbit commented Sep 24, 2024

I've implemented history navigation via [ and ] and switching to the last command using -. Right now, they're pretty similar because your last view will either be back one in the history or forward one, but I still plan to add a history page that lets you select a specific command out of your history - at that time, lastCommand will be much more useful. I opened #2895 to track that so as of this time, this PR is complete and all previous issues addressed.

@merusso
Copy link

merusso commented Oct 28, 2024

@derailed , any thoughts on this PR? Anything else needed to merge this?

@saiskee
Copy link

saiskee commented Nov 4, 2024

As someone that often uses k9s in live demos, this would be a godsend!! @tyzbit Thank you so much for implementing this, and @derailed is there anything that is blocking this from going in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants