mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(commands): run multi-line and Enter commands, restore focus, refresh forks
- Match command arguments across newlines so a multi-line /btw or custom command runs instead of being sent as plain text. - Run a typed command on plain Enter once its name is complete, while Enter stays a new line for regular text and Shift+Enter for commands. - Focus the prompt when a session opens on a pointer device, and return focus to the previously focused element when a dialog closes, except a text field on touch so the keyboard stays closed. - Invalidate the session list on session.forked so a forked session shows in the sidebar without waiting for the next event. - Correct the Quick Start keyboard shortcuts.
This commit is contained in:
1 parent
7e93eb4c34
commit
7102715068
10 files changed
+330
-17
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest'
|
||||
import { stubMatchMedia } from '@/test/test-utils'
|
||||
import { useState } from 'react'
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
|
||||
import type { SessionMessageInfo } from '@opencode-manager/shared/opencode'
|
||||
import { SessionMessagePickerDialog } from './SessionMessagePickerDialog'
|
||||
|
||||
@@ -25,7 +27,48 @@ const renderPicker = (
|
||||
/>,
|
||||
)
|
||||
|
||||
function FocusHost() {
|
||||
const [open, setOpen] = useState(false)
|
||||
return (
|
||||
<>
|
||||
<textarea aria-label="prompt" />
|
||||
<button type="button" onClick={() => setOpen(true)}>open</button>
|
||||
{open && (
|
||||
<SessionMessagePickerDialog
|
||||
open
|
||||
onOpenChange={(next) => {
|
||||
if (!next) setOpen(false)
|
||||
}}
|
||||
title="Fork session"
|
||||
messages={[]}
|
||||
onSelect={vi.fn()}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
describe('SessionMessagePickerDialog', () => {
|
||||
afterEach(() => {
|
||||
Reflect.deleteProperty(window, 'matchMedia')
|
||||
})
|
||||
|
||||
it('focuses its search on open and returns focus to the previous element on Escape', async () => {
|
||||
stubMatchMedia(true)
|
||||
render(<FocusHost />)
|
||||
const prompt = screen.getByLabelText('prompt')
|
||||
prompt.focus()
|
||||
|
||||
fireEvent.click(screen.getByText('open'))
|
||||
|
||||
const search = await screen.findByPlaceholderText('Search messages')
|
||||
await waitFor(() => expect(search).toHaveFocus())
|
||||
|
||||
fireEvent.keyDown(search, { key: 'Escape' })
|
||||
|
||||
await waitFor(() => expect(prompt).toHaveFocus())
|
||||
})
|
||||
|
||||
it('lists only user messages, newest first', () => {
|
||||
renderPicker({
|
||||
messages: [
|
||||
|
||||
Reference in new issue
Block a user