mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
- 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.
28 lines
832 B
TypeScript
28 lines
832 B
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
export const DESKTOP_MEDIA_QUERY = '(min-width: 640px)'
|
|
|
|
export const FINE_POINTER_MEDIA_QUERY = '(hover: hover) and (pointer: fine)'
|
|
|
|
export function useMediaQuery(query: string): boolean {
|
|
const [matches, setMatches] = useState<boolean>(() => {
|
|
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {
|
|
return false
|
|
}
|
|
return window.matchMedia(query).matches
|
|
})
|
|
|
|
useEffect(() => {
|
|
if (typeof window.matchMedia !== 'function') {
|
|
return
|
|
}
|
|
const mediaQuery = window.matchMedia(query)
|
|
setMatches(mediaQuery.matches)
|
|
const update = () => setMatches(mediaQuery.matches)
|
|
mediaQuery.addEventListener('change', update)
|
|
return () => mediaQuery.removeEventListener('change', update)
|
|
}, [query])
|
|
|
|
return matches
|
|
}
|