Skip to content

feat: Added command palette for quick actions and switching between items#2933

Merged
antsgar merged 17 commits into
mainfrom
wip-command-palette
Sep 25, 2025
Merged

feat: Added command palette for quick actions and switching between items#2933
antsgar merged 17 commits into
mainfrom
wip-command-palette

Conversation

@amanharwara

Copy link
Copy Markdown
Member
command-palette image

@amanharwara
amanharwara requested a review from antsgar September 2, 2025 06:08

@antsgar antsgar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@amanharwara this is such great work! I absolutely love it and I'm sure users will too, thank you for implementing it (and having such a great idea) ❤️

A few quirks I noticed:

  • This is a weird one, for some reason the "Archive note" option doesn't seem to be moved to the "Recents" section once used.
  • The command palette doesn't overlay all the dropdowns/modals it opens. E.g. if you open the command palette, choose "Change editor width", this opens up a modal. If you then trigger the command palette again without closing the modal, the palette will show up underneath it.
  • Kinda related to the above. Since the command palette is triggered by the keyboard, the modals/dropdowns that get open by commands don't get closed if you trigger the palette again. This means if you for example click "Open account menu", the dropdown shows up, you don't close it and you trigger the palette again and choose "Open quick settings menu" you get both dropdowns open at the same time. Could we somehow resemble the "click outside" scenario when triggering the palette or would this be complex to do?

This is totally subjective and not important but I was wondering about the reason behind choosing "Cmd+Shift+;" as the shortcut for the command palette. Did you consider "Cmd+Shift+P"? I find that one more intuitive just because it's what VSCode uses, but don't know if that's actually common on other apps as well.

Comment thread packages/web/src/javascripts/Application/Recents.ts Outdated
Comment thread packages/web/src/javascripts/Application/Recents.ts Outdated
Comment thread packages/web/src/javascripts/Components/CommandPalette/CommandPalette.tsx Outdated
Comment thread packages/web/src/javascripts/Components/CommandPalette/CommandPalette.tsx Outdated
@amanharwara

Copy link
Copy Markdown
Member Author

This is a weird one, for some reason the "Archive note" option doesn't seem to be moved to the "Recents" section once used.

Just realized that that seems to be an issue with any of the "_ current note" reasons since we store recent commands' uuids and not objects. Basically, we dispose and re-add the "_ current note" commands when the selected note(s) changes and so the uuid of the command that is stored in the recents state returns undefined when the command palette tries to get the actual command object since the re-added commands will have a newly-generated uuid.
If we add a way for the add command function to take in a stable id, then that would fix the issue partly. That would still cause the same issues for commands that aren't re-added, e.g. if you "pin current note" then only "unpin current note" command will be re-added which will cause the uuid for "pin" stored in recents to be "invalidated". I made it this way to have similar behavior to the notes options menu where for example it only shows "Pin" if none of the selected notes are pinned. We could change it to always add all the options along with the "stable id" change.
I thought of maybe storing the commands directly in the recents but that doesn't work because of how closures work. For e.g. if you use "Pin current note" and then go to another unpinned note and use "Pin .." but from the recents this time, it doesn't work, probably because the handler function closes over old state.

This is totally subjective and not important but I was wondering about the reason behind choosing "Cmd+Shift+;" as the shortcut for the command palette. Did you consider "Cmd+Shift+P"? I find that one more intuitive just because it's what VSCode uses, but don't know if that's actually common on other apps as well.

Different apps seem to have different ones. Github and Discord for e.g. use Cmd/Ctrl+K. I was initially going to use Cmd/Ctrl+Shift+P but it seems like that's already being used as the shortcut for PIN_NOTE_COMMAND and I didn't want to end up changing existing shortcuts. Although from what I can tell pressing that shortcut doesn't seem to actually pin/unpin the note, its broken even on main. So maybe might be better to just use that for the command palette instead.

@antsgar

antsgar commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

@amanharwara oooh super interesting to know why the Archive (and other) options weren't showing up in Recents properly! Yeah perhaps we could just use regular strings as IDs for the commands as opposed to UUIDs, since they're limited in nature and we define the exhaustive list of commands available?

As for the shortcut I don't think it's a huge deal either way, was just wondering! In my case Cmd+Shift+P does seem to be working properly to pin the note. Perhaps it's best that we keep the existing commands unchanged as you mentioned just in case users are already used to them.

@amanharwara
amanharwara requested a review from antsgar September 23, 2025 19:06
@antsgar
antsgar merged commit efba7c6 into main Sep 25, 2025
5 of 7 checks passed
@antsgar
antsgar deleted the wip-command-palette branch September 25, 2025 13:06
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.

2 participants