Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

feat(review): give recorded failures a Review screen in the processor (#7809)

EthanHealy01e2a0a588d6ef
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventController.java b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventController.java
index 24d3558c25..07c992675f 100644
--- a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventController.java
+++ b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventController.java
@@ -55,6 +55,8 @@ public class FileRunEventController {
public FileRunEventsResponse list(
// Spring's converter 400s on a value outside the enum, so no hand-rolled parse.
@RequestParam(required = false) FileRunEventStatus status,
+ // The settled rows rather than the open queue; an explicit status wins over it.
+ @RequestParam(defaultValue = "false") boolean closed,
@RequestParam(required = false) String kindId,
@RequestParam(required = false) Integer limit) {
// No role gate: the service scopes the read instead, so a member gets their own failures
@@ -64,7 +66,7 @@ public class FileRunEventController {
List<FileRunEventView> events =
// The kind filter is part of the query, before the limit is applied: filtering an
// already-limited page could return nothing while matching rows exist.
- service.list(status, kindId, cappedLimit).stream()
+ service.list(status, closed, kindId, cappedLimit).stream()
.map(event -> FileRunEventView.of(event, service.availableActions(event)))
.toList();
return new FileRunEventsResponse(events);
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventService.java b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventService.java
index e3aa15645c..17603fa601 100644
--- a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventService.java
+++ b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventService.java
@@ -118,12 +118,13 @@ public class FileRunEventService {
* The events the caller may read, newest first: the team's for a leader, their own for everyone
* else. Empty when their team cannot be resolved.
*/
- public List<FileRunEvent> list(FileRunEventStatus status, String kindId, int limit) {
+ public List<FileRunEvent> list(
+ FileRunEventStatus status, boolean closed, String kindId, int limit) {
ReadScope scope = readScope();
if (!scope.permitted()) {
return List.of();
}
- return store.list(scope.teamId(), status, kindId, scope.actor(), limit);
+ return store.list(scope.teamId(), status, closed, kindId, scope.actor(), limit);
}
/**
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStatus.java b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStatus.java
index 5e2499753a..bde4348c56 100644
--- a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStatus.java
+++ b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStatus.java
@@ -20,6 +20,10 @@ public enum FileRunEventStatus {
private static final List<FileRunEventStatus> OPEN =
Arrays.stream(values()).filter(status -> !status.terminal).toList();
+ /** The settled rest, kept so a reviewer can see how a past failure was disposed of. */
+ private static final List<FileRunEventStatus> CLOSED =
+ Arrays.stream(values()).filter(status -> status.terminal).toList();
+
/** Whether no further transition is possible: the row is closed. */
private final boolean terminal;
@@ -34,4 +38,8 @@ public enum FileRunEventStatus {
public static List<FileRunEventStatus> open() {
return OPEN;
}
+
+ public static List<FileRunEventStatus> closed() {
+ return CLOSED;
+ }
}
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStore.java b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStore.java
index 2ed86e61b2..f8b99e3e66 100644
--- a/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStore.java
+++ b/app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventStore.java
@@ -117,7 +117,8 @@ public class FileRunEventStore {
*
* <p>With no status asked for this is the <em>open</em> queue rather than every row ever
* recorded: a dismissed failure has been dealt with, and leaving it in the default view means
- * the list can never be cleared. Ask for a status to see closed rows.
+ * the list can never be cleared. {@code closed} asks for the settled rows instead, and a {@code
+ * status} for exactly one disposition; an explicit status wins over {@code closed}.
*
* <p>Both filters live in the query, before the limit: filtering an already-limited page could
* return nothing while matching rows exist.
@@ -127,12 +128,18 @@ public class FileRunEventStore {
*/
@Transactional(readOnly = true)
public List<FileRunEvent> list(
- Long teamId, FileRunEventStatus status, String kindId, String actor, int limit) {
+ Long teamId,
+ FileRunEventStatus status,
+ boolean closed,
+ String kindId,
+ String actor,
+ int limit) {
Pageable page = PageRequest.of(0, Math.max(1, limit));
+ List<FileRunEventStatus> statuses =
+ closed ? FileRunEventStatus.closed() : FileRunEventStatus.open();
List<FileRunEventEntity> rows =
status == null
- ? repository.findByTeamAndStatusIn(
- teamId, FileRunEventStatus.open(), kindId, actor, page)
+ ? repository.findByTeamAndStatusIn(teamId, statuses, kindId, actor, page)
: repository.findByTeamAndStatus(teamId, status, kindId, actor, page);
return rows.stream().map(FileRunEvent::of).toList();
}
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/notification/NotificationService.java b/app/proprietary/src/main/java/stirling/software/proprietary/notification/NotificationService.java
index 9c31f8385a..3b30e9be0f 100644
--- a/app/proprietary/src/main/java/stirling/software/proprietary/notification/NotificationService.java
+++ b/app/proprietary/src/main/java/stirling/software/proprietary/notification/NotificationService.java
@@ -30,7 +30,7 @@ public class NotificationService {
* where those are meant to be read, and it lists them unfiltered.
*/
public List<NotificationView> list(int limit) {
- return fileRunEvents.list(null, null, limit).stream()
+ return fileRunEvents.list(null, false, null, limit).stream()
.filter(event -> event.fileId() != null && !event.fileId().isBlank())
.map(this::fromFailure)
.toList();
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventControllerTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventControllerTest.java
index 4627e37bd4..6cf56a1ec7 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventControllerTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventControllerTest.java
@@ -108,7 +108,7 @@ class FileRunEventControllerTest {
given(FailureKind.UNKNOWN, TEAM, "mine");
given(FailureKind.UNKNOWN, 99L, "theirs");
- assertThat(controller.list(null, null, null).events())
+ assertThat(controller.list(null, false, null, null).events())
.extracting(FileRunEventView::fileId)
.containsExactly("mine");
}
@@ -117,7 +117,7 @@ class FileRunEventControllerTest {
void carriesTheCopyKeysAndTheEnglishFallback() {
given(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "f1");
- FileRunEventView view = controller.list(null, null, null).events().getFirst();
+ FileRunEventView view = controller.list(null, false, null, null).events().getFirst();
assertThat(view.titleKey())
.isEqualTo("portal.failures.kind.inputPasswordProtected.title");
@@ -134,7 +134,7 @@ class FileRunEventControllerTest {
given(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "f1");
List<FileRunEventView.ActionView> actions =
- controller.list(null, null, null).events().getFirst().actions();
+ controller.list(null, false, null, null).events().getFirst().actions();
assertThat(actions)
.extracting(FileRunEventView.ActionView::id)
@@ -148,7 +148,7 @@ class FileRunEventControllerTest {
// build with no copy for a newly shipped action still needs.
given(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "f1");
- assertThat(controller.list(null, null, null).events().getFirst().actions())
+ assertThat(controller.list(null, false, null, null).events().getFirst().actions())
.allSatisfy(
action -> {
assertThat(action.defaultLabel()).isNotBlank();
@@ -174,7 +174,7 @@ class FileRunEventControllerTest {
List<FileRunEventView.ActionView> actions =
controller
- .list(FileRunEventStatus.DISMISSED, null, null)
+ .list(FileRunEventStatus.DISMISSED, false, null, null)
.events()
.getFirst()
.actions();
@@ -184,23 +184,43 @@ class FileRunEventControllerTest {
.allMatch(a -> "portal.failures.disabled.closed".equals(a.disabledReasonKey()));
}
+ @Test
+ void listsEverySettledRowWhenAskedForTheClosedQueue() {
+ // Their own runs, or a RUN-scoped kind would fold all three into one incident.
+ FileRunEvent dismissed =
+ givenHitBy("[email protected]", FailureKind.UNKNOWN, TEAM, "dismissed");
+ givenHitBy("[email protected]", FailureKind.UNKNOWN, TEAM, "removed");
+ givenHitBy("[email protected]", FailureKind.UNKNOWN, TEAM, "still-open");
+ // One of each terminal disposition, which no single status filter could have returned.
+ controller.act(dismissed.id(), "DISMISS", null);
+ // Reported by the owner whose editor held it, which is who the row is filed under.
+ store.markFilesRemoved(TEAM, "[email protected]", List.of("removed"));
+
+ assertThat(controller.list(null, true, null, null).events())
+ .extracting(FileRunEventView::fileId)
+ .containsExactlyInAnyOrder("dismissed", "removed");
+ assertThat(controller.list(null, false, null, null).events())
+ .extracting(FileRunEventView::fileId)
+ .containsExactly("still-open");
+ }
+
@Test
void filtersByStatusAndByKind() {
FileRunEvent locked = given(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "locked");
given(FailureKind.UNKNOWN, TEAM, "open");
controller.act(locked.id(), "DISMISS", null);
- assertThat(controller.list(FileRunEventStatus.DISMISSED, null, null).events())
+ assertThat(controller.list(FileRunEventStatus.DISMISSED, false, null, null).events())
.extracting(FileRunEventView::fileId)
.containsExactly("locked");
// A dismissed row is decided, so the default queue holds only the other one.
- assertThat(controller.list(null, null, null).events())
+ assertThat(controller.list(null, false, null, null).events())
.extracting(FileRunEventView::fileId)
.containsExactly("open");
- assertThat(controller.list(null, "INPUT_PASSWORD_PROTECTED", null).events())
+ assertThat(controller.list(null, false, "INPUT_PASSWORD_PROTECTED", null).events())
.extracting(FileRunEventView::fileId)
.isEmpty();
- assertThat(controller.list(null, "NO_SUCH_KIND", null).events()).isEmpty();
+ assertThat(controller.list(null, false, "NO_SUCH_KIND", null).events()).isEmpty();
}
@Test
@@ -213,9 +233,9 @@ class FileRunEventControllerTest {
}
// Over-large and non-positive limits are both coerced rather than rejected.
- assertThat(controller.list(null, null, 100_000).events()).hasSize(5);
- assertThat(controller.list(null, null, 2).events()).hasSize(2);
- assertThat(controller.list(null, null, 0).events()).hasSize(1);
+ assertThat(controller.list(null, false, null, 100_000).events()).hasSize(5);
+ assertThat(controller.list(null, false, null, 2).events()).hasSize(2);
+ assertThat(controller.list(null, false, null, 0).events()).hasSize(1);
}
@Test
@@ -227,7 +247,7 @@ class FileRunEventControllerTest {
given(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "newer-" + i);
}
- assertThat(controller.list(null, "UNKNOWN", 1).events())
+ assertThat(controller.list(null, false, "UNKNOWN", 1).events())
.extracting(FileRunEventView::fileId)
.containsExactly("old-unknown");
}
@@ -352,7 +372,7 @@ class FileRunEventControllerTest {
givenHitBy("[email protected]", FailureKind.UNKNOWN, TEAM, "theirs");
when(authority.canEditPolicies()).thenReturn(false);
- assertThat(controller.list(null, null, null).events())
+ assertThat(controller.list(null, false, null, null).events())
.extracting(FileRunEventView::fileId)
.containsExactly("mine");
}
@@ -363,7 +383,7 @@ class FileRunEventControllerTest {
givenHitBy("[email protected]", FailureKind.UNKNOWN, TEAM, "theirs");
when(authority.canEditPolicies()).thenReturn(true);
- assertThat(controller.list(null, null, null).events())
+ assertThat(controller.list(null, false, null, null).events())
.extracting(FileRunEventView::fileId)
.containsExactlyInAnyOrder("mine", "theirs");
}
@@ -417,7 +437,7 @@ class FileRunEventControllerTest {
userService,
unsecured));
- assertThatCode(() -> noLogin.list(null, null, null)).doesNotThrowAnyException();
+ assertThatCode(() -> noLogin.list(null, false, null, null)).doesNotThrowAnyException();
// Not merely permitted: the role is never consulted at all, which is what makes the
// carve-out independent of however the authority answers with no users configured.
verify(authority, never()).canEditPolicies();
@@ -435,7 +455,7 @@ class FileRunEventControllerTest {
given(FailureKind.UNKNOWN, 99L, "theirs");
FileRunEventController.FileRunEventsResponse response =
- controller.list(null, null, null);
+ controller.list(null, false, null, null);
assertThat(response.events()).isEmpty();
assertThat(
@@ -464,7 +484,7 @@ class FileRunEventControllerTest {
given(FailureKind.UNKNOWN, null, "unteamed");
given(FailureKind.UNKNOWN, TEAM, "teamed");
- assertThat(noLogin.list(null, null, null).events())
+ assertThat(noLogin.list(null, false, null, null).events())
.extracting(FileRunEventView::fileId)
.containsExactly("unteamed");
}
@@ -486,7 +506,7 @@ class FileRunEventControllerTest {
new EditorFailureReport(
"compress", "E004", List.of("f-1"), "boom")))
.doesNotThrowAnyException();
- assertThat(controller.list(null, null, null).events())
+ assertThat(controller.list(null, false, null, null).events())
.extracting(FileRunEventView::fileId)
.containsExactly("f-1");
}
@@ -518,7 +538,14 @@ class FileRunEventControllerTest {
new EditorFailureReport("compress", "E004", atLimit, "boom");
assertThat(controller.report(report).getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
- assertThat(store.list(TEAM, null, null, null, EditorFailureReport.MAX_FILE_IDS + 10))
+ assertThat(
+ store.list(
+ TEAM,
+ null,
+ false,
+ null,
+ null,
+ EditorFailureReport.MAX_FILE_IDS + 10))
.hasSize(EditorFailureReport.MAX_FILE_IDS);
}
@@ -540,7 +567,14 @@ class FileRunEventControllerTest {
overLimit,
"boom"))))
.isEqualTo(HttpStatus.BAD_REQUEST);
- assertThat(store.list(TEAM, null, null, null, EditorFailureReport.MAX_FILE_IDS + 10))
+ assertThat(
+ store.list(
+ TEAM,
+ null,
+ false,
+ null,
+ null,
+ EditorFailureReport.MAX_FILE_IDS + 10))
.isEmpty();
}
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventServiceTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventServiceTest.java
index 504ec92ba9..a811875aab 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventServiceTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventServiceTest.java
@@ -129,7 +129,7 @@ class FileRunEventServiceTest {
FileRunEvent event = given(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "f1");
acknowledge(event, ACTOR);
- assertThat(service.list(FileRunEventStatus.ACKNOWLEDGED, null, 10)).hasSize(1);
+ assertThat(service.list(FileRunEventStatus.ACKNOWLEDGED, false, null, 10)).hasSize(1);
assertThat(service.dispatch(event.id(), "DISMISS", Map.of()).status())
.isEqualTo(FileRunEventStatus.DISMISSED);
}
@@ -169,7 +169,31 @@ class FileRunEventServiceTest {
assertThat(resolved.status()).isEqualTo(FileRunEventStatus.RESOLVED);
assertThat(resolved.statusActor()).isEqualTo(ACTOR);
- assertThat(service.list(null, null, 10)).as("resolved work is not open work").isEmpty();
+ assertThat(service.list(null, false, null, 10))
+ .as("resolved work is not open work")
+ .isEmpty();
+ assertThat(service.list(null, true, null, 10))
+ .as("but it is still on the record, with its outcome")
+ .extracting(FileRunEvent::status)
+ .containsExactly(FileRunEventStatus.RESOLVED);
+ }
+
+ @Test
+ void listsEverySettledDispositionInTheClosedQueue() {
+ FileRunEvent dismissed = given(FailureKind.UNKNOWN, TEAM, "f-dismissed");
+ FileRunEvent resolved = given(FailureKind.UNKNOWN, TEAM, "f-resolved");
+ FileRunEvent open = given(FailureKind.UNKNOWN, TEAM, "f-open");
+ service.dispatch(dismissed.id(), "DISMISS", Map.of());
+ service.resolve(resolved.id());
+
+ assertThat(service.list(null, true, null, 10))
+ .extracting(FileRunEvent::status)
+ .containsExactlyInAnyOrder(
+ FileRunEventStatus.DISMISSED, FileRunEventStatus.RESOLVED);
+ assertThat(service.list(null, false, null, 10))
+ .as("the open queue keeps only what still needs a decision")
+ .extracting(FileRunEvent::id)
+ .containsExactly(open.id());
}
@Test
@@ -213,12 +237,12 @@ class FileRunEventServiceTest {
void aRecurrenceReopensIt() {
// RESOLVED claims one attempt worked, not that the problem is gone for good.
service.report(new EditorFailureReport("compress", "E004", List.of("f-1"), "boom"));
- FileRunEvent event = service.list(null, null, 10).getFirst();
+ FileRunEvent event = service.list(null, false, null, 10).getFirst();
service.resolve(event.id());
service.report(new EditorFailureReport("compress", "E004", List.of("f-1"), "boom"));
- assertThat(service.list(null, null, 10))
+ assertThat(service.list(null, false, null, 10))
.singleElement()
.extracting(FileRunEvent::status)
.isEqualTo(FileRunEventStatus.NEW);
@@ -230,11 +254,11 @@ class FileRunEventServiceTest {
// into the closed row and the queue never shows the failure again.
service.report(new EditorFailureReport("compress", "E001", List.of("f-1"), "boom"));
service.forgetFiles(List.of("f-1"));
- assertThat(service.list(null, null, 10)).isEmpty();
+ assertThat(service.list(null, false, null, 10)).isEmpty();
service.report(new EditorFailureReport("compress", "E001", List.of("f-1"), "boom"));
- assertThat(service.list(null, null, 10))
+ assertThat(service.list(null, false, null, 10))
.singleElement()
.extracting(FileRunEvent::status)
.isEqualTo(FileRunEventStatus.NEW);
@@ -245,12 +269,12 @@ class FileRunEventServiceTest {
// Dismiss is a decision about the incident, not a claim about the document, so it
// outlasts a repeat where FILE_REMOVED and RESOLVED do not.
service.report(new EditorFailureReport("compress", "E001", List.of("f-1"), "boom"));
- FileRunEvent event = service.list(null, null, 10).getFirst();
+ FileRunEvent event = service.list(null, false, null, 10).getFirst();
service.dispatch(event.id(), "DISMISS", Map.of());
service.report(new EditorFailureReport("compress", "E001", List.of("f-1"), "boom"));
- assertThat(service.list(null, null, 10)).isEmpty();
+ assertThat(service.list(null, false, null, 10)).isEmpty();
}
}
@@ -634,7 +658,7 @@ class FileRunEventServiceTest {
given(FailureKind.UNKNOWN, TEAM, "mine");
given(FailureKind.UNKNOWN, 99L, "theirs");
- assertThat(service.list(null, null, 50))
+ assertThat(service.list(null, false, null, 50))
.extracting(FileRunEvent::fileId)
.containsExactly("mine");
}
@@ -649,7 +673,7 @@ class FileRunEventServiceTest {
FailureKind.UNKNOWN, TEAM, "[email protected]", "theirs", "boom"));
when(authority.canEditPolicies()).thenReturn(false);
- assertThat(service.list(null, null, 50))
+ assertThat(service.list(null, false, null, 50))
.extracting(FileRunEvent::fileId)
.containsExactly("mine");
}
@@ -662,7 +686,7 @@ class FileRunEventServiceTest {
when(authority.canEditPolicies()).thenReturn(false);
when(userService.getCurrentUsername()).thenReturn(null);
- assertThat(service.list(null, null, 50)).isEmpty();
+ assertThat(service.list(null, false, null, 50)).isEmpty();
}
@Test
@@ -709,7 +733,7 @@ class FileRunEventServiceTest {
given(FailureKind.UNKNOWN, TEAM, "mine");
when(authority.currentUserTeamId()).thenReturn(null);
- assertThat(service.list(null, null, 50)).isEmpty();
+ assertThat(service.list(null, false, null, 50)).isEmpty();
}
@Test
@@ -740,7 +764,7 @@ class FileRunEventServiceTest {
given(FailureKind.UNKNOWN, null, "unteamed");
given(FailureKind.UNKNOWN, TEAM, "teamed");
- assertThat(unsecured.list(null, null, 50))
+ assertThat(unsecured.list(null, false, null, 50))
.extracting(FileRunEvent::fileId)
.containsExactly("unteamed");
}
@@ -832,7 +856,7 @@ class FileRunEventServiceTest {
service.report(
new EditorFailureReport("remove-password", "E004", List.of("f-1"), "boom"));
- FileRunEvent event = store.list(TEAM, null, null, null, 10).getFirst();
+ FileRunEvent event = store.list(TEAM, null, false, null, null, 10).getFirst();
assertThat(event.kind()).isEqualTo(FailureKind.INPUT_PASSWORD_PROTECTED);
assertThat(event.origin()).isEqualTo(FailureOrigin.TOOL);
assertThat(event.fileId()).isEqualTo("f-1");
@@ -845,7 +869,7 @@ class FileRunEventServiceTest {
// session.
service.report(new EditorFailureReport("compress", "E004", List.of("f-1"), "boom"));
- FileRunEvent event = store.list(TEAM, null, null, null, 10).getFirst();
+ FileRunEvent event = store.list(TEAM, null, false, null, null, 10).getFirst();
assertThat(event.teamId()).isEqualTo(TEAM);
assertThat(event.actor()).isEqualTo(ACTOR);
}
@@ -860,7 +884,7 @@ class FileRunEventServiceTest {
service.report(new EditorFailureReport("compress", "E004", List.of("f-1"), "boom"));
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.singleElement()
.extracting(FileRunEvent::teamId)
.isEqualTo(TEAM);
@@ -870,7 +894,7 @@ class FileRunEventServiceTest {
void recordsAnUnrecognisedCodeAsUnknownRatherThanDroppingIt() {
service.report(new EditorFailureReport("ocr", "E999", List.of("f-1"), "no idea"));
- assertThat(store.list(TEAM, null, null, null, 10).getFirst().kind())
+ assertThat(store.list(TEAM, null, false, null, null, 10).getFirst().kind())
.isEqualTo(FailureKind.UNKNOWN);
}
@@ -878,7 +902,7 @@ class FileRunEventServiceTest {
void recordsAnAbsentCodeAsUnknown() {
service.report(new EditorFailureReport("ocr", null, List.of("f-1"), "network died"));
- assertThat(store.list(TEAM, null, null, null, 10).getFirst().kind())
+ assertThat(store.list(TEAM, null, false, null, null, 10).getFirst().kind())
.isEqualTo(FailureKind.UNKNOWN);
}
@@ -888,7 +912,7 @@ class FileRunEventServiceTest {
new EditorFailureReport(
"compress", "E004", List.of("f-1", "f-2", "f-3"), "boom"));
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.hasSize(3)
.extracting(FileRunEvent::fileId)
.containsExactlyInAnyOrder("f-1", "f-2", "f-3");
@@ -900,7 +924,7 @@ class FileRunEventServiceTest {
service.report(
new EditorFailureReport("compress", "E004", List.of("f-1"), "boom again"));
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.singleElement()
.extracting(FileRunEvent::occurrences)
.isEqualTo(2);
@@ -910,7 +934,7 @@ class FileRunEventServiceTest {
void recordsOneUnattributedIncidentWhenNoFileWasNamed() {
service.report(new EditorFailureReport("compress", "E004", List.of(), "boom"));
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.singleElement()
.extracting(FileRunEvent::fileId)
.isNull();
@@ -925,7 +949,7 @@ class FileRunEventServiceTest {
service.report(new EditorFailureReport("compress", "E004", many, "boom"));
- assertThat(store.list(TEAM, null, null, null, 200)).hasSize(60);
+ assertThat(store.list(TEAM, null, false, null, null, 200)).hasSize(60);
}
@Test
@@ -935,7 +959,7 @@ class FileRunEventServiceTest {
service.report(
new EditorFailureReport("remove-password", "E004", List.of("f-1"), "boom"));
- FileRunEvent event = store.list(TEAM, null, null, null, 10).getFirst();
+ FileRunEvent event = store.list(TEAM, null, false, null, null, 10).getFirst();
assertThat(event.detail()).contains("remove-password");
assertThat(event.fileId()).isEqualTo("f-1");
}
@@ -948,7 +972,7 @@ class FileRunEventServiceTest {
new EditorFailureReport(
"compress", "E004", List.of("f-1"), "Failed on Q4 report.pdf"));
- assertThat(store.list(TEAM, null, null, null, 10).getFirst().detail())
+ assertThat(store.list(TEAM, null, false, null, null, 10).getFirst().detail())
.isEqualTo("compress: Failed on Q4 report.pdf");
}
@@ -989,7 +1013,7 @@ class FileRunEventServiceTest {
reportedBy("[email protected]", "a-1");
reportedBy("[email protected]", "b-1");
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.extracting(FileRunEvent::actor)
.containsExactlyInAnyOrder("[email protected]", "[email protected]");
}
@@ -999,7 +1023,7 @@ class FileRunEventServiceTest {
reportedBy("[email protected]", "a-1");
reportedBy("[email protected]", "a-2");
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.extracting(FileRunEvent::fileId)
.containsExactlyInAnyOrder("a-1", "a-2");
}
@@ -1009,7 +1033,7 @@ class FileRunEventServiceTest {
reportedBy("[email protected]", "a-1");
reportedBy("[email protected]", "a-1");
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.singleElement()
.extracting(FileRunEvent::occurrences)
.isEqualTo(2);
@@ -1029,7 +1053,7 @@ class FileRunEventServiceTest {
reported("f-1");
assertThat(service.forgetFiles(List.of("f-1"))).isEqualTo(1);
- assertThat(service.list(null, null, 10))
+ assertThat(service.list(null, false, null, 10))
.as("the open queue is what the reviewer works from")
.isEmpty();
}
@@ -1039,7 +1063,7 @@ class FileRunEventServiceTest {
reported("f-1");
service.forgetFiles(List.of("f-1"));
- assertThat(service.list(FileRunEventStatus.FILE_REMOVED, null, 10))
+ assertThat(service.list(FileRunEventStatus.FILE_REMOVED, false, null, 10))
.singleElement()
.satisfies(
event -> {
@@ -1051,13 +1075,13 @@ class FileRunEventServiceTest {
@Test
void aReviewersDismissKeepsItsMeaningAndItsActor() {
reported("f-1");
- FileRunEvent event = service.list(null, null, 10).getFirst();
+ FileRunEvent event = service.list(null, false, null, 10).getFirst();
service.dispatch(event.id(), "DISMISS", Map.of());
assertThat(service.forgetFiles(List.of("f-1")))
.as("only open rows move; a closed one has already been decided")
.isZero();
- assertThat(service.list(FileRunEventStatus.DISMISSED, null, 10)).hasSize(1);
+ assertThat(service.list(FileRunEventStatus.DISMISSED, false, null, 10)).hasSize(1);
}
@Test
@@ -1087,7 +1111,7 @@ class FileRunEventServiceTest {
assertThat(service.forgetFiles(List.of())).isZero();
assertThat(service.forgetFiles(java.util.Arrays.asList(null, " "))).isZero();
- assertThat(service.list(null, null, 10)).hasSize(1);
+ assertThat(service.list(null, false, null, 10)).hasSize(1);
}
}
}
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreDbTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreDbTest.java
index af1353477d..148ee4bc60 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreDbTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreDbTest.java
@@ -79,12 +79,12 @@ class FileRunEventStoreDbTest {
store.record(failure(FailureKind.UNKNOWN, OTHER_TEAM, "theirs"));
store.record(failure(FailureKind.UNKNOWN, null, "unteamed"));
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.extracting(FileRunEvent::fileId)
.containsExactly("ours");
// A plain `e.teamId = :teamId` would return nothing here: SQL equality against NULL is
// never true, which is what the explicit null branch in the JPQL exists for.
- assertThat(store.list(null, null, null, null, 10))
+ assertThat(store.list(null, null, false, null, null, 10))
.extracting(FileRunEvent::fileId)
.containsExactly("unteamed");
}
@@ -100,12 +100,12 @@ class FileRunEventStoreDbTest {
failure(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "[email protected]", "f2"));
store.record(failure(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, null, "f3"));
- assertThat(store.list(TEAM, null, null, "[email protected]", 10))
+ assertThat(store.list(TEAM, null, false, null, "[email protected]", 10))
.extracting(FileRunEvent::fileId)
.containsExactly("f1");
// A null actor is "no filter", which is what a leader reads with: the whole team, including
// the rows nobody is named on.
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.extracting(FileRunEvent::fileId)
.containsExactlyInAnyOrder("f1", "f2", "f3");
}
@@ -196,7 +196,7 @@ class FileRunEventStoreDbTest {
assertThat(replacement.id()).isNotEqualTo(first.id());
assertThat(replacement.occurrences()).isEqualTo(1);
- assertThat(store.list(TEAM, null, null, null, 10)).hasSize(1);
+ assertThat(store.list(TEAM, null, false, null, null, 10)).hasSize(1);
}
@Test
@@ -214,7 +214,7 @@ class FileRunEventStoreDbTest {
FileRunEvent folded = store.record(secondSweep);
assertThat(folded.occurrences()).isEqualTo(2);
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.as("one incident per document, however many runs it failed in")
.extracting(FileRunEvent::fileId)
.containsExactlyInAnyOrder("file-hash-a", "file-hash-b");
@@ -321,7 +321,7 @@ class FileRunEventStoreDbTest {
store.record(failure(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "newer-" + i));
}
- assertThat(store.list(TEAM, null, "UNKNOWN", null, 1))
+ assertThat(store.list(TEAM, null, false, "UNKNOWN", null, 1))
.extracting(FileRunEvent::fileId)
.containsExactly("old-unknown");
}
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreTest.java
index 97de1952e9..cabf19356c 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/failure/FileRunEventStoreTest.java
@@ -281,7 +281,7 @@ class FileRunEventStoreTest {
store.record(failure(FailureKind.UNKNOWN, TEAM, "mine", "a"));
store.record(failure(FailureKind.UNKNOWN, OTHER_TEAM, "theirs", "b"));
- assertThat(store.list(TEAM, null, null, null, 50))
+ assertThat(store.list(TEAM, null, false, null, null, 50))
.extracting(FileRunEvent::fileId)
.containsExactly("mine");
}
@@ -293,7 +293,7 @@ class FileRunEventStoreTest {
store.record(failure(FailureKind.UNKNOWN, null, "unteamed", "a"));
store.record(failure(FailureKind.UNKNOWN, TEAM, "teamed", "b"));
- assertThat(store.list(null, null, null, null, 50))
+ assertThat(store.list(null, null, false, null, null, 50))
.extracting(FileRunEvent::fileId)
.containsExactly("unteamed");
}
@@ -305,8 +305,9 @@ class FileRunEventStoreTest {
FileRunEvent event = store.record(failure(FailureKind.UNKNOWN, TEAM, "f1", "boom"));
store.applyStatus(event.id(), TEAM, FileRunEventStatus.DISMISSED, "reviewer");
- assertThat(store.list(TEAM, null, null, null, 10)).isEmpty();
- assertThat(store.list(TEAM, FileRunEventStatus.DISMISSED, null, null, 10)).hasSize(1);
+ assertThat(store.list(TEAM, null, false, null, null, 10)).isEmpty();
+ assertThat(store.list(TEAM, FileRunEventStatus.DISMISSED, false, null, null, 10))
+ .hasSize(1);
}
@Test
@@ -314,7 +315,7 @@ class FileRunEventStoreTest {
FileRunEvent event = store.record(failure(FailureKind.UNKNOWN, TEAM, "f1", "boom"));
store.applyStatus(event.id(), TEAM, FileRunEventStatus.ACKNOWLEDGED, "reviewer");
- assertThat(store.list(TEAM, null, null, null, 10)).hasSize(1);
+ assertThat(store.list(TEAM, null, false, null, null, 10)).hasSize(1);
}
@Test
@@ -323,7 +324,7 @@ class FileRunEventStoreTest {
store.record(failure(FailureKind.INPUT_PASSWORD_PROTECTED, TEAM, "closed", "b"));
store.applyStatus(open.id(), TEAM, FileRunEventStatus.ACKNOWLEDGED, "me");
- assertThat(store.list(TEAM, FileRunEventStatus.ACKNOWLEDGED, null, null, 50))
+ assertThat(store.list(TEAM, FileRunEventStatus.ACKNOWLEDGED, false, null, null, 50))
.extracting(FileRunEvent::fileId)
.containsExactly("open");
}
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureAttributionTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureAttributionTest.java
index 2a71c236a7..3d1026524f 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureAttributionTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureAttributionTest.java
@@ -188,7 +188,7 @@ class PolicyFailureAttributionTest {
private FileRunEvent asMember(String reader) {
lenient().when(userService.getCurrentUsername()).thenReturn(reader);
lenient().when(authority.canEditPolicies()).thenReturn(false);
- List<FileRunEvent> visible = service.list(null, null, 10);
+ List<FileRunEvent> visible = service.list(null, false, null, 10);
return visible.isEmpty() ? null : visible.getFirst();
}
@@ -196,7 +196,7 @@ class PolicyFailureAttributionTest {
private FileRunEvent asReviewer(String reader) {
lenient().when(userService.getCurrentUsername()).thenReturn(reader);
lenient().when(authority.canEditPolicies()).thenReturn(true);
- return service.list(null, null, 10).getFirst();
+ return service.list(null, false, null, 10).getFirst();
}
@Nested
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureOwnershipTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureOwnershipTest.java
index 0ae6c3a945..0932b65a32 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureOwnershipTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureOwnershipTest.java
@@ -181,7 +181,7 @@ class PolicyFailureOwnershipTest {
private FileRunEvent asMember(String reader) {
lenient().when(userService.getCurrentUsername()).thenReturn(reader);
lenient().when(authority.canEditPolicies()).thenReturn(false);
- List<FileRunEvent> visible = service.list(null, null, 10);
+ List<FileRunEvent> visible = service.list(null, false, null, 10);
return visible.isEmpty() ? null : visible.getFirst();
}
@@ -189,7 +189,7 @@ class PolicyFailureOwnershipTest {
private FileRunEvent asReviewer(String reader) {
lenient().when(userService.getCurrentUsername()).thenReturn(reader);
lenient().when(authority.canEditPolicies()).thenReturn(true);
- return service.list(null, null, 10).getFirst();
+ return service.list(null, false, null, 10).getFirst();
}
private List<FailureActionId> offeredTo(FileRunEvent event) {
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureRecorderTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureRecorderTest.java
index 7472379d36..fd3589d41a 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureRecorderTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/failure/PolicyFailureRecorderTest.java
@@ -96,7 +96,7 @@ class PolicyFailureRecorderTest {
"Policy run failed: locked",
passwordFailure());
- FileRunEvent event = store.list(TEAM, null, null, null, 10).getFirst();
+ FileRunEvent event = store.list(TEAM, null, false, null, null, 10).getFirst();
assertThat(event.kind()).isEqualTo(FailureKind.INPUT_PASSWORD_PROTECTED);
assertThat(event.runId()).isEqualTo("run-1");
assertThat(event.policyId()).isEqualTo("policy-1");
@@ -122,7 +122,7 @@ class PolicyFailureRecorderTest {
"Policy run failed: something we do not recognise",
new RuntimeException("boom"));
- FileRunEvent event = store.list(TEAM, null, null, null, 10).getFirst();
+ FileRunEvent event = store.list(TEAM, null, false, null, null, 10).getFirst();
assertThat(event.kind()).isEqualTo(FailureKind.UNKNOWN);
assertThat(event.detail()).contains("something we do not recognise");
}
@@ -140,7 +140,7 @@ class PolicyFailureRecorderTest {
"Policy run failed: java.lang.NullPointerException",
new RuntimeException("npe"));
- FileRunEvent event = store.list(TEAM, null, null, null, 10).getFirst();
+ FileRunEvent event = store.list(TEAM, null, false, null, null, 10).getFirst();
assertThat(event.kind()).isEqualTo(FailureKind.UNKNOWN);
assertThat(event.detail()).contains("NullPointerException");
}
@@ -153,7 +153,7 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailureAs(
FailureKind.UNKNOWN, "run-3", "policy-1", null, null, "could not be queued");
- assertThat(store.list(TEAM, null, null, null, 10)).hasSize(1);
+ assertThat(store.list(TEAM, null, false, null, null, 10)).hasSize(1);
}
@Test
@@ -181,7 +181,7 @@ class PolicyFailureRecorderTest {
"locked",
passwordFailure());
- List<FileRunEvent> events = store.list(TEAM, null, null, null, 10);
+ List<FileRunEvent> events = store.list(TEAM, null, false, null, null, 10);
assertThat(events).hasSize(2);
assertThat(events).allMatch(event -> event.occurrences() == 1);
assertThat(events)
@@ -204,7 +204,7 @@ class PolicyFailureRecorderTest {
"locked",
passwordFailure());
- FileRunEvent event = store.list(TEAM, null, null, null, 10).getFirst();
+ FileRunEvent event = store.list(TEAM, null, false, null, null, 10).getFirst();
assertThat(event.sourceId()).isEqualTo("src-s3-invoices");
assertThat(event.actor()).isNull();
}
@@ -219,7 +219,7 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailureAs(
FailureKind.UNKNOWN, "run-2", "policy-1", "src-b", null, "unreachable");
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.hasSize(2)
.extracting(FileRunEvent::sourceId)
.containsExactlyInAnyOrder("src-a", "src-b");
@@ -246,7 +246,7 @@ class PolicyFailureRecorderTest {
"locked",
passwordFailure());
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.singleElement()
.extracting(FileRunEvent::occurrences)
.isEqualTo(2);
@@ -264,7 +264,7 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailure(
"run-1", "policy-1", null, null, null, "boom", new RuntimeException());
- assertThat(store.list(TEAM, null, null, null, 10)).hasSize(1);
+ assertThat(store.list(TEAM, null, false, null, null, 10)).hasSize(1);
}
@Test
@@ -274,8 +274,8 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailure(
"run-1", null, null, null, null, "boom", new RuntimeException());
- assertThat(store.list(null, null, null, null, 10)).hasSize(1);
- assertThat(store.list(TEAM, null, null, null, 10)).isEmpty();
+ assertThat(store.list(null, null, false, null, null, 10)).hasSize(1);
+ assertThat(store.list(TEAM, null, false, null, null, 10)).isEmpty();
}
@Test
@@ -294,7 +294,7 @@ class PolicyFailureRecorderTest {
new RuntimeException()))
.doesNotThrowAnyException();
// Still recorded, just unteamed: a lookup problem must not lose the incident.
- assertThat(store.list(null, null, null, null, 10)).hasSize(1);
+ assertThat(store.list(null, null, false, null, null, 10)).hasSize(1);
}
}
@@ -345,7 +345,7 @@ class PolicyFailureRecorderTest {
"no cause",
null))
.doesNotThrowAnyException();
- assertThat(store.list(TEAM, null, null, null, 10).getFirst().kind())
+ assertThat(store.list(TEAM, null, false, null, null, 10).getFirst().kind())
.isEqualTo(FailureKind.UNKNOWN);
}
}
@@ -363,7 +363,7 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailure(
"run-1", "policy-1", null, null, null, "boom", new IOException("x"));
- List<FileRunEvent> events = store.list(TEAM, null, null, null, 10);
+ List<FileRunEvent> events = store.list(TEAM, null, false, null, null, 10);
assertThat(events).hasSize(1);
assertThat(events.getFirst().occurrences()).isEqualTo(2);
}
@@ -378,7 +378,7 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailure(
"run-2", "policy-1", null, null, null, "boom", new IOException("x"));
- assertThat(store.list(TEAM, null, null, null, 10)).hasSize(2);
+ assertThat(store.list(TEAM, null, false, null, null, 10)).hasSize(2);
}
@Test
@@ -392,7 +392,7 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailure(
"run-2", "policy-1", null, "editor-file-1", ACTOR, "locked", passwordFailure());
- List<FileRunEvent> events = store.list(TEAM, null, null, null, 10);
+ List<FileRunEvent> events = store.list(TEAM, null, false, null, null, 10);
assertThat(events).hasSize(1);
assertThat(events.getFirst().occurrences()).isEqualTo(2);
}
@@ -407,7 +407,7 @@ class PolicyFailureRecorderTest {
recorder.recordRunFailure(
"run-2", "policy-1", null, "editor-file-2", ACTOR, "locked", passwordFailure());
- assertThat(store.list(TEAM, null, null, null, 10))
+ assertThat(store.list(TEAM, null, false, null, null, 10))
.hasSize(2)
.allMatch(event -> event.occurrences() == 1);
}
diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.toml
index f8c1d99f7a..b05fe1dc53 100644
--- a/frontend/editor/public/locales/en-US/translation.toml
+++ b/frontend/editor/public/locales/en-US/translation.toml
@@ -3333,6 +3333,7 @@ title = "Choose color"
actions = "Actions"
back = "Back"
cancel = "Cancel"
+clearFilters = "Clear filters"
close = "Close"
codeSample = "Code sample"
collapse = "Collapse"
@@ -3344,6 +3345,7 @@ done = "Done"
enterValue = "Enter value"
error = "Error"
expand = "Expand"
+filterEmpty = "Nothing to filter on"
loading = "Loading..."
next = "Next"
open = "Open"
@@ -3353,6 +3355,7 @@ refresh = "Refresh"
remaining = "Remaining"
retry = "Retry"
save = "Save"
+search = "Search"
stepOf = "Step {{current}} of {{total}}"
[compare]
@@ -8067,30 +8070,27 @@ retry = "Try again"
title = "Something went wrong on this page"
[portal.failures]
-fromSource = "From source {{source}}"
+closedBySystem = "Stirling"
+noMatches = "Nothing matches the current filters"
occurrences = "{{count}} occurrences"
-reportedBy = "Hit by {{actor}}"
-runReference = "Run {{runId}}"
-subtitle = "Failures recorded from your policy runs and your team's editors, with the actions you can take."
-title = "Failures"
+searchPlaceholder = "Search issues, users and errors"
[portal.failures.action]
acknowledge = "Acknowledge"
-confirm = "Are you sure?"
decrypt = "Decrypt and retry"
dismiss = "Dismiss"
-dismissSkipFile = "Skip this file"
openInTool = "Retry"
viewFile = "View file"
viewInProcessor = "View in processor"
-[portal.failures.debug]
-copyJson = "Copy JSON"
-dismissAll = "Dismiss all ({{total}})"
-dismissing = "Dismissing..."
-hideJson = "Hide raw JSON ({{total}})"
-refresh = "Refresh failures"
-showJson = "Show raw JSON ({{total}})"
+[portal.failures.columns]
+closedBy = "Closed by"
+date = "Date"
+failure = "Issue"
+origin = "Raised in"
+outcome = "Outcome"
+source = "Source"
+user = "User"
[portal.failures.disabled]
closed = "This failure is already closed."
@@ -8099,8 +8099,18 @@ unattended = "This file was fed by a folder, bucket or webhook, so nobody's brow
unavailable = "Not available for this failure."
[portal.failures.empty]
-description = "Policy runs that fail will appear here with the actions you can take."
-title = "No failures recorded"
+description = "Anything from a policy run or an editor tool that needs a look will appear here."
+title = "Nothing needs your attention"
+
+[portal.failures.emptyClosed]
+description = "Items you dismiss or resolve are kept here with their outcome."
+title = "Nothing closed yet"
+
+[portal.failures.filters]
+origin = "Raised in"
+source = "Source"
+type = "Type"
+user = "User"
[portal.failures.kind.inputPasswordProtected]
description = "Your file is password protected, so the run could not read it."
@@ -8108,19 +8118,34 @@ title = "Password-protected document"
[portal.failures.kind.unknown]
description = "Something went wrong that Stirling does not recognise yet."
-title = "Unrecognised failure"
+title = "Unrecognised issue"
+
+[portal.failures.log]
+copy = "Copy error"
+view = "View error"
[portal.failures.origin]
pipeline = "Pipeline"
-policy = "Policy"
-tool = "Tool run"
+policy = "Policy run"
+tool = "Editor tool"
-[portal.failures.stage]
-blocked = "Blocked"
-input = "Input"
-internal = "Internal"
-never_ran = "Never ran"
-output = "Output"
+[portal.failures.outcome]
+dismissed = "Dismissed"
+fileRemoved = "File deleted"
+open = "Open"
+resolved = "Resolved"
+
+[portal.failures.scope]
+ariaLabel = "Review state"
+closed = "Closed"
+open = "Open"
+
+[portal.failures.source]
+editor = "Editor"
+
+[portal.failures.unavailable]
+description = "This queue is visible to team leaders on workspaces that run policies."
+title = "Nothing to review"
[portal.home.download]
back = "Back"
@@ -8544,6 +8569,7 @@ integrations = "Integrations"
pipelines = "Pipelines"
policies = "Policies"
procurement = "Procurement"
+review = "Review"
sources = "Sources"
usage = "Usage & Billing"
users = "Users"
@@ -9482,6 +9508,10 @@ maxed = "Maxed out"
subtitle = "Your free trial runs through {{date}}. No card required."
title = "Enterprise trial"
+[portal.review]
+subtitle = "Anything from your policy runs and your team's editors that needs your attention."
+title = "Review"
+
[portal.settings.groups]
admin = "Admin"
diff --git a/frontend/editor/src/core/i18n/translationAudit.ts b/frontend/editor/src/core/i18n/translationAudit.ts
index 0f04e150ee..0f1a856672 100644
--- a/frontend/editor/src/core/i18n/translationAudit.ts
+++ b/frontend/editor/src/core/i18n/translationAudit.ts
@@ -108,9 +108,9 @@ export const I18N_PROJECTS: TranslationProject[] = [
// "portal.policies.operations" - the shape heuristic treats that interpolation as one
// segment, so this whole catalogue-driven family is matched here instead.
/^portal\.policies\.operations\./,
- // A failure's disabled reason arrives from the server as a key and is rendered with
- // t(thatKey), so nothing in source names it, but the copy still has to exist.
+ // Server-sent keys rendered with t(thatKey), so nothing in source names them.
/^portal\.failures\.disabled\./,
+ /^portal\.failures\.action\./,
// Encryption panel copy keyed by backend enum values: key status, write
// state, migration state, and the reason a status read was refused. Each
// is t(`...${value}`) where the value comes from the API response.
diff --git a/frontend/editor/src/core/routes/portalBasename.ts b/frontend/editor/src/core/routes/portalBasename.ts
index a4fdb87a52..7648e6a760 100644
--- a/frontend/editor/src/core/routes/portalBasename.ts
+++ b/frontend/editor/src/core/routes/portalBasename.ts
@@ -6,8 +6,5 @@
*/
export const PORTAL_BASENAME = "/processor";
-/**
- * The recorded-failures section of the portal's Documents view. Here because whoever links to it and
- * whoever renders it are in different layers.
- */
-export const PORTAL_FAILURES_ANCHOR = "failures";
+/** Here because whoever links to the review screen and whoever renders it are in different layers. */
+export const PORTAL_REVIEW_PATH = "/review";
diff --git a/frontend/editor/src/core/ui/DataTable.css b/frontend/editor/src/core/ui/DataTable.css
index c7572efa90..fcdee564ac 100644
--- a/frontend/editor/src/core/ui/DataTable.css
+++ b/frontend/editor/src/core/ui/DataTable.css
@@ -266,12 +266,18 @@
color: var(--c-text-subtle);
}
+/* An action row sizes the column, it does not squeeze into it: without nowrap +
+ no-shrink the labels wrap and a long one is clipped mid-word. */
.sui-dtc__actions {
display: flex;
align-items: center;
justify-content: flex-end;
+ flex-wrap: nowrap;
gap: 0.25rem;
}
+.sui-dtc__actions > * {
+ flex-shrink: 0;
+}
.sui-dtc__menu-item--danger {
color: var(--c-danger);
}
diff --git a/frontend/editor/src/core/ui/DataTableFilterBar.css b/frontend/editor/src/core/ui/DataTableFilterBar.css
new file mode 100644
index 0000000000..5f289a2382
--- /dev/null
+++ b/frontend/editor/src/core/ui/DataTableFilterBar.css
@@ -0,0 +1,105 @@
+/* Faceted filter bar for DataTable's toolbar slot. Colours come from semantic
+ tokens only; no literals. See core/theme/README.md. */
+
+.sui-dtfb {
+ display: flex;
+ flex-direction: column;
+ gap: 0.625rem;
+ flex: 1;
+ min-width: 0;
+}
+
+.sui-dtfb__row {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ flex-wrap: wrap;
+}
+
+/* Far end of the row, so a scope control sits opposite the filters. */
+.sui-dtfb__trailing {
+ margin-inline-start: auto;
+}
+
+.sui-dtfb__search {
+ width: 16rem;
+ max-width: 100%;
+}
+
+.sui-dtfb__facet-count {
+ margin-left: 0.375rem;
+ padding: 0 0.375rem;
+ border-radius: 999px;
+ background: var(--c-primary-subtle);
+ color: var(--c-accent-fg, var(--c-primary));
+ font-size: 0.6875rem;
+ font-weight: 600;
+ line-height: 1.3;
+}
+
+/* Option rows: the Dropdown menu's item look, plus a checkbox + count. */
+.sui-dtfb__option {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ width: 100%;
+ padding: 0.4rem 0.625rem;
+ background: none;
+ border: none;
+ border-radius: 6px;
+ font: inherit;
+ font-size: 0.8125rem;
+ color: var(--c-text);
+ text-align: left;
+ cursor: pointer;
+}
+
+.sui-dtfb__option:hover {
+ background: var(--c-hover);
+}
+
+.sui-dtfb__box {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex: none;
+ width: 1rem;
+ height: 1rem;
+ border: 1px solid var(--c-border-strong);
+ border-radius: 4px;
+ background: var(--c-surface);
+ color: var(--c-text-on-primary);
+}
+
+.sui-dtfb__box--checked {
+ background: var(--c-primary);
+ border-color: var(--c-primary);
+}
+
+.sui-dtfb__option-label {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.sui-dtfb__option-count {
+ font-size: 0.6875rem;
+ color: var(--c-text-subtle);
+ font-variant-numeric: tabular-nums;
+}
+
+.sui-dtfb__no-options {
+ padding: 0.5rem 0.625rem;
+ font-size: 0.8125rem;
+ color: var(--c-text-subtle);
+}
+
+/* Active picks as removable chips, with the clear-all at the end. */
+.sui-dtfb__active {
+ display: flex;
+ align-items: center;
+ gap: 0.375rem;
+ flex-wrap: wrap;
+}
diff --git a/frontend/editor/src/core/ui/DataTableFilterBar.stories.tsx b/frontend/editor/src/core/ui/DataTableFilterBar.stories.tsx
new file mode 100644
index 0000000000..5ca3491200
--- /dev/null
+++ b/frontend/editor/src/core/ui/DataTableFilterBar.stories.tsx
@@ -0,0 +1,128 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { column, DataTable, type DataTableColumn } from "@app/ui/DataTable";
+import {
+ DataTableFilterBar,
+ useDataTableFilters,
+} from "@app/ui/DataTableFilterBar";
+
+interface Incident {
+ id: string;
+ title: string;
+ user: string | null;
+ source: string | null;
+ kind: string;
+ severity: "danger" | "warning" | "info";
+}
+
+const INCIDENTS: Incident[] = [
+ {
+ id: "1",
+ title: "Password-protected document",
+ source: null,
+ kind: "Input",
+ severity: "danger",
+ },
+ {
+ id: "2",
+ title: "Password-protected document",
+ user: null,
+ source: "s3-invoices",
+ kind: "Input",
+ severity: "danger",
+ },
+ {
+ id: "3",
+ title: "Unrecognised failure",
+ source: null,
+ kind: "Internal",
+ severity: "warning",
+ },
+ {
+ id: "4",
+ title: "Delivery refused",
+ user: null,
+ source: "webhook-erp",
+ kind: "Output",
+ severity: "danger",
+ },
+ {
+ id: "5",
+ title: "Unrecognised failure",
+ source: null,
+ kind: "Internal",
+ severity: "info",
+ },
+];
+
+const COLUMNS: DataTableColumn<Incident>[] = [
+ column.text({
+ key: "title",
+ header: "Failure",
+ sortable: true,
+ get: (r) => r.title,
+ }),
+ column.badge({
+ key: "kind",
+ header: "Stage",
+ sortable: true,
+ get: (r) => ({ tone: r.severity, label: r.kind }),
+ }),
+ column.muted({
+ key: "user",
+ header: "User",
+ sortable: true,
+ get: (r) => r.user,
+ placeholder: "-",
+ }),
+ column.muted({
+ key: "source",
+ header: "Source",
+ sortable: true,
+ get: (r) => r.source,
+ placeholder: "-",
+ }),
+];
+
+/** The full pairing: hook owns state + derivation, bar sits in the toolbar. */
+function FilteredTable({ rows }: { rows: Incident[] }) {
+ const filters = useDataTableFilters({
+ rows,
+ facets: [
+ { key: "type", label: "Type", getValue: (r) => r.title },
+ { key: "user", label: "User", getValue: (r) => r.user },
+ { key: "source", label: "Source", getValue: (r) => r.source },
+ { key: "stage", label: "Stage", getValue: (r) => r.kind },
+ ],
+ searchText: (r) => [r.title, r.user ?? "", r.source ?? ""].join(" "),
+ });
+
+ return (
+ <DataTable<Incident>
+ columns={COLUMNS}
+ rows={filters.rows}
+ rowKey={(r) => r.id}
+ toolbar={<DataTableFilterBar {...filters.filterBar} />}
+ empty="No rows match the current filters"
+ caption="Incidents"
+ />
+ );
+}
+
+const meta: Meta<typeof FilteredTable> = {
+ title: "Compound/DataTableFilterBar",
+ component: FilteredTable,
+ parameters: { layout: "padded" },
+};
+export default meta;
+type Story = StoryObj<typeof FilteredTable>;
+
+export const Default: Story = {
+ args: { rows: INCIDENTS },
+};
+
+export const Empty: Story = {
+ args: { rows: [] },
+};
diff --git a/frontend/editor/src/core/ui/DataTableFilterBar.tsx b/frontend/editor/src/core/ui/DataTableFilterBar.tsx
new file mode 100644
index 0000000000..463dd0e7da
--- /dev/null
+++ b/frontend/editor/src/core/ui/DataTableFilterBar.tsx
@@ -0,0 +1,307 @@
+import { useMemo, useState, type ReactNode } from "react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@app/ui/Button";
+import { Chip } from "@app/ui/Chip";
+import { Dropdown } from "@app/ui/Dropdown";
+import { Input } from "@app/ui/Input";
+import "@app/ui/DataTableFilterBar.css";
+
+/** Faceted filtering for {@link DataTable}'s `toolbar` slot. Facets chain; counts answer "if I picked this next". */
+
+/** One filterable dimension of the rows, as declared by the call-site. */
+export interface DataTableFacet<T> {
+ key: string;
+ /** Translated facet name (dropdown trigger + chip prefix). */
+ label: string;
+ /** The row's value here. Null/undefined/"" means it has none. */
+ getValue: (row: T) => string | null | undefined;
+ /** Display label for a value. Defaults to the value itself. */
+ formatValue?: (value: string) => string;
+}
+
+/** A pickable value within a facet, with how many rows it would keep. */
+export interface DataTableFacetOption {
+ value: string;
+ label: string;
+ count: number;
+}
+
+/** A facet resolved against the current rows, ready to render. */
+export interface DataTableFacetView {
+ key: string;
+ label: string;
+ options: DataTableFacetOption[];
+}
+
+export interface DataTableFilterBarProps {
+ facets: DataTableFacetView[];
+ /** Active picks per facet key. */
+ selected: Record<string, string[]>;
+ onToggle: (facetKey: string, value: string) => void;
+ onClearAll: () => void;
+ /** Free-text search box. Omit to render facets only. */
+ search?: {
+ value: string;
+ onChange: (value: string) => void;
+ placeholder?: string;
+ };
+ /** Pushed to the far end of the filter row, for a control that scopes the rows. */
+ trailing?: ReactNode;
+}
+
+export interface UseDataTableFiltersResult<T> {
+ /** Rows surviving every active facet and the search text. */
+ rows: T[];
+ /** Ready-made props for a `<DataTableFilterBar/>` in the table's toolbar. */
+ filterBar: DataTableFilterBarProps;
+}
+
+/** Owns one table's filter state and derives the rows, options and bar props from it. */
+export function useDataTableFilters<T>({
+ rows,
+ facets,
+ searchText,
+ searchPlaceholder,
+}: {
+ rows: T[];
+ facets: DataTableFacet<T>[];
+ /** Enables the search box; returns the haystack a row is matched against. */
+ searchText?: (row: T) => string;
+ /** Names what the box searches. Pass translated. */
+ searchPlaceholder?: string;
+}): UseDataTableFiltersResult<T> {
+ const [selected, setSelected] = useState<Record<string, string[]>>({});
+ const [query, setQuery] = useState("");
+
+ const derived = useMemo(() => {
+ const q = query.trim().toLowerCase();
+ const matchesSearch = (row: T) =>
+ !q || !searchText || searchText(row).toLowerCase().includes(q);
+ const matchesFacet = (row: T, facet: DataTableFacet<T>) => {
+ const picks = selected[facet.key];
+ if (!picks || picks.length === 0) return true;
+ const value = facet.getValue(row);
+ return value != null && picks.includes(value);
+ };
+
+ const filtered = rows.filter(
+ (row) =>
+ matchesSearch(row) && facets.every((facet) => matchesFacet(row, facet)),
+ );
+
+ const views: DataTableFacetView[] = facets.map((facet) => {
+ // Against the rows every OTHER facet admits, or one pick would hide its siblings.
+ const admitted = rows.filter(
+ (row) =>
+ matchesSearch(row) &&
+ facets.every((f) => f.key === facet.key || matchesFacet(row, f)),
+ );
+ const counts = new Map<string, number>();
+ for (const row of admitted) {
+ const value = facet.getValue(row);
+ if (value != null && value !== "") {
+ counts.set(value, (counts.get(value) ?? 0) + 1);
+ }
+ }
+ // A picked value stays listed at zero, or it could never be unpicked.
+ for (const value of selected[facet.key] ?? []) {
+ if (!counts.has(value)) counts.set(value, 0);
+ }
+ const format = facet.formatValue ?? ((value: string) => value);
+ const options = [...counts.entries()]
+ .map(([value, count]) => ({ value, label: format(value), count }))
+ .sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));
+ return { key: facet.key, label: facet.label, options };
+ });
+
+ return { filtered, views };
+ }, [rows, facets, selected, query, searchText]);
+
+ const onToggle = (facetKey: string, value: string) =>
+ setSelected((prev) => {
+ const current = prev[facetKey] ?? [];
+ const next = current.includes(value)
+ ? current.filter((v) => v !== value)
+ : [...current, value];
+ return { ...prev, [facetKey]: next };
+ });
+
+ return {
+ rows: derived.filtered,
+ filterBar: {
+ facets: derived.views,
+ selected,
+ onToggle,
+ onClearAll: () => setSelected({}),
+ search: searchText
+ ? { value: query, onChange: setQuery, placeholder: searchPlaceholder }
+ : undefined,
+ },
+ };
+}
+
+function SearchGlyph() {
+ return (
+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" aria-hidden>
+ <circle cx="11" cy="11" r="7" stroke="currentColor" strokeWidth="2" />
+ <path
+ d="m20 20-3.5-3.5"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ />
+ </svg>
+ );
+}
+
+function CaretGlyph() {
+ return (
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" aria-hidden>
+ <path
+ d="m6 9 6 6 6-6"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+}
+
+function CheckGlyph() {
+ return (
+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" aria-hidden>
+ <path
+ d="m4.5 12.5 5 5 10-11"
+ stroke="currentColor"
+ strokeWidth="3"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+}
+
+/** The bar itself. State and derivation come from {@link useDataTableFilters}. */
+export function DataTableFilterBar({
+ facets,
+ selected,
+ onToggle,
+ onClearAll,
+ search,
+ trailing,
+}: DataTableFilterBarProps) {
+ const { t } = useTranslation();
+
+ // Every active pick, labelled for the chip row.
+ const active = facets.flatMap((facet) =>
+ (selected[facet.key] ?? []).map((value) => ({
+ facet,
+ value,
+ label:
+ facet.options.find((option) => option.value === value)?.label ?? value,
+ })),
+ );
+
+ return (
+ <div className="sui-dtfb">
+ <div className="sui-dtfb__row">
+ {search && (
+ <Input
+ className="sui-dtfb__search"
+ inputSize="sm"
+ leadingIcon={<SearchGlyph />}
+ value={search.value}
+ onChange={(e) => search.onChange(e.target.value)}
+ placeholder={search.placeholder ?? t("common.search", "Search")}
+ aria-label={search.placeholder ?? t("common.search", "Search")}
+ />
+ )}
+ {facets.map((facet) => {
+ const picked = selected[facet.key] ?? [];
+ return (
+ <Dropdown.Root key={facet.key} align="start">
+ <Dropdown.Trigger>
+ <Button
+ variant="secondary"
+ size="sm"
+ className={
+ picked.length > 0
+ ? "sui-dtfb__facet sui-dtfb__facet--active"
+ : "sui-dtfb__facet"
+ }
+ rightSection={<CaretGlyph />}
+ >
+ {facet.label}
+ {picked.length > 0 && (
+ <span className="sui-dtfb__facet-count">
+ {picked.length}
+ </span>
+ )}
+ </Button>
+ </Dropdown.Trigger>
+ <Dropdown.Menu width={240} className="sui-dtfb__menu">
+ {facet.options.length === 0 ? (
+ <div className="sui-dtfb__no-options">
+ {t("common.filterEmpty", "Nothing to filter on")}
+ </div>
+ ) : (
+ facet.options.map((option) => {
+ const checked = picked.includes(option.value);
+ return (
+ // Not a Dropdown.Item: the menu stays open for several picks.
+ <button
+ key={option.value}
+ type="button"
+ role="menuitemcheckbox"
+ aria-checked={checked}
+ className="sui-dtfb__option"
+ onClick={() => onToggle(facet.key, option.value)}
+ >
+ <span
+ className={
+ checked
+ ? "sui-dtfb__box sui-dtfb__box--checked"
+ : "sui-dtfb__box"
+ }
+ aria-hidden
+ >
+ {checked && <CheckGlyph />}
+ </span>
+ <span className="sui-dtfb__option-label">
+ {option.label}
+ </span>
+ <span className="sui-dtfb__option-count">
+ {option.count}
+ </span>
+ </button>
+ );
+ })
+ )}
+ </Dropdown.Menu>
+ </Dropdown.Root>
+ );
+ })}
+ {trailing && <div className="sui-dtfb__trailing">{trailing}</div>}
+ </div>
+
+ {active.length > 0 && (
+ <div className="sui-dtfb__active">
+ {active.map(({ facet, value, label }) => (
+ <Chip
+ key={`${facet.key}:${value}`}
+ size="sm"
+ showDot={false}
+ onRemove={() => onToggle(facet.key, value)}
+ >
+ {facet.label}: {label}
+ </Chip>
+ ))}
+ <Button variant="quiet" size="sm" onClick={onClearAll}>
+ {t("common.clearFilters", "Clear filters")}
+ </Button>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/frontend/editor/src/core/ui/index.ts b/frontend/editor/src/core/ui/index.ts
index 1fa5f997b0..120c3cc1eb 100644
--- a/frontend/editor/src/core/ui/index.ts
+++ b/frontend/editor/src/core/ui/index.ts
@@ -47,6 +47,7 @@ export * from "@app/ui/Tabs";
export * from "@app/ui/Dropdown";
export * from "@app/ui/Drawer";
export * from "@app/ui/DataTable";
+export * from "@app/ui/DataTableFilterBar";
// Forms
export * from "@app/ui/FormField";
diff --git a/frontend/editor/src/portal-saas/components/sidebarGroups.test.ts b/frontend/editor/src/portal-saas/components/sidebarGroups.test.ts
index a5571510bb..75208a234b 100644
--- a/frontend/editor/src/portal-saas/components/sidebarGroups.test.ts
+++ b/frontend/editor/src/portal-saas/components/sidebarGroups.test.ts
@@ -12,6 +12,7 @@ describe("sidebarGroups (SaaS)", () => {
"sources",
"pipelines",
"documents",
+ "review",
]);
});
diff --git a/frontend/editor/src/portal/ViewRouter.tsx b/frontend/editor/src/portal/ViewRouter.tsx
index 9db3c91e07..7404108d2e 100644
--- a/frontend/editor/src/portal/ViewRouter.tsx
+++ b/frontend/editor/src/portal/ViewRouter.tsx
@@ -3,6 +3,7 @@ import { Navigate, Route, Routes, useLocation } from "react-router-dom";
import { Home } from "@portal/views/Home";
import { Users } from "@portal/views/Users";
import { Documents } from "@portal/views/Documents";
+import { Review } from "@portal/views/Review";
import { Pipelines } from "@portal/views/Pipelines";
import { PipelineBuilder } from "@portal/views/PipelineBuilder";
import { Sources } from "@portal/views/Sources";
@@ -78,6 +79,7 @@ export function ViewRouter() {
path working, preserving its query (e.g. onboarding's ?setup=<category>). */}
<Route path={rel(VIEW_PATHS.policies)} element={<PoliciesRedirect />} />
<Route path={rel(VIEW_PATHS.documents)} element={<Documents />} />
+ <Route path={rel(VIEW_PATHS.review)} element={<Review />} />
<Route
path={rel(VIEW_PATHS.infrastructure)}
element={<Infrastructure />}
diff --git a/frontend/editor/src/portal/api/fileRunEvents.ts b/frontend/editor/src/portal/api/fileRunEvents.ts
index 768618132e..6a5c82cfa2 100644
--- a/frontend/editor/src/portal/api/fileRunEvents.ts
+++ b/frontend/editor/src/portal/api/fileRunEvents.ts
@@ -39,6 +39,12 @@ export type FileRunEventStatus =
/** Its document was deleted from the owner's editor, so there is nothing left to act on. */
| "FILE_REMOVED";
+/** Intent, not layout: only the client knows what this device can actually run. */
+export type FailureActionSlot = "RESOLUTION" | "SECONDARY" | "OVERFLOW";
+
+/** Who performs the action: this client, or the server via the actions endpoint. */
+export type FailureActionExecution = "SERVER" | "CLIENT";
+
/**
* One button as offered for one row. `id` is a plain string rather than a union
* because the server may know actions this build does not; the renderer skips them.
@@ -46,6 +52,10 @@ export type FileRunEventStatus =
export interface FailureActionOffer {
id: string;
labelKey: string;
+ /** English fallback, for a build with no copy for `labelKey`. */
+ defaultLabel: string;
+ execution: FailureActionExecution;
+ slot: FailureActionSlot;
enabled: boolean;
disabledReasonKey: string | null;
}
@@ -87,8 +97,24 @@ export interface FileRunEventsResponse {
events: FileRunEvent[];
}
+/** Which half of the queue a read asks for: still needing a decision, or already settled. */
+export type FileRunEventScope = "open" | "closed";
+
+/** Mirrors the server's terminal statuses: a closed row admits no further transition. */
+const CLOSED_STATUSES: ReadonlySet<FileRunEventStatus> = new Set([
+ "DISMISSED",
+ "RESOLVED",
+ "FILE_REMOVED",
+]);
+
+export function isClosedStatus(status: FileRunEventStatus): boolean {
+ return CLOSED_STATUSES.has(status);
+}
+
export interface ListFileRunEventsParams {
status?: FileRunEventStatus;
+ /** The settled rows rather than the open queue; an explicit status wins over it. */
+ closed?: boolean;
kindId?: string;
limit?: number;
}
@@ -99,6 +125,7 @@ export async function fetchFileRunEvents(
): Promise<FileRunEvent[]> {
const query = new URLSearchParams();
if (params.status) query.set("status", params.status);
+ if (params.closed) query.set("closed", "true");
if (params.kindId) query.set("kindId", params.kindId);
if (params.limit != null) query.set("limit", String(params.limit));
const suffix = query.toString() ? `?${query}` : "";
diff --git a/frontend/editor/src/portal/components/failures/FailureActionButtons.stories.tsx b/frontend/editor/src/portal/components/failures/FailureActionButtons.stories.tsx
deleted file mode 100644
index b63fec7220..0000000000
--- a/frontend/editor/src/portal/components/failures/FailureActionButtons.stories.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import type { Meta, StoryObj } from "@storybook/react-vite";
-import type { FailureActionOffer } from "@portal/api/fileRunEvents";
-import { FILE_RUN_EVENTS } from "@portal/mocks/fileRunEvents";
-import { FailureActionButtons } from "@portal/components/failures/FailureActionButtons";
-import "@portal/components/failures/failures.css";
-
-const OPEN_EVENT = FILE_RUN_EVENTS[0];
-
-const meta: Meta<typeof FailureActionButtons> = {
- title: "Portal/Failures/FailureActionButtons",
- component: FailureActionButtons,
- parameters: { layout: "padded" },
- args: { event: OPEN_EVENT, onAction: () => {} },
-};
-export default meta;
-type Story = StoryObj<typeof FailureActionButtons>;
-
-/**
- * Labels come from the server's per-kind overrides, so a password failure reads
- * "I'll unlock this" and "Skip this file" rather than the generic wording.
- */
-export const PerKindLabels: Story = {};
-
-/** The generic labels, used by any kind that declares no override. */
-export const GenericLabels: Story = {
- args: { event: FILE_RUN_EVENTS[1] },
-};
-
-/** A closed incident keeps its buttons, disabled with a reason, so the reviewer
- * can still see what was possible. */
-export const Closed: Story = {
- args: { event: FILE_RUN_EVENTS[2] },
-};
-
-/** An action mid-flight. */
-export const Busy: Story = {
- args: { busyActionId: "ACKNOWLEDGE" },
-};
-
-/**
- * An action id this build does not implement is skipped rather than rendered
- * unwired, since the server can be newer than the client (notably on desktop).
- */
-export const UnknownActionIsSkipped: Story = {
- args: {
- event: {
- ...OPEN_EVENT,
- actions: [
- ...OPEN_EVENT.actions,
- {
- id: "REMEDIATE_AND_RETRY",
- labelKey: "portal.failures.action.remediateAndRetry",
- enabled: true,
- disabledReasonKey: null,
- } satisfies FailureActionOffer,
- ],
- },
- },
-};
diff --git a/frontend/editor/src/portal/components/failures/FailureActionButtons.test.tsx b/frontend/editor/src/portal/components/failures/FailureActionButtons.test.tsx
deleted file mode 100644
index 2409a03ec9..0000000000
--- a/frontend/editor/src/portal/components/failures/FailureActionButtons.test.tsx
+++ /dev/null
@@ -1,209 +0,0 @@
-import { describe, expect, it, vi } from "vitest";
-import {
- fireEvent,
- render as baseRender,
- screen,
-} from "@testing-library/react";
-import { MantineProvider } from "@mantine/core";
-import { FailureActionButtons } from "@portal/components/failures/FailureActionButtons";
-import type {
- FailureActionOffer,
- FileRunEvent,
-} from "@portal/api/fileRunEvents";
-
-// @app/ui Button is a Mantine wrapper, so it needs the provider in the tree.
-const render = (
- ui: Parameters<typeof baseRender>[0],
- options?: Parameters<typeof baseRender>[1],
-) => baseRender(ui, { wrapper: MantineProvider, ...options });
-
-/**
- * The renderer is driven entirely by what the server sent, so a new failure kind or
- * label needs no change here. These pin that, plus the two rules the client owns:
- * skip unknown actions, confirm the ones that close an incident.
- */
-
-vi.mock("react-i18next", () => ({
- useTranslation: () => ({
- // Mirrors i18next's contract closely enough to exercise the fallback logic:
- // a known key resolves, an unknown key returns its defaultValue.
- t: (key: string, options?: { defaultValue?: string } | string) => {
- const known: Record<string, string> = {
- "portal.failures.action.acknowledge": "Acknowledge",
- "portal.failures.action.dismiss": "Dismiss",
- "portal.failures.action.dismissSkipFile": "Skip this file",
- "portal.failures.action.confirm": "Are you sure?",
- "portal.failures.disabled.closed": "This failure is already closed.",
- };
- if (known[key]) return known[key];
- if (typeof options === "string") return options;
- if (options?.defaultValue) return options.defaultValue;
- return key;
- },
- }),
-}));
-
-function offer(
- overrides: Partial<FailureActionOffer> = {},
-): FailureActionOffer {
- return {
- id: "ACKNOWLEDGE",
- labelKey: "portal.failures.action.acknowledge",
- enabled: true,
- disabledReasonKey: null,
- ...overrides,
- };
-}
-
-function event(actions: FailureActionOffer[]): FileRunEvent {
- return {
- id: "evt-1",
- kindId: "UNKNOWN",
- stage: "INTERNAL",
- severity: "ERROR",
- scope: "RUN",
- origin: "POLICY",
- remedy: "PERMANENT",
- titleKey: "portal.failures.kind.unknown.title",
- descriptionKey: "portal.failures.kind.unknown.description",
- defaultTitle: "Unrecognised failure",
- detail: "boom",
- policyId: "p1",
- runId: "r1",
- sourceId: null,
- fileId: "f-1",
- actor: "[email protected]",
- occurrences: 1,
- status: "NEW",
- statusActor: null,
- actions,
- createdAt: 0,
- lastSeenAt: 0,
- };
-}
-
-describe("FailureActionButtons", () => {
- it("renders one button per declared action, labelled from the server's key", () => {
- render(
- <FailureActionButtons
- event={event([
- offer(),
- offer({
- id: "DISMISS",
- labelKey: "portal.failures.action.dismissSkipFile",
- }),
- ])}
- onAction={vi.fn()}
- />,
- );
-
- expect(screen.getByRole("button", { name: "Acknowledge" })).toBeTruthy();
- // The kind's override wins over the generic label, without the client
- // knowing which kinds override what.
- expect(screen.getByRole("button", { name: "Skip this file" })).toBeTruthy();
- });
-
- it("skips an action id this build cannot perform instead of crashing", () => {
- // The server may be newer than the client (notably on desktop). An
- // unrenderable button is worse than none.
- render(
- <FailureActionButtons
- event={event([
- offer(),
- offer({ id: "REMEDIATE_AND_RETRY", labelKey: "x" }),
- ])}
- onAction={vi.fn()}
- />,
- );
-
- expect(screen.getAllByRole("button")).toHaveLength(1);
- expect(screen.getByRole("button", { name: "Acknowledge" })).toBeTruthy();
- });
-
- it("renders nothing when no action is recognised", () => {
- const { container } = render(
- <FailureActionButtons
- event={event([offer({ id: "APPROVE", labelKey: "x" })])}
- onAction={vi.fn()}
- />,
- );
-
- expect(container.querySelectorAll("button")).toHaveLength(0);
- });
-
- it("falls back to the generic label when the server's key is unknown to this build", () => {
- render(
- <FailureActionButtons
- event={event([
- offer({ labelKey: "portal.failures.action.brandNewKey" }),
- ])}
- onAction={vi.fn()}
- />,
- );
-
- expect(screen.getByRole("button", { name: "Acknowledge" })).toBeTruthy();
- });
-
- it("disables an action the server marked unusable and explains why", () => {
- render(
- <FailureActionButtons
- event={event([
- offer({
- enabled: false,
- disabledReasonKey: "portal.failures.disabled.closed",
- }),
- ])}
- onAction={vi.fn()}
- />,
- );
-
- const button = screen.getByRole("button", { name: /already closed/ });
- expect(button.hasAttribute("disabled")).toBe(true);
- });
-
- it("dispatches a non-terminal action immediately", () => {
- const onAction = vi.fn();
- render(
- <FailureActionButtons event={event([offer()])} onAction={onAction} />,
- );
-
- fireEvent.click(screen.getByRole("button", { name: "Acknowledge" }));
-
- expect(onAction).toHaveBeenCalledWith("ACKNOWLEDGE");
- });
-
- it("asks for confirmation before dispatching a terminal action", () => {
- const onAction = vi.fn();
- render(
- <FailureActionButtons
- event={event([
- offer({ id: "DISMISS", labelKey: "portal.failures.action.dismiss" }),
- ])}
- onAction={onAction}
- />,
- );
-
- fireEvent.click(screen.getByRole("button", { name: "Dismiss" }));
- // Dismiss closes the incident, so the first click only arms it.
- expect(onAction).not.toHaveBeenCalled();
-
- fireEvent.click(screen.getByRole("button", { name: "Are you sure?" }));
- expect(onAction).toHaveBeenCalledWith("DISMISS");
- });
-
- it("disables the action that is in flight", () => {
- render(
- <FailureActionButtons
- event={event([offer()])}
- onAction={vi.fn()}
- busyActionId="ACKNOWLEDGE"
- />,
- );
-
- expect(
- screen
- .getByRole("button", { name: "Acknowledge" })
- .hasAttribute("disabled"),
- ).toBe(true);
- });
-});
diff --git a/frontend/editor/src/portal/components/failures/FailureActionButtons.tsx b/frontend/editor/src/portal/components/failures/FailureActionButtons.tsx
deleted file mode 100644
index de8fcdbc24..0000000000
--- a/frontend/editor/src/portal/components/failures/FailureActionButtons.tsx
+++ /dev/null
@@ -1,96 +0,0 @@
-import { useState } from "react";
-import { useTranslation } from "react-i18next";
-import { Button } from "@app/ui";
-import type {
- FailureActionOffer,
- FileRunEvent,
-} from "@portal/api/fileRunEvents";
-
-/**
- * Renders a row's action buttons from the data the server sent, knowing nothing about
- * individual failure kinds. Two client-side rules: an id this build cannot handle is
- * skipped rather than rendered unwired, and closing an incident confirms first.
- */
-
-/** Actions this build can actually perform. Anything else is skipped. */
-const HANDLED_ACTIONS = new Set(["ACKNOWLEDGE", "DISMISS"]);
-
-/** Actions that close the incident, so they warrant a confirmation step. */
-const CONFIRMING_ACTIONS = new Set(["DISMISS"]);
-
-interface FailureActionButtonsProps {
- event: FileRunEvent;
- onAction: (actionId: string) => void | Promise<void>;
- busyActionId?: string | null;
-}
-
-export function FailureActionButtons({
- event,
- onAction,
- busyActionId,
-}: FailureActionButtonsProps) {
- const { t } = useTranslation();
- const [confirming, setConfirming] = useState<string | null>(null);
-
- const renderable = event.actions.filter((action) =>
- HANDLED_ACTIONS.has(action.id),
- );
- if (renderable.length === 0) return null;
-
- const labelFor = (action: FailureActionOffer) =>
- // The server's key first, falling back to the generic label for this action.
- t(action.labelKey, {
- defaultValue: t(
- `portal.failures.action.${action.id.toLowerCase()}`,
- action.id,
- ),
- });
-
- return (
- <div className="portal-failures__actions">
- {renderable.map((action) => {
- const isConfirming = confirming === action.id;
- const busy = busyActionId === action.id;
- const disabled = !action.enabled || busy;
-
- return (
- <Button
- key={action.id}
- variant={isConfirming ? "primary" : "secondary"}
- disabled={disabled}
- aria-label={
- action.enabled
- ? undefined
- : `${labelFor(action)} — ${t(
- action.disabledReasonKey ??
- "portal.failures.disabled.unavailable",
- "unavailable",
- )}`
- }
- title={
- action.enabled
- ? undefined
- : t(
- action.disabledReasonKey ??
- "portal.failures.disabled.unavailable",
- "unavailable",
- )
- }
- onClick={() => {
- if (CONFIRMING_ACTIONS.has(action.id) && !isConfirming) {
- setConfirming(action.id);
- return;
- }
- setConfirming(null);
- void onAction(action.id);
- }}
- >
- {isConfirming
- ? t("portal.failures.action.confirm", "Are you sure?")
- : labelFor(action)}
- </Button>
- );
- })}
- </div>
- );
-}
diff --git a/frontend/editor/src/portal/components/failures/FileRunEventList.test.tsx b/frontend/editor/src/portal/components/failures/FileRunEventList.test.tsx
index d60f855566..2d41fef926 100644
--- a/frontend/editor/src/portal/components/failures/FileRunEventList.test.tsx
+++ b/frontend/editor/src/portal/components/failures/FileRunEventList.test.tsx
@@ -1,28 +1,38 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
-import { render as baseRender, screen, waitFor } from "@testing-library/react";
+import {
+ fireEvent,
+ render as baseRender,
+ screen,
+ waitFor,
+} from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { PortalTestProviders } from "@portal/test/TestQueryProvider";
-import type { FileRunEvent } from "@portal/api/fileRunEvents";
+import type {
+ FailureActionOffer,
+ FileRunEvent,
+} from "@portal/api/fileRunEvents";
-/**
- * Tests for the list: the states it survives (loading, empty, no registry, refused),
- * plus replacing a row in place after acting, re-reading when the server refuses, and
- * bringing itself into view when a notification links to it.
- */
-
-// jsdom does no layout and so implements no scrollIntoView.
-const scrollIntoView = vi.fn();
-Element.prototype.scrollIntoView = scrollIntoView;
+/** The review table: its states, its copy, faceted filtering, and acting on a row. */
const fetchFileRunEvents = vi.fn();
const applyFileRunEventAction = vi.fn();
-vi.mock("@portal/api/fileRunEvents", () => ({
+// Spread the real module: the queries layer also reads its status helpers.
+vi.mock("@portal/api/fileRunEvents", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@portal/api/fileRunEvents")>()),
fetchFileRunEvents: (...args: unknown[]) => fetchFileRunEvents(...args),
applyFileRunEventAction: (...args: unknown[]) =>
applyFileRunEventAction(...args),
}));
+// The sources list only exists to turn source ids into display names.
+const sourcesData = vi.fn<
+ () => { sources: { id: string; name: string }[] } | null
+>(() => null);
+vi.mock("@portal/queries/sources", () => ({
+ useSources: () => ({ data: sourcesData(), loading: false, error: null }),
+}));
+
vi.mock("react-i18next", () => ({
useTranslation: () => ({
// Faithful to i18next: a known key resolves, an unknown key falls back to
@@ -38,20 +48,20 @@ vi.mock("react-i18next", () => ({
const known: Record<string, string> = {
"portal.failures.kind.inputPasswordProtected.title":
"Password-protected document",
+ "portal.failures.kind.inputPasswordProtected.description":
+ "Your file is password protected, so the run could not read it.",
+ "portal.failures.kind.unknown.title": "Unrecognised failure",
"portal.failures.action.acknowledge": "Acknowledge",
- "portal.failures.empty.title": "No failures recorded",
+ "portal.failures.action.dismiss": "Dismiss",
+ "portal.failures.empty.title": "Nothing needs your attention",
"portal.failures.occurrences": "occurrences",
- "portal.failures.runReference": "Run r1",
- "portal.failures.stage.input": "Input",
- "portal.failures.origin.tool": "Tool run",
- "portal.failures.origin.policy": "Policy",
+ "portal.failures.scope.open": "Open",
+ "portal.failures.scope.closed": "Closed",
+ "portal.failures.outcome.dismissed": "Dismissed",
+ "portal.failures.outcome.fileRemoved": "File deleted",
+ "portal.failures.origin.tool": "Editor tool",
+ "portal.failures.origin.policy": "Policy run",
};
- if (key === "portal.failures.fromSource") {
- return `From source ${(options as { source?: string })?.source ?? ""}`;
- }
- if (key === "portal.failures.reportedBy") {
- return `Hit by ${(options as { actor?: string })?.actor ?? ""}`;
- }
if (known[key]) return known[key];
if ((options as { defaultValue?: string })?.defaultValue) {
return (options as { defaultValue: string }).defaultValue;
@@ -61,16 +71,12 @@ vi.mock("react-i18next", () => ({
}),
}));
-// The list reads through the shared query hooks, @app/ui needs Mantine, and the section reads
-// the location to know whether it was linked to.
-const render = (
- ui: Parameters<typeof baseRender>[0],
- at = "/processor/documents",
-) =>
+// The table reads through the shared query hooks and @app/ui needs Mantine.
+const render = (ui: Parameters<typeof baseRender>[0]) =>
baseRender(ui, {
wrapper: ({ children }) => (
<PortalTestProviders>
- <MemoryRouter initialEntries={[at]}>{children}</MemoryRouter>
+ <MemoryRouter>{children}</MemoryRouter>
</PortalTestProviders>
),
});
@@ -78,6 +84,19 @@ const render = (
const { FileRunEventList } =
await import("@portal/components/failures/FileRunEventList");
+function offer(overrides: Partial<FailureActionOffer>): FailureActionOffer {
+ return {
+ id: "ACKNOWLEDGE",
+ labelKey: "portal.failures.action.acknowledge",
+ defaultLabel: "Acknowledge",
+ execution: "SERVER",
+ slot: "SECONDARY",
+ enabled: true,
+ disabledReasonKey: null,
+ ...overrides,
+ };
+}
+
function event(overrides: Partial<FileRunEvent> = {}): FileRunEvent {
return {
id: "fre-1",
@@ -99,54 +118,71 @@ function event(overrides: Partial<FileRunEvent> = {}): FileRunEvent {
occurrences: 1,
status: "NEW",
statusActor: null,
- actions: [
- {
- id: "ACKNOWLEDGE",
- labelKey: "portal.failures.action.acknowledge",
- enabled: true,
- disabledReasonKey: null,
- },
- ],
+ actions: [offer({})],
createdAt: 0,
lastSeenAt: 0,
...overrides,
};
}
+/** Distinguished from the sort header of the same name by its aria-expanded state. */
+const userFacetTrigger = () =>
+ screen.getByRole("button", { name: "User", expanded: false });
+
describe("FileRunEventList", () => {
beforeEach(() => {
fetchFileRunEvents.mockReset();
applyFileRunEventAction.mockReset();
- scrollIntoView.mockReset();
- // The dev-panel test stubs import.meta.env.DEV, which would otherwise persist
- // into every test after it.
- vi.unstubAllEnvs();
+ sourcesData.mockReturnValue(null);
});
- it("renders a row's title, run reference and raw detail, but no document name", async () => {
+ it("shows the kind's title alone: no second line, no raw error, no document name", async () => {
fetchFileRunEvents.mockResolvedValue([event()]);
render(<FileRunEventList />);
expect(await screen.findByText("Password-protected document")).toBeTruthy();
- // A run reference, not a document name: the record holds no file identity.
- expect(screen.getByText("Run r1")).toBeTruthy();
- // The raw message is shown, not swallowed: for an unclassified failure it is
- // the only diagnostic available.
+ // The kind's sentence only repeats its title, so the row does not carry one.
+ expect(
+ screen.queryByText(
+ "Your file is password protected, so the run could not read it.",
+ ),
+ ).toBeNull();
+ expect(screen.queryByText("The PDF Document is passworded")).toBeNull();
+ // No file identity either; the record deliberately holds none.
+ expect(screen.queryByText("f-1")).toBeNull();
+ });
+
+ it("opens the raw error in a modal from the row's own action", async () => {
+ fetchFileRunEvents.mockResolvedValue([event()]);
+
+ render(<FileRunEventList />);
+ await screen.findByText("Password-protected document");
+
+ fireEvent.click(screen.getByRole("button", { name: "View error" }));
+
expect(screen.getByText("The PDF Document is passworded")).toBeTruthy();
+ expect(screen.getAllByText("Copy error").length).toBeGreaterThan(0);
});
- it("names the person whose editor hit it, and marks it a tool run", async () => {
- // The point of reporting editor failures: a reviewer needs the person, since a
- // run reference means nothing for a failure that never had a run.
+ it("offers no View error on a row with no diagnostic to show", async () => {
+ fetchFileRunEvents.mockResolvedValue([event({ detail: null })]);
+
+ render(<FileRunEventList />);
+ await screen.findByText("Password-protected document");
+
+ expect(screen.queryByRole("button", { name: "View error" })).toBeNull();
+ });
+
+ it("names the person whose editor hit it, and where it failed", async () => {
fetchFileRunEvents.mockResolvedValue([
event({ origin: "TOOL", actor: "[email protected]", runId: null }),
]);
render(<FileRunEventList />);
- expect(await screen.findByText("Tool run")).toBeTruthy();
- expect(screen.getByText("Hit by [email protected]")).toBeTruthy();
+ expect(await screen.findByText("Editor tool")).toBeTruthy();
+ expect(screen.getByText("[email protected]")).toBeTruthy();
});
it("names the source when no user was involved, since that is the only attribution", async () => {
@@ -156,13 +192,27 @@ describe("FileRunEventList", () => {
render(<FileRunEventList />);
- expect(await screen.findByText("From source src-s3-invoices")).toBeTruthy();
+ expect(await screen.findByText("src-s3-invoices")).toBeTruthy();
+ });
+
+ it("shows the source's display name once the sources list resolves it", async () => {
+ sourcesData.mockReturnValue({
+ sources: [{ id: "src-s3-invoices", name: "Invoice bucket" }],
+ });
+ fetchFileRunEvents.mockResolvedValue([
+ event({ origin: "POLICY", actor: null, sourceId: "src-s3-invoices" }),
+ ]);
+
+ render(<FileRunEventList />);
+
+ expect(await screen.findByText("Invoice bucket")).toBeTruthy();
+ expect(screen.queryByText("src-s3-invoices")).toBeNull();
});
it("shows the occurrence count only once a failure has repeated", async () => {
fetchFileRunEvents.mockResolvedValue([event({ occurrences: 1 })]);
const { unmount } = render(<FileRunEventList />);
- await screen.findByText("Run r1");
+ await screen.findByText("Password-protected document");
expect(screen.queryByText(/occurrences/)).toBeNull();
unmount();
@@ -171,42 +221,128 @@ describe("FileRunEventList", () => {
expect(await screen.findByText(/occurrences/)).toBeTruthy();
});
- it("shows an empty state when there is nothing to triage", async () => {
+ it("narrows to the picked value and restores on clear", async () => {
+ fetchFileRunEvents.mockResolvedValue([
+ event(),
+ event({
+ id: "fre-2",
+ actor: "[email protected]",
+ kindId: "UNKNOWN",
+ titleKey: "portal.failures.kind.unknown.title",
+ descriptionKey: "portal.failures.kind.unknown.description",
+ defaultTitle: "Unrecognised failure",
+ }),
+ ]);
+
+ render(<FileRunEventList />);
+ await screen.findByText("Unrecognised failure");
+
+ fireEvent.click(userFacetTrigger());
+ fireEvent.click(
+ screen.getByRole("menuitemcheckbox", { name: /[email protected]/ }),
+ );
+
+ // Only dana's failure survives the pick.
+ expect(screen.queryByText("Unrecognised failure")).toBeNull();
+ expect(screen.getByText("Password-protected document")).toBeTruthy();
+
+ // The pick surfaced the clear affordance; clearing restores the row.
+ fireEvent.click(screen.getByRole("button", { name: "Clear filters" }));
+ expect(await screen.findByText("Unrecognised failure")).toBeTruthy();
+ });
+
+ it("chains facets: a second pick narrows within the first", async () => {
+ fetchFileRunEvents.mockResolvedValue([
+ event(),
+ event({ id: "fre-2", origin: "TOOL" }),
+ event({
+ id: "fre-3",
+ actor: "[email protected]",
+ kindId: "UNKNOWN",
+ titleKey: "portal.failures.kind.unknown.title",
+ descriptionKey: "portal.failures.kind.unknown.description",
+ defaultTitle: "Unrecognised failure",
+ }),
+ ]);
+
+ render(<FileRunEventList />);
+ await screen.findByText("Unrecognised failure");
+
+ // First facet: dana only (drops lee's row).
+ fireEvent.click(userFacetTrigger());
+ fireEvent.click(
+ screen.getByRole("menuitemcheckbox", { name: /[email protected]/ }),
+ );
+ expect(screen.queryByText("Unrecognised failure")).toBeNull();
+ expect(screen.getAllByText("Password-protected document")).toHaveLength(2);
+
+ // Second facet chains on top: dana AND raised-in-policy.
+ fireEvent.click(
+ screen.getByRole("button", { name: "Raised in", expanded: false }),
+ );
+ fireEvent.click(
+ screen.getByRole("menuitemcheckbox", { name: /Policy run/ }),
+ );
+ expect(screen.getAllByText("Password-protected document")).toHaveLength(1);
+ });
+
+ it("matches the search text against the raw diagnostic", async () => {
+ fetchFileRunEvents.mockResolvedValue([
+ event(),
+ event({
+ id: "fre-2",
+ detail: "AI engine returned error: 502",
+ kindId: "UNKNOWN",
+ titleKey: "portal.failures.kind.unknown.title",
+ descriptionKey: "portal.failures.kind.unknown.description",
+ defaultTitle: "Unrecognised failure",
+ }),
+ ]);
+
+ render(<FileRunEventList />);
+ await screen.findByText("Unrecognised failure");
+
+ fireEvent.change(
+ screen.getByRole("textbox", {
+ name: "Search issues, users and errors",
+ }),
+ {
+ target: { value: "502" },
+ },
+ );
+
+ expect(screen.queryByText("Password-protected document")).toBeNull();
+ expect(screen.getByText("Unrecognised failure")).toBeTruthy();
+ });
+
+ it("says nothing needs attention, not that no errors exist", async () => {
fetchFileRunEvents.mockResolvedValue([]);
render(<FileRunEventList />);
- expect(await screen.findByText("No failures recorded")).toBeTruthy();
+ expect(
+ await screen.findByText("Nothing needs your attention"),
+ ).toBeTruthy();
});
- it("renders nothing when the server has no failure registry", async () => {
- // A core-only build has no such route, which is not worth showing a reviewer as
- // an error, so the section stays silent.
+ it("explains itself rather than erroring when the server has no failure registry", async () => {
+ // A core-only build has no such route, which is no reviewer's problem.
fetchFileRunEvents.mockRejectedValue(new Error("404"));
- const { container } = render(<FileRunEventList />);
+ render(<FileRunEventList />);
- await waitFor(() => {
- expect(container.querySelector(".portal-failures__list")).toBeNull();
- });
- expect(screen.queryByText("No failures recorded")).toBeNull();
+ expect(await screen.findByText("Nothing to review")).toBeTruthy();
+ expect(screen.queryByText("Nothing needs your attention")).toBeNull();
});
- it("renders no heading at all for a caller the server refuses", async () => {
- // Reviewing is leader-only, so a member's read returns 403. With no dev panel to
- // frame, the whole section goes rather than leaving a bare heading.
- vi.stubEnv("DEV", false);
+ it("says so for a caller the server refuses", async () => {
+ // Leader-only, so a member's read 403s; a whole screen must say why it is empty.
fetchFileRunEvents.mockRejectedValue(new Error("403"));
const { container } = render(<FileRunEventList />);
- await waitFor(() => {
- expect(container.querySelector(".portal-failures")).toBeNull();
- });
- // No section, and specifically no heading: Mantine puts its <style> tags in
- // the container, so "renders nothing" is asserted on our own output.
- expect(screen.queryByRole("heading")).toBeNull();
- expect(container.querySelector(".portal-failures__debug")).toBeNull();
+ expect(await screen.findByText("Nothing to review")).toBeTruthy();
+ expect(container.querySelector(".sui-datatable")).toBeNull();
});
it("replaces the acted-on row in place using the server's response", async () => {
@@ -216,10 +352,9 @@ describe("FileRunEventList", () => {
);
render(<FileRunEventList />);
- const button = await screen.findByRole("button", {
- name: "Acknowledge",
- });
- button.click();
+ await screen.findByText("Password-protected document");
+ fireEvent.click(screen.getByRole("button", { name: "More options" }));
+ fireEvent.click(screen.getByRole("menuitem", { name: "Acknowledge" }));
await waitFor(() => {
expect(applyFileRunEventAction).toHaveBeenCalledWith(
@@ -232,22 +367,106 @@ describe("FileRunEventList", () => {
expect(fetchFileRunEvents).toHaveBeenCalledTimes(1);
});
- it("brings itself into view when a notification links to it", async () => {
- // It sits below the review queue, so landing on the page is not the same as seeing it.
+ it("keeps Dismiss as every row's second button", async () => {
+ fetchFileRunEvents.mockResolvedValue([
+ event({
+ actions: [
+ offer({}),
+ offer({
+ id: "DISMISS",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ slot: "OVERFLOW",
+ }),
+ ],
+ }),
+ ]);
+ applyFileRunEventAction.mockResolvedValue(
+ event({ status: "DISMISSED", statusActor: "[email protected]" }),
+ );
+
+ render(<FileRunEventList />);
+ await screen.findByText("Password-protected document");
+
+ fireEvent.click(screen.getByRole("button", { name: "Dismiss" }));
+
+ await waitFor(() => {
+ expect(applyFileRunEventAction).toHaveBeenCalledWith("fre-1", "DISMISS");
+ });
+ });
+
+ it("reads the closed queue when the reader switches scope", async () => {
fetchFileRunEvents.mockResolvedValue([event()]);
- render(<FileRunEventList />, "/processor/documents#failures");
+ render(<FileRunEventList />);
+ await screen.findByText("Password-protected document");
+ expect(fetchFileRunEvents).toHaveBeenLastCalledWith(
+ expect.objectContaining({ closed: false }),
+ );
+
+ fetchFileRunEvents.mockResolvedValue([
+ event({ status: "DISMISSED", statusActor: "[email protected]" }),
+ ]);
+ fireEvent.click(screen.getByRole("radio", { name: "Closed" }));
- await waitFor(() => expect(scrollIntoView).toHaveBeenCalled());
+ await waitFor(() =>
+ expect(fetchFileRunEvents).toHaveBeenLastCalledWith(
+ expect.objectContaining({ closed: true }),
+ ),
+ );
});
- it("stays where it is on an ordinary visit to the page", async () => {
+ it("shows how a closed failure was settled, and by whom", async () => {
+ fetchFileRunEvents.mockResolvedValueOnce([]);
+ fetchFileRunEvents.mockResolvedValue([
+ event({ status: "DISMISSED", statusActor: "[email protected]" }),
+ event({ id: "fre-2", status: "FILE_REMOVED", statusActor: null }),
+ ]);
+
+ render(<FileRunEventList />);
+ fireEvent.click(screen.getByRole("radio", { name: "Closed" }));
+
+ expect(await screen.findByText("Dismissed")).toBeTruthy();
+ expect(screen.getByText("File deleted")).toBeTruthy();
+ expect(screen.getByText("[email protected]")).toBeTruthy();
+ // Nobody closed it by hand, so the actor column names the system instead.
+ expect(screen.getByText("Stirling")).toBeTruthy();
+ });
+
+ it("offers no outcome column while the open queue is showing", async () => {
fetchFileRunEvents.mockResolvedValue([event()]);
render(<FileRunEventList />);
+ await screen.findByText("Password-protected document");
+
+ expect(screen.queryByRole("columnheader", { name: /outcome/i })).toBeNull();
+ });
+
+ it("takes a dismissed row out of the open queue rather than greying it in place", async () => {
+ fetchFileRunEvents.mockResolvedValue([
+ event({
+ actions: [
+ offer({
+ id: "DISMISS",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ slot: "OVERFLOW",
+ }),
+ ],
+ }),
+ ]);
+ applyFileRunEventAction.mockResolvedValue(
+ event({ status: "DISMISSED", statusActor: "[email protected]" }),
+ );
+ render(<FileRunEventList />);
await screen.findByText("Password-protected document");
- expect(scrollIntoView).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole("button", { name: "Dismiss" }));
+
+ // It belongs to the closed queue now, so the open one must stop listing it.
+ await waitFor(() =>
+ expect(screen.queryByText("Password-protected document")).toBeNull(),
+ );
});
it("re-reads from the server when an action is refused", async () => {
@@ -256,10 +475,9 @@ describe("FileRunEventList", () => {
applyFileRunEventAction.mockRejectedValue(new Error("409"));
render(<FileRunEventList />);
- const button = await screen.findByRole("button", {
- name: "Acknowledge",
- });
- button.click();
+ await screen.findByText("Password-protected document");
+ fireEvent.click(screen.getByRole("button", { name: "More options" }));
+ fireEvent.click(screen.getByRole("menuitem", { name: "Acknowledge" }));
await waitFor(() => {
expect(fetchFileRunEvents).toHaveBeenCalledTimes(2);
diff --git a/frontend/editor/src/portal/components/failures/FileRunEventList.tsx b/frontend/editor/src/portal/components/failures/FileRunEventList.tsx
index 31c0671f0b..fac6e93d38 100644
--- a/frontend/editor/src/portal/components/failures/FileRunEventList.tsx
+++ b/frontend/editor/src/portal/components/failures/FileRunEventList.tsx
@@ -1,52 +1,106 @@
-import { useEffect, useRef, useState } from "react";
-import { useLocation } from "react-router-dom";
+import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
-import { Button, EmptyState, Skeleton, StatusBadge } from "@app/ui";
-import { PORTAL_FAILURES_ANCHOR } from "@app/routes/portalBasename";
-import type { FileRunEvent, FailureSeverity } from "@portal/api/fileRunEvents";
+import {
+ Button,
+ column,
+ DataTable,
+ type DataTableColumn,
+ DataTableFilterBar,
+ EmptyState,
+ Modal,
+ SegmentedControl,
+ type SegmentedOption,
+ useDataTableFilters,
+} from "@app/ui";
+import { formatRelativeTime } from "@app/utils/timeUtils";
+import type {
+ FileRunEvent,
+ FileRunEventScope,
+} from "@portal/api/fileRunEvents";
import {
useFileRunEvents,
useFileRunEventActions,
} from "@portal/queries/fileRunEvents";
-import { FailureActionButtons } from "@portal/components/failures/FailureActionButtons";
-import "@portal/theme/surface.css";
-
-/**
- * Recorded policy and pipeline failures, with the triage actions the server offered
- * for each. Renders the section including its heading, or nothing at all, so one
- * place decides whether the block exists; reviewing is leader-only and a refused
- * read yields no section. Covers policy runs only, since the older watched-folder
- * pipeline is not instrumented.
- */
+import { useSources } from "@portal/queries/sources";
+import { buildFailureActionCells } from "@portal/components/failures/failureActionCells";
+import { outcomeOf } from "@portal/components/failures/failureOutcomes";
-const SEVERITY_TONE: Record<FailureSeverity, "danger" | "warning" | "info"> = {
- ERROR: "danger",
- WARNING: "warning",
- INFO: "info",
-};
+/** The review queue: what a policy run or an editor tool needs a human to look at. */
export function FileRunEventList() {
const { t } = useTranslation();
- const { data: events, error } = useFileRunEvents();
- const { apply, refresh } = useFileRunEventActions();
+ const [scope, setScope] = useState<FileRunEventScope>("open");
+ const { data: events, error } = useFileRunEvents(scope);
+ const { apply } = useFileRunEventActions();
const [busy, setBusy] = useState<{ id: string; action: string } | null>(null);
- const [showJson, setShowJson] = useState(false);
- const [clearing, setClearing] = useState(false);
- const section = useRef<HTMLElement>(null);
- const { hash, key } = useLocation();
+ /** The row whose raw error is open in the modal. */
+ const [logOf, setLogOf] = useState<FileRunEvent | null>(null);
- // A fragment is only honoured on a real page load, not a client-side route change. Keyed on the
- // navigation too: a second notification changes neither the path nor the hash.
- useEffect(() => {
- if (hash !== `#${PORTAL_FAILURES_ANCHOR}`) return;
- section.current?.scrollIntoView({ behavior: "smooth", block: "start" });
- }, [hash, key]);
+ // Server keys, with the English fallbacks that carry a kind this build has no copy for.
+ const titleFor = (event: FileRunEvent) =>
+ t(event.titleKey, { defaultValue: event.defaultTitle });
+ const originFor = (event: FileRunEvent) =>
+ t(`portal.failures.origin.${event.origin.toLowerCase()}`, event.origin);
+ // The record stores an id; falls back to it while the list loads, or for a deleted source.
+ const sources = useSources();
+ const sourceNames = useMemo(
+ () =>
+ new Map(
+ (sources.data?.sources ?? []).map((source) => [source.id, source.name]),
+ ),
+ [sources.data],
+ );
+ // A null sourceId means a person fed the file in, so the editor is the source.
+ const sourceFor = (event: FileRunEvent) =>
+ event.sourceId
+ ? (sourceNames.get(event.sourceId) ?? event.sourceId)
+ : t("portal.failures.source.editor", "Editor");
// A build without the proprietary module has no such route, and a caller who is
// not a team leader gets a 403. Both mean there is nothing to show.
const unavailable = error !== null;
- const act = async (event: FileRunEvent, actionId: string) => {
+ const filters = useDataTableFilters<FileRunEvent>({
+ rows: events ?? [],
+ facets: [
+ {
+ key: "type",
+ label: t("portal.failures.filters.type", "Type"),
+ getValue: titleFor,
+ },
+ {
+ key: "source",
+ label: t("portal.failures.filters.source", "Source"),
+ getValue: sourceFor,
+ },
+ {
+ key: "user",
+ label: t("portal.failures.filters.user", "User"),
+ getValue: (event) => event.actor,
+ },
+ {
+ key: "origin",
+ label: t("portal.failures.filters.origin", "Raised in"),
+ getValue: originFor,
+ },
+ ],
+ searchText: (event) =>
+ [
+ titleFor(event),
+ event.detail ?? "",
+ event.runId ?? "",
+ event.actor ?? "",
+ // Both forms: the name a reviewer types, the id a log shows.
+ event.sourceId ?? "",
+ sourceFor(event),
+ ].join(" "),
+ searchPlaceholder: t(
+ "portal.failures.searchPlaceholder",
+ "Search issues, users and errors",
+ ),
+ });
+
+ const runAction = async (event: FileRunEvent, actionId: string) => {
setBusy({ id: event.id, action: actionId });
try {
await apply(event.id, actionId);
@@ -55,209 +109,186 @@ export function FileRunEventList() {
}
};
- // Empties the queue so a test run starts from nothing. Sequential rather than
- // concurrent: dismissing is cheap, and one request at a time keeps the failure
- // obvious if the endpoint refuses one of them.
- const dismissAll = async () => {
- setClearing(true);
- try {
- for (const event of events ?? []) {
- const dismiss = event.actions.find(
- (action) => action.id === "DISMISS" && action.enabled,
- );
- if (dismiss) {
- await apply(event.id, "DISMISS");
- }
- }
- } finally {
- setClearing(false);
- await refresh();
- }
+ const copyLog = (event: FileRunEvent) => {
+ if (!event.detail) return;
+ void navigator.clipboard.writeText(event.detail).catch(() => {
+ // No clipboard permission. Nothing worth an error of its own.
+ });
};
- // Dev-only inspector for hand-checking classification against real uploads.
- // Vite folds `import.meta.env.DEV` to false, so builds drop this entirely.
- const debugPanel = !import.meta.env.DEV ? null : (
- <div className="portal-failures__debug">
- <Button variant="secondary" size="sm" onClick={() => void refresh()}>
- {t("portal.failures.debug.refresh", "Refresh failures")}
- </Button>
- <Button
- variant="secondary"
- size="sm"
- disabled={clearing || (events?.length ?? 0) === 0}
- onClick={() => void dismissAll()}
- >
- {clearing
- ? t("portal.failures.debug.dismissing", "Dismissing...")
- : t("portal.failures.debug.dismissAll", "Dismiss all ({{total}})", {
- total: events?.length ?? 0,
- })}
- </Button>
- <Button
- variant="secondary"
- size="sm"
- onClick={() => setShowJson((shown) => !shown)}
- >
- {showJson
- ? t("portal.failures.debug.hideJson", "Hide raw JSON ({{total}})", {
- total: events?.length ?? 0,
+ const columns: DataTableColumn<FileRunEvent>[] = [
+ column.entity({
+ key: "failure",
+ header: t("portal.failures.columns.failure", "Issue"),
+ sortable: true,
+ primary: titleFor,
+ // A folded repeat is one row; the count rides the title.
+ suffix: (event) =>
+ event.occurrences > 1
+ ? t("portal.failures.occurrences", "{{count}} occurrences", {
+ count: event.occurrences,
})
- : t("portal.failures.debug.showJson", "Show raw JSON ({{total}})", {
- total: events?.length ?? 0,
- })}
- </Button>
- <Button
- variant="secondary"
- size="sm"
- onClick={() =>
- void navigator.clipboard.writeText(
- JSON.stringify(events ?? [], null, 2),
- )
- }
- >
- {t("portal.failures.debug.copyJson", "Copy JSON")}
- </Button>
- {showJson && (
- <pre className="portal-failures__debug-json">
- {JSON.stringify(events ?? [], null, 2)}
- </pre>
- )}
- </div>
- );
+ : null,
+ }),
+ // What kind of work raised it: a policy run, a pipeline, or someone's editor tool.
+ column.text({
+ key: "origin",
+ header: t("portal.failures.columns.origin", "Raised in"),
+ sortable: true,
+ get: originFor,
+ }),
+ // Source before user: the system that fed the document, then the person, if any.
+ column.muted({
+ key: "source",
+ header: t("portal.failures.columns.source", "Source"),
+ sortable: true,
+ get: sourceFor,
+ }),
+ // An unattended file has no user, so its source is the only attribution.
+ column.muted({
+ key: "user",
+ header: t("portal.failures.columns.user", "User"),
+ sortable: true,
+ get: (event) => event.actor,
+ placeholder: "-",
+ }),
+ // Relative in the row; the error modal carries the full timestamp.
+ column.muted({
+ key: "date",
+ header: t("portal.failures.columns.date", "Date"),
+ sortable: true,
+ get: (event) => formatRelativeTime(event.lastSeenAt, t),
+ sortBy: (event) => event.lastSeenAt,
+ }),
+ // How it was settled, and by whom. Only closed rows have an answer.
+ ...(scope === "closed"
+ ? [
+ column.badge<FileRunEvent>({
+ key: "outcome",
+ header: t("portal.failures.columns.outcome", "Outcome"),
+ sortable: true,
+ get: (event) => {
+ const outcome = outcomeOf(event.status);
+ return {
+ tone: outcome.tone,
+ label: t(outcome.labelKey, outcome.defaultLabel),
+ };
+ },
+ }),
+ column.muted<FileRunEvent>({
+ key: "closedBy",
+ header: t("portal.failures.columns.closedBy", "Closed by"),
+ sortable: true,
+ get: (event) => event.statusActor,
+ placeholder: t("portal.failures.closedBySystem", "Stirling"),
+ }),
+ ]
+ : []),
+ column.actions({
+ key: "actions",
+ get: (event) =>
+ buildFailureActionCells({
+ event,
+ t,
+ busyActionId: busy?.id === event.id ? busy.action : null,
+ onAction: (actionId) => runAction(event, actionId),
+ onViewError: event.detail ? () => setLogOf(event) : undefined,
+ onCopyLog: () => copyLog(event),
+ }),
+ }),
+ ];
- // Nothing to show and no dev panel to frame, so skip the heading too rather
- // than leaving an empty "Failures" section.
- if (unavailable && debugPanel === null) {
- return null;
- }
+ const scopeOptions: SegmentedOption<FileRunEventScope>[] = [
+ { value: "open", label: t("portal.failures.scope.open", "Open") },
+ { value: "closed", label: t("portal.failures.scope.closed", "Closed") },
+ ];
return (
- <section
- className="portal-failures"
- id={PORTAL_FAILURES_ANCHOR}
- ref={section}
- >
- <h2 className="portal-failures__heading">
- {t("portal.failures.title", "Failures")}
- </h2>
- <p className="portal-failures__sub">
- {t(
- "portal.failures.subtitle",
- "Failures recorded from your policy runs, with the actions you can take.",
- )}
- </p>
- {debugPanel}
- {unavailable ? null : (
- <FailureBody events={events} busy={busy} onAction={act} />
- )}
- </section>
- );
-}
-
-/** What fills the section: loading, empty, or the rows. */
-function FailureBody({
- events,
- busy,
- onAction,
-}: {
- events: FileRunEvent[] | null;
- busy: { id: string; action: string } | null;
- onAction: (event: FileRunEvent, actionId: string) => void;
-}) {
- const { t } = useTranslation();
-
- if (events === null) {
- return (
- <div className="portal-failures__skeleton" aria-hidden>
- {Array.from({ length: 3 }).map((_, i) => (
- <Skeleton key={i} height="4rem" />
- ))}
- </div>
- );
- }
-
- if (events.length === 0) {
- return (
- <EmptyState
- title={t("portal.failures.empty.title", "No failures recorded")}
- description={t(
- "portal.failures.empty.description",
- "Policy runs that fail will appear here with the actions you can take.",
- )}
- />
- );
- }
-
- return (
- <ul className="portal-failures__list">
- {events.map((event) => (
- <li key={event.id} className="portal-surface portal-failures__row">
- <div className="portal-failures__meta">
- <StatusBadge tone={SEVERITY_TONE[event.severity]}>
- {t(
- `portal.failures.stage.${event.stage.toLowerCase()}`,
- event.stage,
- )}
- </StatusBadge>
- <span className="portal-failures__title">
- {/* The server's key, with its English fallback for kinds this
- build has no copy for. */}
- {t(event.titleKey, { defaultValue: event.defaultTitle })}
- </span>
- {event.occurrences > 1 && (
- <span className="portal-failures__count">
- {t("portal.failures.occurrences", "{{count}} occurrences", {
- count: event.occurrences,
- })}
- </span>
- )}
- <span className="portal-failures__origin">
- {t(
- `portal.failures.origin.${event.origin.toLowerCase()}`,
- event.origin,
- )}
- </span>
- </div>
-
- {/* Who or what it came from. An unattended file has no user, so the source
- is the only attribution there is. */}
- {event.actor ? (
- <div className="portal-failures__actor">
- {t("portal.failures.reportedBy", "Hit by {{actor}}", {
- actor: event.actor,
- })}
- </div>
- ) : (
- event.sourceId && (
- <div className="portal-failures__actor">
- {t("portal.failures.fromSource", "From source {{source}}", {
- source: event.sourceId,
- })}
- </div>
- )
- )}
-
- {/* A reference, not a name. The record deliberately holds no document
- identity, so a reviewer sees which run failed, never which file. */}
- {event.runId && (
- <div className="portal-failures__file">
- {t("portal.failures.runReference", "Run {{runId}}", {
- runId: event.runId,
- })}
- </div>
- )}
- {event.detail && (
- <p className="portal-failures__detail">{event.detail}</p>
+ <div className="portal-failures">
+ {unavailable ? (
+ <EmptyState
+ title={t("portal.failures.unavailable.title", "Nothing to review")}
+ description={t(
+ "portal.failures.unavailable.description",
+ "This queue is visible to team leaders on workspaces that run policies.",
)}
+ />
+ ) : (
+ <DataTable<FileRunEvent>
+ columns={columns}
+ rows={filters.rows}
+ rowKey={(event) => event.id}
+ defaultSort={{ key: "date", direction: "desc" }}
+ loading={events === null}
+ empty={
+ (events?.length ?? 0) === 0 ? (
+ <EmptyState
+ title={
+ scope === "closed"
+ ? t(
+ "portal.failures.emptyClosed.title",
+ "Nothing closed yet",
+ )
+ : t(
+ "portal.failures.empty.title",
+ "Nothing needs your attention",
+ )
+ }
+ description={
+ scope === "closed"
+ ? t(
+ "portal.failures.emptyClosed.description",
+ "Items you dismiss or resolve are kept here with their outcome.",
+ )
+ : t(
+ "portal.failures.empty.description",
+ "Anything from a policy run or an editor tool that needs a look will appear here.",
+ )
+ }
+ />
+ ) : (
+ t(
+ "portal.failures.noMatches",
+ "Nothing matches the current filters",
+ )
+ )
+ }
+ toolbar={
+ <DataTableFilterBar
+ {...filters.filterBar}
+ trailing={
+ <SegmentedControl<FileRunEventScope>
+ options={scopeOptions}
+ value={scope}
+ onChange={setScope}
+ ariaLabel={t(
+ "portal.failures.scope.ariaLabel",
+ "Review state",
+ )}
+ />
+ }
+ />
+ }
+ />
+ )}
- <FailureActionButtons
- event={event}
- busyActionId={busy?.id === event.id ? busy.action : null}
- onAction={(actionId) => onAction(event, actionId)}
- />
- </li>
- ))}
- </ul>
+ <Modal
+ open={logOf !== null}
+ onClose={() => setLogOf(null)}
+ width="lg"
+ title={logOf ? titleFor(logOf) : undefined}
+ // The row shows a relative time, so the full moment lives here.
+ subtitle={
+ logOf ? new Date(logOf.lastSeenAt).toLocaleString() : undefined
+ }
+ footer={
+ <Button variant="secondary" onClick={() => logOf && copyLog(logOf)}>
+ {t("portal.failures.log.copy", "Copy error")}
+ </Button>
+ }
+ >
+ <pre className="portal-failures__log">{logOf?.detail}</pre>
+ </Modal>
+ </div>
);
}
diff --git a/frontend/editor/src/portal/components/failures/failureActionCells.test.tsx b/frontend/editor/src/portal/components/failures/failureActionCells.test.tsx
new file mode 100644
index 0000000000..68b2b76de9
--- /dev/null
+++ b/frontend/editor/src/portal/components/failures/failureActionCells.test.tsx
@@ -0,0 +1,317 @@
+import { describe, expect, it, vi } from "vitest";
+import {
+ fireEvent,
+ render as baseRender,
+ screen,
+} from "@testing-library/react";
+import { MantineProvider } from "@mantine/core";
+import type { TFunction } from "i18next";
+import { renderCellActions } from "@app/ui";
+import { buildFailureActionCells } from "@portal/components/failures/failureActionCells";
+import type {
+ FailureActionOffer,
+ FileRunEvent,
+} from "@portal/api/fileRunEvents";
+
+// @app/ui buttons are Mantine wrappers, so they need the provider in the tree.
+const render = (
+ ui: Parameters<typeof baseRender>[0],
+ options?: Parameters<typeof baseRender>[1],
+) => baseRender(ui, { wrapper: MantineProvider, ...options });
+
+/** The one-button shape, what falls back into the menu, and that a client-executed
+ * offer never reaches this surface. */
+
+// Mirrors i18next closely enough: a known key resolves, an unknown one falls back.
+const t = ((key: string, second?: { defaultValue?: string } | string) => {
+ const known: Record<string, string> = {
+ "portal.failures.action.acknowledge": "Acknowledge",
+ "portal.failures.action.dismiss": "Dismiss",
+ };
+ if (known[key]) return known[key];
+ if (typeof second === "string") return second;
+ if (second?.defaultValue) return second.defaultValue;
+ return key;
+}) as TFunction;
+
+function offer(overrides: Partial<FailureActionOffer>): FailureActionOffer {
+ return {
+ id: "ACKNOWLEDGE",
+ labelKey: "portal.failures.action.acknowledge",
+ defaultLabel: "Acknowledge",
+ execution: "SERVER",
+ slot: "SECONDARY",
+ enabled: true,
+ disabledReasonKey: null,
+ ...overrides,
+ };
+}
+
+function event(
+ actions: FailureActionOffer[],
+ overrides: Partial<FileRunEvent> = {},
+): FileRunEvent {
+ return {
+ id: "evt-1",
+ kindId: "UNKNOWN",
+ stage: "INTERNAL",
+ severity: "ERROR",
+ scope: "RUN",
+ origin: "POLICY",
+ remedy: "PERMANENT",
+ titleKey: "portal.failures.kind.unknown.title",
+ descriptionKey: "portal.failures.kind.unknown.description",
+ defaultTitle: "Unrecognised failure",
+ detail: "boom",
+ policyId: "p1",
+ runId: "r1",
+ sourceId: null,
+ fileId: "f-1",
+ actor: "[email protected]",
+ occurrences: 1,
+ status: "NEW",
+ statusActor: null,
+ actions,
+ createdAt: 0,
+ lastSeenAt: 0,
+ ...overrides,
+ };
+}
+
+function build(
+ failureEvent: FileRunEvent,
+ overrides: Partial<Parameters<typeof buildFailureActionCells>[0]> = {},
+) {
+ return buildFailureActionCells({
+ event: failureEvent,
+ t,
+ busyActionId: null,
+ onAction: vi.fn(),
+ onCopyLog: vi.fn(),
+ ...overrides,
+ });
+}
+
+const openMenu = () =>
+ fireEvent.click(screen.getByRole("button", { name: "More options" }));
+
+describe("buildFailureActionCells", () => {
+ it("shows only Dismiss and the menu, offers ordered by the server's slots", () => {
+ render(
+ <>
+ {renderCellActions(
+ build(
+ event([
+ offer({ id: "ACKNOWLEDGE", slot: "SECONDARY" }),
+ offer({
+ id: "DISMISS",
+ slot: "OVERFLOW",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ }),
+ ]),
+ ),
+ )}
+ </>,
+ );
+
+ // One flat button, everything else in the menu.
+ expect(screen.getByRole("button", { name: "Dismiss" })).toBeTruthy();
+ openMenu();
+ const items = screen.getAllByRole("menuitem").map((el) => el.textContent);
+ expect(items).toEqual(["Acknowledge", "Copy error"]);
+ });
+
+ it("drops every client-executed offer: reviewing stays in the processor", () => {
+ render(
+ <>
+ {renderCellActions(
+ build(
+ event([
+ offer({
+ id: "VIEW_FILE",
+ execution: "CLIENT",
+ defaultLabel: "View file",
+ }),
+ offer({
+ id: "DECRYPT_AND_RETRY",
+ execution: "CLIENT",
+ slot: "RESOLUTION",
+ defaultLabel: "Decrypt and retry",
+ }),
+ offer({
+ id: "VIEW_IN_PROCESSOR",
+ execution: "CLIENT",
+ defaultLabel: "View in processor",
+ }),
+ offer({ id: "ACKNOWLEDGE" }),
+ ]),
+ ),
+ )}
+ </>,
+ );
+
+ openMenu();
+ const items = screen.getAllByRole("menuitem").map((el) => el.textContent);
+ expect(items).toEqual(["Acknowledge", "Copy error"]);
+ });
+
+ it("tucks View error into the menu when Dismiss holds the button slot", () => {
+ const onViewError = vi.fn();
+ render(
+ <>
+ {renderCellActions(
+ build(
+ event([
+ offer({
+ id: "DISMISS",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ slot: "OVERFLOW",
+ }),
+ ]),
+ { onViewError },
+ ),
+ )}
+ </>,
+ );
+
+ const labels = screen
+ .getAllByRole("button")
+ .map((el) => el.getAttribute("aria-label") ?? el.textContent);
+ expect(labels).toEqual(["Dismiss", "More options"]);
+
+ openMenu();
+ expect(screen.getAllByRole("menuitem").map((el) => el.textContent)).toEqual(
+ ["View error", "Copy error"],
+ );
+ fireEvent.click(screen.getByRole("menuitem", { name: "View error" }));
+ expect(onViewError).toHaveBeenCalled();
+ });
+
+ it("gives View error the button slot on a row with nothing to act on", () => {
+ const onViewError = vi.fn();
+ render(
+ <>
+ {renderCellActions(
+ build(
+ event([
+ offer({
+ id: "DISMISS",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ slot: "OVERFLOW",
+ enabled: false,
+ disabledReasonKey: "portal.failures.disabled.closed",
+ }),
+ ]),
+ { onViewError },
+ ),
+ )}
+ </>,
+ );
+
+ const labels = screen
+ .getAllByRole("button")
+ .map((el) => el.getAttribute("aria-label") ?? el.textContent);
+ expect(labels).toEqual(["View error", "More options"]);
+ fireEvent.click(screen.getByRole("button", { name: "View error" }));
+ expect(onViewError).toHaveBeenCalled();
+ });
+
+ it("posts the offer it was clicked with", () => {
+ const onAction = vi.fn();
+ render(
+ <>
+ {renderCellActions(
+ build(event([offer({ id: "ACKNOWLEDGE" })]), { onAction }),
+ )}
+ </>,
+ );
+
+ openMenu();
+ fireEvent.click(screen.getByRole("menuitem", { name: "Acknowledge" }));
+ expect(onAction).toHaveBeenCalledWith("ACKNOWLEDGE");
+ });
+
+ it("keeps the log copyable from the menu on a row with nothing to resolve", () => {
+ const onCopyLog = vi.fn();
+ render(
+ <>
+ {renderCellActions(
+ build(
+ event([
+ offer({
+ id: "DISMISS",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ slot: "OVERFLOW",
+ }),
+ ]),
+ { onCopyLog },
+ ),
+ )}
+ </>,
+ );
+
+ expect(screen.getByRole("button", { name: "Dismiss" })).toBeTruthy();
+ openMenu();
+ fireEvent.click(screen.getByRole("menuitem", { name: "Copy error" }));
+ expect(onCopyLog).toHaveBeenCalled();
+ });
+
+ it("offers no Dismiss button on a closed row, whose dismiss came back disabled", () => {
+ render(
+ <>
+ {renderCellActions(
+ build(
+ event([
+ offer({
+ id: "DISMISS",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ slot: "OVERFLOW",
+ enabled: false,
+ disabledReasonKey: "portal.failures.disabled.closed",
+ }),
+ ]),
+ ),
+ )}
+ </>,
+ );
+
+ expect(screen.queryByRole("button", { name: "Dismiss" })).toBeNull();
+ // The log outlives the incident.
+ openMenu();
+ expect(screen.getByRole("menuitem", { name: "Copy error" })).toBeTruthy();
+ });
+
+ it("renders nothing at all for a row with no offers and no log", () => {
+ const cells = build(event([], { detail: null }));
+ expect(cells).toHaveLength(0);
+ });
+
+ it("marks the action in flight busy", () => {
+ render(
+ <>
+ {renderCellActions(
+ build(
+ event([
+ offer({
+ id: "DISMISS",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ slot: "OVERFLOW",
+ }),
+ ]),
+ { busyActionId: "DISMISS" },
+ ),
+ )}
+ </>,
+ );
+
+ expect(
+ screen.getByRole("button", { name: "Dismiss" }).hasAttribute("disabled"),
+ ).toBe(true);
+ });
+});
diff --git a/frontend/editor/src/portal/components/failures/failureActionCells.ts b/frontend/editor/src/portal/components/failures/failureActionCells.ts
new file mode 100644
index 0000000000..15ee890143
--- /dev/null
+++ b/frontend/editor/src/portal/components/failures/failureActionCells.ts
@@ -0,0 +1,101 @@
+import type { TFunction } from "i18next";
+import type { CellAction, CellMenuItem } from "@app/ui";
+import { promoteActions } from "@app/components/notifications/notificationActionSlots";
+import type { NotificationActionOffer } from "@app/services/notifications";
+import type { FileRunEvent } from "@portal/api/fileRunEvents";
+
+/** A row's actions as [primary][menu]: one button at most, everything else behind the kebab. */
+
+export interface FailureActionCellsOptions {
+ event: FileRunEvent;
+ t: TFunction;
+ busyActionId?: string | null;
+ /** Runs the offer against the actions endpoint. */
+ onAction: (actionId: string) => void | Promise<void>;
+ /** Omitted for a row with no diagnostic, which has no error to show. */
+ onViewError?: () => void;
+ onCopyLog: () => void;
+}
+
+export function buildFailureActionCells({
+ event,
+ t,
+ busyActionId,
+ onAction,
+ onViewError,
+ onCopyLog,
+}: FailureActionCellsOptions): CellAction[] {
+ // Server-executed only: a client action wants a workbench to land in, and reviewing
+ // is meant to finish here rather than send the reviewer off into the editor.
+ const offers = event.actions.filter((offer) => offer.execution === "SERVER");
+
+ // Fixed button, so it sits out the promotion the rest contest.
+ const dismiss = offers.find((offer) => offer.id === "DISMISS");
+ const contested = offers.filter((offer) => offer.id !== "DISMISS");
+
+ const { primary, secondary, overflow } = promoteActions(
+ contested satisfies NotificationActionOffer[],
+ () => true,
+ () => true,
+ );
+
+ const labelOf = (offer: NotificationActionOffer) =>
+ t(offer.labelKey, offer.defaultLabel);
+
+ const buttons: CellAction[] = [];
+ if (dismiss?.enabled) {
+ buttons.push({
+ label: labelOf(dismiss),
+ loading: busyActionId === dismiss.id,
+ disabled: busyActionId === dismiss.id,
+ onClick: () => void onAction(dismiss.id),
+ });
+ }
+ // Reading the error is not what the row is for, so it only takes the button slot
+ // when nothing the reviewer can act on has claimed it.
+ const viewErrorInMenu = onViewError !== undefined && buttons.length > 0;
+ if (onViewError && !viewErrorInMenu) {
+ buttons.push({
+ label: t("portal.failures.log.view", "View error"),
+ onClick: onViewError,
+ });
+ }
+
+ const menu: CellMenuItem[] = [primary, secondary, ...overflow]
+ .filter((offer): offer is NotificationActionOffer => offer != null)
+ .map((offer) => ({
+ label: labelOf(offer),
+ disabled: busyActionId === offer.id,
+ onClick: () => void onAction(offer.id),
+ }));
+ // The diagnostic pair sits together, after whatever can be acted on.
+ const diagnostics: CellMenuItem[] = [];
+ if (viewErrorInMenu && onViewError) {
+ diagnostics.push({
+ label: t("portal.failures.log.view", "View error"),
+ onClick: onViewError,
+ });
+ }
+ if (event.detail) {
+ diagnostics.push({
+ label: t("portal.failures.log.copy", "Copy error"),
+ onClick: onCopyLog,
+ });
+ }
+ if (diagnostics.length > 0) {
+ diagnostics[0]!.dividerBefore = menu.length > 0;
+ menu.push(...diagnostics);
+ }
+
+ // Not gated on a button existing: a row with nothing runnable still owns its log.
+ if (menu.length > 0) {
+ buttons.push({
+ label: t("notifications.action.more", "More options"),
+ glyph: "kebab",
+ iconOnly: true,
+ menu,
+ });
+ }
+
+ return buttons;
+}
diff --git a/frontend/editor/src/portal/components/failures/failureOutcomes.ts b/frontend/editor/src/portal/components/failures/failureOutcomes.ts
new file mode 100644
index 0000000000..8e4fa44eef
--- /dev/null
+++ b/frontend/editor/src/portal/components/failures/failureOutcomes.ts
@@ -0,0 +1,38 @@
+import type { StatusTone } from "@app/ui";
+import type { FileRunEventStatus } from "@portal/api/fileRunEvents";
+
+/** How a closed failure was settled. Must stay in sync with the server's terminal statuses. */
+
+interface FailureOutcome {
+ labelKey: string;
+ defaultLabel: string;
+ tone: StatusTone;
+}
+
+const OUTCOMES: Partial<Record<FileRunEventStatus, FailureOutcome>> = {
+ RESOLVED: {
+ labelKey: "portal.failures.outcome.resolved",
+ defaultLabel: "Resolved",
+ tone: "success",
+ },
+ DISMISSED: {
+ labelKey: "portal.failures.outcome.dismissed",
+ defaultLabel: "Dismissed",
+ tone: "neutral",
+ },
+ FILE_REMOVED: {
+ labelKey: "portal.failures.outcome.fileRemoved",
+ defaultLabel: "File deleted",
+ tone: "neutral",
+ },
+};
+
+const STILL_OPEN: FailureOutcome = {
+ labelKey: "portal.failures.outcome.open",
+ defaultLabel: "Open",
+ tone: "info",
+};
+
+export function outcomeOf(status: FileRunEventStatus): FailureOutcome {
+ return OUTCOMES[status] ?? STILL_OPEN;
+}
diff --git a/frontend/editor/src/portal/components/failures/failures.css b/frontend/editor/src/portal/components/failures/failures.css
index 9e43361e43..b7bc1f45c1 100644
--- a/frontend/editor/src/portal/components/failures/failures.css
+++ b/frontend/editor/src/portal/components/failures/failures.css
@@ -1,123 +1,21 @@
-/*
- * Recorded failures list. Colours come from semantic tokens only; no literals.
- * See core/theme/README.md.
- */
+/* Failures chrome only: rows, cells and the filter bar belong to the DataTable. */
.portal-failures {
- margin-top: var(--space-8, 2rem);
-}
-
-.portal-failures__heading {
- font-size: 1.05rem;
- font-weight: 600;
- color: var(--c-text);
- margin: 0;
-}
-
-.portal-failures__sub {
- font-size: 0.85rem;
- color: var(--c-text-muted);
- margin: 0.2rem 0 1rem;
-}
-
-.portal-failures__skeleton {
display: flex;
flex-direction: column;
- gap: 0.5rem;
+ gap: 1rem;
}
-.portal-failures__list {
- list-style: none;
+/* One row's raw log inside the View-log modal. */
+.portal-failures__log {
margin: 0;
- padding: 0;
- display: flex;
- flex-direction: column;
- gap: 0.6rem;
-}
-
-.portal-failures__row {
- padding: 0.8rem 0.95rem;
-}
-
-.portal-failures__meta {
- display: flex;
- align-items: center;
- gap: 0.55rem;
- flex-wrap: wrap;
-}
-
-.portal-failures__title {
- font-weight: 600;
- font-size: 0.9rem;
- color: var(--c-text);
-}
-
-.portal-failures__count {
- font-size: 0.75rem;
- color: var(--c-text-subtle);
-}
-
-.portal-failures__file {
- font-size: 0.82rem;
- color: var(--c-text-muted);
- margin-top: 0.3rem;
-}
-
-/* The raw failure message. Monospace because for an unclassified failure this is
- a stack-trace-ish diagnostic, not prose. */
-.portal-failures__origin {
- font-size: 0.75rem;
- color: var(--c-text-subtle);
- border: 1px solid var(--c-border-subtle);
- border-radius: var(--radius-sm, 0.25rem);
- padding: 0 0.35rem;
-}
-
-.portal-failures__actor {
- font-size: 0.8125rem;
- color: var(--c-text-muted);
-}
-
-.portal-failures__detail {
- font-family: var(--font-mono, ui-monospace, monospace);
- font-size: 0.76rem;
- color: var(--c-text-subtle);
- background: var(--c-surface-sunken);
- border-radius: 6px;
- padding: 0.45rem 0.6rem;
- margin: 0.5rem 0 0;
- overflow-wrap: anywhere;
-}
-
-.portal-failures__actions {
- display: flex;
- gap: 0.45rem;
- margin-top: 0.7rem;
- flex-wrap: wrap;
-}
-
-/* ── Dev-only inspector (see FileRunEventList) ─────────────────────────────── */
-.portal-failures__debug {
- display: flex;
- gap: 0.4rem;
- flex-wrap: wrap;
- align-items: flex-start;
- margin-bottom: 0.8rem;
padding: 0.5rem;
- border: 1px dashed var(--c-border-strong);
- border-radius: 6px;
-}
-
-.portal-failures__debug-json {
- flex: 1 1 100%;
- max-height: 26rem;
overflow: auto;
- margin: 0.4rem 0 0;
- padding: 0.5rem;
background: var(--c-surface-sunken);
border-radius: 4px;
font-family: var(--font-mono, ui-monospace, monospace);
- font-size: 0.7rem;
- white-space: pre;
+ font-size: 0.76rem;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
user-select: all;
}
diff --git a/frontend/editor/src/portal/components/icons.tsx b/frontend/editor/src/portal/components/icons.tsx
index 86a4eb81d1..9a17c1df86 100644
--- a/frontend/editor/src/portal/components/icons.tsx
+++ b/frontend/editor/src/portal/components/icons.tsx
@@ -87,6 +87,17 @@ export function DocumentsIcon(props: IconProps) {
);
}
+/** A checklist, not a warning sign: the tab is a queue to work through, not an alert. */
+export function ReviewIcon(props: IconProps) {
+ return (
+ <Svg {...props}>
+ <path d="M9 4H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2" />
+ <rect x="9" y="2" width="6" height="4" rx="1" />
+ <polyline points="9 13 11 15 15 11" />
+ </Svg>
+ );
+}
+
export function InfrastructureIcon(props: IconProps) {
return (
<Svg {...props}>
diff --git a/frontend/editor/src/portal/components/sidebarGroups.tsx b/frontend/editor/src/portal/components/sidebarGroups.tsx
index b7796a66bf..274fb915ba 100644
--- a/frontend/editor/src/portal/components/sidebarGroups.tsx
+++ b/frontend/editor/src/portal/components/sidebarGroups.tsx
@@ -7,6 +7,7 @@ import {
IntegrationsIcon,
PipelinesIcon,
DocumentsIcon,
+ ReviewIcon,
InfrastructureIcon,
UsageIcon,
DocsIcon,
@@ -37,6 +38,7 @@ export const GROUP_PROCESSOR: NavEntry[] = [
{ id: "sources", icon: <SourcesIcon /> },
{ id: "pipelines", icon: <PipelinesIcon /> },
{ id: "documents", icon: <DocumentsIcon /> },
+ { id: "review", icon: <ReviewIcon /> },
];
// The wider platform around the processor: people, connections, infra, billing, docs.
diff --git a/frontend/editor/src/portal/contexts/ViewContext.tsx b/frontend/editor/src/portal/contexts/ViewContext.tsx
index 9da2d1517c..dc1a132017 100644
--- a/frontend/editor/src/portal/contexts/ViewContext.tsx
+++ b/frontend/editor/src/portal/contexts/ViewContext.tsx
@@ -1,6 +1,9 @@
import { useCallback, useMemo } from "react";
import { useLocation, useNavigate } from "react-router-dom";
-import { PORTAL_BASENAME } from "@app/routes/portalBasename";
+import {
+ PORTAL_BASENAME,
+ PORTAL_REVIEW_PATH,
+} from "@app/routes/portalBasename";
export type ViewId =
| "home"
@@ -10,6 +13,7 @@ export type ViewId =
| "policies"
| "pipelines"
| "documents"
+ | "review"
| "infrastructure"
| "usage"
| "docs"
@@ -23,6 +27,8 @@ export const VIEW_PATHS: Record<ViewId, string> = {
policies: "/policies",
pipelines: "/pipelines",
documents: "/documents",
+ // Shared with the notification action that deep-links here, which cannot import portal code.
+ review: PORTAL_REVIEW_PATH,
infrastructure: "/infrastructure",
usage: "/usage",
docs: "/docs",
diff --git a/frontend/editor/src/portal/mocks/fileRunEvents.ts b/frontend/editor/src/portal/mocks/fileRunEvents.ts
index 0e0fd25679..804b3d5095 100644
--- a/frontend/editor/src/portal/mocks/fileRunEvents.ts
+++ b/frontend/editor/src/portal/mocks/fileRunEvents.ts
@@ -6,26 +6,35 @@
* a closed row whose actions come back disabled.
*/
-import type { FileRunEvent } from "@portal/api/fileRunEvents";
+import type {
+ FailureActionOffer,
+ FileRunEvent,
+} from "@portal/api/fileRunEvents";
const HOUR = 3_600_000;
/** Fixed base so fixtures are stable across renders and snapshots. */
const NOW = Date.UTC(2026, 6, 31, 12, 0, 0);
-function acknowledgeOffer(enabled = true, labelKey?: string) {
+function acknowledgeOffer(enabled = true): FailureActionOffer {
return {
id: "ACKNOWLEDGE",
- labelKey: labelKey ?? "portal.failures.action.acknowledge",
+ labelKey: "portal.failures.action.acknowledge",
+ defaultLabel: "Acknowledge",
+ execution: "SERVER",
+ slot: "SECONDARY",
enabled,
disabledReasonKey: enabled ? null : "portal.failures.disabled.closed",
};
}
-function dismissOffer(enabled = true, labelKey?: string) {
+function dismissOffer(enabled = true): FailureActionOffer {
return {
id: "DISMISS",
- labelKey: labelKey ?? "portal.failures.action.dismiss",
+ labelKey: "portal.failures.action.dismiss",
+ defaultLabel: "Dismiss",
+ execution: "SERVER",
+ slot: "OVERFLOW",
enabled,
disabledReasonKey: enabled ? null : "portal.failures.disabled.closed",
};
@@ -52,10 +61,7 @@ export const FILE_RUN_EVENTS: FileRunEvent[] = [
occurrences: 1,
status: "NEW",
statusActor: null,
- actions: [
- acknowledgeOffer(true, "portal.failures.action.acknowledge"),
- dismissOffer(true, "portal.failures.action.dismissSkipFile"),
- ],
+ actions: [acknowledgeOffer(), dismissOffer()],
createdAt: NOW - HOUR,
lastSeenAt: NOW - HOUR,
},
@@ -135,7 +141,7 @@ export const FILE_RUN_EVENTS: FileRunEvent[] = [
statusActor: null,
// A colleague's own upload. Nothing here acts on the document, so triage is just
// acknowledging or clearing the row.
- actions: [dismissOffer(true, "portal.failures.action.dismissSkipFile")],
+ actions: [dismissOffer()],
createdAt: NOW - 4 * HOUR,
lastSeenAt: NOW - 4 * HOUR,
},
@@ -161,10 +167,7 @@ export const FILE_RUN_EVENTS: FileRunEvent[] = [
occurrences: 3,
status: "DISMISSED",
statusActor: "[email protected]",
- actions: [
- acknowledgeOffer(false, "portal.failures.action.acknowledge"),
- dismissOffer(false, "portal.failures.action.dismissSkipFile"),
- ],
+ actions: [acknowledgeOffer(false), dismissOffer(false)],
createdAt: NOW - 30 * HOUR,
lastSeenAt: NOW - 26 * HOUR,
},
diff --git a/frontend/editor/src/portal/mocks/handlers/fileRunEvents.ts b/frontend/editor/src/portal/mocks/handlers/fileRunEvents.ts
index c6440fb13b..5a1f9fc2a5 100644
--- a/frontend/editor/src/portal/mocks/handlers/fileRunEvents.ts
+++ b/frontend/editor/src/portal/mocks/handlers/fileRunEvents.ts
@@ -1,5 +1,5 @@
import { http, HttpResponse, delay } from "msw";
-import type { FileRunEvent } from "@portal/api/fileRunEvents";
+import { isClosedStatus, type FileRunEvent } from "@portal/api/fileRunEvents";
import { FILE_RUN_EVENTS } from "@portal/mocks/fileRunEvents";
/**
@@ -24,15 +24,15 @@ export const fileRunEventsHandlers = [
await delay(120);
const url = new URL(request.url);
const status = url.searchParams.get("status");
+ const closed = url.searchParams.get("closed") === "true";
const kindId = url.searchParams.get("kindId");
- // Mirrors the server: no status asked for means the open queue, so a dismissed
- // row leaves the list instead of sitting there with its buttons greyed out.
+ // Mirrors the server: a dismissed row leaves the open queue for the closed one.
const filtered = events.filter(
(event) =>
(status
? event.status === status
- : event.status !== "DISMISSED" && event.status !== "RESOLVED") &&
+ : isClosedStatus(event.status) === closed) &&
(!kindId || event.kindId === kindId),
);
return HttpResponse.json({
diff --git a/frontend/editor/src/portal/queries/fileRunEvents.ts b/frontend/editor/src/portal/queries/fileRunEvents.ts
index 2a39912494..a30c4da83a 100644
--- a/frontend/editor/src/portal/queries/fileRunEvents.ts
+++ b/frontend/editor/src/portal/queries/fileRunEvents.ts
@@ -5,7 +5,9 @@ import type { AsyncState } from "@portal/hooks/useAsync";
import {
applyFileRunEventAction,
fetchFileRunEvents,
+ isClosedStatus,
type FileRunEvent,
+ type FileRunEventScope,
} from "@portal/api/fileRunEvents";
import { HttpError } from "@portal/api/http";
@@ -31,12 +33,15 @@ function isPermanentRefusal(error: unknown): boolean {
);
}
-/** Base query: recorded policy failures for the caller's team. */
-export function useFileRunEvents(): AsyncState<FileRunEvent[]> {
+/** Base query: recorded policy failures for the caller's team, open or closed. */
+export function useFileRunEvents(
+ scope: FileRunEventScope = "open",
+): AsyncState<FileRunEvent[]> {
return toAsyncState(
useQuery({
- queryKey: qk.fileRunEvents(),
- queryFn: () => fetchFileRunEvents({ limit: PAGE_SIZE }),
+ queryKey: qk.fileRunEvents(scope),
+ queryFn: () =>
+ fetchFileRunEvents({ closed: scope === "closed", limit: PAGE_SIZE }),
// A build without the failure registry 404s and a non-leader gets a 403.
// Neither improves on retry, and the caller renders nothing either way.
retry: false,
@@ -61,16 +66,24 @@ export function useFileRunEventActions() {
const apply = async (eventId: string, actionId: string) => {
try {
const updated = await applyFileRunEventAction(eventId, actionId);
- queryClient.setQueryData<FileRunEvent[]>(qk.fileRunEvents(), (rows) =>
- (rows ?? []).map((row) => (row.id === updated.id ? updated : row)),
+ queryClient.setQueryData<FileRunEvent[]>(
+ qk.fileRunEvents("open"),
+ (rows) =>
+ // Closing it takes it out of the open queue; anything else updates in place.
+ isClosedStatus(updated.status)
+ ? (rows ?? []).filter((row) => row.id !== updated.id)
+ : (rows ?? []).map((row) =>
+ row.id === updated.id ? updated : row,
+ ),
);
+ // It has landed in the other list, which would now answer stale.
+ await queryClient.invalidateQueries({
+ queryKey: qk.fileRunEvents("closed"),
+ });
} catch {
- await queryClient.invalidateQueries({ queryKey: qk.fileRunEvents() });
+ await queryClient.invalidateQueries({ queryKey: qk.fileRunEventsAll() });
}
};
- const refresh = () =>
- queryClient.invalidateQueries({ queryKey: qk.fileRunEvents() });
-
- return { apply, refresh };
+ return { apply };
}
diff --git a/frontend/editor/src/portal/queries/keys.ts b/frontend/editor/src/portal/queries/keys.ts
index e1c46a59c0..1e4b830f7a 100644
--- a/frontend/editor/src/portal/queries/keys.ts
+++ b/frontend/editor/src/portal/queries/keys.ts
@@ -1,4 +1,5 @@
import type { Tier } from "@portal/contexts/TierContext";
+import type { FileRunEventScope } from "@portal/api/fileRunEvents";
/**
* The portal's TanStack Query keys, in one place. Convention:
@@ -16,7 +17,11 @@ export const qk = {
pipelines: () => ["portal", "pipelines"] as const,
fleetStats: () => ["portal", "fleetStats"] as const,
appConfig: () => ["portal", "appConfig"] as const,
- fileRunEvents: () => ["portal", "fileRunEvents"] as const,
+ // Keyed on scope: the open queue and the closed one are different reads.
+ fileRunEvents: (scope: FileRunEventScope) =>
+ ["portal", "fileRunEvents", scope] as const,
+ /** Prefix matching both scopes, for invalidating the pair. */
+ fileRunEventsAll: () => ["portal", "fileRunEvents"] as const,
// Keyed on linkage: an unlinked account has no deal to read, so linking must not
// serve the unlinked (null) snapshot back from cache.
procurement: (linked: boolean) => ["portal", "procurement", linked] as const,
diff --git a/frontend/editor/src/portal/views/Documents.tsx b/frontend/editor/src/portal/views/Documents.tsx
index 6bd394c13d..3f2deb2c71 100644
--- a/frontend/editor/src/portal/views/Documents.tsx
+++ b/frontend/editor/src/portal/views/Documents.tsx
@@ -8,8 +8,6 @@ import {
type ReviewDocument,
} from "@portal/api/documents";
import { ReviewQueue } from "@portal/components/documents/ReviewQueue";
-import { FileRunEventList } from "@portal/components/failures/FileRunEventList";
-import "@portal/components/failures/failures.css";
import "@portal/views/Documents.css";
function DownloadIcon() {
@@ -106,15 +104,6 @@ export function Documents() {
</header>
<ReviewQueue documents={documents} loading={state.loading} />
-
- {/* Recorded policy, pipeline and editor failures. DEV ONLY, deliberately: this list is a
- stand-in until failures get their own review screen, and it is not the surface we want to
- ship. The endpoints behind it are live and gated, so nothing here is load-bearing.
-
- Vite folds this to false in a build, so neither the section nor its fetch ships. The bell's
- "View in processor" action is gated the same way and for the same reason - lift both
- together when the review screen lands, or that button navigates nowhere. */}
- {import.meta.env.DEV && <FileRunEventList />}
</div>
);
}
diff --git a/frontend/editor/src/portal/views/Review.css b/frontend/editor/src/portal/views/Review.css
new file mode 100644
index 0000000000..c8b300b256
--- /dev/null
+++ b/frontend/editor/src/portal/views/Review.css
@@ -0,0 +1,32 @@
+/* Review screen shell. Colours come from semantic tokens only; no literals.
+ See core/theme/README.md. */
+
+.portal-review {
+ display: flex;
+ flex-direction: column;
+ gap: 1.25rem;
+ padding: 1.5rem;
+ max-width: 84rem;
+ margin: 0 auto;
+}
+
+.portal-review__head {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+}
+
+.portal-review__title {
+ margin: 0;
+ font-size: 1.375rem;
+ font-weight: 650;
+ color: var(--c-text);
+}
+
+.portal-review__sub {
+ margin: 0;
+ font-size: 0.8125rem;
+ line-height: 1.5;
+ color: var(--c-text-subtle);
+ max-width: 46rem;
+}
diff --git a/frontend/editor/src/portal/views/Review.stories.tsx b/frontend/editor/src/portal/views/Review.stories.tsx
new file mode 100644
index 0000000000..b6769c003c
--- /dev/null
+++ b/frontend/editor/src/portal/views/Review.stories.tsx
@@ -0,0 +1,73 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { http, HttpResponse } from "msw";
+import { screen } from "storybook/test";
+import { Review } from "@portal/views/Review";
+
+const meta: Meta<typeof Review> = {
+ title: "Portal/Views/Review",
+ component: Review,
+ parameters: { layout: "padded" },
+};
+export default meta;
+type Story = StoryObj<typeof Review>;
+
+/** Seeded mock data: a classified issue, an unclassified one, a repeat, and a closed row. */
+export const Default: Story = {};
+
+/** The settled half of the queue, with each row's outcome and who closed it. */
+export const Closed: Story = {
+ play: async ({ canvas, userEvent }) => {
+ await canvas.findAllByText("Password-protected document");
+ await userEvent.click(await canvas.findByText("Closed"));
+ await canvas.findByText("Outcome");
+ },
+};
+
+/** A facet menu open: multi-select, with the row count each value would keep. */
+export const Filtering: Story = {
+ play: async ({ canvas, userEvent }) => {
+ await canvas.findAllByText("Password-protected document");
+ await userEvent.click(
+ await canvas.findByRole("button", { name: "Raised in", expanded: false }),
+ );
+ },
+};
+
+/** The raw error behind the row menu, so no row has to carry a diagnostic. */
+export const ViewingError: Story = {
+ play: async ({ canvas, userEvent }) => {
+ await canvas.findAllByText("Password-protected document");
+ await userEvent.click(
+ (await canvas.findAllByRole("button", { name: "More options" }))[0]!,
+ );
+ await userEvent.click(
+ await screen.findByRole("menuitem", { name: "View error" }),
+ );
+ },
+};
+
+/** Nothing needs attention: the queue is clear, not the workspace error-free. */
+export const Empty: Story = {
+ parameters: {
+ msw: {
+ handlers: [
+ http.get("*/api/v1/file-run-events", () =>
+ HttpResponse.json({ events: [] }),
+ ),
+ ],
+ },
+ },
+};
+
+/** Reviewing is leader-only, so a member's read is refused and the screen says so. */
+export const Refused: Story = {
+ parameters: {
+ msw: {
+ handlers: [
+ http.get("*/api/v1/file-run-events", () =>
+ HttpResponse.json({ detail: "Forbidden" }, { status: 403 }),
+ ),
+ ],
+ },
+ },
+};
diff --git a/frontend/editor/src/portal/views/Review.tsx b/frontend/editor/src/portal/views/Review.tsx
new file mode 100644
index 0000000000..8a0fd155e3
--- /dev/null
+++ b/frontend/editor/src/portal/views/Review.tsx
@@ -0,0 +1,28 @@
+import { useTranslation } from "react-i18next";
+import { FileRunEventList } from "@portal/components/failures/FileRunEventList";
+import "@portal/components/failures/failures.css";
+import "@portal/views/Review.css";
+
+/** What the processor needs a human to look at. Recorded failures today; held files
+ * and approvals are meant to join them here. */
+export function Review() {
+ const { t } = useTranslation();
+
+ return (
+ <div className="portal-review">
+ <div className="portal-review__head">
+ <h1 className="portal-review__title">
+ {t("portal.review.title", "Review")}
+ </h1>
+ <p className="portal-review__sub">
+ {t(
+ "portal.review.subtitle",
+ "Anything from your policy runs and your team's editors that needs your attention.",
+ )}
+ </p>
+ </div>
+
+ <FileRunEventList />
+ </div>
+ );
+}
diff --git a/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsx b/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsx
index cd1c319b28..36d56822b6 100644
--- a/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsx
+++ b/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsx
@@ -619,10 +619,10 @@ describe("useNotificationActions", () => {
});
});
- it("links to the recorded failures section of the processor", () => {
+ it("links to the processor's review screen", () => {
registry().VIEW_IN_PROCESSOR?.run(context());
- expect(navigate).toHaveBeenCalledWith("/processor/documents#failures");
+ expect(navigate).toHaveBeenCalledWith("/processor/review");
});
it("navigates in place even with a loaded workbench, never opening a tab", () => {
@@ -632,7 +632,7 @@ describe("useNotificationActions", () => {
registry().VIEW_IN_PROCESSOR?.run(context());
expect(openTab).not.toHaveBeenCalled();
- expect(navigate).toHaveBeenCalledWith("/processor/documents#failures");
+ expect(navigate).toHaveBeenCalledWith("/processor/review");
openTab.mockRestore();
});
@@ -642,7 +642,7 @@ describe("useNotificationActions", () => {
registry(inProcessor).VIEW_IN_PROCESSOR?.run(context());
expect(openTab).not.toHaveBeenCalled();
- expect(navigate).toHaveBeenCalledWith("/processor/documents#failures");
+ expect(navigate).toHaveBeenCalledWith("/processor/review");
openTab.mockRestore();
});
diff --git a/frontend/editor/src/proprietary/components/notifications/notificationActions.ts b/frontend/editor/src/proprietary/components/notifications/notificationActions.ts
index 6074525e25..4aa1d1d50a 100644
--- a/frontend/editor/src/proprietary/components/notifications/notificationActions.ts
+++ b/frontend/editor/src/proprietary/components/notifications/notificationActions.ts
@@ -11,7 +11,7 @@ import { ViewerContext } from "@app/contexts/ViewerContext";
import { getToolUrlPath } from "@app/data/toolsTaxonomy";
import {
PORTAL_BASENAME,
- PORTAL_FAILURES_ANCHOR,
+ PORTAL_REVIEW_PATH,
} from "@app/routes/portalBasename";
import { EDITOR_BASENAME } from "@app/routes/editorBasename";
import { fileStorage } from "@app/services/fileStorage";
@@ -60,7 +60,7 @@ export {
const HANDOFF_KEY = "stirling.notifications.pendingSelection";
-const FAILURES_DESTINATION = `${PORTAL_BASENAME}/documents#${PORTAL_FAILURES_ANCHOR}`;
+const REVIEW_DESTINATION = `${PORTAL_BASENAME}${PORTAL_REVIEW_PATH}`;
/** The document to open on arrival, and the tool to open it into. */
interface Handoff {
@@ -450,10 +450,9 @@ export function useNotificationActions(): ClientActionRegistry {
};
const viewInProcessor: ClientActionSpec = {
- // Dev-only until failures get a review screen; portal/views/Documents holds the other half.
- available: () => import.meta.env.DEV,
+ available: () => true,
closesPanel: true,
- run: () => navigate(FAILURES_DESTINATION),
+ run: () => navigate(REVIEW_DESTINATION),
};
return {
diff --git a/frontend/editor/src/proprietary/data/processorSearchIndex.ts b/frontend/editor/src/proprietary/data/processorSearchIndex.ts
index 8d99b2f77a..f00d47a242 100644
--- a/frontend/editor/src/proprietary/data/processorSearchIndex.ts
+++ b/frontend/editor/src/proprietary/data/processorSearchIndex.ts
@@ -1,4 +1,7 @@
-import { PORTAL_BASENAME } from "@app/routes/portalBasename";
+import {
+ PORTAL_BASENAME,
+ PORTAL_REVIEW_PATH,
+} from "@app/routes/portalBasename";
// A static leaf module (its portal import is type-only), so it doesn't pull
// the lazy portal chunk into the main bundle the way @portal/* values would.
import { usersCapabilities } from "@app/portal/usersCapabilities";
@@ -56,6 +59,13 @@ const VIEWS: ProcessorSearchEntry[] = [
path: `${PORTAL_BASENAME}/documents`,
keywords: ["audit", "files"],
},
+ {
+ id: "review",
+ labelKey: "portal.nav.review",
+ labelFallback: "Review",
+ path: `${PORTAL_BASENAME}${PORTAL_REVIEW_PATH}`,
+ keywords: ["failures", "errors", "triage", "retry"],
+ },
{
id: "integrations",
labelKey: "portal.nav.integrations",