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:
Chris Scott authored and GitHub committed 2026-05-07 18:36:03 -04:00
1 parent c7291518c8
commit 74cdeb3926
73 files changed
+4073 -632

No files matched your search

+22 -18
View File
@@ -1,7 +1,6 @@
import { useMemo } from 'react'
import { useMessages } from './useOpenCode'
import { useQuery } from '@tanstack/react-query'
import { useModelSelection } from './useModelSelection'
import { fetchWrapper } from '@/api/fetchWrapper'
interface ContextUsage {
@@ -39,8 +38,6 @@ async function fetchProviders(opcodeUrl: string): Promise<ProvidersResponse> {
export const useContextUsage = (opcodeUrl: string | null | undefined, sessionID: string | undefined, directory?: string): ContextUsage => {
const { data: messages, isLoading: messagesLoading } = useMessages(opcodeUrl, sessionID, directory)
const { modelString: globalModelString } = useModelSelection(opcodeUrl, directory)
const modelString = globalModelString
const { data: providersData } = useQuery({
queryKey: ['providers', opcodeUrl],
@@ -53,19 +50,30 @@ export const useContextUsage = (opcodeUrl: string | null | undefined, sessionID:
})
return useMemo(() => {
const currentModel = modelString || null
const assistantMessages = messages?.filter(msg => msg.info.role === 'assistant') || []
let latestAssistantMessage = assistantMessages[assistantMessages.length - 1]
if (latestAssistantMessage?.info.role === 'assistant') {
const msgInfo = latestAssistantMessage.info as { tokens?: { input: number; output: number; reasoning: number; cache?: { read: number } } }
const tokens = (msgInfo.tokens?.input ?? 0) + (msgInfo.tokens?.output ?? 0) + (msgInfo.tokens?.reasoning ?? 0) + (msgInfo.tokens?.cache?.read ?? 0)
if (tokens === 0 && assistantMessages.length > 1) {
latestAssistantMessage = assistantMessages[assistantMessages.length - 2]
}
const sumTokens = (msg: typeof latestAssistantMessage) => {
if (msg?.info.role !== 'assistant') return 0
const msgInfo = msg.info as { tokens?: { input: number; output: number; reasoning: number; cache?: { read: number } } }
return (msgInfo.tokens?.input ?? 0) + (msgInfo.tokens?.output ?? 0) + (msgInfo.tokens?.reasoning ?? 0) + (msgInfo.tokens?.cache?.read ?? 0)
}
if (sumTokens(latestAssistantMessage) === 0 && assistantMessages.length > 1) {
latestAssistantMessage = assistantMessages[assistantMessages.length - 2]
}
const currentModel = (() => {
if (!latestAssistantMessage || latestAssistantMessage.info.role !== 'assistant') {
return null
}
const msg = latestAssistantMessage.info as { providerID?: string; modelID?: string }
if (msg.providerID && msg.modelID) {
return `${msg.providerID}/${msg.modelID}`
}
return null
})()
let contextLimit: number | null = null
if (currentModel && providersData) {
const [providerId, modelId] = currentModel.split('/')
@@ -88,11 +96,7 @@ export const useContextUsage = (opcodeUrl: string | null | undefined, sessionID:
}
}
let totalTokens = 0
if (latestAssistantMessage?.info.role === 'assistant') {
const msgInfo = latestAssistantMessage.info as { tokens?: { input: number; output: number; reasoning: number; cache?: { read: number } } }
totalTokens = (msgInfo.tokens?.input ?? 0) + (msgInfo.tokens?.output ?? 0) + (msgInfo.tokens?.reasoning ?? 0) + (msgInfo.tokens?.cache?.read ?? 0)
}
const totalTokens = sumTokens(latestAssistantMessage)
const usagePercentage = contextLimit ? (totalTokens / contextLimit) * 100 : null
@@ -103,5 +107,5 @@ export const useContextUsage = (opcodeUrl: string | null | undefined, sessionID:
currentModel,
isLoading: false
}
}, [messages, messagesLoading, modelString, providersData])
}, [messages, messagesLoading, providersData])
}