mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix(frontend): resolve the deepest owning remote project and refresh VCS info after branch changes
findRemoteProjectForDirectory now returns the longest matching canonical path, so nested linked-server projects attribute sessions to the innermost project. Switching, creating and renaming a local branch invalidate that directory's VCS info query, so branch labels refresh immediately.
This commit is contained in:
1 parent
4b7652451b
commit
adb251081f
8 files changed
+128
-15
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { QueryClient } from '@tanstack/react-query'
|
||||
import { LOCAL_OPENCODE_SERVER_ID } from '@opencode-manager/shared/schemas'
|
||||
import { serverScopedKey } from '@/lib/serverScope'
|
||||
import type { GitStatusResponse } from '@/types/git'
|
||||
|
||||
export function sessionTranscriptQueryKey(sessionID: string | null | undefined) {
|
||||
@@ -14,6 +15,36 @@ export function invalidateShellCaches(queryClient: QueryClient) {
|
||||
queryClient.invalidateQueries({ queryKey: ['opencode', 'shells'] })
|
||||
}
|
||||
|
||||
/**
|
||||
* Query key of the VCS info cached for one directory on one server.
|
||||
*
|
||||
* @param directory Directory the info describes; a missing directory keeps the placeholder key.
|
||||
* @param serverId Server that owns the directory; defaults to the local one.
|
||||
*/
|
||||
export function vcsInfoQueryKey(
|
||||
directory: string | null | undefined,
|
||||
serverId: string = LOCAL_OPENCODE_SERVER_ID,
|
||||
) {
|
||||
return [...serverScopedKey(['opencode', 'vcs', directory ?? ''], serverId), 'info']
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the VCS info of one directory so a branch change reaches every surface that shows the
|
||||
* branch, while the status and diff caches of the same directory stay untouched.
|
||||
*
|
||||
* @param queryClient Client that owns the cache.
|
||||
* @param directory Directory whose info is invalidated; a missing directory is ignored.
|
||||
* @param serverId Server that owns the directory; defaults to the local one.
|
||||
*/
|
||||
export function invalidateVcsInfoCache(
|
||||
queryClient: QueryClient,
|
||||
directory: string | null | undefined,
|
||||
serverId: string = LOCAL_OPENCODE_SERVER_ID,
|
||||
) {
|
||||
if (!directory) return
|
||||
queryClient.invalidateQueries({ queryKey: vcsInfoQueryKey(directory, serverId), exact: true })
|
||||
}
|
||||
|
||||
export function childSessionReconciliationQueryKey(sessionID: string | null | undefined) {
|
||||
return ['opencode', 'session-reconcile', sessionID]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user