feat(web): add extensible command palette#1103
feat(web): add extensible command palette#1103binbandit wants to merge 9 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
| data-testid="command-palette" | ||
| > | ||
| <Command aria-label="Command palette" items={groups}> | ||
| <CommandInput placeholder="Search commands and threads..." /> |
There was a problem hiding this comment.
Is search still incoming? I don't see any code for that functionality and it doesn't appear to work on my end.
| await navigate({ | ||
| to: "/$threadId", | ||
| params: { threadId: thread.id }, |
There was a problem hiding this comment.
Not an issue with your code, but something I noticed. If this is done to a thread that is hidden beneath "view more", that section doesn't expand, so it ends up looking like no sidebar item is highlighted.
There was a problem hiding this comment.
Could you point me to how this was addressed? Still seems to be happening to me on the latest pull.
713d184 to
869181f
Compare
|
@binbandit Yours is obviously more of a strict command pallette than #1076, but it might be worth looking into. I also think that some of the ordering of actions could be slightly different and be a slightly better workflow. I have been playing with my own command pallette in a branch, and I think for me the best structure wasn't a strict Actions/Threads split, but was more like this:
I found that a lot of the "Actions" I initially had were actually pretty infrequently used, so I had to move down a lot to get to the stuff that I actually wanted. Especially stuff like "Settings", which should be very infrequently used, and can live at the very bottom of the list. Not saying this is objectively better, but it's what I found worked for me after I originally had basically the order you have. Happy to push up my branch if you wanna see what I mean. |
|
@Noojuno This is good feedback. Thanks. I was going to get this in, then allow for users to drag and drop in settings to re-organise the palette etc. Choose what they want to see etc. -- Was going to do this after so as to not bloat this pr. |
| { key: "mod+n", command: "terminal.new", when: "terminalFocus" }, | ||
| { key: "mod+w", command: "terminal.close", when: "terminalFocus" }, | ||
| { key: "mod+d", command: "diff.toggle", when: "!terminalFocus" }, | ||
| { key: "mod+k", command: "commandPalette.toggle", when: "!terminalFocus" }, |
There was a problem hiding this comment.
I think there's probably justification for triggering the command pallette even when the terminal is open. I doubt mod+k is gonna be a terminal keyboard shortcut, but I could see myself working in the terminal and wanting to navigate away and it being annoying to click out to focus the window
There was a problem hiding this comment.
Yeah true, this wasn't something i've considered, as I have previously seen the two as two different states of interaction.
- Working with the ai and the threads
- Working with the terminal and running additional commands rather than asking ai to do it.
There was a problem hiding this comment.
The main time I would run into it I think is if I'm working on two worktrees of the same thing (like T3 Code).
I will usually have my dev command running into the terminal on the worktree I was last testing, then I'll kill that command and want to navigate to the next worktree I need to check on and run the command there. Being able to Ctrl+K would be useful there (and also how I've been doing it in my command pallette branch)
| title: "New thread", | ||
| description: activeProjectTitle | ||
| ? `Create a draft thread in ${activeProjectTitle}` | ||
| : "Create a new draft thread", |
There was a problem hiding this comment.
I don't think this description adds much beyond clutter tbh. I don't think I'm getting more info than just the title, and we could compact the UI a bit by removing the descriptions that aren't needed.
If the title was just "New draft thread in ${activeProjectTitle}" I think it would be more compact overall
The desc is useful for the thread list though, with the project being the desc
| executeItem(item); | ||
| }} | ||
| > | ||
| <span className="flex size-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-muted/30"> |
That's fair, although honestly I feel like that level of customisation is probs overkill tbh. It could be useful, but I don't think I can think of a command pallette in an app where I can reorder sections, or a time where I have ever really looked for that option haha. |
| const descriptionParts = [ | ||
| projectTitle, | ||
| thread.branch ? `#${thread.branch}` : null, | ||
| thread.id === activeThread?.id ? "Current thread" : null, | ||
| ].filter(Boolean); |
There was a problem hiding this comment.
If my Tray PR is ever merged, I might "steal" this as our canonical "description" for a thread. Unless we expect this to change frequently as we iterate.
| {item.description ? ( | ||
| <span className="truncate text-muted-foreground/70 text-xs"> | ||
| {item.description} | ||
| </span> |
There was a problem hiding this comment.
Do we want to truncate the description? Would it ever get too long?
| value: `thread:${thread.id}`, | ||
| label: `${thread.title} ${projectTitle ?? ""} ${thread.branch ?? ""}`.trim(), | ||
| title: thread.title, | ||
| description: descriptionParts.join(" · "), |
There was a problem hiding this comment.
Using this character (or really any separator character) might not be super friendly to screen readers. Perhaps that could be fixed with ARIA.
|
@huxcrux ooft quality suggestions. Thank you! U wanna contribute them to own them? Reach out on discord and ill give you write access so then your name appears next to the feature 😄 |
|
Heyyy, nice work! We can close 1076 if you consider adding add project functionality with autocompletion here, I mean we can close it regardless 🤣 but I would really love that feature. |
do you want to contribute that feature of it? So then your work / recognition doesn't get lost? |
Would love to! The filesystem browse endpoint and autocomplete logic from #1076 should fit right in, commits in there are detailed so we could cherry pick the relevant pieces. I'll reach out on Discord. edit: @binbandit invite sent. |
| readonly items: ReadonlyArray<CommandPaletteItem>; | ||
| } | ||
|
|
||
| const CommandPaletteContext = createContext<CommandPaletteState | null>(null); |
There was a problem hiding this comment.
Any thoughts on moving this out into zustand to match (most of) the rest of the app state?
|
Added project browser to the command palette across contracts, server, WS transport, and frontend. How it works: "Add project" action opens browse mode with I suggest checking individual commits rather then final diff. thanks! @binbandit @Noojuno @huxcrux @nmggithub edit: will upload video shortly, obs is fighting me for some reason |
| const { setOpen } = useCommandPalette(); | ||
| const [query, setQuery] = useState(""); | ||
| const deferredQuery = useDeferredValue(query); | ||
| const isBrowsing = query.startsWith("/") || query.startsWith("~/") || query.startsWith("./"); |
There was a problem hiding this comment.
Maybe we should also have windows absolute path support. ex C:\code\repo?
I added one review already, but I have another. This might be nitpicking, but because path browsing is debounced by 200ms, pressing Enter before the results update can act on a stale path instead of the latest input. |



Summary
commandPalette.togglethrough contracts, server defaults, the sidebar trigger, and keybinding docsValidation
bun fmtbun lintbun typecheckbun run test -- src/keybindings.test.tsinpackages/contractsbun run test -- src/keybindings.test.tsinapps/serverbun run test -- src/keybindings.test.tsinapps/webbun run test:browser -- src/components/ChatView.browser.tsx -t "opens the command palette from the configurable shortcut and runs a command"inapps/webVisual
Note
Add extensible command palette to the web UI with filesystem browsing
CommandPaletteProviderandOpenCommandPaletteDialogin CommandPalette.tsx that lets users search and execute actions: new thread, open/add projects, jump to recent threads, and open settings.mod+ktocommandPalette.toggle(when not in terminal focus) via new keybinding infrastructure in both server and web client./,~/,./) backed by a newfilesystem.browseWebSocket RPC that returns up to 50 directory suggestions with Tab autocompletion.formatRelativeTimeutility.ChatViewand the chat route are suppressed.Macroscope summarized 7bc39e6.