SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(llm-attribute-mapping): read-only listing [2/5] (#11779)
Gaurav Tewarif764a8d9afd2
diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/AttributeMappingsTab.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/AttributeMappingsTab.module.scssnew file mode 100644index 0000000000..4974d10ddb--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/AttributeMappingsTab.module.scss@@ -0,0 +1,7 @@+.pageError {+ padding: var(--padding-3) var(--padding-4);+ border-radius: var(--radius-2);+ background: var(--callout-error-background);+ color: var(--callout-error-title);+ font-size: var(--periscope-font-size-base);+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/AttributeMappingsTab.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/AttributeMappingsTab.tsxnew file mode 100644index 0000000000..589b7dc5a8--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/AttributeMappingsTab.tsx@@ -0,0 +1,21 @@+import styles from './AttributeMappingsTab.module.scss';+import MappingsTable from './components/MappingsTable/MappingsTable';+import { useAttributeMappingStore } from './hooks/useAttributeMappingStore';++function AttributeMappingsTab(): JSX.Element {+ const store = useAttributeMappingStore();++ return (+ <div data-testid="attribute-mappings-tab">+ {store.isError ? (+ <div className={styles.pageError} role="alert">+ Failed to load mapping groups. Please try again.+ </div>+ ) : (+ <MappingsTable store={store} />+ )}+ </div>+ );+}++export default AttributeMappingsTab;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/__tests__/AttributeMappingsTab.test.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/__tests__/AttributeMappingsTab.test.tsxnew file mode 100644index 0000000000..25125ffc8c--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/__tests__/AttributeMappingsTab.test.tsx@@ -0,0 +1,267 @@+import {+ SpantypesFieldContextDTO as FieldContext,+ SpantypesSpanMapperOperationDTO as MapperOperation,+} from 'api/generated/services/sigNoz.schemas';+import { rest, server } from 'mocks-server/server';+import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';++import {+ GROUPS_ENDPOINT,+ makeGroupsResponse,+ makeMapper,+ makeMappersResponse,+ mappersEndpoint,+ mockGroups,+ mockMappers,+} from 'container/LLMObservability/AttributeMapping/__tests__/fixtures';+import AttributeMappingsTab from '../AttributeMappingsTab';++function setupGroups(groups = mockGroups): void {+ server.use(+ rest.get(GROUPS_ENDPOINT, (_req, res, ctx) =>+ res(ctx.status(200), ctx.json(makeGroupsResponse(groups))),+ ),+ );+}++function setupMappers(mappers = mockMappers, groupId = 'group-1'): void {+ server.use(+ rest.get(mappersEndpoint(groupId), (_req, res, ctx) =>+ res(ctx.status(200), ctx.json(makeMappersResponse(mappers))),+ ),+ );+}++async function expandGroup(+ user: ReturnType<typeof userEvent.setup>,+ groupId = 'group-1',+): Promise<void> {+ await user.click(screen.getByTestId(`group-expand-${groupId}`));+}++describe('AttributeMappingsTab (integration)', () => {+ beforeEach(() => {+ // Reset URL state between tests — jsdom shares window.location across a file.+ window.history.pushState(null, '', '/');+ });++ afterEach(() => {+ server.resetHandlers();+ });++ it('renders no error banner on a successful load', async () => {+ setupGroups();+ render(<AttributeMappingsTab />);++ await waitFor(() =>+ expect(screen.getByTestId('group-name-group-1')).toBeInTheDocument(),+ );+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ });++ it('shows an error banner when the groups request fails', async () => {+ server.use(+ rest.get(GROUPS_ENDPOINT, (_req, res, ctx) => res(ctx.status(500))),+ );+ render(<AttributeMappingsTab />);++ await expect(screen.findByRole('alert')).resolves.toHaveTextContent(+ 'Failed to load mapping groups. Please try again.',+ );+ });++ it('shows the empty state when there are no groups', async () => {+ setupGroups([]);+ render(<AttributeMappingsTab />);++ await expect(+ screen.findByTestId('mapper-groups-empty'),+ ).resolves.toHaveTextContent('No mapping groups yet.');+ });++ it('renders each group header row with its name, condition count and status', async () => {+ setupGroups();+ render(<AttributeMappingsTab />);++ // Condition filters are no longer shown inline as clauses — the header+ // carries a count instead (the keys surface in the group drawer, later PR).+ // Group headers are antd Collapse panels, so rows scope to the panel item.+ // group-1: enabled, with attribute + resource condition keys.+ const enabledRow = (await screen.findByTestId('group-name-group-1')).closest(+ '.ant-collapse-item',+ ) as HTMLElement;+ expect(+ within(enabledRow).getByTestId('group-name-group-1'),+ ).toHaveTextContent('demo');+ expect(+ within(enabledRow).getByTestId('group-condition-count-group-1'),+ ).toHaveTextContent('2 conditions');+ expect(within(enabledRow).getByTestId('group-enabled-group-1')).toBeChecked();++ // group-2: disabled, with no condition keys.+ const disabledRow = screen+ .getByTestId('group-name-group-2')+ .closest('.ant-collapse-item') as HTMLElement;+ expect(within(disabledRow).getByText('Tool')).toBeInTheDocument();+ expect(+ within(disabledRow).getByTestId('group-condition-count-group-2'),+ ).toHaveTextContent('0 conditions');+ expect(+ within(disabledRow).getByTestId('group-enabled-group-2'),+ ).not.toBeChecked();+ });++ it('renders the group enable state as a read-only switch', async () => {+ setupGroups();+ render(<AttributeMappingsTab />);++ // The status switch reflects enabled state but is non-interactive in this+ // read-only listing — editing lands in a later PR.+ const toggle = await screen.findByTestId('group-enabled-group-1');+ expect(toggle).toBeChecked();+ expect(toggle).toBeDisabled();+ });++ it("reveals a group's mappers on expand and hides them on collapse", async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ setupGroups();+ setupMappers([makeMapper({ id: 'mapper-1' })]);+ render(<AttributeMappingsTab />);++ await screen.findByTestId('group-name-group-1');+ // The toggle is the antd Collapse header, which owns the expanded state.+ const header = screen+ .getByTestId('group-expand-group-1')+ .closest('.ant-collapse-header') as HTMLElement;+ expect(header).toHaveAttribute('aria-expanded', 'false');++ await expandGroup(user);+ expect(header).toHaveAttribute('aria-expanded', 'true');+ await expect(+ screen.findByTestId('mapper-target-mapper-1'),+ ).resolves.toBeInTheDocument();++ await expandGroup(user);+ await waitFor(() =>+ expect(+ screen.queryByTestId('mapper-target-mapper-1'),+ ).not.toBeInTheDocument(),+ );+ });++ it("lazily fetches and renders a group's mappers on first expand", async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ setupGroups();+ setupMappers([+ makeMapper({ id: 'mapper-1', name: 'gen_ai.request.model', enabled: true }),+ ]);+ render(<AttributeMappingsTab />);++ await screen.findByTestId('group-name-group-1');+ // Mappers are not fetched until the row is expanded.+ expect(+ screen.queryByTestId('mapper-target-mapper-1'),+ ).not.toBeInTheDocument();++ await expandGroup(user);++ const target = await screen.findByTestId('mapper-target-mapper-1');+ expect(target).toHaveTextContent('gen_ai.request.model');+ const mapperRow = target.closest('tr') as HTMLElement;+ // Sources ordered by priority, highest first (see fixtures).+ const sources = within(mapperRow).getByTestId('mapper-sources-mapper-1');+ expect(sources).toHaveTextContent('genai.model');+ expect(sources).toHaveTextContent('llm.model');+ // Writes-to field context + enabled status (an inline Switch, not text).+ expect(within(mapperRow).getByText('attribute')).toBeInTheDocument();+ expect(+ within(mapperRow).getByTestId('mapper-enabled-mapper-1'),+ ).toBeChecked();+ });++ it("renders a mapper's enable state as a read-only switch", async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ setupGroups();+ setupMappers([makeMapper({ id: 'mapper-1', enabled: true })]);+ render(<AttributeMappingsTab />);++ await screen.findByTestId('group-name-group-1');+ await expandGroup(user);++ // Like the group switch, a mapper's status switch reflects state without+ // accepting flips in this read-only listing.+ const toggle = await screen.findByTestId('mapper-enabled-mapper-1');+ expect(toggle).toBeChecked();+ expect(toggle).toBeDisabled();+ });++ it('shows the mappers error state when the mappers request fails', async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ setupGroups();+ server.use(+ rest.get(mappersEndpoint('group-1'), (_req, res, ctx) =>+ res(ctx.status(500)),+ ),+ );+ render(<AttributeMappingsTab />);++ await screen.findByTestId('group-name-group-1');+ await expandGroup(user);++ await expect(+ screen.findByTestId('mappers-error-group-1'),+ ).resolves.toHaveTextContent('Failed to load mappings. Please try again.');+ });++ it('shows the mappers empty state when a group has no mappers', async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ setupGroups();+ setupMappers([]);+ render(<AttributeMappingsTab />);++ await screen.findByTestId('group-name-group-1');+ await expandGroup(user);++ await expect(+ screen.findByTestId('mappers-empty-group-1'),+ ).resolves.toHaveTextContent('No mappings in this group yet.');+ });++ it('collapses extra mapper sources into a "+N more" label beyond the visible cap', async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ setupGroups();+ setupMappers([+ makeMapper({+ id: 'mapper-1',+ config: {+ sources: [1, 2, 3, 4, 5].map((priority) => ({+ key: `source-${priority}`,+ context: FieldContext.attribute,+ operation: MapperOperation.copy,+ priority,+ })),+ },+ }),+ ]);+ render(<AttributeMappingsTab />);++ await screen.findByTestId('group-name-group-1');+ await expandGroup(user);++ await expect(screen.findByText('+2 more')).resolves.toBeInTheDocument();+ });++ it('shows a muted placeholder when a mapper has no sources', async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ setupGroups();+ setupMappers([makeMapper({ id: 'mapper-1', config: { sources: [] } })]);+ render(<AttributeMappingsTab />);++ await screen.findByTestId('group-name-group-1');+ await expandGroup(user);++ await waitFor(() =>+ expect(screen.getByTestId('mapper-sources-mapper-1')).toHaveTextContent('—'),+ );+ });+});diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/GroupHeader.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/GroupHeader.module.scssnew file mode 100644index 0000000000..d0a8341f93--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/GroupHeader.module.scss@@ -0,0 +1,19 @@+.groupHeaderLabel {+ display: flex;+ align-items: center;+ gap: var(--spacing-3);+ min-width: 0;+}++.groupName {+ color: var(--l1-foreground);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.groupCount {+ color: var(--l3-foreground);+ font-size: var(--font-size-xs);+ white-space: nowrap;+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/GroupHeader.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/GroupHeader.tsxnew file mode 100644index 0000000000..4fdb316b16--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/GroupHeader.tsx@@ -0,0 +1,36 @@+import { Typography } from '@signozhq/ui/typography';+import { MappingGroup } from 'container/LLMObservability/AttributeMapping/types';++import styles from './GroupHeader.module.scss';++interface GroupHeaderProps {+ group: MappingGroup;+}++function GroupHeader({ group }: GroupHeaderProps): JSX.Element {+ const conditionCount = group.attributes.length + group.resource.length;++ return (+ <div+ className={styles.groupHeaderLabel}+ data-testid={`group-expand-${group.id}`}+ >+ <Typography.Text+ as="span"+ className={styles.groupName}+ testId={`group-name-${group.id}`}+ >+ {group.name}+ </Typography.Text>+ <Typography.Text+ as="span"+ className={styles.groupCount}+ testId={`group-condition-count-${group.id}`}+ >+ · {conditionCount} {conditionCount === 1 ? 'condition' : 'conditions'}+ </Typography.Text>+ </div>+ );+}++export default GroupHeader;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/index.ts b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/index.tsnew file mode 100644index 0000000000..dbb33c5b2b--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeader/index.ts@@ -0,0 +1 @@+export { default } from './GroupHeader';diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/GroupHeaderActions.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/GroupHeaderActions.module.scssnew file mode 100644index 0000000000..f4d4a2cfe1--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/GroupHeaderActions.module.scss@@ -0,0 +1,6 @@+.actions {+ display: flex;+ align-items: center;+ justify-content: flex-end;+ gap: var(--spacing-3);+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/GroupHeaderActions.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/GroupHeaderActions.tsxnew file mode 100644index 0000000000..341548f993--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/GroupHeaderActions.tsx@@ -0,0 +1,26 @@+import { Switch } from '@signozhq/ui/switch';++import { MappingGroup } from 'container/LLMObservability/AttributeMapping/types';+import styles from './GroupHeaderActions.module.scss';++interface GroupHeaderActionsProps {+ group: MappingGroup;+}++function GroupHeaderActions({ group }: GroupHeaderActionsProps): JSX.Element {+ return (+ <div+ className={styles.actions}+ onClick={(event): void => event.stopPropagation()}+ >+ <Switch+ value={group.enabled}+ // We don't yet support toggling a group's enabled state in this read-only PR, so disable the switch. A later PR will add the toggle handler and its drawer.+ disabled+ testId={`group-enabled-${group.id}`}+ />+ </div>+ );+}++export default GroupHeaderActions;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/index.ts b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/index.tsnew file mode 100644index 0000000000..ccb12c7a7c--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupHeaderActions/index.ts@@ -0,0 +1 @@+export { default } from './GroupHeaderActions';diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/GroupMappers.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/GroupMappers.module.scssnew file mode 100644index 0000000000..c56a9ec3ca--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/GroupMappers.module.scss@@ -0,0 +1,14 @@+.table {+ width: 100%;+ border-collapse: collapse;+ table-layout: fixed;+}++.mapperStateRow .stateCell {+ color: var(--l3-foreground);+}++.stateCell {+ padding: var(--spacing-4) var(--spacing-6) var(--spacing-4) var(--spacing-12);+ font-size: var(--periscope-font-size-base);+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/GroupMappers.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/GroupMappers.tsxnew file mode 100644index 0000000000..32ea9f1ae8--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/GroupMappers.tsx@@ -0,0 +1,98 @@+import { useListSpanMappers } from 'api/generated/services/spanmapper';+import { motion } from 'motion/react';++import {+ MappingGroup,+ Mapping,+} from 'container/LLMObservability/AttributeMapping/types';+import { buildMappingsFromListResponse } from 'container/LLMObservability/AttributeMapping/utils';+import { COLUMN_COUNT } from '../constants';+import MapperRow, { MapperRowSkeleton } from '../MapperRow';+import MappingsColgroup from '../MappingsColgroup';+import styles from './GroupMappers.module.scss';++const MAPPER_SKELETON_ROWS = 1;++const STATE_ROW_MOTION = {+ initial: { opacity: 0 },+ animate: { opacity: 1 },+ transition: { duration: 0.18, ease: 'easeOut' },+} as const;++interface StateRowProps {+ groupId: string;+}++function ErrorRow({ groupId }: StateRowProps): JSX.Element {+ return (+ <motion.tr className={styles.mapperStateRow} {...STATE_ROW_MOTION}>+ <td+ colSpan={COLUMN_COUNT}+ className={styles.stateCell}+ data-testid={`mappers-error-${groupId}`}+ >+ Failed to load mappings. Please try again.+ </td>+ </motion.tr>+ );+}++function EmptyRow({ groupId }: StateRowProps): JSX.Element {+ return (+ <motion.tr className={styles.mapperStateRow} {...STATE_ROW_MOTION}>+ <td+ colSpan={COLUMN_COUNT}+ className={styles.stateCell}+ data-testid={`mappers-empty-${groupId}`}+ >+ No mappings in this group yet.+ </td>+ </motion.tr>+ );+}++interface GroupMappersProps {+ group: MappingGroup;+}++function GroupMappers({ group }: GroupMappersProps): JSX.Element {+ const {+ data: mappers = [],+ isLoading,+ isError,+ } = useListSpanMappers<Mapping[]>(+ {+ groupId: group.id,+ },+ {+ query: {+ refetchOnMount: false,+ select: buildMappingsFromListResponse,+ },+ },+ );++ let rows: JSX.Element[];+ if (isError) {+ rows = [<ErrorRow key="error" groupId={group.id} />];+ } else if (isLoading) {+ rows = Array.from({ length: MAPPER_SKELETON_ROWS }).map((_, index) => (+ <MapperRowSkeleton key={`mapper-skeleton-${index}`} />+ ));+ } else if (mappers.length === 0) {+ rows = [<EmptyRow key="empty" groupId={group.id} />];+ } else {+ rows = mappers.map((mapper, index) => (+ <MapperRow key={mapper.id} mapper={mapper} index={index} />+ ));+ }++ return (+ <table className={styles.table}>+ <MappingsColgroup />+ <tbody>{rows}</tbody>+ </table>+ );+}++export default GroupMappers;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/index.ts b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/index.tsnew file mode 100644index 0000000000..c310dc8ef9--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/GroupMappers/index.ts@@ -0,0 +1 @@+export { default } from './GroupMappers';diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRow.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRow.module.scssnew file mode 100644index 0000000000..6e56390b43--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRow.module.scss@@ -0,0 +1,65 @@+.mapperRow {+ &:hover {+ background: var(--l2-background-hover);+ }+}++.cell {+ padding: var(--spacing-4) var(--spacing-6);+ vertical-align: middle;+ color: var(--l1-foreground);+ font-size: var(--periscope-font-size-base);+}++// Indent the first cell so mapper rows read as nested under their group.+.targetCell {+ padding-left: var(--spacing-12);+}++// Shorter vertical padding so the loading state reads as a compact placeholder.+.skeletonCell {+ composes: cell;+ :global(.ant-skeleton-input) {+ min-height: 18px !important;+ height: 18px !important;+ }+ :global(.ant-skeleton-button) {+ min-height: 18px !important;+ height: 18px !important;+ }+}++.statusCell {+ text-align: right;+}++.rowActions {+ display: flex;+ align-items: center;+ justify-content: flex-end;+ gap: var(--spacing-3);+}++.sources {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: var(--spacing-3);+}++.sourceChipText {+ display: block;+ max-width: 220px;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.sourceMore {+ font-size: var(--font-size-xs);+ white-space: nowrap;+}++.muted {+ color: var(--l3-foreground);+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRow.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRow.tsxnew file mode 100644index 0000000000..13ca795d23--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRow.tsx@@ -0,0 +1,102 @@+import { Badge } from '@signozhq/ui/badge';+import { Switch } from '@signozhq/ui/switch';+import { Typography } from '@signozhq/ui/typography';+import { SpantypesFieldContextDTO } from 'api/generated/services/sigNoz.schemas';+import cx from 'classnames';+import { motion } from 'motion/react';++import { Mapping } from 'container/LLMObservability/AttributeMapping/types';+import styles from './MapperRow.module.scss';++const MAX_VISIBLE_SOURCES = 3;++const ROW_TRANSITION = { duration: 0.18, ease: 'easeOut' } as const;+const MAX_STAGGERED_ROWS = 6;+const STAGGER_STEP = 0.03;++interface MapperRowProps {+ mapper: Mapping;+ index: number;+}++function MapperRow({ mapper, index }: MapperRowProps): JSX.Element {+ const sources = mapper.sources ?? [];+ const visibleSources = sources.slice(0, MAX_VISIBLE_SOURCES);+ const remainingSources = sources.length - visibleSources.length;++ return (+ <motion.tr+ className={styles.mapperRow}+ data-testid={`mapper-row-${mapper.id}`}+ initial={{ opacity: 0, y: -4 }}+ animate={{ opacity: 1, y: 0 }}+ transition={{+ ...ROW_TRANSITION,+ delay: Math.min(index, MAX_STAGGERED_ROWS) * STAGGER_STEP,+ }}+ >+ <td className={cx(styles.cell, styles.targetCell)}>+ <Typography.Text+ truncate={1}+ title={mapper.name}+ data-testid={`mapper-target-${mapper.id}`}+ >+ {mapper.name}+ </Typography.Text>+ </td>+ <td className={styles.cell}>+ {sources.length === 0 ? (+ <span className={styles.muted} data-testid={`mapper-sources-${mapper.id}`}>+ —+ </span>+ ) : (+ <div+ className={styles.sources}+ data-testid={`mapper-sources-${mapper.id}`}+ >+ {visibleSources.map((source) => (+ <Badge+ variant="outline"+ color="vanilla"+ className={styles.sourceChip}+ key={`${source.context}:${source.key}`}+ >+ <span className={styles.sourceChipText} title={source.key}>+ {source.key}+ </span>+ </Badge>+ ))}+ {remainingSources > 0 && (+ <span className={cx(styles.sourceMore, styles.muted)}>+ +{remainingSources} more+ </span>+ )}+ </div>+ )}+ </td>+ <td className={styles.cell}>+ <Badge+ color={+ mapper.fieldContext === SpantypesFieldContextDTO.resource+ ? 'amber'+ : 'robin'+ }+ variant="outline"+ >+ {mapper.fieldContext}+ </Badge>+ </td>+ <td className={cx(styles.cell, styles.statusCell)}>+ <div className={styles.rowActions}>+ <Switch+ value={mapper.enabled}+ disabled+ testId={`mapper-enabled-${mapper.id}`}+ />+ </div>+ </td>+ </motion.tr>+ );+}++export default MapperRow;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRowSkeleton.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRowSkeleton.tsxnew file mode 100644index 0000000000..60bd8a0ed0--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/MapperRowSkeleton.tsx@@ -0,0 +1,30 @@+import { Skeleton } from 'antd';+import cx from 'classnames';++import styles from './MapperRow.module.scss';++function MapperRowSkeleton(): JSX.Element {+ return (+ <tr className={styles.mapperRow}>+ <td className={cx(styles.skeletonCell, styles.targetCell)}>+ <Skeleton.Input active size="small" style={{ width: '55%' }} />+ </td>+ <td className={styles.skeletonCell}>+ <div className={styles.sources}>+ <Skeleton.Button active size="small" style={{ width: 88 }} />+ <Skeleton.Button active size="small" style={{ width: 56 }} />+ </div>+ </td>+ <td className={styles.skeletonCell}>+ <Skeleton.Button active size="small" style={{ width: 72 }} />+ </td>+ <td className={cx(styles.skeletonCell, styles.statusCell)}>+ <div className={styles.rowActions}>+ <Skeleton.Button active size="small" shape="round" />+ </div>+ </td>+ </tr>+ );+}++export default MapperRowSkeleton;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/index.ts b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/index.tsnew file mode 100644index 0000000000..8a989a7c94--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MapperRow/index.ts@@ -0,0 +1,2 @@+export { default } from './MapperRow';+export { default as MapperRowSkeleton } from './MapperRowSkeleton';diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/MappingsColgroup.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/MappingsColgroup.module.scssnew file mode 100644index 0000000000..38a08287c5--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/MappingsColgroup.module.scss@@ -0,0 +1,11 @@+.colTarget {+ width: 32%;+}++.colWritesTo {+ width: 140px;+}++.colStatus {+ width: 120px;+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/MappingsColgroup.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/MappingsColgroup.tsxnew file mode 100644index 0000000000..9713f1173e--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/MappingsColgroup.tsx@@ -0,0 +1,14 @@+import styles from './MappingsColgroup.module.scss';++function MappingsColgroup(): JSX.Element {+ return (+ <colgroup>+ <col className={styles.colTarget} />+ <col />+ <col className={styles.colWritesTo} />+ <col className={styles.colStatus} />+ </colgroup>+ );+}++export default MappingsColgroup;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/index.ts b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/index.tsnew file mode 100644index 0000000000..dac407760a--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsColgroup/index.ts@@ -0,0 +1 @@+export { default } from './MappingsColgroup';diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsTable.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsTable.module.scssnew file mode 100644index 0000000000..f030aea816--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsTable.module.scss@@ -0,0 +1,124 @@+.table {+ width: 100%;+ border-collapse: collapse;+ table-layout: fixed;+}++.headerRow {+ border-bottom: 1px solid var(--l2-border);+}++.headerCell {+ padding: var(--spacing-4) var(--spacing-6);+ text-align: left;+ font-size: var(--periscope-font-size-base);+ font-weight: var(--font-weight-normal);+ color: var(--l2-foreground);++ &:last-child {+ text-align: right;+ }+}++.groupsCollapse:global(.ant-collapse) {+ background: transparent;+ border: none;+ border-radius: 0;++ > :global(.ant-collapse-item) {+ border-bottom: none;+ border-top: 1px solid var(--l2-border);+ border-radius: 0;++ &:last-child {+ border-bottom: 1px solid var(--l2-border);+ border-radius: 0;+ }++ > :global(.ant-collapse-header) {+ align-items: center;+ gap: var(--spacing-3);+ background: var(--l2-background);+ border-radius: 0;+ padding: var(--spacing-3) var(--spacing-6);+ color: var(--l3-foreground);++ :global(.ant-collapse-expand-icon) {+ display: flex;+ align-items: center;+ height: auto;+ padding-inline-end: 0;+ color: var(--l3-foreground);+ }++ :global(.ant-collapse-header-text) {+ min-width: 0;+ }++ :global(.ant-collapse-extra) {+ display: flex;+ align-items: center;+ }+ }+ }++ :global(.ant-collapse-content) {+ background: transparent;+ border-top: none;+ color: inherit;++ > :global(.ant-collapse-content-box) {+ padding: 0;+ }+ }+}++.tableEmpty {+ padding: var(--spacing-12) var(--spacing-6);+ text-align: center;+ color: var(--l3-foreground);+ font-size: var(--periscope-font-size-base);+}++.skeletonList {+ display: flex;+ flex-direction: column;+}++// Mirrors the Collapse header banner while groups load.+.skeletonBanner {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: var(--spacing-4);+ padding: var(--spacing-3) var(--spacing-6);+ background: var(--l2-background);+ border-top: 1px solid var(--l2-border);++ &:last-child {+ border-bottom: 1px solid var(--l2-border);+ }+ :global(.ant-skeleton-input) {+ min-height: 18px !important;+ height: 18px !important;+ }+ :global(.ant-skeleton-button) {+ min-height: 18px !important;+ height: 18px !important;+ }+}++.skeletonGroupLeft {+ display: flex;+ align-items: center;+ gap: var(--spacing-3);+ flex: 1;+ min-width: 0;+}++.skeletonGroupRight {+ display: flex;+ align-items: center;+ gap: var(--spacing-3);+ flex-shrink: 0;+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsTable.tsx b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsTable.tsxnew file mode 100644index 0000000000..e3ca1beec2--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/MappingsTable.tsx@@ -0,0 +1,96 @@+import { useState } from 'react';+import { ChevronDown, ChevronRight } from '@signozhq/icons';+import { Collapse, type CollapseProps, Skeleton } from 'antd';++import { AttributeMappingStore } from 'container/LLMObservability/AttributeMapping/AttributeMappingsTab/hooks/useAttributeMappingStore';+import GroupHeader from './GroupHeader';+import GroupHeaderActions from './GroupHeaderActions';+import GroupMappers from './GroupMappers';+import MappingsColgroup from './MappingsColgroup';+import styles from './MappingsTable.module.scss';++const SKELETON_ROW_COUNT = 3;++interface MappingsTableProps {+ store: AttributeMappingStore;+}++function MappingsTable({ store }: MappingsTableProps): JSX.Element {+ const [expandedGroups, setExpandedGroups] = useState<string[]>([]);++ const isEmpty = !store.isLoading && store.groups.length === 0;++ const items: CollapseProps['items'] = store.groups.map((group) => ({+ key: group.id,+ label: <GroupHeader group={group} />,+ extra: <GroupHeaderActions group={group} />,+ children: <GroupMappers group={group} />,+ }));++ const skeletonBanners = (+ <div className={styles.skeletonList}>+ {Array.from({ length: SKELETON_ROW_COUNT }).map((_, index) => (+ <div+ // eslint-disable-next-line react/no-array-index-key+ key={`group-skeleton-${index}`}+ className={styles.skeletonBanner}+ >+ <div className={styles.skeletonGroupLeft}>+ <Skeleton.Input+ active+ size="small"+ style={{ width: index % 2 === 0 ? 200 : 140 }}+ />+ <Skeleton.Input active size="small" style={{ width: 64 }} />+ </div>+ <div className={styles.skeletonGroupRight}>+ <Skeleton.Button active size="small" shape="round" />+ </div>+ </div>+ ))}+ </div>+ );++ if (isEmpty) {+ return (+ <div className={styles.tableEmpty} data-testid="mapper-groups-empty">+ No mapping groups yet.+ </div>+ );+ }++ return (+ <div data-testid="mappings-table">+ <table className={styles.table}>+ <MappingsColgroup />+ <thead>+ <tr className={styles.headerRow}>+ <th className={styles.headerCell}>Target</th>+ <th className={styles.headerCell}>Sources</th>+ <th className={styles.headerCell}>Writes to</th>+ <th className={styles.headerCell}>Status</th>+ </tr>+ </thead>+ </table>+ {store.isLoading ? (+ skeletonBanners+ ) : (+ <Collapse+ className={styles.groupsCollapse}+ activeKey={expandedGroups}+ onChange={(keys): void =>+ setExpandedGroups(Array.isArray(keys) ? keys : [keys])+ }+ bordered={false}+ destroyInactivePanel+ expandIcon={({ isActive }): JSX.Element =>+ isActive ? <ChevronDown size={14} /> : <ChevronRight size={14} />+ }+ items={items}+ />+ )}+ </div>+ );+}++export default MappingsTable;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/constants.ts b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/constants.tsnew file mode 100644index 0000000000..1ebf9d9c57--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/components/MappingsTable/constants.ts@@ -0,0 +1 @@+export const COLUMN_COUNT = 4;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/hooks/useAttributeMappingStore.ts b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/hooks/useAttributeMappingStore.tsnew file mode 100644index 0000000000..a62ce43d1b--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/AttributeMappingsTab/hooks/useAttributeMappingStore.ts@@ -0,0 +1,33 @@+import { useMemo } from 'react';+import { SpantypesSpanMapperGroupDTO } from 'api/generated/services/sigNoz.schemas';+import { useListSpanMapperGroups } from 'api/generated/services/spanmapper';++import { MappingGroup } from 'container/LLMObservability/AttributeMapping/types';+import { buildMappingGroup } from 'container/LLMObservability/AttributeMapping/utils';++export interface AttributeMappingStore {+ groups: MappingGroup[];+ isLoading: boolean;+ isError: boolean;+}++// Read-only store for the listing view: loads the server groups only. Each+// group's mappers are fetched lazily when its panel is expanded (see+// GroupMappers), so page load is a single request instead of an N+1 fan-out+// across every group. Editing (enabled toggles, save/discard) and its drawers+// land in a later PR — this PR only lists.+export function useAttributeMappingStore(): AttributeMappingStore {+ const groupsQuery = useListSpanMapperGroups();++ const groups = useMemo<MappingGroup[]>(() => {+ const serverGroups: SpantypesSpanMapperGroupDTO[] =+ groupsQuery.data?.data?.items ?? [];+ return serverGroups.map((group) => buildMappingGroup(group));+ }, [groupsQuery.data]);++ return {+ groups,+ isLoading: groupsQuery.isLoading,+ isError: groupsQuery.isError,+ };+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.module.scssindex 45e43aa851..579d402276 100644--- a/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.module.scss+++ b/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.module.scss@@ -2,12 +2,5 @@display: flex;flex-direction: column;gap: var(--spacing-8);- padding: var(--spacing-12);-}--.tableEmpty {- padding: var(--spacing-12) var(--spacing-6);- text-align: center;- color: var(--l3-foreground);- font-size: var(--periscope-font-size-base);+ padding: var(--spacing-0);}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.tsx b/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.tsxindex d1dad3a1dc..32c99930b5 100644--- a/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.tsx+++ b/frontend/src/container/LLMObservability/AttributeMapping/LLMObservabilityAttributeMapping.tsx@@ -1,9 +1,27 @@+import { Tabs } from '@signozhq/ui/tabs';+import AttributeMappingHeader from './components/AttributeMappingHeader';+import AttributeMappingsTab from './AttributeMappingsTab/AttributeMappingsTab';import styles from './LLMObservabilityAttributeMapping.module.scss';const noop = (): void => undefined;function LLMObservabilityAttributeMapping(): JSX.Element {+ const tabItems = [+ {+ key: 'attribute-mappings',+ label: 'Attribute mappings',+ children: <AttributeMappingsTab />,+ },+ {+ key: 'test',+ label: 'Test',+ disabled: true,+ disabledReason: 'Coming soon',+ children: null,+ },+ ];+return (<divclassName={styles.llmObservabilityAttributeMapping}@@ -16,9 +34,11 @@ function LLMObservabilityAttributeMapping(): JSX.Element {onSave={noop}/>- <div className={styles.tableEmpty} data-testid="attribute-mapping-empty">- No mapping groups configured yet.- </div>+ <Tabs+ testId="attribute-mapping-tabs"+ defaultValue="attribute-mappings"+ items={tabItems}+ /></div>);}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/__tests__/LLMObservabilityAttributeMapping.test.tsx b/frontend/src/container/LLMObservability/AttributeMapping/__tests__/LLMObservabilityAttributeMapping.test.tsxnew file mode 100644index 0000000000..3cc1c723a2--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/__tests__/LLMObservabilityAttributeMapping.test.tsx@@ -0,0 +1,67 @@+import { rest, server } from 'mocks-server/server';+import { render, screen } from 'tests/test-utils';++import LLMObservabilityAttributeMapping from '../LLMObservabilityAttributeMapping';+import { GROUPS_ENDPOINT, makeGroupsResponse, mockGroups } from './fixtures';++function setupGroups(): void {+ server.use(+ rest.get(GROUPS_ENDPOINT, (_req, res, ctx) =>+ res(ctx.status(200), ctx.json(makeGroupsResponse(mockGroups))),+ ),+ );+}++describe('LLMObservabilityAttributeMapping', () => {+ beforeEach(() => {+ window.history.pushState(null, '', '/');+ setupGroups();+ });++ afterEach(() => {+ server.resetHandlers();+ });++ it('renders the page shell', () => {+ render(<LLMObservabilityAttributeMapping />);++ expect(+ screen.getByTestId('llm-observability-attribute-mapping-page'),+ ).toBeInTheDocument();+ });++ it('shows the attribute-mappings and test sub-tab labels', () => {+ render(<LLMObservabilityAttributeMapping />);++ expect(+ screen.getByRole('tab', { name: 'Attribute mappings' }),+ ).toBeInTheDocument();+ expect(screen.getByRole('tab', { name: 'Test' })).toBeInTheDocument();+ });++ it('activates the attribute-mappings tab by default and renders its content', async () => {+ render(<LLMObservabilityAttributeMapping />);++ const attributeMappingsTab = screen.getByRole('tab', {+ name: 'Attribute mappings',+ });+ expect(attributeMappingsTab).toHaveAttribute('data-state', 'active');+ await expect(+ screen.findByTestId('attribute-mappings-tab'),+ ).resolves.toBeInTheDocument();+ });++ it('renders the header with its description and no Save/Discard while pristine', () => {+ render(<LLMObservabilityAttributeMapping />);++ expect(+ screen.getByText(+ 'Configure source-to-target attribute remapping for LLM traces',+ ),+ ).toBeInTheDocument();+ // The actions only appear once there are staged changes.+ expect(screen.queryByTestId('save-changes-btn')).not.toBeInTheDocument();+ expect(screen.queryByTestId('discard-changes-btn')).not.toBeInTheDocument();+ expect(screen.queryByTestId('unsaved-changes')).not.toBeInTheDocument();+ });+});diff --git a/frontend/src/container/LLMObservability/AttributeMapping/__tests__/fixtures.ts b/frontend/src/container/LLMObservability/AttributeMapping/__tests__/fixtures.tsnew file mode 100644index 0000000000..f39324eb83--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/__tests__/fixtures.ts@@ -0,0 +1,93 @@+import {+ SpantypesFieldContextDTO as FieldContext,+ SpantypesSpanMapperDTO as Mapper,+ SpantypesSpanMapperGroupDTO as MapperGroup,+ SpantypesSpanMapperOperationDTO as MapperOperation,+} from 'api/generated/services/sigNoz.schemas';++// Endpoint globs used by MSW handlers. The generated client hits relative+// `/api/v1/span_mapper_groups[...]`, so the `*` prefix matches regardless of+// base URL.+export const GROUPS_ENDPOINT = '*/api/v1/span_mapper_groups';+export function mappersEndpoint(groupId: string): string {+ return `*/api/v1/span_mapper_groups/${groupId}/span_mappers`;+}++export function makeGroup(overrides: Partial<MapperGroup> = {}): MapperGroup {+ return {+ id: 'group-1',+ orgId: 'org-1',+ name: 'demo',+ enabled: true,+ condition: {+ attributes: ['ai.embeddings'],+ resource: ['cloud.account.id'],+ },+ ...overrides,+ };+}++export function makeMapper(overrides: Partial<Mapper> = {}): Mapper {+ return {+ id: 'mapper-1',+ group_id: 'group-1',+ name: 'gen_ai.request.model',+ enabled: true,+ fieldContext: FieldContext.attribute,+ config: {+ sources: [+ {+ key: 'genai.model',+ context: FieldContext.attribute,+ operation: MapperOperation.copy,+ priority: 2,+ },+ {+ key: 'llm.model',+ context: FieldContext.attribute,+ operation: MapperOperation.move,+ priority: 1,+ },+ ],+ },+ ...overrides,+ };+}++// Both list endpoints share the same `{ status, data: { items } }` envelope —+// the generated schema mis-types the mappers response with the groups DTO+// (see GroupMappers), but the runtime envelope shape is identical.+export function makeGroupsResponse(groups: MapperGroup[]): {+ status: string;+ data: { items: MapperGroup[] };+} {+ return { status: 'ok', data: { items: groups } };+}++export function makeMappersResponse(mappers: Mapper[]): {+ status: string;+ data: { items: Mapper[] };+} {+ return { status: 'ok', data: { items: mappers } };+}++export const mockGroups: MapperGroup[] = [+ makeGroup({+ id: 'group-1',+ name: 'demo',+ condition: {+ attributes: ['ai.embeddings'],+ resource: ['cloud.account.id'],+ },+ }),+ makeGroup({+ id: 'group-2',+ name: 'Tool',+ enabled: false,+ condition: { attributes: null, resource: null },+ }),+];++export const mockMappers: Mapper[] = [+ makeMapper({ id: 'mapper-1', group_id: 'group-1' }),+];diff --git a/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.module.scss b/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.module.scssindex 98fc346d00..54f3411823 100644--- a/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.module.scss+++ b/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.module.scss@@ -5,23 +5,6 @@gap: var(--spacing-8);}-.pageHeaderTitle {- display: flex;- flex-direction: column;-}--.title {- margin: 0;- font-size: var(--periscope-font-size-large);- font-weight: var(--font-weight-semibold);-}--.description {- margin: var(--spacing-2) 0 0;- font-size: var(--periscope-font-size-base);- color: var(--l3-foreground);-}-.pageHeaderActions {display: flex;align-items: center;diff --git a/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.tsx b/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.tsxindex 7b9cb70999..2e30446728 100644--- a/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.tsx+++ b/frontend/src/container/LLMObservability/AttributeMapping/components/AttributeMappingHeader/AttributeMappingHeader.tsx@@ -1,4 +1,5 @@import { Button } from '@signozhq/ui/button';+import { Typography } from '@signozhq/ui/typography';import styles from './AttributeMappingHeader.module.scss';@@ -17,38 +18,35 @@ function AttributeMappingHeader({}: AttributeMappingHeaderProps): JSX.Element {return (<header className={styles.pageHeader}>- <div className={styles.pageHeaderTitle}>- <h1 className={styles.title}>Attribute Mapping</h1>- <p className={styles.description}>- Configure source-to-target attribute remapping for LLM traces- </p>- </div>- <div className={styles.pageHeaderActions}>- {isDirty && (+ <Typography.Text as="p" size="base" color="muted">+ Configure source-to-target attribute remapping for LLM traces+ </Typography.Text>+ {isDirty && (+ <div className={styles.pageHeaderActions}><span className={styles.unsavedChanges} data-testid="unsaved-changes">Unsaved changes</span>- )}- <Button- variant="outlined"- color="secondary"- onClick={onDiscard}- disabled={!isDirty || isSaving}- testId="discard-changes-btn"- >- Discard- </Button>- <Button- variant="solid"- color="primary"- onClick={onSave}- loading={isSaving}- disabled={!isDirty || isSaving}- testId="save-changes-btn"- >- {isSaving ? 'Saving…' : 'Save changes'}- </Button>- </div>+ <Button+ variant="outlined"+ color="secondary"+ onClick={onDiscard}+ disabled={isSaving}+ testId="discard-changes-btn"+ >+ Discard+ </Button>+ <Button+ variant="solid"+ color="primary"+ onClick={onSave}+ loading={isSaving}+ disabled={isSaving}+ testId="save-changes-btn"+ >+ {isSaving ? 'Saving…' : 'Save changes'}+ </Button>+ </div>+ )}</header>);}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/types.ts b/frontend/src/container/LLMObservability/AttributeMapping/types.tsnew file mode 100644index 0000000000..b54d88978d--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/types.ts@@ -0,0 +1,26 @@+import {+ SpantypesFieldContextDTO,+ SpantypesSpanMapperOperationDTO,+} from 'api/generated/services/sigNoz.schemas';++export interface SourceConfig {+ key: string;+ context: SpantypesFieldContextDTO;+ operation: SpantypesSpanMapperOperationDTO;+}++export interface Mapping {+ id: string;+ name: string;+ fieldContext: SpantypesFieldContextDTO;+ sources: SourceConfig[];+ enabled: boolean;+}++export interface MappingGroup {+ id: string;+ name: string;+ attributes: string[];+ resource: string[];+ enabled: boolean;+}diff --git a/frontend/src/container/LLMObservability/AttributeMapping/utils.ts b/frontend/src/container/LLMObservability/AttributeMapping/utils.tsnew file mode 100644index 0000000000..58de11fb41--- /dev/null+++ b/frontend/src/container/LLMObservability/AttributeMapping/utils.ts@@ -0,0 +1,48 @@+import {+ ListSpanMappers200,+ SpantypesSpanMapperDTO,+ SpantypesSpanMapperGroupDTO,+} from 'api/generated/services/sigNoz.schemas';++import { MappingGroup, Mapping, SourceConfig } from './types';++function getMapperSources(mapper: SpantypesSpanMapperDTO): SourceConfig[] {+ const sources = mapper.config?.sources ?? [];+ return [...sources]+ .sort((a, b) => a.priority - b.priority)+ .map((source) => ({+ key: source.key,+ context: source.context,+ operation: source.operation,+ }));+}++export function buildMapping(mapper: SpantypesSpanMapperDTO): Mapping {+ return {+ id: mapper.id,+ name: mapper.name,+ fieldContext: mapper.fieldContext,+ sources: getMapperSources(mapper),+ enabled: mapper.enabled,+ };+}++export function buildMappingsFromListResponse(+ response: ListSpanMappers200,+): Mapping[] {+ const items = (response.data?.items ??+ []) as unknown as SpantypesSpanMapperDTO[];+ return items.map(buildMapping);+}++export function buildMappingGroup(+ group: SpantypesSpanMapperGroupDTO,+): MappingGroup {+ return {+ id: group.id,+ name: group.name,+ attributes: group.condition?.attributes ?? [],+ resource: group.condition?.resource ?? [],+ enabled: group.enabled,+ };+}