mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
refactor(session-search): move the AI Vault project key to shared
The host must spell a project key exactly as the client does, so the two sides share one function instead of two copies that can drift.
This commit is contained in:
@@ -1,18 +1,9 @@
|
||||
import type { ProjectHostSetup } from '../../../../shared/project-types'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { Worktree } from '../../../../shared/worktree/types'
|
||||
import { toAiVaultProjectKey } from '../../../../shared/ai-vault-project-key'
|
||||
|
||||
export function toAiVaultProjectKey(
|
||||
projectId: string | null | undefined,
|
||||
repoId?: string | null
|
||||
): string | null {
|
||||
if (projectId) {
|
||||
// Why: legacy projections can already use repo-prefixed project ids; wrapping
|
||||
// them again would split active scope and resolved session keys.
|
||||
return projectId.startsWith('repo:') ? projectId : `project:${projectId}`
|
||||
}
|
||||
return repoId ? `repo:${repoId}` : null
|
||||
}
|
||||
export { toAiVaultProjectKey } from '../../../../shared/ai-vault-project-key'
|
||||
|
||||
export function resolveActiveProjectKey(
|
||||
activeRepo: Repo | null,
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { ProjectHostSetupProjection } from '../../../../shared/project-host
|
||||
import type { ProjectHostSetup } from '../../../../shared/project-types'
|
||||
import type { Worktree } from '../../../../shared/worktree/types'
|
||||
import { splitWorktreeIdForFilesystem } from '../../../../shared/worktree/id'
|
||||
import { toAiVaultProjectKey } from '../../../../shared/ai-vault-project-key'
|
||||
|
||||
export function deriveAiVaultWorkspaceScopePaths(
|
||||
activeWorktree: Pick<Worktree, 'id' | 'path' | 'priorWorktreeIds' | 'repoId'> | null,
|
||||
@@ -103,11 +104,7 @@ function worktreeProjectKey(
|
||||
entry: Pick<Worktree, 'projectId' | 'repoId'> | { projectId?: string | null; repoId?: string },
|
||||
setup?: { projectId?: string | null; repoId?: string }
|
||||
): string | null {
|
||||
const projectId = entry.projectId ?? setup?.projectId ?? null
|
||||
if (projectId) {
|
||||
return projectId.startsWith('repo:') ? projectId : `project:${projectId}`
|
||||
}
|
||||
return entry.repoId ? `repo:${entry.repoId}` : null
|
||||
return toAiVaultProjectKey(entry.projectId ?? setup?.projectId ?? null, entry.repoId)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* One spelling of "which project" for the sessions panel and for a host
|
||||
* resolving a search scope, so a key minted on a client and a key matched on the
|
||||
* execution host cannot drift apart.
|
||||
*/
|
||||
export function toAiVaultProjectKey(
|
||||
projectId: string | null | undefined,
|
||||
repoId?: string | null
|
||||
): string | null {
|
||||
if (projectId) {
|
||||
// Why: legacy projections can already use repo-prefixed project ids; wrapping
|
||||
// them again would split active scope and resolved session keys.
|
||||
return projectId.startsWith('repo:') ? projectId : `project:${projectId}`
|
||||
}
|
||||
return repoId ? `repo:${repoId}` : null
|
||||
}
|
||||
Reference in New Issue
Block a user