Show actual file changes recorded for each Agent task
Verify control plane / verify (push) Canceled after 0s
Verify control plane / verify (pull_request) Canceled after 0s

This commit is contained in:
WebUp Cloud committed 2026-11-08 09:10:32 +08:00
1 parent d04777247b
commit 3296d378c9
14 files changed
+453 -16

No files matched your search

@@ -745,6 +745,67 @@ class AgentWorkerIntegrationTest {
return result;
}
@Test
void toolFileChangesAreSummedAndVisibleOnlyToTheTaskOwner() throws Exception {
UUID id =
(UUID)
tasks
.create(user, project, model, "Build", new BigDecimal("20"), "file-changes")
.get("id");
var claimed = tasks.claim();
when(transport.request(anyString(), anyString(), anyString(), anyString(), anyInt(), any()))
.thenReturn(
response("Write", "write_file"),
response("Edit", "write_file"),
response("Done", null));
when(sandbox.execute(eq(project), any()))
.thenReturn(
"""
{"written":12,"fileChanges":{"complete":true,"files":[{"path":"index.html","status":"ADDED","added":3,"removed":0,"binary":false}]}}
""",
"""
{"written":10,"fileChanges":{"complete":true,"files":[{"path":"index.html","status":"MODIFIED","added":1,"removed":2,"binary":false}]}}
""");
new AgentWorker(tasks, gateway, sandbox, vault, json).run(claimed);
assertEquals("COMPLETED", tasks.config(id).get("status"));
assertTrue(
tasks.history(id).stream()
.noneMatch(message -> message.toString().contains("fileChanges")));
String token =
users
.login("worker@test.com", "StrongPassword123", "test", "test", 1)
.get("token")
.toString();
mvc.perform(get("/api/tasks/" + id + "/changes").header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andExpect(
org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(
"$.totals.file_count")
.value(1))
.andExpect(
org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(
"$.totals.added_lines")
.value(4))
.andExpect(
org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(
"$.totals.removed_lines")
.value(2))
.andExpect(
org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(
"$.files[0].last_status")
.value("MODIFIED"));
users.create("other-owner@test.com", "Other", "StrongPassword123", "test");
String other =
users
.login("other-owner@test.com", "StrongPassword123", "test", "test", 1)
.get("token")
.toString();
mvc.perform(get("/api/tasks/" + id + "/changes").header("Authorization", "Bearer " + other))
.andExpect(status().isNotFound());
}
@Test
void failedToolReturnsResultsForWholeBatchAndLetsAgentRecover() throws Exception {
var batch = response("Build, then update the site", "run_command");