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:
Chris Scott authored and GitHub committed 2026-06-20 00:40:36 -04:00
1 parent e53b4fd32c
commit 617962f2dd
48 files changed
+1522 -293

No files matched your search

+31 -2
View File
@@ -4,11 +4,12 @@ import { useNavigate } from 'react-router-dom'
import { useQueryClient, useQuery } from '@tanstack/react-query'
import { OpenCodeClient } from '@/api/opencode'
import { listRepos } from '@/api/repos'
import type { PermissionRequest, PermissionResponse, QuestionRequest, SSEEvent, SSHHostKeyRequest, MessageWithParts } from '@/api/types'
import type { PermissionRequest, PermissionResponse, QuestionRequest, SSEEvent, SSHHostKeyRequest, MessageWithParts, Repo } from '@/api/types'
import { showToast } from '@/lib/toast'
import { openCodeEventStream, type EventStreamHealthState } from '@/lib/opencode-event-stream'
import { OPENCODE_API_ENDPOINT } from '@/config'
import { addToSessionKeyedState, removeFromSessionKeyedState } from '@/lib/sessionKeyedState'
import { invalidateRepoGitCachesDebounced } from '@/lib/queryInvalidation'
type PermissionsBySession = Record<string, PermissionRequest[]>
type QuestionsBySession = Record<string, QuestionRequest[]>
@@ -29,6 +30,18 @@ function sortById<T extends SessionScopedItem>(items: T[]): T[] {
return [...items].sort((a, b) => a.id.localeCompare(b.id))
}
function normalizeDirectory(directory?: string | null) {
return directory?.replace(/\/+$/, '') ?? null
}
function repoMatchesDirectory(repo: Repo, directory?: string | null) {
const normalizedDirectory = normalizeDirectory(directory)
if (!normalizedDirectory) return false
return [repo.fullPath, repo.localPath, repo.sourcePath]
.some((path) => normalizeDirectory(path) === normalizedDirectory)
}
function reconcileBySessionForDirectory<T extends SessionScopedItem>(
prev: Record<string, T[]>,
directory: string,
@@ -265,7 +278,7 @@ export function EventProvider({ children }: { children: React.ReactNode }) {
if (!repos) return null
const directory = findSessionDirectory(sessionID)
if (!directory) return null
const repo = repos.find(r => r.fullPath === directory)
const repo = repos.find(r => repoMatchesDirectory(r, directory))
return repo?.id ?? null
}, [repos, findSessionDirectory])
@@ -503,6 +516,22 @@ export function EventProvider({ children }: { children: React.ReactNode }) {
queryKey: ['opencode', 'lsp']
})
break
case 'vcs.branch.updated': {
const repo = reposRef.current?.find((candidate) => repoMatchesDirectory(candidate, event.directory))
if (!repo) break
const branch = event.properties.branch
if (branch) {
const updatedRepo = { ...repo, currentBranch: branch, branch }
queryClient.setQueryData(['repo', repo.id], updatedRepo)
queryClient.setQueryData<Repo[]>(['repos'], (current) =>
current?.map((candidate) => candidate.id === repo.id ? updatedRepo : candidate)
)
}
invalidateRepoGitCachesDebounced(queryClient, repo.id)
break
}
}
}