Skip to content

Commit 71a0a00

Browse files
committed
fix(webapp): key an investigation's action rows by position, not by kind
1 parent 332a595 commit 71a0a00

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

apps/webapp/app/components/dashboard-agent/InvestigationCard.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { investigationCapabilitiesSchema } from "@internal/dashboard-agent-contracts";
12
import { readFileSync } from "node:fs";
23
import { describe, expect, it } from "vitest";
34

@@ -39,3 +40,29 @@ describe("InvestigationCard purity", () => {
3940
expect(source).toMatch(/if \(!onIntent \|\| actions\.length === 0\) return null;/);
4041
});
4142
});
43+
44+
describe("InvestigationCard action rows", () => {
45+
const twoOfAKind = {
46+
version: 1,
47+
actions: [
48+
{ kind: "ask_follow_up", label: "Why the retries?", intent: { kind: "ask", prompt: "Why?" } },
49+
{
50+
kind: "ask_follow_up",
51+
label: "Why the timeouts?",
52+
intent: { kind: "ask", prompt: "How?" },
53+
},
54+
],
55+
};
56+
57+
it("can be handed two actions of the same kind", () => {
58+
const parsed = investigationCapabilitiesSchema.safeParse(twoOfAKind);
59+
expect(parsed.success).toBe(true);
60+
expect(parsed.success && parsed.data.actions).toHaveLength(2);
61+
});
62+
63+
// Structural: there is no DOM in this suite, so the key is read off the source.
64+
it("keys the rows by position, which two of a kind cannot collide on", () => {
65+
const row = source.match(/actions\.map\(\(action, i\) => \([\s\S]*?key=\{(.+?)\}/);
66+
expect(row?.[1]).toBe("i");
67+
});
68+
});

apps/webapp/app/components/dashboard-agent/InvestigationCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function InvestigationActions({
122122
<ChatActionsRow>
123123
{actions.map((action, i) => (
124124
<Button
125-
key={action.kind}
125+
key={i}
126126
variant={i === 0 ? "primary/small" : "secondary/small"}
127127
onClick={() => onIntent(action.intent)}
128128
>

0 commit comments

Comments
 (0)