fix(session-history): keep Pi listed for scope-only and let scoped rows stand in across scopes

OMP shares Pi's folder under PI_CODING_AGENT_DIR and Pi's listing decides which files OMP parses, so scope-only keeps listing Pi. Workspace and Project rows now stand in for any scope but All, since the renderer filter narrows them.
This commit is contained in:
Kelvin Amoaba
2026-11-08 21:17:48 +00:00
parent 477fd82c86
commit fd13c174f7
3 changed files with 20 additions and 6 deletions
@@ -138,6 +138,17 @@ describe('scanAiVaultSessions with overlapping Pi and OMP roots', () => {
layout: 'a parent folder for a workspace',
piRoot: parentFolder,
scope: { scopePaths: ['/repo/app'], limit: 1 }
},
// Workspace and Project skip the recency pass for cwd-bucket agents.
{
layout: 'the same folder for a scope-only workspace',
piRoot: sameFolder,
scope: { scopePaths: ['/repo/app'], scopeOnly: true }
},
{
layout: 'a parent folder for a scope-only workspace',
piRoot: parentFolder,
scope: { scopePaths: ['/repo/app'], scopeOnly: true }
}
])('lists each transcript once under its writer when Pi scans $layout', async (testCase) => {
const root = await mkdtemp(join(tmpdir(), 'orca-ai-vault-pi-omp-shared-'))
@@ -52,7 +52,12 @@ function agentDiscoveries(
): Promise<SessionFileDiscovery>[] {
const rootDirs = source.rootDirs(options, wslHomeDirs)
// Scope-only scans read cwd-bucket agents through their bucket inventory and can't place cwd-less ones.
if (scopeOnlyScan(options) && !scopeWalksAgentFiles(agent, options.scopePaths)) {
// Pi stays listed: OMP shares its folder under PI_CODING_AGENT_DIR, and Pi's listing decides who parses a file.
if (
scopeOnlyScan(options) &&
!scopeWalksAgentFiles(agent, options.scopePaths) &&
agent !== 'pi'
) {
return rootDirs.map(async (rootDir) => ({ agent, rootDir, files: [] }))
}
const discover = (rootDir: string): Promise<SessionFileDiscovery> =>
@@ -81,11 +81,9 @@ export function useAiVaultSessionRefresh(
const mountedRef = useRef(true)
const publicationGateRef = useRef<AiVaultSessionPublicationGate>(undefined!)
publicationGateRef.current ??= new AiVaultSessionPublicationGate()
const scopeBaseKey = aiVaultSessionResultCacheKey(executionHostScope, scopePaths, scopeOnly)
const scanScopeKey = `${scopeBaseKey}\n${sessionLimit}`
// Another scope's scope-only rows would pass for this scope's list while it loads or after it fails.
const shown =
scan && (!scan.scopeOnly || scan.scopeKey === `${scopeBaseKey}\n${scan.limit}`) ? scan : null
const scanScopeKey = `${aiVaultSessionResultCacheKey(executionHostScope, scopePaths, scopeOnly)}\n${sessionLimit}`
// Workspace or Project rows would pass for All's list while it loads or after it fails; the filter narrows the rest.
const shown = scan?.scopeOnly && !scopeOnly ? null : scan
// Kept through rescans so a repeat failure doesn't blink; shown only for the scope that failed.
const error = failure?.scopeKey === scanScopeKey ? aiVaultScanErrorText(failure.cause) : null
const scopePathsRef = useRef<readonly string[]>(scopePaths)