Skip to content

Find code by asking what it does. A CLI for coding agents that uses Jev to discover relevant files and source context.

fix: retain scored navigation on probe cancellation

David Zhang5e4bcdce209f
diff --git a/packages/core/src/retrieve.ts b/packages/core/src/retrieve.ts
index 085ace2..e13b30d 100644
--- a/packages/core/src/retrieve.ts
+++ b/packages/core/src/retrieve.ts
@@ -197,11 +197,11 @@ export async function retrieve(input: SearchInput, evaluator: Evaluator): Promis
if (score >= weakScoreCeiling) strongScoreSeen = true;
if (score > relevanceBoundary) positiveScoresSeen++;
}
- await confirmSource(classified);
results.push(...classified);
group.results = classified;
group.state = "done";
flush();
+ await confirmSource(classified);
}
function pump() {
while (
diff --git a/test/discovery.test.ts b/test/discovery.test.ts
index edf21b1..b428cca 100644
--- a/test/discovery.test.ts
+++ b/test/discovery.test.ts
@@ -1104,3 +1104,43 @@ testIfDocker(
}
},
);
+
+testIfDocker(
+ "cancellation during per-group source confirmation preserves the scored Python file",
+ async () => {
+ const root = await mkdtemp(join(tmpdir(), "jg-discovery-probe-cancel-"));
+ const controller = new AbortController();
+ const source = await import("../packages/core/src/source");
+ const { spyOn } = await import("bun:test");
+ const reason = new DOMException("cancelled during probe", "AbortError");
+ let inspect;
+ try {
+ await writeFile(
+ join(root, "target.py"),
+ "class Target:\n def run(self):\n return 1\n",
+ );
+ inspect = spyOn(source, "inspect").mockImplementation(async () => {
+ controller.abort(reason);
+ throw reason;
+ });
+ const result = await retrieve(
+ { root, query: "find Target", signal: controller.signal },
+ {
+ requests: 0,
+ async evaluate(request) {
+ const items = (request.state as { items?: unknown[] }).items;
+ return Object.fromEntries(
+ Object.keys(request.questions).map((id) => [id, items ? 0.9 : 0.9]),
+ );
+ },
+ },
+ );
+ expect(result.status).toBe("interrupted");
+ expect(result.files.map(({ path }) => path)).toContain("target.py");
+ } finally {
+ controller.abort(reason);
+ inspect?.mockRestore();
+ await rm(root, { recursive: true, force: true });
+ }
+ },
+);