mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +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
@@ -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)}
|
||||
|
||||
Reference in new issue
Block a user