Skip to content

Commit 4f26e67

Browse files
committed
fix(webapp): stop saying error twice when naming a watched error
1 parent 4697e90 commit 4f26e67

4 files changed

Lines changed: 31 additions & 6 deletions

File tree

apps/webapp/app/components/dashboard-agent/watch-card.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,19 @@ describe("the card's copy", () => {
270270
expect(watchSubjectLabel(healthWatchRecommendation("warn"))).toBe("health");
271271
});
272272

273+
it("says the kind once, though the fingerprint carries it too", () => {
274+
// Fingerprints are stored prefixed (`error_c4b4a797397a9c43`), so shortening the
275+
// raw value would read "error error_c4".
276+
expect(
277+
watchSubjectLabel({
278+
kind: "error_recurrence",
279+
fingerprint: "error_c4b4a797397a9c43",
280+
checkEveryMinutes: 5,
281+
maxHours: 0.5,
282+
})
283+
).toBe("error c4b4a797");
284+
});
285+
273286
it("states the condition and the duration as §2.2 writes them", () => {
274287
const spec = queueWatchRecommendation("email-sends", { oldestWaitMs: OLDEST_WAIT_WARNING_MS });
275288
expect(watchConditionLabel(spec)).toBe("Until the queue drains");

apps/webapp/app/components/dashboard-agent/watch-chips.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import type { WatchStatus } from "@internal/dashboard-agent-contracts";
1212
// user-facing copy. Re-exported here for chip callers.
1313
export { immediateWatchMessage } from "~/presenters/v3/dashboardAgent";
1414

15-
import { formatWatchCadence, watchIdentityValue } from "~/presenters/v3/dashboardAgent";
15+
import {
16+
formatWatchCadence,
17+
shortFingerprint,
18+
watchIdentityValue,
19+
} from "~/presenters/v3/dashboardAgent";
1620

1721
export const WATCH_STATUS_LABEL: Record<WatchStatus, string> = {
1822
active: "watching",
@@ -22,8 +26,6 @@ export const WATCH_STATUS_LABEL: Record<WatchStatus, string> = {
2226
};
2327

2428
/** Fingerprints are hashes — a chip shows just enough of one to tell them apart. */
25-
const FINGERPRINT_CHARS = 8;
26-
2729
/**
2830
* The chip label for a watch. `identity` is `{kind}:{value}`, so the value is the
2931
* thing being watched; a health watch has no per-instance value, so its kind is
@@ -48,7 +50,7 @@ export function watchChipLabel(watch: { kind: string; identity: string; note: st
4850
case "queue_oldest_age":
4951
return watchIdentityValue(watch.kind, watch.identity) || fallbackLabel(watch);
5052
case "error_recurrence":
51-
return value ? value.slice(0, FINGERPRINT_CHARS) : fallbackLabel(watch);
53+
return value ? shortFingerprint(value) : fallbackLabel(watch);
5254
case "health_recovery":
5355
return "health";
5456
default:

apps/webapp/app/presenters/v3/dashboardAgent/watch-wording.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export {
1717
WATCH_IN_CHAT_DELIVERY_LINE,
1818
WATCH_PRESENTATION_FALLBACK,
1919
WATCH_UPDATE_LABEL,
20+
shortFingerprint,
2021
watchConditionLabel,
2122
watchConditionWording,
2223
watchConfirmationBlockBody,

internal-packages/dashboard-agent-contracts/src/watch-wording.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ export const WATCH_UPDATE_LABEL = "Watch update";
3535
/** Fingerprints are hashes, so show just enough to tell them apart. */
3636
const FINGERPRINT_CHARS = 8;
3737

38+
/**
39+
* A fingerprint carries its own `error_` prefix, and every surface names the kind
40+
* itself — so the prefix is dropped before shortening, or the line reads
41+
* "error error_c4".
42+
*/
43+
export function shortFingerprint(fingerprint: string): string {
44+
return fingerprint.replace(/^error_/, "").slice(0, FINGERPRINT_CHARS);
45+
}
46+
3847
/* ------------------------------------------------------------------ *
3948
* Identity formatting
4049
* ------------------------------------------------------------------ */
@@ -80,7 +89,7 @@ function bareQueueName(identity: string, kind: string): string {
8089
/** How an error group is named in a sentence. */
8190
function errorName(identity: string, kind: string): string {
8291
const value = watchIdentityValue(kind, identity);
83-
return value ? `Error ${value.slice(0, FINGERPRINT_CHARS)}` : "The error";
92+
return value ? `Error ${shortFingerprint(value)}` : "The error";
8493
}
8594

8695
/* ------------------------------------------------------------------ *
@@ -486,7 +495,7 @@ export function watchSubjectLabel(spec: WatchSpec): string {
486495
case "queue_oldest_age":
487496
return spec.queue;
488497
case "error_recurrence":
489-
return `error ${spec.fingerprint.slice(0, FINGERPRINT_CHARS)}`;
498+
return `error ${shortFingerprint(spec.fingerprint)}`;
490499
case "health_recovery":
491500
return "health";
492501
}

0 commit comments

Comments
 (0)