Add session commands, auth picker, and completion#191
Add session commands, auth picker, and completion#191OmarMcAdam merged 6 commits intodifferent-ai:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive command support to the session prompt interface, including provider authentication, model selection, agent management, and session operations. It introduces a provider auth picker modal to simplify authentication flows and implements command autocomplete with keyboard navigation. Sessions are now sorted by activity timestamp for better UX.
Changes:
- Added six new session commands:
/model,/connect,/auth,/agent,/save, and/rename - Implemented command autocomplete with arrow key/Tab navigation and Enter-to-execute
- Added provider authentication modal with OAuth/API key method display
- Implemented session sorting by activity (updated/created timestamps)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/desktop/src/app/pages/session.tsx | Added command handlers, autocomplete logic, provider auth modal integration, and helper functions for command argument extraction |
| packages/desktop/src/app/demo-state.ts | Added session sorting by activity and demo session rename functionality |
| packages/desktop/src/app/context/session.ts | Implemented session activity sorting utilities and remote session rename function |
| packages/desktop/src/app/components/provider-auth-modal.tsx | New modal component for selecting and authenticating providers with OAuth/API key indicators |
| packages/desktop/src/app/app.tsx | Added state management, API functions for auth/agent/save/rename operations, and integration with session view |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| if (!candidate) { | ||
| setCommandToast("Agent name is required"); |
There was a problem hiding this comment.
Missing clearPrompt() call when agent name is required. When the candidate agent name is empty (line 473-475), the command shows a toast but doesn't clear the prompt. This is inconsistent with other error paths in commands which typically clear the prompt. Consider adding clearPrompt() after the toast message for consistency.
| setCommandToast("Agent name is required"); | |
| setCommandToast("Agent name is required"); | |
| clearPrompt(); |
| (agent) => agent.name.toLowerCase() === candidate.toLowerCase(), | ||
| ); | ||
| if (!match) { | ||
| setCommandToast(`Unknown agent. Available: ${formatListHint(agentNames)}`); |
There was a problem hiding this comment.
Missing clearPrompt() call when agent is unknown. When an agent is not found (line 481-483), the command shows a toast but doesn't clear the prompt. This is inconsistent with other error paths in commands which typically clear the prompt. Consider adding clearPrompt() after the toast message for consistency.
| setCommandToast(`Unknown agent. Available: ${formatListHint(agentNames)}`); | |
| setCommandToast(`Unknown agent. Available: ${formatListHint(agentNames)}`); | |
| clearPrompt(); |
| } | ||
|
|
||
| if (!nextTitle) { | ||
| setCommandToast("Session name is required"); |
There was a problem hiding this comment.
Missing clearPrompt() call when session name validation fails. When the session title is empty after trimming (line 531-533), the command shows a toast but doesn't clear the prompt. This is inconsistent with other error paths in commands which typically clear the prompt. Consider adding clearPrompt() after the toast message for consistency.
| setCommandToast("Session name is required"); | |
| setCommandToast("Session name is required"); | |
| clearPrompt(); |
| try { | ||
| const providerId = extractCommandArgs(props.prompt); | ||
| if (providerId) { | ||
| const message = await props.startProviderAuth(providerId || undefined); |
There was a problem hiding this comment.
Redundant condition in the auth command. Line 423 extracts providerId from the command args, and line 425 evaluates providerId || undefined. However, if providerId is truthy (line 424's condition), then providerId || undefined will always be providerId, making the || undefined part unnecessary. This should be simplified to just pass providerId.
| const message = await props.startProviderAuth(providerId || undefined); | |
| const message = await props.startProviderAuth(providerId); |
| if (event.key === "Enter") { | ||
| event.preventDefault(); | ||
| const active = matches[commandIndex()]; | ||
| if (active) { | ||
| applyCommandCompletion(active.id); | ||
| runCommand(active.id); | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
The Enter key handling logic appears redundant. Lines 665-673 handle Enter when the command menu is open by applying the completion and running the command. However, lines 676-679 also handle Enter (after the menuOpen condition block), which calls handlePrimaryAction. The handlePrimaryAction function (lines 613-624) already contains logic to handle command menu execution. This creates duplication where Enter in the command menu context is handled twice - once explicitly here and once through handlePrimaryAction. Consider removing lines 665-673 and relying solely on the handlePrimaryAction logic for consistency.
| if (event.key === "Enter") { | |
| event.preventDefault(); | |
| const active = matches[commandIndex()]; | |
| if (active) { | |
| applyCommandCompletion(active.id); | |
| runCommand(active.id); | |
| return; | |
| } | |
| } |
|
|
||
| const agents = await props.listAgents(); | ||
| if (!agents.length) { | ||
| setCommandToast("No agents available"); |
There was a problem hiding this comment.
Missing clearPrompt() call when no agents are available. When the agent list is empty (line 458-460), the command shows a toast but doesn't clear the prompt input. This is inconsistent with other error paths in commands which typically clear the prompt. Consider adding clearPrompt() after the toast message for consistency.
| setCommandToast("No agents available"); | |
| setCommandToast("No agents available"); | |
| clearPrompt(); |
|
@Golenspade wow that looks great. Will look a bit deeper and test and report back. But really appreciate the direction. |
# Conflicts: # packages/app/src/app/components/provider-auth-modal.tsx
6302150 to
9c22d56
Compare
Summary
/model,/connect,/auth,/agent,/save, and/renamecommand support in the session prompt.Testing
pnpm --filter @different-ai/openwork typecheckpnpm --filter @different-ai/openwork test:e2e