mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat(commands): align built-in slash commands with OpenCode v2
Replace the split built-in command name list and switch with one typed registry, so a registered command without a handler is a compile error. Remove the broken themes/share/unshare/editor entries and the hardcoded init; server and custom commands now win on a name clash and built-ins dispatch by registry identity. Add /copy, /btw, /rename, /fork (message picker), /timeline, /model, /agent, /variants, /mcp, /skills, /settings and /connect. Open the model picker through state so /model and the select-model shortcut work while a response is running, load full session history in the fork picker, and keep attachments when a built-in command is submitted. Extract shared clipboard and primary-agent helpers, reuse CopyButton in the manager token settings, and update the Quick Start and chat docs.
This commit is contained in:
1 parent
7cac8baade
commit
7e93eb4c34
35 files changed
+2291
-767
No files matched your search
@@ -87,3 +87,38 @@ describe('ModelQuickSelect theme tokens', () => {
|
||||
expect(findDarkOnlyClassOffenders(dialog)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('ModelQuickSelect controlled open', () => {
|
||||
it('uses the controlled open prop as the source of truth', () => {
|
||||
const onOpenChange = vi.fn()
|
||||
const { rerender } = render(<ModelQuickSelect open={false} onOpenChange={onOpenChange} />)
|
||||
|
||||
expect(screen.queryByRole('dialog', { name: 'Select model' })).not.toBeInTheDocument()
|
||||
|
||||
rerender(<ModelQuickSelect open onOpenChange={onOpenChange} />)
|
||||
|
||||
expect(screen.getByRole('dialog', { name: 'Select model' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders only the sheet without a trigger when no children are provided', () => {
|
||||
render(<ModelQuickSelect open />)
|
||||
|
||||
expect(screen.getByRole('dialog', { name: 'Select model' })).toBeInTheDocument()
|
||||
expect(document.querySelector('[data-model-select-trigger]')).toBeNull()
|
||||
})
|
||||
|
||||
it('resets the internal navigation state when the sheet is closed through the component', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onOpenChange = vi.fn()
|
||||
render(<ModelQuickSelect open onOpenChange={onOpenChange} />)
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /More models/ }))
|
||||
expect(screen.getByPlaceholderText('Search providers...')).toBeInTheDocument()
|
||||
|
||||
await user.keyboard('{Escape}')
|
||||
|
||||
expect(onOpenChange).toHaveBeenCalledWith(false)
|
||||
expect(screen.getByRole('button', { name: /More models/ })).toBeInTheDocument()
|
||||
expect(screen.queryByPlaceholderText('Search providers...')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
@@ -18,7 +18,9 @@ import type { Model, Provider } from '@/api/providers'
|
||||
interface ModelQuickSelectProps {
|
||||
directory?: string
|
||||
disabled?: boolean
|
||||
children: React.ReactNode
|
||||
children?: React.ReactNode
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
}
|
||||
|
||||
interface ModelListItem {
|
||||
@@ -189,8 +191,11 @@ export function ModelQuickSelect({
|
||||
directory,
|
||||
disabled,
|
||||
children,
|
||||
open,
|
||||
onOpenChange,
|
||||
}: ModelQuickSelectProps) {
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
const [internalIsOpen, setInternalIsOpen] = useState(false)
|
||||
const isOpen = open ?? internalIsOpen
|
||||
const [showAllModels, setShowAllModels] = useState(false)
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const deferredSearchQuery = useDeferredValue(searchQuery)
|
||||
@@ -416,13 +421,16 @@ export function ModelQuickSelect({
|
||||
setSelectedProviderId(null)
|
||||
}
|
||||
|
||||
const handleOpenChange = (open: boolean) => {
|
||||
setIsOpen(open)
|
||||
if (!open) {
|
||||
const handleOpenChange = (nextOpen: boolean) => {
|
||||
if (open === undefined) {
|
||||
setInternalIsOpen(nextOpen)
|
||||
}
|
||||
if (!nextOpen) {
|
||||
setShowAllModels(false)
|
||||
setSearchQuery('')
|
||||
setSelectedProviderId(null)
|
||||
}
|
||||
onOpenChange?.(nextOpen)
|
||||
}
|
||||
|
||||
const handleProviderSelect = (providerID: string) => {
|
||||
@@ -567,9 +575,11 @@ export function ModelQuickSelect({
|
||||
|
||||
return (
|
||||
<>
|
||||
<span onClick={() => !disabled && handleOpenChange(true)} data-model-select-trigger>
|
||||
{children}
|
||||
</span>
|
||||
{children && (
|
||||
<span onClick={() => !disabled && handleOpenChange(true)}>
|
||||
{children}
|
||||
</span>
|
||||
)}
|
||||
<BottomSheet
|
||||
isOpen={isOpen}
|
||||
onClose={() => handleOpenChange(false)}
|
||||
|
||||
Reference in new issue
Block a user