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
@@ -1,6 +1,4 @@
|
||||
import { useContextUsage } from '@/hooks/useContextUsage'
|
||||
import { getModel, formatModelName } from '@/api/providers'
|
||||
import { useState, useEffect } from 'react'
|
||||
|
||||
interface ContextUsageIndicatorProps {
|
||||
opcodeUrl: string | null
|
||||
@@ -10,35 +8,14 @@ interface ContextUsageIndicatorProps {
|
||||
isReconnecting?: boolean
|
||||
}
|
||||
|
||||
const getUsageTextColor = (percentage: number) => {
|
||||
if (percentage < 50) return 'text-green-700 dark:text-green-400'
|
||||
if (percentage < 80) return 'text-yellow-700 dark:text-yellow-400'
|
||||
return 'text-red-700 dark:text-red-400'
|
||||
}
|
||||
|
||||
export function ContextUsageIndicator({ opcodeUrl, sessionID, directory, isConnected, isReconnecting }: ContextUsageIndicatorProps) {
|
||||
const { totalTokens, contextLimit, usagePercentage, currentModel, isLoading } = useContextUsage(opcodeUrl, sessionID, directory)
|
||||
const [modelName, setModelName] = useState<string>('')
|
||||
|
||||
useEffect(() => {
|
||||
const loadModelName = async () => {
|
||||
if (currentModel) {
|
||||
try {
|
||||
const [providerId, modelId] = currentModel.split('/')
|
||||
if (providerId && modelId) {
|
||||
const model = await getModel(providerId, modelId)
|
||||
if (model) {
|
||||
setModelName(formatModelName(model))
|
||||
} else {
|
||||
setModelName(currentModel)
|
||||
}
|
||||
} else {
|
||||
setModelName(currentModel)
|
||||
}
|
||||
} catch {
|
||||
setModelName(currentModel)
|
||||
}
|
||||
} else {
|
||||
setModelName('')
|
||||
}
|
||||
}
|
||||
|
||||
loadModelName()
|
||||
}, [currentModel])
|
||||
const { totalTokens, contextLimit, usagePercentage, isLoading } = useContextUsage(opcodeUrl, sessionID, directory)
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -56,39 +33,15 @@ export function ContextUsageIndicator({ opcodeUrl, sessionID, directory, isConne
|
||||
return <span className="text-xs text-muted-foreground font-medium">Disconnected</span>
|
||||
}
|
||||
|
||||
if (!modelName) {
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">No model</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const getUsageTextColor = (percentage: number) => {
|
||||
if (percentage < 50) return 'text-green-700 dark:text-green-400'
|
||||
if (percentage < 80) return 'text-yellow-700 dark:text-yellow-400'
|
||||
return 'text-red-700 dark:text-red-400'
|
||||
}
|
||||
|
||||
if (isReconnecting) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (!contextLimit) {
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">{modelName}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const tokenText = contextLimit
|
||||
? `${totalTokens.toLocaleString()} / ${contextLimit.toLocaleString()}`
|
||||
: totalTokens.toLocaleString()
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${getUsageTextColor(usagePercentage || 0)}`}>
|
||||
{totalTokens.toLocaleString()} / {contextLimit.toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
<span className={`text-xs font-medium whitespace-nowrap ${getUsageTextColor(usagePercentage || 0)}`}>
|
||||
{tokenText}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user