mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
chore: bump version to 0.7.3, set package to public, and add per-session agent mode switching
Changes: - Bump version to 0.7.3 - Set package.private to false - Add useSessionAgent hook for per-session agent mode - Remove global mode preference, use session-level mode - Add mobile drag-and-drop toggle for repo list - Improve repo card UI with truncation and compact status - Fix TypeScript errors in repo.ts (undefined handling)
This commit is contained in:
1 parent
94725ce473
commit
e6156f3c47
12 files changed
+202
-76
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useMessages } from './useOpenCode'
|
||||
import type { components } from '@/api/opencode-types'
|
||||
|
||||
type UserMessage = components['schemas']['UserMessage']
|
||||
|
||||
const DEFAULT_AGENT = 'plan'
|
||||
|
||||
export function useSessionAgent(
|
||||
opcodeUrl: string | null | undefined,
|
||||
sessionID: string | undefined,
|
||||
directory?: string
|
||||
) {
|
||||
const { data: messages } = useMessages(opcodeUrl, sessionID, directory)
|
||||
|
||||
return useMemo(() => {
|
||||
if (!messages || messages.length === 0) {
|
||||
return {
|
||||
agent: DEFAULT_AGENT,
|
||||
model: undefined as { providerID: string; modelID: string } | undefined,
|
||||
variant: undefined as string | undefined,
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = messages.length - 1; i >= 0; i--) {
|
||||
const msg = messages[i]
|
||||
if (msg.info.role === 'user') {
|
||||
const userInfo = msg.info as UserMessage
|
||||
return {
|
||||
agent: userInfo.agent || DEFAULT_AGENT,
|
||||
model: userInfo.model,
|
||||
variant: userInfo.variant,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
agent: DEFAULT_AGENT,
|
||||
model: undefined,
|
||||
variant: undefined,
|
||||
}
|
||||
}, [messages])
|
||||
}
|
||||
|
||||
export function getSessionAgentFromMessages(
|
||||
messages: Array<{ info: { role: string; agent?: string } }> | undefined
|
||||
): string {
|
||||
if (!messages || messages.length === 0) {
|
||||
return DEFAULT_AGENT
|
||||
}
|
||||
|
||||
for (let i = messages.length - 1; i >= 0; i--) {
|
||||
const msg = messages[i]
|
||||
if (msg.info.role === 'user' && 'agent' in msg.info) {
|
||||
return (msg.info.agent as string) || DEFAULT_AGENT
|
||||
}
|
||||
}
|
||||
|
||||
return DEFAULT_AGENT
|
||||
}
|
||||
Reference in new issue
Block a user