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

@@ -2,6 +2,7 @@ package run.webup.platform;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.*;
@@ -377,8 +378,20 @@ public class TaskService {
@Transactional
public boolean tool(UUID id, String lease, ModelGateway.Call call, String output)
throws JsonProcessingException {
return tool(id, lease, call, output, false);
}
@Transactional
public boolean tool(
UUID id, String lease, ModelGateway.Call call, String output, boolean trackChanges)
throws JsonProcessingException {
locked(id, lease);
var result = json.readTree(output);
if (trackChanges) {
var report = result instanceof ObjectNode object ? object.remove("fileChanges") : null;
recordFileChanges(id, report);
output = result.toString();
}
boolean failed =
result.hasNonNull("error")
|| result.path("timedOut").asBoolean(false)
@@ -395,6 +408,62 @@ public class TaskService {
return failed;
}
private void recordFileChanges(UUID task, JsonNode report) {
if (report == null || !report.path("files").isArray() || report.path("files").size() > 120) {
db.update("UPDATE ai_tasks SET file_changes_partial=TRUE WHERE id=?", task);
return;
}
boolean partial = !report.path("complete").asBoolean(false);
for (var file : report.path("files")) {
String path = file.path("path").asText(), status = file.path("status").asText();
int added = file.path("added").asInt(-1), removed = file.path("removed").asInt(-1);
if (path.isEmpty()
|| path.indexOf(0) >= 0
|| path.getBytes(java.nio.charset.StandardCharsets.UTF_8).length > 1000
|| !Set.of("ADDED", "MODIFIED", "DELETED").contains(status)
|| added < 0
|| removed < 0) {
partial = true;
continue;
}
boolean binary = file.path("binary").asBoolean(false);
int updated =
db.update(
"UPDATE ai_task_file_changes SET last_status=?,added_lines=added_lines+?,"
+ " removed_lines=removed_lines+?,binary_change=(binary_change OR ?)"
+ " WHERE task_id=? AND file_path=?",
status,
added,
removed,
binary,
task,
path);
if (updated == 0) {
db.update(
"INSERT INTO ai_task_file_changes"
+ " (task_id,file_path,last_status,added_lines,removed_lines,binary_change)"
+ " VALUES (?,?,?,?,?,?)",
task,
path,
status,
added,
removed,
binary);
}
}
db.update(
"UPDATE ai_tasks SET file_change_checks=file_change_checks+1,"
+ " file_changes_partial=(file_changes_partial OR ?) WHERE id=?",
partial,
task);
}
@Transactional
public void markFileChangesPartial(UUID task, String lease) {
locked(task, lease);
recordFileChanges(task, null);
}
@Transactional
public void requireSource(UUID id, String lease) {
locked(id, lease);