@langwatch/server 3.1.0-beta.19 → 3.1.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/langwatch/prisma/migrations/20260425000000_consolidate_gateway_audit_into_audit_log/migration.sql +44 -0
  2. package/langwatch/prisma/migrations/20260426150000_drop_redundant_audit_log_org_index/migration.sql +25 -0
  3. package/langwatch/prisma/schema.prisma +34 -41
  4. package/langwatch/scripts/seed-gateway-dogfood.ts +26 -26
  5. package/langwatch/src/app/api/gateway-platform/[[...route]]/app.ts +8 -4
  6. package/langwatch/src/app/api/middleware/trace-limit.ts +10 -0
  7. package/langwatch/src/components/MainMenu.tsx +4 -15
  8. package/langwatch/src/components/SettingsLayout.tsx +1 -1
  9. package/langwatch/src/components/llmPromptConfigs/__tests__/LLMConfigPopover.test.tsx +45 -0
  10. package/langwatch/src/components/llmPromptConfigs/parameterRegistry.ts +22 -13
  11. package/langwatch/src/components/prompts/PromptEditorDrawer.tsx +5 -3
  12. package/langwatch/src/components/settings/AddCustomModelDialog.tsx +7 -6
  13. package/langwatch/src/evaluations-v3/__tests__/TableDisplay.integration.test.tsx +90 -5
  14. package/langwatch/src/evaluations-v3/__tests__/TableSettingsMenu.integration.test.tsx +26 -26
  15. package/langwatch/src/evaluations-v3/components/DatasetSection/TableCell.tsx +2 -10
  16. package/langwatch/src/evaluations-v3/components/EvaluationsV3Table.tsx +10 -4
  17. package/langwatch/src/evaluations-v3/components/TableSettingsMenu.tsx +6 -6
  18. package/langwatch/src/evaluations-v3/components/TargetSection/EvaluatorChip.tsx +19 -11
  19. package/langwatch/src/evaluations-v3/components/TargetSection/TargetCell.tsx +55 -42
  20. package/langwatch/src/evaluations-v3/components/TargetSection/TargetHeader.tsx +2 -1
  21. package/langwatch/src/evaluations-v3/components/TargetSection/__tests__/EvaluatorChip.test.tsx +57 -0
  22. package/langwatch/src/evaluations-v3/components/TargetSection/__tests__/TargetCell.test.tsx +199 -11
  23. package/langwatch/src/evaluations-v3/components/VirtualizedTableBody.tsx +1 -1
  24. package/langwatch/src/evaluations-v3/constants.ts +9 -0
  25. package/langwatch/src/evaluations-v3/types/__tests__/persistence.test.ts +1 -1
  26. package/langwatch/src/evaluations-v3/types.ts +13 -1
  27. package/langwatch/src/evaluations-v3/utils/__tests__/evaluatorEditorCallbacks.test.ts +32 -0
  28. package/langwatch/src/evaluations-v3/utils/evaluatorEditorCallbacks.ts +36 -5
  29. package/langwatch/src/optimization_studio/components/datasets/DatasetSelection.tsx +1 -6
  30. package/langwatch/src/optimization_studio/components/datasets/__tests__/DatasetSelection.integration.test.tsx +194 -0
  31. package/langwatch/src/optimization_studio/components/drawers/SignaturePromptEditorBridge.tsx +6 -6
  32. package/langwatch/src/optimization_studio/components/drawers/__tests__/SignaturePromptEditorBridge.integration.test.tsx +36 -11
  33. package/langwatch/src/pages/[project]/gateway/budgets/[id].tsx +1 -1
  34. package/langwatch/src/pages/[project]/gateway/virtual-keys/[id].tsx +1 -1
  35. package/langwatch/src/pages/settings/audit-log.tsx +82 -59
  36. package/langwatch/src/routes.tsx +0 -4
  37. package/langwatch/src/server/agents/agent.service.ts +6 -2
  38. package/langwatch/src/server/api/__tests__/rbac-integration.test.ts +53 -0
  39. package/langwatch/src/server/api/__tests__/rbac.auditLog.test.ts +100 -0
  40. package/langwatch/src/server/api/rbac.ts +12 -0
  41. package/langwatch/src/server/api/root.ts +0 -2
  42. package/langwatch/src/server/api/routers/organization.ts +1 -1
  43. package/langwatch/src/server/app-layer/organizations/repositories/organization.prisma.repository.ts +58 -120
  44. package/langwatch/src/server/app-layer/organizations/repositories/organization.repository.ts +8 -11
  45. package/langwatch/src/server/evaluators/evaluator.service.ts +6 -2
  46. package/langwatch/src/server/gateway/__tests__/auditLog.consolidation.integration.test.ts +237 -0
  47. package/langwatch/src/server/gateway/__tests__/cacheRule.service.unit.test.ts +2 -2
  48. package/langwatch/src/server/gateway/__tests__/providerCredential.service.unit.test.ts +6 -6
  49. package/langwatch/src/server/gateway/__tests__/virtualKey.service.unit.test.ts +6 -6
  50. package/langwatch/src/server/gateway/auditLog.repository.ts +46 -8
  51. package/langwatch/src/server/gateway/auditSerializer.ts +2 -2
  52. package/langwatch/src/server/gateway/budget.service.ts +6 -6
  53. package/langwatch/src/server/gateway/cacheRule.service.ts +5 -5
  54. package/langwatch/src/server/gateway/providerCredential.service.ts +5 -5
  55. package/langwatch/src/server/gateway/virtualKey.service.ts +9 -9
  56. package/langwatch/src/server/pat/__tests__/auth-middleware.unit.test.ts +138 -3
  57. package/langwatch/src/server/pat/auth-middleware.ts +68 -13
  58. package/langwatch/src/server/routes/__tests__/otel.unit.test.ts +241 -0
  59. package/langwatch/src/server/routes/otel.ts +281 -45
  60. package/langwatch/src/server/scenarios/adapters/__tests__/http-agent.adapter.test.ts +271 -6
  61. package/langwatch/src/server/scenarios/adapters/http-agent.adapter.ts +43 -35
  62. package/langwatch/src/server/scenarios/execution/http-template-engine.ts +124 -0
  63. package/langwatch/src/server/scenarios/execution/serialized-adapters/__tests__/http-agent.adapter.unit.test.ts +180 -0
  64. package/langwatch/src/server/scenarios/execution/serialized-adapters/http-agent.adapter.ts +26 -30
  65. package/langwatch/src/tasks/__tests__/migrateCustomModels.unit.test.ts +0 -2
  66. package/langwatch/src/tasks/migrateCustomModels.ts +1 -1
  67. package/langwatch/src/utils/__tests__/dbMultiTenancyProtection.unit.test.ts +0 -17
  68. package/langwatch/src/utils/permissionsConfig.ts +6 -0
  69. package/langwatch/src/utils/routes.ts +0 -5
  70. package/package.json +1 -1
  71. package/packages/server/dist/cli.cjs +39 -70
  72. package/langwatch/src/pages/[project]/gateway/audit.tsx +0 -606
  73. package/langwatch/src/server/api/routers/gatewayAudit.ts +0 -109
  74. package/langwatch/src/server/gateway/__tests__/audit.service.unit.test.ts +0 -156
  75. package/langwatch/src/server/gateway/audit.service.ts +0 -104
