feat: slash command palette in chat composer#21
Open
NOirBRight wants to merge 3 commits into
Open
Conversation
- /api/commands endpoint serves command list (static defaults + dynamic from ~/.pi/agent/pi-web/commands.json) - Command palette JS module: shows suggestions when typing /, filters as you type, arrow key navigation, Enter/Tab to select, Escape to dismiss - Portal-based positioning: palette appended to document.body with fixed positioning to escape parent stacking contexts - CSS themed with var(--container-bg), var(--dim), var(--accent) - pi-web extension writes commands.json on load (with 3s delay for other extensions to register) and refreshes every 5 minutes - 29 default commands including /compact, /clear, /model, /gsd-* Co-authored-by: noirbright <noirbright@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a command palette to the pi-web chat composer that shows slash command suggestions when the user types
/in the chat input.Changes
Backend (
internal/server/)commands.go: New/api/commandsendpoint returning JSON array of{name, description}objects. Reads from~/.pi/agent/pi-web/commands.jsonif available, falls back to 8 built-in defaults.commands_test.go: Tests for GET handler, POST rejection, file-based loading, and fallback to defaults.server.go: Register/api/commandsroute.Frontend (
web/src/session/chat/)command-palette.js: New module —setupCommandPalette()that:/api/commands(5-min cache, eager load)/is typed, filters as user continues typingdocument.bodywithposition: fixedandz-index: 99999to escape parent stacking contextsgetBoundingClientRect()command-palette.test.js: 5 tests covering null input, fetch, filter, hide, and selection.chat-composer-runner.js: Import and callsetupCommandPaletteForSession()during init.Styling (
internal/ui/live_templates/styles/session.css)var(--container-bg),var(--dim),var(--accent),var(--text),var(--muted)max-heightvia@media (max-height: 600px)Extension (
.pi/extensions/pi-web.ts)pi.getCommands()after a 3-second delay (to allow other extensions to register), then writescommands.jsonfor the Go server to read. Refreshes every 5 minutes.How to test
/in the chat input — command suggestions should appear above the input/com→ shows/compact)Screenshots
Command palette showing filtered suggestions above the chat input, correctly layered above all UI elements.