-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add commands for navigation of alerts #1568
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks for creating this PR. I think there are several functions in result-keys.ts
that can be removed. And I have not tried this myself, but I will soon.
Thanks for the quick review @aeisenberg! I wasn't expecting reviews while the PR is in draft state, as I'd like to get some more feedback on the UI, but I'm happy to iterate on it if you're OK with the scope of the PR changing along the way. In particular, I'm not 100% convinced these commands are actually right. I feels a little off to have two different set of key bindings for moving up/down in different parts of the alert view. It's possible we want to change the commands to be more general "move left/right/up/down". Like the arrow keys in a common tree-view, with the caveat that moving up/down shouldn't leave the current level (moving down past the last path step should not skip over to the next path - that would be annoying). |
Nice 💪
When thinking about this, I feel like it would work OK, but without having tried it I guess it's hard to really say. Is your feeling about annoyance based on having tried it and it being bad, or from your intuitive feeling? |
I've pushed another commit that changes the commands to left/right/up/down behaviour. On my machine I bound the keys to cmd+shift+{I,J,K,L} in a WASD-like pattern. Personally I like this a bit better, but I'd be very interested in feedback about how this works for others. The internal command ID for up/down is |
We register a handler for the old command ID, but do not mention it in package.json. This seems to be backward compatible without polluting the command palette.
After using this for a few days I noticed some quirky behaviour when stepping down while a node was expanded. I pushed another commit to collapse the previous node when stepping up or down. Perhaps it's best if I keep using it for a few more days before moving ahead. |
I've tried out the navigation in this PR, and overall I'm a big fan. Especially for quick evaling predicates, being able to move left/right for columns is amazing! However, for Suggestion: When you expand an alert, could you be taken directly to the first path-step of the first path? -- at least if there is only one path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's really neat. It works great for me. I have a handful of small comments.
If we are not going to bind the new commands to key shortcuts by default, then we should update the README with some instructions on how to do it manually. Perhaps it would fit after the ### Running a query
section.
|
||
/** | ||
* Looks up a specific result in a result set. | ||
*/ | ||
export function getResult(sarif: sarif.Log, key: Result): sarif.Result | undefined { | ||
export function getResult(sarif: sarif.Log, key: Result | Path | PathNode): sarif.Result | undefined { | ||
if (sarif.runs.length === 0) return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: The body of this function can be replaced with this:
return sarif.runs?.[0]?.results?.[key.resultIndex];
It's really outside the scope of this PR, but it's a minor readability improvement if you want to add it.
Document the changes in this PR: github/vscode-codeql#1568
Co-authored-by: Andrew Eisenberg <[email protected]>
Co-authored-by: Andrew Eisenberg <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor change in command name, and then it looks good.
Thanks for the feedback @RasmusWL
Yeah the same thing happened to me, and I also tried various ways of skipping over the 'path' layer. But it never felt right. It generates that uncanny feeling where the UI tries to be really smart, but then becomes less predictable and less consistent with other UI components. My take is that the current version is something you can get used to, and then it stops being annoying, whereas the other one will always feel a little off. |
I updated the PR description to match the current behavior. |
I want this feature more than I want to discuss it, so although I'm not 100% convinced I will learn this, I say we ship it 🚢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm feeling good about this. I think this will be a nice change. I still think we can add some more documentation for this. We can either expand the readme, or put it into the codeql extension docs on the codeql microsite.
But, that could be done later. Nice work.
Feel free to merge when you're ready.
Thanks @aeisenberg! It seems I'm not authorized to merge in this repo. Can you trigger the merge? |
Some time ago I added commands for navigating the steps on a path, but didn't add commands for navigating between alerts - this PR does that.
This PR adds the commands:
CodeQL: Navigate Up in Local Result Viewer
CodeQL: Navigate Down in Local Result Viewer
CodeQL: Navigate Left in Local Result Viewer
CodeQL: Navigate Right in Local Result Viewer
The intent is that you can bind keyboard shortcuts to these commands to navigate alerts with the keyboard.
When viewing 'raw' results, such as from quick-eval, the alert-navigation commands move between rows and columns.
When viewing alerts, the left/right commands instead move into or out of nesting levels of tree view:
There are no commands for clicking the individual links in an interpreted alert message, but you can sort of achieve this by viewing the
#select
result set as a raw result table.Checklist
ready-for-doc-review
label there.