@@ -218,19 +218,19 @@ describe("Row height mode", () => {
218
218
  expect(store.ui.rowHeightMode).toBe("compact");
219
219
  });
220
220
 
221
- it("setRowHeightMode changes mode to expanded", () => {
221
+ it("setRowHeightMode changes mode to fit", () => {
222
222
  const store = useEvaluationsV3Store.getState();
223
223
 
224
- store.setRowHeightMode("expanded");
224
+ store.setRowHeightMode("fit");
225
225
 
226
226
  const updatedStore = useEvaluationsV3Store.getState();
227
- expect(updatedStore.ui.rowHeightMode).toBe("expanded");
227
+ expect(updatedStore.ui.rowHeightMode).toBe("fit");
228
228
  });
229
229
 
230
230
  it("setRowHeightMode changes mode back to compact", () => {
231
231
  const store = useEvaluationsV3Store.getState();
232
232
 
233
- store.setRowHeightMode("expanded");
233
+ store.setRowHeightMode("fit");
234
234
  store.setRowHeightMode("compact");
235
235
 
236
236
  const updatedStore = useEvaluationsV3Store.getState();
@@ -247,7 +247,7 @@ describe("Row height mode", () => {
247
247
  ).toBe(true);
248
248
 
249
249
  // Switch mode
250
- store.setRowHeightMode("expanded");
250
+ store.setRowHeightMode("fit");
251
251
 
252
252
  const updatedStore = useEvaluationsV3Store.getState();
253
253
  expect(updatedStore.ui.expandedCells.size).toBe(0);
@@ -633,3 +633,88 @@ describe("TargetHeader stability", () => {
633
633
  console.log = originalLog;
634
634
  });
635
635
  });
636
+
637
+ // Regression for issue #3441 fix 4: the table always renders a trailing
638
+ // phantom row (Excel-style "click to add"), but target columns must NOT
639
+ // render content for phantom rows — no input = nothing to run. Dataset cells
640
+ // keep their click-to-add affordance for the phantom row.
641
+ describe("phantom empty rows", () => {
642
+ beforeEach(() => {
643
+ useEvaluationsV3Store.getState().reset();
644
+ });
645
+
646
+ afterEach(() => {
647
+ cleanup();
648
+ vi.clearAllMocks();
649
+ });
650
+
651
+ describe("when the dataset has 2 populated rows (displayRowCount = 3)", () => {
652
+ const seedTwoPopulatedRowsAndOneTarget = () => {
653
+ // displayRowCount = max(rowCount + 1, 3) = max(3, 3) = 3, so rows 0..1
654
+ // are populated and row 2 is the trailing phantom row that should be
655
+ // suppressed in the target column but kept in the dataset column (for
656
+ // click-to-add).
657
+ const store = useEvaluationsV3Store.getState();
658
+ store.updateDataset("test-data", {
659
+ columns: [
660
+ { id: "input", name: "input", type: "string" },
661
+ { id: "expected_output", name: "expected_output", type: "string" },
662
+ ],
663
+ inline: {
664
+ columns: [
665
+ { id: "input", name: "input", type: "string" },
666
+ { id: "expected_output", name: "expected_output", type: "string" },
667
+ ],
668
+ records: {
669
+ input: ["row 0 input", "row 1 input"],
670
+ expected_output: ["row 0 expected", "row 1 expected"],
671
+ },
672
+ },
673
+ });
674
+
675
+ store.addTarget({
676
+ id: "test-target",
677
+ type: "prompt",
678
+ inputs: [{ identifier: "input", type: "str" }],
679
+ outputs: [{ identifier: "output", type: "str" }],
680
+ mappings: {},
681
+ });
682
+ };
683
+
684
+ it("still renders a dataset cell on the phantom row (click-to-add affordance)", async () => {
685
+ seedTwoPopulatedRowsAndOneTarget();
686
+
687
+ render(<EvaluationsV3Table disableVirtualization />, { wrapper: Wrapper });
688
+
689
+ await waitFor(() => {
690
+ expect(screen.getByTestId("cell-0-input")).toBeInTheDocument();
691
+ expect(screen.getByTestId("cell-1-input")).toBeInTheDocument();
692
+ });
693
+
694
+ // The phantom row (row 2) DOES get a dataset cell.
695
+ expect(screen.getByTestId("cell-2-input")).toBeInTheDocument();
696
+ });
697
+
698
+ it("renders target cell content only for populated rows, not the phantom row", async () => {
699
+ seedTwoPopulatedRowsAndOneTarget();
700
+
701
+ render(<EvaluationsV3Table disableVirtualization />, { wrapper: Wrapper });
702
+
703
+ await waitFor(() => {
704
+ expect(screen.getByTestId("cell-0-input")).toBeInTheDocument();
705
+ });
706
+
707
+ // TargetCellContent for an empty-output cell renders "No output yet".
708
+ // With the fix: 2 populated rows → 2 target cells → 2 "No output yet".
709
+ // Without the fix: the phantom row (row 2) also renders a target cell,
710
+ // yielding 3 matches.
711
+ expect(screen.getAllByText("No output yet")).toHaveLength(2);
712
+
713
+ // Add-evaluator button sits inside TargetCellContent — same invariant,
714
+ // one per populated row.
715
+ expect(
716
+ screen.getAllByTestId("add-evaluator-button-test-target"),
717
+ ).toHaveLength(2);
718
+ });
719
+ });
720
+ });
@@ -68,7 +68,7 @@ describe("TableSettingsMenu", () => {
68
68
 
69
69
  await waitFor(() => {
70
70
  expect(screen.getByText("Compact")).toBeInTheDocument();
71
- expect(screen.getByText("Expanded")).toBeInTheDocument();
71
+ expect(screen.getByText("Fit")).toBeInTheDocument();
72
72
  });
73
73
  });
74
74
 
@@ -107,7 +107,7 @@ describe("TableSettingsMenu", () => {
107
107
  });
108
108
 
109
109
  describe("Row height functionality", () => {
110
- it("clicking Expanded changes row height mode", async () => {
110
+ it("clicking Fit changes row height mode to 'fit'", async () => {
111
111
  const user = userEvent.setup();
112
112
  render(<TableSettingsMenu />, { wrapper: Wrapper });
113
113
 
@@ -116,18 +116,18 @@ describe("TableSettingsMenu", () => {
116
116
  });
117
117
  await user.click(button);
118
118
 
119
- // Find the button containing "Expanded" text
120
- const expandedText = await screen.findByText("Expanded");
121
- const expandedButton = expandedText.closest("button");
122
- expect(expandedButton).not.toBeNull();
123
- await user.click(expandedButton!);
119
+ // Find the button containing "Fit" text
120
+ const fitText = await screen.findByText("Fit");
121
+ const fitButton = fitText.closest("button");
122
+ expect(fitButton).not.toBeNull();
123
+ await user.click(fitButton!);
124
124
 
125
125
  const updatedStore = useEvaluationsV3Store.getState();
126
- expect(updatedStore.ui.rowHeightMode).toBe("expanded");
126
+ expect(updatedStore.ui.rowHeightMode).toBe("fit");
127
127
  });
128
128
 
129
129
  it("clicking Compact changes row height mode back", async () => {
130
- useEvaluationsV3Store.getState().setRowHeightMode("expanded");
130
+ useEvaluationsV3Store.getState().setRowHeightMode("fit");
131
131
 
132
132
  const user = userEvent.setup();
133
133
  render(<TableSettingsMenu />, { wrapper: Wrapper });
@@ -254,8 +254,8 @@ describe("TableSettingsMenu", () => {
254
254
  });
255
255
  });
256
256
 
257
- describe("expanded mode restriction", () => {
258
- it("disables Expanded option when dataset has more than 100 rows", async () => {
257
+ describe("fit mode restriction", () => {
258
+ it("disables Fit option when dataset has more than 100 rows", async () => {
259
259
  // Add a dataset with more than 100 rows
260
260
  useEvaluationsV3Store.setState({
261
261
  activeDatasetId: "large-dataset",
@@ -288,15 +288,15 @@ describe("TableSettingsMenu", () => {
288
288
  expect(screen.getByText("Compact")).toBeInTheDocument();
289
289
  });
290
290
 
291
- // Find the button containing "Expanded" text
292
- const expandedText = await screen.findByText("Expanded");
293
- const expandedButton = expandedText.closest("button");
291
+ // Find the button containing "Fit" text
292
+ const fitText = await screen.findByText("Fit");
293
+ const fitButton = fitText.closest("button");
294
294
 
295
295
  // Button should be disabled
296
- expect(expandedButton).toBeDisabled();
296
+ expect(fitButton).toBeDisabled();
297
297
  });
298
298
 
299
- it("does not change to expanded mode when clicking disabled Expanded option", async () => {
299
+ it("does not change to fit mode when clicking disabled Fit option", async () => {
300
300
  // Add a dataset with more than 100 rows
301
301
  useEvaluationsV3Store.setState({
302
302
  activeDatasetId: "large-dataset",
@@ -324,18 +324,18 @@ describe("TableSettingsMenu", () => {
324
324
  });
325
325
  await user.click(button);
326
326
 
327
- const expandedText = await screen.findByText("Expanded");
328
- const expandedButton = expandedText.closest("button");
327
+ const fitText = await screen.findByText("Fit");
328
+ const fitButton = fitText.closest("button");
329
329
 
330
330
  // Try to click the disabled button
331
- await user.click(expandedButton!);
331
+ await user.click(fitButton!);
332
332
 
333
333
  // Mode should still be compact
334
334
  const store = useEvaluationsV3Store.getState();
335
335
  expect(store.ui.rowHeightMode).toBe("compact");
336
336
  });
337
337
 
338
- it("allows Expanded option when dataset has 100 or fewer rows", async () => {
338
+ it("allows Fit option when dataset has 100 or fewer rows", async () => {
339
339
  // Add a dataset with exactly 100 rows
340
340
  useEvaluationsV3Store.setState({
341
341
  activeDatasetId: "medium-dataset",
@@ -367,17 +367,17 @@ describe("TableSettingsMenu", () => {
367
367
  expect(screen.getByText("Compact")).toBeInTheDocument();
368
368
  });
369
369
 
370
- // Find the button containing "Expanded" text
371
- const expandedText = await screen.findByText("Expanded");
372
- const expandedButton = expandedText.closest("button");
370
+ // Find the button containing "Fit" text
371
+ const fitText = await screen.findByText("Fit");
372
+ const fitButton = fitText.closest("button");
373
373
 
374
374
  // Button should NOT be disabled
375
- expect(expandedButton).not.toBeDisabled();
375
+ expect(fitButton).not.toBeDisabled();
376
376
 
377
377
  // Click should work
378
- await user.click(expandedButton!);
378
+ await user.click(fitButton!);
379
379
  const store = useEvaluationsV3Store.getState();
380
- expect(store.ui.rowHeightMode).toBe("expanded");
380
+ expect(store.ui.rowHeightMode).toBe("fit");
381
381
  });
382
382
  });
383
383
  });
@@ -2,6 +2,7 @@ import { Skeleton, VStack } from "@chakra-ui/react";
2
2
  import { type Cell, flexRender } from "@tanstack/react-table";
3
3
  import type { DatasetColumnType } from "~/server/datasets/types";
4
4
  import { useEvaluationsV3Store } from "../../hooks/useEvaluationsV3Store";
5
+ import type { TableRowData } from "../../types";
5
6
  import { EditableCell } from "./EditableCell";
6
7
 
7
8
  // ============================================================================
@@ -16,17 +17,8 @@ type ColumnMeta = {
16
17
  dataType?: DatasetColumnType; // The actual data type (string, json, list, etc.)
17
18
  };
18
19
 
19
- type RowData = {
20
- rowIndex: number;
21
- dataset: Record<string, string>;
22
- targets: Record<
23
- string,
24
- { output: unknown; evaluators: Record<string, unknown> }
25
- >;
26
- };
27
-
28
20
  type TableCellProps = {
29
- cell: Cell<RowData, unknown>;
21
+ cell: Cell<TableRowData, unknown>;
30
22
  rowIndex: number;
31
23
  activeDatasetId: string;
32
24
  isLoading?: boolean;
@@ -71,7 +71,7 @@ import { TargetSuperHeader } from "./TargetSuperHeader";
71
71
  import { VirtualizedTableBody } from "./VirtualizedTableBody";
72
72
 
73
73
  // Max rows for expanded mode (disable virtualization above this)
74
- const MAX_ROWS_FOR_EXPANDED_MODE = 100;
74
+ const MAX_ROWS_FOR_FIT_MODE = 100;
75
75
 
76
76
  // Default percentage widths for columns (stored as numbers, e.g., 16 means 16%)
77
77
  const CHECKBOX_WIDTH_PX = 40; // Checkbox is fixed pixels
@@ -870,7 +870,7 @@ export function EvaluationsV3Table({
870
870
  // - Disable virtualization in expanded mode for datasets <= 100 rows
871
871
  const rowHeightMode = ui.rowHeightMode;
872
872
  const shouldVirtualize =
873
- rowHeightMode === "compact" || rowCount > MAX_ROWS_FOR_EXPANDED_MODE;
873
+ rowHeightMode === "compact" || rowCount > MAX_ROWS_FOR_FIT_MODE;
874
874
 
875
875
  const selectedRows = ui.selectedRows;
876
876
  const allSelected = selectedRows.size === rowCount && rowCount > 0;
@@ -920,12 +920,14 @@ export function EvaluationsV3Table({
920
920
  ]),
921
921
  );
922
922
 
923
- // Check if this row is empty - empty rows don't get executed
924
- const _rowIsEmpty = isRowEmpty(datasetValues);
923
+ // Empty rows (the Excel-style trailing phantom row) don't get executed
924
+ // and shouldn't render target outputs / evaluator chips.
925
+ const rowIsEmpty = isRowEmpty(datasetValues);
925
926
 
926
927
  return {
927
928
  rowIndex: index,
928
929
  dataset: datasetValues,
930
+ isEmpty: rowIsEmpty,
929
931
  targets: Object.fromEntries(
930
932
  targets.map((target) => [
931
933
  target.id,
@@ -1152,6 +1154,10 @@ export function EvaluationsV3Table({
1152
1154
  <TargetHeaderFromMeta targetId={targetId} context={context} />
1153
1155
  ),
1154
1156
  cell: (info) => {
1157
+ // Phantom empty rows render nothing in target columns — the
1158
+ // dataset side keeps the click-to-add affordance, but there's
1159
+ // no input to run a target against.
1160
+ if (info.row.original.isEmpty) return null;
1155
1161
  const data = info.getValue() as {
1156
1162
  output: unknown;
1157
1163
  evaluators: Record<string, unknown>;
@@ -53,14 +53,14 @@ const rowHeightOptions: ToggleOption[] = [
53
53
  icon: <ListChevronsDownUp size={18} />,
54
54
  },
55
55
  {
56
- value: "expanded",
57
- label: "Expanded",
56
+ value: "fit",
57
+ label: "Fit",
58
58
  icon: <ListChevronsUpDown size={18} />,
59
59
  },
60
60
  ];
61
61
 
62
62
  // Max rows for expanded mode
63
- const MAX_ROWS_FOR_EXPANDED_MODE = 100;
63
+ const MAX_ROWS_FOR_FIT_MODE = 100;
64
64
 
65
65
  // =============================================================================
66
66
  // Concurrency Popover Component
@@ -198,7 +198,7 @@ export function TableSettingsMenu({
198
198
 
199
199
  // Get current row count to determine if expanded mode should be disabled
200
200
  const rowCount = getRowCount(activeDatasetId);
201
- const isExpandedDisabled = rowCount > MAX_ROWS_FOR_EXPANDED_MODE;
201
+ const isFitDisabled = rowCount > MAX_ROWS_FOR_FIT_MODE;
202
202
 
203
203
  const { project } = useOrganizationTeamProject();
204
204
  const cicdDialog = useDisclosure();
@@ -250,7 +250,7 @@ export function TableSettingsMenu({
250
250
  {rowHeightOptions.map((option) => {
251
251
  const isActive = rowHeightMode === option.value;
252
252
  const isDisabled =
253
- option.value === "expanded" && isExpandedDisabled;
253
+ option.value === "fit" && isFitDisabled;
254
254
 
255
255
  const button = (
256
256
  <Button
@@ -279,7 +279,7 @@ export function TableSettingsMenu({
279
279
  return (
280
280
  <Tooltip
281
281
  key={option.value}
282
- content={`Expanded mode is disabled for datasets with more than ${MAX_ROWS_FOR_EXPANDED_MODE} rows for performance reasons`}
282
+ content={`Fit mode is disabled for datasets with more than ${MAX_ROWS_FOR_FIT_MODE} rows for performance reasons`}
283
283
  positioning={{ placement: "top" }}
284
284
  openDelay={100}
285
285
  >
@@ -28,6 +28,7 @@ import {
28
28
  parseEvaluationResult,
29
29
  } from "~/utils/evaluationResults";
30
30
  import { parseLLMError } from "~/utils/formatLLMError";
31
+ import { TARGET_MISSING_MAPPING_TOOLTIP } from "../../constants";
31
32
  import { useEvaluatorName } from "../../hooks/useEvaluatorName";
32
33
  import type { EvaluatorConfig } from "../../types";
33
34
 
@@ -166,17 +167,24 @@ export function EvaluatorChip({
166
167
  {status !== "running" && getInlineResult()}
167
168
  {/* Missing mapping alert icon - on the right side like prompts */}
168
169
  {hasMissingMappings && (
169
- <Icon
170
- as={LuCircleAlert}
171
- color="yellow.fg"
172
- boxSize="14px"
173
- css={{ animation: `${pulseAnimation} 2s ease-in-out infinite` }}
174
- onClick={(e) => {
175
- e.stopPropagation();
176
- onEdit();
177
- }}
178
- data-testid={`evaluator-missing-mapping-alert-${evaluator.id}`}
179
- />
170
+ <Tooltip
171
+ content={TARGET_MISSING_MAPPING_TOOLTIP}
172
+ positioning={{ placement: "top" }}
173
+ openDelay={0}
174
+ showArrow
175
+ >
176
+ <Icon
177
+ as={LuCircleAlert}
178
+ color="yellow.fg"
179
+ boxSize="14px"
180
+ css={{ animation: `${pulseAnimation} 2s ease-in-out infinite` }}
181
+ onClick={(e) => {
182
+ e.stopPropagation();
183
+ onEdit();
184
+ }}
185
+ data-testid={`evaluator-missing-mapping-alert-${evaluator.id}`}
186
+ />
187
+ </Tooltip>
180
188
  )}
181
189
  <Box className="chevron-icon" marginLeft={-0.5}>
182
190
  <LuChevronDown size={12} />
@@ -30,6 +30,7 @@ import {
30
30
  convertFromUIMapping,
31
31
  convertToUIMapping,
32
32
  } from "../../utils/fieldMappingConverters";
33
+ import { createEvaluatorEditorCallbacks } from "../../utils/evaluatorEditorCallbacks";
33
34
  import { evaluatorHasMissingMappings } from "../../utils/mappingValidation";
34
35
  import { EvaluatorChip } from "../TargetSection/EvaluatorChip";
35
36
 
@@ -170,12 +171,11 @@ export function TargetCellContent({
170
171
  return missing;
171
172
  }, [evaluators, activeDatasetId, target.id]);
172
173
 
173
- // Helper to create mappingsConfig for an evaluator
174
- const createMappingsConfig = useCallback(
174
+ // Build the serializable `mappingsConfig` for an evaluator. Stays
175
+ // serializable because it goes through the drawer's ephemeral complexProps
176
+ // path (cleared on ErrorBoundary remount — see issue #3087).
177
+ const buildMappingsConfig = useCallback(
175
178
  (evaluator: EvaluatorConfig) => {
176
- const datasetIds = new Set(datasets.map((d) => d.id));
177
- const isDatasetSource = (sourceId: string) => datasetIds.has(sourceId);
178
-
179
179
  // Build available sources
180
180
  const activeDataset = datasets.find((d) => d.id === activeDatasetId);
181
181
  const availableSources = [];
@@ -210,37 +210,42 @@ export function TargetCellContent({
210
210
  initialMappings[key] = convertToUIMapping(mapping);
211
211
  }
212
212
 
213
- return {
214
- availableSources,
215
- initialMappings,
216
- onMappingChange: (
217
- identifier: string,
218
- mapping: UIFieldMapping | undefined,
219
- ) => {
220
- if (mapping) {
221
- const storeMapping = convertFromUIMapping(mapping, isDatasetSource);
222
- setEvaluatorMapping(
223
- evaluator.id,
224
- activeDatasetId,
225
- target.id,
226
- identifier,
227
- storeMapping,
228
- );
229
- } else {
230
- removeEvaluatorMapping(
231
- evaluator.id,
232
- activeDatasetId,
233
- target.id,
234
- identifier,
235
- );
236
- }
237
- },
213
+ return { availableSources, initialMappings };
214
+ },
215
+ [datasets, activeDatasetId, target, targetName],
216
+ );
217
+
218
+ // Build the durable `onMappingChange` callback for an evaluator. Lives
219
+ // separately from `mappingsConfig` because it must survive the drawer's
220
+ // complexProps clears — registered via `setFlowCallbacks` instead (#3441).
221
+ const buildOnMappingChange = useCallback(
222
+ (evaluator: EvaluatorConfig) => {
223
+ const datasetIds = new Set(datasets.map((d) => d.id));
224
+ const isDatasetSource = (sourceId: string) => datasetIds.has(sourceId);
225
+ return (identifier: string, mapping: UIFieldMapping | undefined) => {
226
+ if (mapping) {
227
+ const storeMapping = convertFromUIMapping(mapping, isDatasetSource);
228
+ setEvaluatorMapping(
229
+ evaluator.id,
230
+ activeDatasetId,
231
+ target.id,
232
+ identifier,
233
+ storeMapping,
234
+ );
235
+ } else {
236
+ removeEvaluatorMapping(
237
+ evaluator.id,
238
+ activeDatasetId,
239
+ target.id,
240
+ identifier,
241
+ );
242
+ }
238
243
  };
239
244
  },
240
245
  [
241
246
  datasets,
242
247
  activeDatasetId,
243
- target,
248
+ target.id,
244
249
  setEvaluatorMapping,
245
250
  removeEvaluatorMapping,
246
251
  ],
@@ -397,21 +402,29 @@ export function TargetCellContent({
397
402
  hasAnyTargetOutputs={hasAnyTargetOutputs}
398
403
  targetType={target.type}
399
404
  onEdit={() => {
400
- const mappingsConfig = createMappingsConfig(evaluator);
401
-
402
- // Set up local state callbacks for the evaluator editor
403
- setFlowCallbacks("evaluatorEditor", {
404
- onLocalConfigChange: (config: unknown) => {
405
- updateEvaluator(evaluator.id, {
406
- localEvaluatorConfig: config as EvaluatorConfig["localEvaluatorConfig"],
407
- });
408
- },
409
- });
405
+ // Route all non-serializable callbacks through setFlowCallbacks.
406
+ // onMappingChange + onLocalConfigChange must live here (not in
407
+ // mappingsConfig) so the drawer's mappings section renders — see
408
+ // issue #3441.
409
+ //
410
+ // We use the direct `onLocalConfigChange` form (not the
411
+ // target-bound `targetId + updateTarget` convenience) because
412
+ // the chip's local config persists onto the evaluator, not the
413
+ // target.
414
+ setFlowCallbacks(
415
+ "evaluatorEditor",
416
+ createEvaluatorEditorCallbacks({
417
+ onLocalConfigChange: (localEvaluatorConfig) => {
418
+ updateEvaluator(evaluator.id, { localEvaluatorConfig });
419
+ },
420
+ onMappingChange: buildOnMappingChange(evaluator),
421
+ }),
422
+ );
410
423
 
411
424
  openDrawer("evaluatorEditor", {
412
425
  evaluatorId: evaluator.dbEvaluatorId,
413
426
  evaluatorType: evaluator.evaluatorType,
414
- mappingsConfig,
427
+ mappingsConfig: buildMappingsConfig(evaluator),
415
428
  initialLocalConfig: evaluator.localEvaluatorConfig,
416
429
  });
417
430
  }}
@@ -31,6 +31,7 @@ import { ColorfulBlockIcon } from "~/optimization_studio/components/ColorfulBloc
31
31
  import { transposeColumnsFirstToRowsFirstWithId } from "~/optimization_studio/utils/datasetUtils";
32
32
  import { VersionBadge } from "~/prompts/components/ui/VersionBadge";
33
33
  import { useLatestPromptVersion } from "~/prompts/hooks/useLatestPromptVersion";
34
+ import { TARGET_MISSING_MAPPING_TOOLTIP } from "../../constants";
34
35
  import { useEvaluationsV3Store } from "../../hooks/useEvaluationsV3Store";
35
36
  import { useTargetName } from "../../hooks/useTargetName";
36
37
  import type { TargetConfig } from "../../types";
@@ -314,7 +315,7 @@ export const TargetHeader = memo(function TargetHeader({
314
315
  )}
315
316
  {hasMissingMappings && (
316
317
  <Tooltip
317
- content="Missing variable mappings - Click to configure"
318
+ content={TARGET_MISSING_MAPPING_TOOLTIP}
318
319
  positioning={{ placement: "top" }}
319
320
  openDelay={0}
320
321
  showArrow
@@ -412,6 +412,63 @@ describe("EvaluatorChip", () => {
412
412
  });
413
413
  });
414
414
 
415
+ // Regression for issue #3441 fix 2: the missing-mapping alert icon on
416
+ // an evaluator chip must be wrapped in a Tooltip with the same copy as
417
+ // the prompt/target header's equivalent alert in TargetHeader.tsx. Before
418
+ // this fix the `(!)` icon rendered bare, giving no hover affordance.
419
+ describe("when hasMissingMappings is true — alert icon tooltip", () => {
420
+ it("renders the missing-mapping alert icon with an accessible trigger", () => {
421
+ render(
422
+ <EvaluatorChip
423
+ evaluator={createEvaluator()}
424
+ result={undefined}
425
+ hasMissingMappings
426
+ onEdit={vi.fn()}
427
+ onRemove={vi.fn()}
428
+ />,
429
+ { wrapper: Wrapper },
430
+ );
431
+
432
+ const alert = screen.getByTestId(
433
+ `evaluator-missing-mapping-alert-${createEvaluator().id}`,
434
+ );
435
+ expect(alert).toBeInTheDocument();
436
+ // Chakra's Tooltip.Trigger adds `data-scope="tooltip"` / aria-describedby
437
+ // on the wrapped element. Its presence is proof the icon is wrapped
438
+ // rather than bare.
439
+ expect(
440
+ alert.getAttribute("aria-describedby") ??
441
+ alert.getAttribute("data-scope"),
442
+ ).not.toBeNull();
443
+ });
444
+
445
+ it("shows the 'Missing variable mappings - Click to configure' copy on hover", async () => {
446
+ const user = userEvent.setup();
447
+
448
+ render(
449
+ <EvaluatorChip
450
+ evaluator={createEvaluator()}
451
+ result={undefined}
452
+ hasMissingMappings
453
+ onEdit={vi.fn()}
454
+ onRemove={vi.fn()}
455
+ />,
456
+ { wrapper: Wrapper },
457
+ );
458
+
459
+ const alert = screen.getByTestId(
460
+ `evaluator-missing-mapping-alert-${createEvaluator().id}`,
461
+ );
462
+ await user.hover(alert);
463
+
464
+ expect(
465
+ await screen.findByText(
466
+ "Missing variable mappings - Click to configure",
467
+ ),
468
+ ).toBeInTheDocument();
469
+ });
470
+ });
471
+
415
472
  describe("when evaluator has missing mappings", () => {
416
473
  it("redirects Rerun click to onEdit", async () => {
417
474
  const onEdit = vi.fn();