fix: address pr-bug-scan validated finding from #8267

Added isRuntimeScopedRepo guard to Step 3 browser-ingest loop in mergeSnapshotAndSessions.ts, mirroring Steps 1/2; runtime repos no longer get a Resource Manager row.
This commit is contained in:
orca-bug-scan-bot
2026-07-11 20:25:20 -07:00
parent 5092ba9fb8
commit d954a30597
2 changed files with 37 additions and 0 deletions
@@ -107,6 +107,38 @@ describe('mergeSnapshotAndSessions', () => {
})
})
it('excludes runtime-scoped browser-only workspaces', () => {
const worktree = {
id: 'runtime-repo::/runtime/browser-only',
repoId: 'runtime-repo',
displayName: 'browser-only'
} as Worktree
const browser = {
id: 'browser-1',
worktreeId: worktree.id,
title: 'Orca docs',
url: 'https://docs.orca.dev',
loading: false,
faviconUrl: null,
canGoBack: false,
canGoForward: false,
loadError: null,
createdAt: 1
} as BrowserWorkspace
const out = mergeSnapshotAndSessions(
null,
[],
baseCtx({
repoDisplayNameById: new Map([['runtime-repo', 'RUNTIME']]),
repoRuntimeScopedById: new Map([['runtime-repo', true]]),
worktreeById: new Map([[worktree.id, worktree]]),
browserTabsByWorktree: { [worktree.id]: [browser] }
})
)
expect(out).toEqual([])
})
it('passes through snapshot worktrees with numeric metrics and hasLocalSamples', () => {
const wt: WorktreeMemory = {
worktreeId: 'orca::/Users/me/Triton',
@@ -302,6 +302,11 @@ export function mergeSnapshotAndSessions(
if (!worktree || browsers.length === 0) {
continue
}
// Why: runtime-hosted repos are excluded from Steps 1 and 2; a mirrored
// browser must not re-expose one as a local repo/worktree row here.
if (isRuntimeScopedRepo(worktree.repoId)) {
continue
}
const repoName = ctx.repoDisplayNameById.get(worktree.repoId) || worktree.repoId
const repo = ensureRepo(worktree.repoId, repoName)
let row = findWorktreeRow(repo, worktreeId)