mirror of
https://github.com/stablyai/orca.git
synced 2026-10-15 08:03:08 +00:00
fix: handle large workspace cleanup comment lists
This commit is contained in:
@@ -344,6 +344,34 @@ describe('workspace cleanup scan', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('handles persisted diff note lists larger than the JavaScript argument limit', async () => {
|
||||
const diffComments = Array.from({ length: 130_000 }, (_, index): DiffComment => {
|
||||
return {
|
||||
id: `comment-${index}`,
|
||||
worktreeId: 'repo-1::/repo-feature',
|
||||
filePath: 'src/file.ts',
|
||||
lineNumber: 12,
|
||||
body: 'Follow up before deleting',
|
||||
createdAt: NOW - index,
|
||||
side: 'modified'
|
||||
}
|
||||
})
|
||||
|
||||
const result = await scanWorkspaceCleanup(
|
||||
makeStore({
|
||||
baseRef: undefined,
|
||||
diffComments
|
||||
})
|
||||
)
|
||||
|
||||
expect(result.candidates[0]).toMatchObject({
|
||||
localContext: {
|
||||
diffCommentCount: diffComments.length,
|
||||
newestDiffCommentAt: NOW
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('does not expose PR cache state in inactivity cleanup results', async () => {
|
||||
const result = await scanWorkspaceCleanup(
|
||||
makeStore({
|
||||
|
||||
@@ -582,7 +582,15 @@ function getNewestDiffCommentAt(diffComments: Worktree['diffComments'] | undefin
|
||||
if (!diffComments || diffComments.length === 0) {
|
||||
return null
|
||||
}
|
||||
return Math.max(...diffComments.map((comment) => comment.createdAt))
|
||||
// Why: persisted review notes can exceed V8's argument limit if expanded
|
||||
// into Math.max(), and cleanup must still show the workspace safely.
|
||||
let newest = Number.NEGATIVE_INFINITY
|
||||
for (const comment of diffComments) {
|
||||
if (comment.createdAt > newest) {
|
||||
newest = comment.createdAt
|
||||
}
|
||||
}
|
||||
return newest
|
||||
}
|
||||
|
||||
function createEmptyGitEvidence(): GitEvidence {
|
||||
|
||||
Reference in New Issue
Block a user