mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat: directory files upload system, deferred restart model, cache invalidation consolidation, and misc improvements (#281)
* feat: show variant label on model picker and add folder upload for agents/commands
- Replace three-dot variant menu trigger with selected variant label
- Add POST /api/settings/opencode-directory-files/install endpoint
- Upload agents/commands markdown folders into .config/opencode/{agents,commands}/
- Reload OpenCode server after upload so files are picked up
* fix: revalidate branch/git caches when mobile sheet opens and on vcs.branch.updated SSE
- add shared invalidateRepoGitCaches() helper for consistent invalidation
- revalidate repo list when mobile repo quick-switch sheet opens
- revalidate current repo when mobile More drawer opens
- revalidate repo/git caches when Source Control dialog opens
- handle vcs.branch.updated SSE event with optimistic cache update
- use helper in branch create/switch mutations in useGit and BranchesTab
* style: make variant selector look more like a button with chevron and compact sizing
* refactor: consolidate settings editors, add folder upload support, and clean up unused code
* refactor: consolidate settings editors, add folder upload support, and clean up unused code
* feat: add opencode-directory-files listing service and consolidate settings editors
* fix: distinguish scroll from tap in suggestion popups on touch devices
* refactor: consolidate settings editors and add DirectoryFilesList component
* refactor: target repo status cache updates only to affected batch entries
* refactor: streamline settings, git hooks, and query invalidation logic
This commit is contained in:
1 parent
e53b4fd32c
commit
617962f2dd
48 files changed
+1522
-293
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createOpenCodeClient } from '@/api/opencode'
|
||||
import type { components } from '@/api/opencode-types'
|
||||
|
||||
@@ -163,36 +163,23 @@ const BUILTIN_COMMANDS: CommandType[] = [
|
||||
}
|
||||
]
|
||||
|
||||
const SORTED_BUILTIN_COMMANDS = sortCommandsByName(BUILTIN_COMMANDS)
|
||||
|
||||
export function useCommands(opcodeUrl: string | null) {
|
||||
const [commands, setCommands] = useState<CommandType[]>(sortCommandsByName(BUILTIN_COMMANDS))
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!opcodeUrl) return
|
||||
|
||||
const fetchCommands = async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
|
||||
try {
|
||||
const client = createOpenCodeClient(opcodeUrl)
|
||||
const commandList = await client.listCommands()
|
||||
const allCommands = [...BUILTIN_COMMANDS, ...commandList]
|
||||
const uniqueCommands = allCommands.filter((command, index, self) =>
|
||||
index === self.findIndex((c) => c.name === command.name)
|
||||
)
|
||||
setCommands(sortCommandsByName(uniqueCommands))
|
||||
} catch {
|
||||
setError('Failed to load commands')
|
||||
setCommands(sortCommandsByName(BUILTIN_COMMANDS))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
fetchCommands()
|
||||
}, [opcodeUrl])
|
||||
const { data: commands, isLoading: loading, error } = useQuery({
|
||||
queryKey: ['opencode', 'commands', opcodeUrl],
|
||||
queryFn: async () => {
|
||||
const client = createOpenCodeClient(opcodeUrl!)
|
||||
const commandList = await client.listCommands()
|
||||
const allCommands = [...BUILTIN_COMMANDS, ...commandList]
|
||||
const uniqueCommands = allCommands.filter((command, index, self) =>
|
||||
index === self.findIndex((c) => c.name === command.name)
|
||||
)
|
||||
return sortCommandsByName(uniqueCommands)
|
||||
},
|
||||
enabled: !!opcodeUrl,
|
||||
initialData: SORTED_BUILTIN_COMMANDS,
|
||||
})
|
||||
|
||||
const filterCommands = (query: string) => {
|
||||
if (!query.trim()) return commands
|
||||
@@ -210,7 +197,7 @@ export function useCommands(opcodeUrl: string | null) {
|
||||
return {
|
||||
commands,
|
||||
loading,
|
||||
error,
|
||||
error: error ? 'Failed to load commands' : null,
|
||||
filterCommands
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user