Skip to content

An open-source, faster Devin alternative

TypeScript

Work index: one branch for re-reading a closed page after its bodies are read

Igor Zalutski via Computer1315cd356891
diff --git a/services/managed-agents/src/computer/work/index.ts b/services/managed-agents/src/computer/work/index.ts
index ec3dcb34..5ce48ae8 100644
--- a/services/managed-agents/src/computer/work/index.ts
+++ b/services/managed-agents/src/computer/work/index.ts
@@ -506,8 +506,10 @@ export class WorkIndex {
let rows = select();
const pending = rows.slice(0, limit).filter((r) => r.parser === 0);
// Bodies not read yet are read now, for at most READ_WAIT_MS; the page then shows what it has.
- if (pending.length && (await within(this.clock, READ_WAIT_MS, this.fillLater(pending).then(() => true), () => false))) rows = select();
- else if (pending.length) rows = select();
+ if (pending.length) {
+ await within(this.clock, READ_WAIT_MS, this.fillLater(pending).then(() => true), () => false);
+ rows = select();
+ }
const page = rows.slice(0, limit);
const nextCursor = rows.length > limit ? encodeCursor({ n: page[page.length - 1]!.number }) : null;
return { ok: true, ...this.readState(), repository, items: this.indexed(page), nextCursor };