mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat: add assistant mode, SSE streaming, and OpenCode server integration (#214)
This commit is contained in:
1 parent
3cc24288a6
commit
c3d6549f01
133 files changed
+7284
-6293
No files matched your search
@@ -47,7 +47,7 @@ const revokeBlobUrls = (attachments: ImageAttachment[]) => {
|
||||
|
||||
const ACCEPTED_FILE_TYPES = [...ACCEPTED_IMAGE_TYPES, "application/pdf"]
|
||||
|
||||
const VOICE_SEND_SWIPE_THRESHOLD = 48
|
||||
const VOICE_SEND_SWIPE_THRESHOLD = 30
|
||||
type VoiceButtonVariant = 'desktop' | 'mobile'
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ interface PromptInputProps {
|
||||
opcodeUrl: string
|
||||
directory?: string
|
||||
sessionID: string
|
||||
repoId?: number
|
||||
disabled?: boolean
|
||||
showScrollButton?: boolean
|
||||
isSessionActive?: boolean
|
||||
@@ -81,7 +80,6 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
opcodeUrl,
|
||||
directory,
|
||||
sessionID,
|
||||
repoId,
|
||||
disabled,
|
||||
showScrollButton,
|
||||
isSessionActive = false,
|
||||
@@ -177,7 +175,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
}), [imageAttachments, clearSTT, isRecording, abortRecording, resetVoiceGestureState])
|
||||
const sendPrompt = useSendPrompt(opcodeUrl, directory)
|
||||
const sendShell = useSendShell(opcodeUrl, directory)
|
||||
const abortSession = useAbortSession(opcodeUrl, directory, sessionID, repoId)
|
||||
const abortSession = useAbortSession(opcodeUrl, directory, sessionID)
|
||||
const { filterCommands } = useCommands(opcodeUrl)
|
||||
const { executeCommand } = useCommandHandler({
|
||||
opcodeUrl,
|
||||
@@ -241,7 +239,8 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
parts,
|
||||
model: currentModel,
|
||||
agent: agentUsed,
|
||||
variant: currentVariant
|
||||
variant: currentVariant,
|
||||
queued: true
|
||||
})
|
||||
setStoredAgent(sessionID, agentUsed)
|
||||
if (model) {
|
||||
@@ -1241,10 +1240,10 @@ return (
|
||||
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 md:gap-2 flex-shrink-0">
|
||||
{isMobile && showScrollButton ? (
|
||||
{isMobile && showScrollButton && !showVoiceFeedback ? (
|
||||
<button
|
||||
onClick={onScrollToBottom}
|
||||
className="px-4 py-2 rounded-lg bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground transition-all duration-200 active:scale-95 shadow-md flex items-center justify-center min-w-[52px] border border-border"
|
||||
className="px-4 py-2 rounded-lg bg-black hover:bg-zinc-900 text-white transition-all duration-200 active:scale-95 shadow-md flex items-center justify-center min-w-[52px] border border-zinc-700"
|
||||
title="Scroll to bottom"
|
||||
>
|
||||
<ArrowDown className="w-5 h-5" />
|
||||
@@ -1252,7 +1251,7 @@ return (
|
||||
) : !isMobile ? (
|
||||
<button
|
||||
onClick={onScrollToBottom}
|
||||
className={`p-2 rounded-lg bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground transition-all duration-200 active:scale-95 hover:scale-105 shadow-md ${showScrollButton ? 'visible' : 'invisible'}`}
|
||||
className={`p-2 rounded-lg bg-black hover:bg-zinc-900 text-white transition-all duration-200 active:scale-95 hover:scale-105 shadow-md border border-zinc-700 ${showScrollButton ? 'visible' : 'invisible'}`}
|
||||
title="Scroll to bottom"
|
||||
>
|
||||
<ArrowDown className="w-6 h-6" />
|
||||
@@ -1286,7 +1285,7 @@ return (
|
||||
{sttEnabled && sttSupported && (
|
||||
renderVoiceButton('desktop')
|
||||
)}
|
||||
{isMobile && !showScrollButton && sttEnabled && sttSupported && !hasPendingPermissionForSession && (
|
||||
{isMobile && sttEnabled && sttSupported && !hasPendingPermissionForSession && (!showScrollButton || showVoiceFeedback) && (
|
||||
renderVoiceButton('mobile')
|
||||
)}
|
||||
<button
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useState, useMemo } from 'react'
|
||||
import { ChevronDown, ChevronRight } from 'lucide-react'
|
||||
import { useState, useMemo, useEffect, useRef } from 'react'
|
||||
import { ChevronDown, ChevronRight, X } from 'lucide-react'
|
||||
import { TodoItem } from './TodoItem'
|
||||
import { useSessionTodosForSession } from '@/stores/sessionTodosStore'
|
||||
import { useSessionStatusForSession } from '@/stores/sessionStatusStore'
|
||||
import type { components } from '@/api/opencode-types'
|
||||
|
||||
export type Todo = components['schemas']['Todo']
|
||||
@@ -11,12 +10,28 @@ interface SessionTodoDisplayProps {
|
||||
sessionID: string | undefined
|
||||
}
|
||||
|
||||
const todoSignature = (todos: Todo[]) =>
|
||||
todos.map((t) => `${t.id}:${t.status}`).join(',')
|
||||
|
||||
export function SessionTodoDisplay({ sessionID }: SessionTodoDisplayProps) {
|
||||
const todos = useSessionTodosForSession(sessionID)
|
||||
const sessionStatus = useSessionStatusForSession(sessionID)
|
||||
const [isCollapsed, setIsCollapsed] = useState(false)
|
||||
const [isDismissed, setIsDismissed] = useState(false)
|
||||
const dismissedSignatureRef = useRef<string>('')
|
||||
|
||||
const isSessionActive = sessionStatus.type === 'busy' || sessionStatus.type === 'compact' || sessionStatus.type === 'retry'
|
||||
const signature = useMemo(() => todoSignature(todos), [todos])
|
||||
|
||||
useEffect(() => {
|
||||
if (isDismissed && signature !== dismissedSignatureRef.current) {
|
||||
setIsDismissed(false)
|
||||
}
|
||||
}, [signature, isDismissed])
|
||||
|
||||
const handleDismiss = (e: React.MouseEvent) => {
|
||||
e.stopPropagation()
|
||||
dismissedSignatureRef.current = signature
|
||||
setIsDismissed(true)
|
||||
}
|
||||
|
||||
const stats = useMemo(() => {
|
||||
const completed = todos.filter((t) => t.status === 'completed').length
|
||||
@@ -57,7 +72,7 @@ export function SessionTodoDisplay({ sessionID }: SessionTodoDisplayProps) {
|
||||
)
|
||||
}
|
||||
|
||||
if (!sessionID || !isSessionActive || todos.length === 0 || stats.completed === stats.total) {
|
||||
if (!sessionID || todos.length === 0 || stats.completed === stats.total || isDismissed) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -78,6 +93,13 @@ export function SessionTodoDisplay({ sessionID }: SessionTodoDisplayProps) {
|
||||
style={{ width: `${stats.percentage}%` }}
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleDismiss}
|
||||
className="ml-1 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors"
|
||||
aria-label="Dismiss tasks"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -99,6 +121,13 @@ export function SessionTodoDisplay({ sessionID }: SessionTodoDisplayProps) {
|
||||
style={{ width: `${stats.percentage}%` }}
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleDismiss}
|
||||
className="ml-1 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors"
|
||||
aria-label="Dismiss tasks"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="max-h-[80px] sm:max-h-[160px] overflow-y-auto p-1.5 sm:p-2 bg-muted/30">
|
||||
{renderGroup('In Progress', inProgress)}
|
||||
|
||||
@@ -186,32 +186,6 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
}
|
||||
|
||||
if (isTodoTool) {
|
||||
if (part.state.status === 'pending') {
|
||||
return (
|
||||
<div className="my-2 text-sm text-muted-foreground flex items-center gap-2">
|
||||
<Loader2 className="w-3 h-3 animate-spin" />
|
||||
<span>Preparing task list...</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (part.state.status === 'running') {
|
||||
return (
|
||||
<div className="my-2 text-sm text-muted-foreground flex items-center gap-2">
|
||||
<Loader2 className="w-3 h-3 animate-spin" />
|
||||
<span>Updating task list...</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (part.state.status === 'completed') {
|
||||
return (
|
||||
<div className="my-2 text-xs text-muted-foreground">
|
||||
Task list updated
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (part.state.status === 'error') {
|
||||
return (
|
||||
<div className="my-2 text-sm text-red-600 dark:text-red-400">
|
||||
|
||||
@@ -8,31 +8,36 @@ interface VoiceStatusOverlayProps {
|
||||
state: VoiceStatusOverlayState | null
|
||||
}
|
||||
|
||||
function WaveformBars() {
|
||||
return (
|
||||
<div className="flex items-end gap-[3px] h-8">
|
||||
{[0, 1, 2, 3, 4].map((i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="w-1.5 rounded-full bg-white"
|
||||
style={{
|
||||
height: '100%',
|
||||
animation: `waveBar 0.9s ease-in-out infinite`,
|
||||
animationDelay: `${i * 0.12}s`,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
<style>{`
|
||||
@keyframes waveBar {
|
||||
0%, 100% { transform: scaleY(0.2); }
|
||||
50% { transform: scaleY(1); }
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function VoiceStatusOverlay({ show, label, state }: VoiceStatusOverlayProps) {
|
||||
if (!show || !label || !state) {
|
||||
return null
|
||||
}
|
||||
|
||||
const isLoading = state === 'starting' || state === 'processing' || state === 'sending'
|
||||
const showLoadingText = state !== 'starting'
|
||||
const topLabel = state === 'readyToSend'
|
||||
? 'Release'
|
||||
: state === 'starting'
|
||||
? 'Starting'
|
||||
: state === 'processing'
|
||||
? 'Transcribe'
|
||||
: state === 'sending'
|
||||
? 'Sending'
|
||||
: 'Swipe'
|
||||
const bottomLabel = state === 'starting'
|
||||
? 'Mic'
|
||||
: state === 'processing'
|
||||
? 'Speech'
|
||||
: state === 'sending'
|
||||
? 'Prompt'
|
||||
: state === 'readyToSend'
|
||||
? 'Send'
|
||||
: 'Send'
|
||||
const actionWords = state === 'readyToSend'
|
||||
? ['Release', 'To', 'Send']
|
||||
: ['Swipe', 'To', 'Send']
|
||||
@@ -47,12 +52,11 @@ export function VoiceStatusOverlay({ show, label, state }: VoiceStatusOverlayPro
|
||||
<div className="absolute inset-x-1 top-1 h-10 rounded-full bg-white/20 blur-sm" />
|
||||
<div className="relative flex flex-1 flex-col items-center justify-center gap-1">
|
||||
{isLoading ? (
|
||||
<>
|
||||
state === 'processing' ? (
|
||||
<WaveformBars />
|
||||
) : (
|
||||
<LoaderCircle className="h-6 w-6 animate-spin" />
|
||||
{showLoadingText && (
|
||||
<span className="text-[10px] font-bold uppercase leading-none tracking-wide">{topLabel}</span>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
) : (
|
||||
<>
|
||||
<ArrowUp className="h-8 w-8 animate-bounce" />
|
||||
@@ -64,11 +68,9 @@ export function VoiceStatusOverlay({ show, label, state }: VoiceStatusOverlayPro
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{isLoading && showLoadingText ? (
|
||||
<span className="relative text-[10px] font-bold uppercase leading-none tracking-wide">{bottomLabel}</span>
|
||||
) : !isLoading ? (
|
||||
{!isLoading && (
|
||||
<X className="relative h-4 w-4" />
|
||||
) : null}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user