mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix: update settings and skills handling with assistant redirect (#220)
* fix: enable swipe-back suspension on more drawer and remove unused variable * refactor(frontend): improve dialog component and settings navigation * fix: disable route swipe suspension in MoreDrawer to prevent unintended navigation * fix(frontend): enable swipe-back suspension on more drawer route * refactor(frontend): improve mobile navigation drawer and tab bar * feat: add schedules service and workspace hook with navigation updates * chore: add workspace hook, schedules library, and tests * fix: prevent MoreDrawer sentinel from undoing navigation * feat: per-agent model selection and UI refinements (#217) * feat: per-agent model selection and UI refinements - Add agentModels store with setAgentModel/getAgentModel - PromptInput uses session model priority and stores agent model on change - useContextUsage derives model from assistant message instead of global - Migrate sub-agent/subtask badges from purple to blue with refined styling - Fix MoreDrawer sentinel to skip history-back on navigation * refactor: improve per-agent model selection and task tool call status indicators * feat: add repo management skill and internal repos API * fix: improve assistant session launcher and UI components * fix: update atomic-json test assertions * refactor: split Assistant Mode instructions between AGENTS.md and assistant.md * loop: todo-header-mobile completed after 3 iterations (#218) * loop: stt-perf-1 completed after 5 iterations * fix: load audio worklet per recording context * fix: canonicalize assistant navigation routes * fix: adjust scroll-up threshold for header visibility * fix: update settings and skills handling with assistant redirect * refactor: simplify context usage indicator and extract token sum helper * feat: add currently selected model row to popover and fix responsive truncate
This commit is contained in:
1 parent
c7291518c8
commit
74cdeb3926
73 files changed
+4073
-632
No files matched your search
@@ -177,7 +177,7 @@ export const MessagePart = memo(function MessagePart({ part, role, allParts, par
|
||||
case 'subtask': {
|
||||
const label = part.description || part.prompt || 'Sub-agent task'
|
||||
return (
|
||||
<div className="my-1 w-full rounded border border-purple-500/20 bg-purple-500/5 px-2 py-1 text-left text-xs text-muted-foreground">
|
||||
<div className="my-1 w-full rounded-lg border border-blue-500/20 bg-blue-500/5 px-3 py-1.5 text-left text-xs text-muted-foreground shadow-sm shadow-blue-500/5">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<span className="truncate">{label}</span>
|
||||
<span className="ml-auto shrink-0 text-[11px] text-muted-foreground">sub-agent</span>
|
||||
|
||||
@@ -429,9 +429,13 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
setMentionRange(null)
|
||||
}
|
||||
|
||||
const handleAgentChange = (agent: string) => {
|
||||
setLocalMode(agent)
|
||||
setStoredAgent(sessionID, agent)
|
||||
const handleAgentChange = (agentName: string) => {
|
||||
setLocalMode(agentName)
|
||||
setStoredAgent(sessionID, agentName)
|
||||
const agent = agents.find(a => a.name === agentName)
|
||||
if (agent?.model) {
|
||||
setStoredModel({ providerID: agent.model.providerID, modelID: agent.model.modelID })
|
||||
}
|
||||
}
|
||||
|
||||
const startVoiceRecording = async () => {
|
||||
@@ -1226,10 +1230,10 @@ return (
|
||||
directory={directory}
|
||||
onOpenFullDialog={() => onShowModelsDialog?.()}
|
||||
>
|
||||
<button
|
||||
className="px-2.5 py-0.5 md:px-3 min-h-[36px] rounded-lg text-xs md:text-sm font-medium border bg-muted border-border text-muted-foreground hover:bg-muted-foreground/10 hover:border-foreground/30 transition-colors cursor-pointer max-w-[150px] md:max-w-[220px] dark:border-white/30 flex flex-col items-start justify-center"
|
||||
>
|
||||
<span className="truncate w-full text-left">{displayModelName || 'Select model'}</span>
|
||||
<button
|
||||
className="px-2.5 py-0.5 md:px-3 min-h-[36px] min-w-0 rounded-lg text-xs md:text-sm font-medium border bg-muted border-border text-muted-foreground hover:bg-muted-foreground/10 hover:border-foreground/30 transition-colors cursor-pointer w-full md:w-auto md:max-w-[220px] dark:border-white/30 flex flex-col items-start justify-center overflow-hidden"
|
||||
>
|
||||
<span className="truncate w-full text-left">{displayModelName || 'Select model'}</span>
|
||||
{hasVariants && currentVariant && (
|
||||
<span className="text-[10px] text-orange-500 truncate w-full text-center capitalize">{currentVariant}</span>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { SessionTodoDisplay } from './SessionTodoDisplay'
|
||||
import { useSessionTodos } from '@/stores/sessionTodosStore'
|
||||
import type { Todo } from './SessionTodoDisplay'
|
||||
|
||||
const activeTodos: Todo[] = [
|
||||
{ id: '1', content: 'Implement mobile header fix', status: 'in_progress', priority: 'high' },
|
||||
{ id: '2', content: 'Add regression tests', status: 'pending', priority: 'medium' },
|
||||
{ id: '3', content: 'Verify completed item grouping', status: 'completed', priority: 'low' },
|
||||
]
|
||||
|
||||
const allCompletedTodos: Todo[] = [
|
||||
{ id: '1', content: 'Task one', status: 'completed', priority: 'high' },
|
||||
{ id: '2', content: 'Task two', status: 'completed', priority: 'medium' },
|
||||
]
|
||||
|
||||
describe('SessionTodoDisplay', () => {
|
||||
beforeEach(() => {
|
||||
useSessionTodos.setState({ todos: new Map() })
|
||||
})
|
||||
|
||||
it('renders collapsed by default', () => {
|
||||
useSessionTodos.getState().setTodos('session-1', activeTodos)
|
||||
|
||||
render(<SessionTodoDisplay sessionID="session-1" />)
|
||||
|
||||
expect(screen.getByText('Tasks: 1/3 complete')).toBeInTheDocument()
|
||||
|
||||
expect(screen.queryByText('Implement mobile header fix')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Add regression tests')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('expands to show a small scrollable task preview when clicked', async () => {
|
||||
const user = userEvent.setup()
|
||||
useSessionTodos.getState().setTodos('session-1', activeTodos)
|
||||
|
||||
render(<SessionTodoDisplay sessionID="session-1" />)
|
||||
|
||||
const collapsedRow = screen.getByText('Tasks: 1/3 complete')
|
||||
await user.click(collapsedRow)
|
||||
|
||||
expect(screen.getByText('Implement mobile header fix')).toBeInTheDocument()
|
||||
expect(screen.getByText('Add regression tests')).toBeInTheDocument()
|
||||
expect(screen.getByText('Verify completed item grouping')).toBeInTheDocument()
|
||||
|
||||
const expandedContainer = screen.getByTestId('todo-expanded-list')
|
||||
expect(expandedContainer).toHaveClass('max-h-[80px]')
|
||||
expect(expandedContainer).toHaveClass('sm:max-h-[160px]')
|
||||
expect(expandedContainer).toHaveClass('overflow-y-auto')
|
||||
})
|
||||
|
||||
it('collapses again when expanded header is clicked', async () => {
|
||||
const user = userEvent.setup()
|
||||
useSessionTodos.getState().setTodos('session-1', activeTodos)
|
||||
|
||||
render(<SessionTodoDisplay sessionID="session-1" />)
|
||||
|
||||
const collapsedRow = screen.getByText('Tasks: 1/3 complete')
|
||||
await user.click(collapsedRow)
|
||||
|
||||
expect(screen.getByTestId('todo-expanded-list')).toBeInTheDocument()
|
||||
|
||||
const expandedHeader = screen.getByText('Tasks: 1/3 complete')
|
||||
await user.click(expandedHeader)
|
||||
|
||||
expect(screen.queryByTestId('todo-expanded-list')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('does not render when all tasks are completed', () => {
|
||||
useSessionTodos.getState().setTodos('session-1', allCompletedTodos)
|
||||
|
||||
const { container } = render(<SessionTodoDisplay sessionID="session-1" />)
|
||||
|
||||
expect(container.firstChild).toBeNull()
|
||||
})
|
||||
|
||||
it('dismisses current todo signature and reappears when todo status changes', async () => {
|
||||
const user = userEvent.setup()
|
||||
useSessionTodos.getState().setTodos('session-1', activeTodos)
|
||||
|
||||
const { rerender } = render(<SessionTodoDisplay sessionID="session-1" />)
|
||||
|
||||
expect(screen.getByText('Tasks: 1/3 complete')).toBeInTheDocument()
|
||||
|
||||
const dismissButton = screen.getByLabelText('Dismiss tasks')
|
||||
await user.click(dismissButton)
|
||||
|
||||
expect(screen.queryByText('Tasks: 1/3 complete')).not.toBeInTheDocument()
|
||||
|
||||
const updatedTodos: Todo[] = [
|
||||
{ id: '1', content: 'Implement mobile header fix', status: 'completed', priority: 'high' },
|
||||
{ id: '2', content: 'Add regression tests', status: 'pending', priority: 'medium' },
|
||||
{ id: '3', content: 'Verify completed item grouping', status: 'completed', priority: 'low' },
|
||||
]
|
||||
useSessionTodos.getState().setTodos('session-1', updatedTodos)
|
||||
|
||||
rerender(<SessionTodoDisplay sessionID="session-1" />)
|
||||
|
||||
expect(screen.getByText('Tasks: 2/3 complete')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
@@ -15,7 +15,7 @@ const todoSignature = (todos: Todo[]) =>
|
||||
|
||||
export function SessionTodoDisplay({ sessionID }: SessionTodoDisplayProps) {
|
||||
const todos = useSessionTodosForSession(sessionID)
|
||||
const [isCollapsed, setIsCollapsed] = useState(false)
|
||||
const [isCollapsed, setIsCollapsed] = useState(true)
|
||||
const [isDismissed, setIsDismissed] = useState(false)
|
||||
const dismissedSignatureRef = useRef<string>('')
|
||||
|
||||
@@ -129,7 +129,7 @@ export function SessionTodoDisplay({ sessionID }: SessionTodoDisplayProps) {
|
||||
<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">
|
||||
<div data-testid="todo-expanded-list" className="max-h-[80px] sm:max-h-[160px] overflow-y-auto p-1.5 sm:p-2 bg-muted/30">
|
||||
{renderGroup('In Progress', inProgress)}
|
||||
{renderGroup('Pending', pending)}
|
||||
{renderGroup('Completed', completedTodos)}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState, useRef, useEffect } from 'react'
|
||||
import type { components } from '@/api/opencode-types'
|
||||
import { useSettings } from '@/hooks/useSettings'
|
||||
import { useUserBash } from '@/stores/userBashStore'
|
||||
import { useSessionStatusForSession } from '@/stores/sessionStatusStore'
|
||||
import { usePermissions, useQuestions } from '@/contexts/EventContext'
|
||||
import { detectFileReferences } from '@/lib/fileReferences'
|
||||
import { ExternalLink, Loader2 } from 'lucide-react'
|
||||
@@ -68,6 +69,8 @@ function ClickableJson({ json, onFileClick }: { json: unknown; onFileClick?: (fi
|
||||
export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCallPartProps) {
|
||||
const { preferences } = useSettings()
|
||||
const { userBashCommands } = useUserBash()
|
||||
const taskSessionId = part.tool === 'task' ? getTaskSessionId(part) : undefined
|
||||
const taskSessionStatus = useSessionStatusForSession(taskSessionId)
|
||||
const { getForCallID: getPermissionForCallID } = usePermissions()
|
||||
const { getForCallID: getQuestionForCallID } = useQuestions()
|
||||
const outputRef = useRef<HTMLDivElement>(null)
|
||||
@@ -152,17 +155,36 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
const isFileTool = ['read', 'write', 'edit'].includes(part.tool)
|
||||
|
||||
if (part.tool === 'task') {
|
||||
const sessionId = getTaskSessionId(part)
|
||||
const sessionId = taskSessionId
|
||||
const description = previewText || 'Sub-agent task'
|
||||
const isRunning = part.state.status === 'running' || part.state.status === 'pending'
|
||||
const status = part.state.status
|
||||
|
||||
const isPending = status === 'pending'
|
||||
const isRunning = status === 'running' && taskSessionStatus.type !== 'idle'
|
||||
const isCompleted = status === 'completed' || (status === 'running' && !!sessionId && taskSessionStatus.type === 'idle')
|
||||
const isError = status === 'error'
|
||||
|
||||
const content = (
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
{isRunning ? (
|
||||
<Loader2 className="w-3.5 h-3.5 animate-spin text-purple-600 dark:text-purple-400" />
|
||||
) : null}
|
||||
{isPending && (
|
||||
<div className="flex gap-1">
|
||||
<span className="w-2 h-2 rounded-full bg-muted-foreground" />
|
||||
<span className="w-2 h-2 rounded-full bg-muted-foreground" />
|
||||
<span className="w-2 h-2 rounded-full bg-muted-foreground" />
|
||||
</div>
|
||||
)}
|
||||
{isRunning && (
|
||||
<div className="flex gap-1">
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-blue-500 animate-bounce" style={{ animationDelay: '0ms' }} />
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-blue-500 animate-bounce" style={{ animationDelay: '150ms' }} />
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-blue-500 animate-bounce" style={{ animationDelay: '300ms' }} />
|
||||
</div>
|
||||
)}
|
||||
{isCompleted && <span className="text-green-600 text-sm font-medium">✓</span>}
|
||||
{isError && <span className="text-red-600 text-sm font-medium">✗</span>}
|
||||
<span className="font-medium text-foreground truncate">{description}</span>
|
||||
<span className="text-[11px] text-muted-foreground ml-auto shrink-0">sub-agent</span>
|
||||
{sessionId && <ExternalLink className="w-3 h-3 shrink-0 text-purple-600 dark:text-purple-400" />}
|
||||
<span className="text-[11px] font-medium text-orange-600 dark:text-orange-400 shrink-0">sub-agent</span>
|
||||
{sessionId && <ExternalLink className="w-3 h-3 shrink-0 text-blue-600 dark:text-blue-400" />}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -170,7 +192,7 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
return (
|
||||
<button
|
||||
onClick={() => onChildSessionClick?.(sessionId)}
|
||||
className="my-1 w-full rounded border border-purple-500/20 bg-purple-500/5 px-2 py-1 text-left text-xs text-muted-foreground hover:bg-purple-500/10 transition-colors"
|
||||
className="my-1 w-full rounded-lg border border-blue-500/20 bg-blue-500/5 px-3 py-1.5 text-left text-xs text-muted-foreground hover:bg-blue-500/10 hover:border-blue-500/30 transition-all duration-200 shadow-sm shadow-blue-500/5"
|
||||
title="View subagent session"
|
||||
>
|
||||
{content}
|
||||
@@ -179,7 +201,7 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="my-1 rounded border border-purple-500/20 bg-purple-500/5 px-2 py-1 text-xs text-muted-foreground">
|
||||
<div className="my-1 rounded-lg border border-blue-500/20 bg-blue-500/5 px-3 py-1.5 text-xs text-muted-foreground shadow-sm shadow-blue-500/5">
|
||||
{content}
|
||||
</div>
|
||||
)
|
||||
@@ -278,7 +300,7 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
e.stopPropagation()
|
||||
onChildSessionClick?.(sessionId)
|
||||
}}
|
||||
className="text-purple-600 dark:text-purple-400 text-xs hover:text-purple-700 dark:hover:text-purple-300 cursor-pointer underline decoration-dotted flex items-center gap-1"
|
||||
className="text-blue-600 dark:text-blue-400 text-xs hover:text-blue-700 dark:hover:text-blue-300 cursor-pointer underline decoration-dotted flex items-center gap-1"
|
||||
title="View subagent session"
|
||||
>
|
||||
<ExternalLink className="w-3 h-3" />
|
||||
|
||||
Reference in new issue
Block a user