mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +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
@@ -0,0 +1,98 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import type { SessionMessageInfo } from '@opencode-manager/shared/opencode'
|
||||
import { SessionMessagePickerDialog } from './SessionMessagePickerDialog'
|
||||
|
||||
function userMessage(id: string, text: string, created = 1000): SessionMessageInfo {
|
||||
return { id, type: 'user', text, time: { created } } as SessionMessageInfo
|
||||
}
|
||||
|
||||
function assistantMessage(id: string, text: string): SessionMessageInfo {
|
||||
return { id, type: 'assistant', text, time: { created: 1000 } } as unknown as SessionMessageInfo
|
||||
}
|
||||
|
||||
const renderPicker = (
|
||||
props: Partial<React.ComponentProps<typeof SessionMessagePickerDialog>> = {},
|
||||
) =>
|
||||
render(
|
||||
<SessionMessagePickerDialog
|
||||
open
|
||||
onOpenChange={vi.fn()}
|
||||
title="Fork session"
|
||||
messages={[]}
|
||||
onSelect={vi.fn()}
|
||||
{...props}
|
||||
/>,
|
||||
)
|
||||
|
||||
describe('SessionMessagePickerDialog', () => {
|
||||
it('lists only user messages, newest first', () => {
|
||||
renderPicker({
|
||||
messages: [
|
||||
userMessage('old', 'older prompt', 1000),
|
||||
assistantMessage('assistant', 'reply'),
|
||||
userMessage('new', 'newer prompt', 2000),
|
||||
],
|
||||
})
|
||||
|
||||
const older = screen.getByText('older prompt')
|
||||
const newer = screen.getByText('newer prompt')
|
||||
|
||||
expect(screen.queryByText('reply')).not.toBeInTheDocument()
|
||||
expect(
|
||||
newer.compareDocumentPosition(older) & Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
it('narrows the rows with the search query', () => {
|
||||
renderPicker({
|
||||
messages: [userMessage('a', 'alpha prompt'), userMessage('b', 'beta prompt')],
|
||||
})
|
||||
|
||||
expect(screen.getByText('alpha prompt')).toBeInTheDocument()
|
||||
expect(screen.getByText('beta prompt')).toBeInTheDocument()
|
||||
|
||||
fireEvent.change(screen.getByPlaceholderText('Search messages'), {
|
||||
target: { value: 'beta' },
|
||||
})
|
||||
|
||||
expect(screen.queryByText('alpha prompt')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('beta prompt')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('calls onSelect with the message id when a row is clicked', () => {
|
||||
const onSelect = vi.fn()
|
||||
renderPicker({ messages: [userMessage('msg-1', 'hello')], onSelect })
|
||||
|
||||
fireEvent.click(screen.getByText('hello'))
|
||||
|
||||
expect(onSelect).toHaveBeenCalledWith('msg-1')
|
||||
})
|
||||
|
||||
it('calls onSelect with undefined from the leading row', () => {
|
||||
const onSelect = vi.fn()
|
||||
renderPicker({
|
||||
messages: [userMessage('msg-1', 'hello')],
|
||||
leadingOptionLabel: 'Entire conversation',
|
||||
onSelect,
|
||||
})
|
||||
|
||||
fireEvent.click(screen.getByText('Entire conversation'))
|
||||
|
||||
expect(onSelect).toHaveBeenCalledWith(undefined)
|
||||
})
|
||||
|
||||
it('shows an empty state when no messages match', () => {
|
||||
renderPicker({ messages: [assistantMessage('a', 'reply')] })
|
||||
|
||||
expect(screen.getByText('No messages')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows a loading state instead of the rows while loading', () => {
|
||||
renderPicker({ messages: [userMessage('msg-1', 'hello')], loading: true })
|
||||
|
||||
expect(screen.getByText('Loading messages…')).toBeInTheDocument()
|
||||
expect(screen.queryByText('hello')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('No messages')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user