mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +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
@@ -13,12 +13,26 @@ import type {
|
||||
SkillScope,
|
||||
InstallSkillFromGithubRequest,
|
||||
InstallSkillResponse,
|
||||
OpenCodeDirectoryFileInfo,
|
||||
} from './types/settings'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import { fetchWrapper, FetchError } from './fetchWrapper'
|
||||
|
||||
const DEFAULT_USER_ID = 'default'
|
||||
|
||||
function appendFilesWithManifest(formData: FormData, files: File[]): void {
|
||||
const fileManifest: Array<{ fieldName: string; relativePath: string }> = []
|
||||
|
||||
files.forEach((file, index) => {
|
||||
const fieldName = `file${index}`
|
||||
const relativePath = file.webkitRelativePath || file.name
|
||||
fileManifest.push({ fieldName, relativePath })
|
||||
formData.append(fieldName, file)
|
||||
})
|
||||
|
||||
formData.append('fileManifest', JSON.stringify(fileManifest))
|
||||
}
|
||||
|
||||
export const settingsApi = {
|
||||
getSettings: async (userId = DEFAULT_USER_ID): Promise<SettingsResponse> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings`, {
|
||||
@@ -291,22 +305,65 @@ export const settingsApi = {
|
||||
if (data.repoId !== undefined) formData.append('repoId', String(data.repoId))
|
||||
if (data.overwrite !== undefined) formData.append('overwrite', String(data.overwrite))
|
||||
|
||||
const fileManifest: Array<{ fieldName: string; relativePath: string }> = []
|
||||
|
||||
data.files.forEach((file, index) => {
|
||||
const fieldName = `file${index}`
|
||||
const relativePath = file.webkitRelativePath || file.name
|
||||
fileManifest.push({ fieldName, relativePath })
|
||||
formData.append(fieldName, file)
|
||||
})
|
||||
|
||||
formData.append('fileManifest', JSON.stringify(fileManifest))
|
||||
appendFilesWithManifest(formData, data.files)
|
||||
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills/install`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
},
|
||||
|
||||
installOpenCodeDirectoryFiles: async (data: {
|
||||
kind: 'agents' | 'commands'
|
||||
files: File[]
|
||||
}): Promise<{ kind: 'agents' | 'commands'; filesInstalled: string[] }> => {
|
||||
const formData = new FormData()
|
||||
formData.append('kind', data.kind)
|
||||
|
||||
appendFilesWithManifest(formData, data.files)
|
||||
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/opencode-directory-files/install`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
},
|
||||
|
||||
listOpenCodeDirectoryFiles: async (kind: 'agents' | 'commands'): Promise<OpenCodeDirectoryFileInfo[]> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/opencode-directory-files`, {
|
||||
params: { kind },
|
||||
})
|
||||
},
|
||||
|
||||
getOpenCodeDirectoryFile: async (
|
||||
kind: 'agents' | 'commands',
|
||||
relativePath: string,
|
||||
): Promise<OpenCodeDirectoryFileInfo & { content: string }> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/opencode-directory-files/content`, {
|
||||
params: { kind, relativePath },
|
||||
})
|
||||
},
|
||||
|
||||
updateOpenCodeDirectoryFile: async (data: {
|
||||
kind: 'agents' | 'commands'
|
||||
relativePath: string
|
||||
content: string
|
||||
}): Promise<OpenCodeDirectoryFileInfo> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/opencode-directory-files`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
},
|
||||
|
||||
deleteOpenCodeDirectoryFile: async (
|
||||
kind: 'agents' | 'commands',
|
||||
relativePath: string,
|
||||
): Promise<{ kind: 'agents' | 'commands'; relativePath: string }> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/opencode-directory-files`, {
|
||||
method: 'DELETE',
|
||||
params: { kind, relativePath },
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export interface VersionInfo {
|
||||
|
||||
Reference in new issue
Block a user