mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +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
@@ -112,7 +112,7 @@ export function remoteProjectName(project: OpenCodeProject): string {
|
||||
|
||||
/**
|
||||
* Finds the project that owns a directory, matching its canonical directory and anything nested
|
||||
* inside it.
|
||||
* inside it. Nested projects share a canonical prefix, so the deepest match owns the directory.
|
||||
*
|
||||
* @param projects Projects of the server that owns the directory.
|
||||
* @param directory Directory whose owning project is resolved.
|
||||
@@ -122,9 +122,14 @@ export function findRemoteProjectForDirectory(
|
||||
projects: OpenCodeProject[],
|
||||
directory: string,
|
||||
): OpenCodeProject | undefined {
|
||||
return projects.find(
|
||||
(project) => directory === project.canonical || directory.startsWith(`${project.canonical}/`),
|
||||
)
|
||||
let owner: OpenCodeProject | undefined
|
||||
for (const project of projects) {
|
||||
if (directory !== project.canonical && !directory.startsWith(`${project.canonical}/`)) continue
|
||||
if (!owner || project.canonical.length > owner.canonical.length) {
|
||||
owner = project
|
||||
}
|
||||
}
|
||||
return owner
|
||||
}
|
||||
|
||||
export type VcsInfo = Awaited<ReturnType<OpenCodeApi['vcs']['get']>>['data']
|
||||
|
||||
Reference in new issue
Block a user