mirror of
https://github.com/stablyai/orca.git
synced 2026-10-27 16:02:42 +00:00
fix: hydrate large daemon pty session lists
This commit is contained in:
@@ -206,4 +206,24 @@ describe('hydrateLocalPtyRegistryAtBoot', () => {
|
||||
expect(entry!.pid).toBe(4242)
|
||||
expect(entry!.worktreeId).toBe('repo-a::/local/Triton')
|
||||
})
|
||||
|
||||
it('registers daemon session lists larger than the JavaScript argument limit', async () => {
|
||||
const { hydrate, listRegisteredPtys } = await loadFresh()
|
||||
|
||||
const sessions = Array.from({ length: 130_000 }, (_, index) => {
|
||||
const ptyId = `repo-a::/local/Triton@@session-${index}`
|
||||
return { sessionId: ptyId, pid: index + 1, cwd: '/local/Triton' } as unknown as SessionInfo
|
||||
})
|
||||
const provider = makeProvider(sessions)
|
||||
getDaemonProviderMock.mockReturnValue(provider)
|
||||
listRepoWorktreesMock.mockResolvedValue([
|
||||
{ path: '/local/Triton', head: '', branch: '', isBare: false, isMainWorktree: true }
|
||||
])
|
||||
|
||||
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
await hydrate(makeStore([{ id: 'repo-a', connectionId: null }]))
|
||||
warnSpy.mockRestore()
|
||||
|
||||
expect(listRegisteredPtys()).toHaveLength(sessions.length)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -146,7 +146,7 @@ async function collectSessionInfos(
|
||||
for (const adapter of adapters) {
|
||||
try {
|
||||
const sessions = await adapter.listSessions()
|
||||
out.push(...sessions)
|
||||
appendSessionInfos(out, sessions)
|
||||
} catch (err) {
|
||||
// Why: a single adapter failing should not abort hydration of the
|
||||
// others — the current adapter and any legacy daemons each have
|
||||
@@ -159,3 +159,11 @@ async function collectSessionInfos(
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function appendSessionInfos(target: SessionInfo[], source: readonly SessionInfo[]): void {
|
||||
// Why: a daemon can return an unexpectedly large live-session list; spreading
|
||||
// it into push would look like an adapter failure and drop every session.
|
||||
for (const session of source) {
|
||||
target.push(session)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user