Compare commits

...

3 Commits

Author SHA1 Message Date
Gaurav Tewari
cb0adcc618 refactor(ai-assistant): import assistant types from @signozhq/noz-client (#13526)
Some checks are pending
build-staging / prepare (push) Waiting to run
build-staging / js-build (push) Blocked by required conditions
build-staging / go-build (push) Blocked by required conditions
build-staging / staging (push) Blocked by required conditions
cacheci / tests (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
#### Description

- AI Assistant DTOs and enums now come from the `@signozhq/noz-client`
package (pinned `1.12.2`) instead of a generated copy in
`src/api/ai-assistant/`. The API spec lives in the assistant repo, so
bumping a package version replaces hand-syncing the files on every
release.
- Deleted `sigNozAIAssistantAPI.schemas.ts` and the unused orval hooks
in `index.ts`. `chat.ts` (REST + SSE client) stays and keeps using
`AIAssistantInstance`.
- Only types and enums are imported, so the package's hooks and
`setGeneratedAPIInstance` are not wired.

#### Issues closed by this PR


https://github.com/orgs/SigNoz/projects/59/views/18?pane=issue&itemId=315100999&issue=SigNoz%7Cnerve-pod%7C677

#### Screenshots / Screen Recordings

#### Additional Information

- The package exports the same schemas as the deleted file, plus
`ReadinessChecksDTODrain`.

---------

Co-authored-by: Gaurav Tewari <tewarig@users.noreply.github.com>
2026-11-23 18:36:19 +00:00
Vinicius Lourenço
b14b634bce perf(web): keep the tab bar while a lazy tab loads (#13691)
#### Description

Pages with tabs (Settings, Logs, Traces, Metrics and others) render them
through `RouteTab`, which mounts only the active tab but receives every
tab's component already imported. To let a page load each tab when it
opens, a tab has to be able to suspend. Each tab pane now has its own
loading boundary, so a tab that is still loading shows a spinner under
the tab bar instead of the whole page turning into one.

Nothing changes on its own: no tab is lazy yet. The pages follow in
separate PRs per owner, and with them and the entry PRs in, opening
Settings goes from 11.76 MB to 2.55 MB (3.19 MB to 0.77 MB gzipped).

The jest setup's `getComputedStyle` fallback now returns a width and
height, since tables mounted inside a lazy pane crashed without them.

Part of #10192

#### Screenshots / Screen Recordings

Settings with its pages loading on demand through this change (the
follow-up PR), in Storybook with the network slowed to 1.6 Mbps, main on
the left:


https://github.com/user-attachments/assets/d22bf877-1ff8-4d25-a4eb-85a0a046998c
2026-11-23 17:48:51 +00:00
Vinicius Lourenço
7ea0d57417 fix(roles): keep the editor loading until the role's grants are in local state (#13671)
Some checks failed
build-staging / staging (push) Has been cancelled
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
cacheci / tests (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
#### Description

Opening a role's JSON view from a link or after a reload
(`/settings/roles/:id/edit?viewMode=json`) could show `[]` instead of
the role's grants, and saving then replaced them with whatever was
typed. It happened whenever the permission check answered before the
role fetch.

The editor reads its value only once, when it mounts, so the page now
stays in its loading state until the fetched role is in local state.
2026-11-23 14:26:30 +00:00
40 changed files with 249 additions and 3574 deletions

View File

@@ -137,6 +137,8 @@ window.getComputedStyle = function (
return {
display: '',
visibility: '',
width: '',
height: '',
opacity: '1',
animationName: 'none',
getPropertyValue: () => '',

View File

@@ -56,6 +56,7 @@
"@sentry/vite-plugin": "5.3.0",
"@signozhq/design-tokens": "2.8.0",
"@signozhq/icons": "0.4.0",
"@signozhq/noz-client": "1.13.0",
"@signozhq/ui": "0.4.0-rc.5",
"@tanstack/react-table": "8.21.3",
"@tanstack/react-virtual": "3.13.22",

View File

@@ -82,6 +82,9 @@ importers:
'@signozhq/icons':
specifier: 0.4.0
version: 0.4.0
'@signozhq/noz-client':
specifier: 1.13.0
version: 1.13.0(axios@1.21.1)(react-query@3.39.3(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react@18.2.0)
'@signozhq/ui':
specifier: 0.4.0-rc.5
version: 0.4.0-rc.5(@date-fns/tz@1.4.1)(@signozhq/design-tokens@2.8.0)(@signozhq/icons@0.4.0)(@types/react@18.0.26)(date-fns@4.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
@@ -3248,6 +3251,13 @@ packages:
'@signozhq/icons@0.4.0':
resolution: {integrity: sha512-QctNvNPlQlsefFdIVmSy/P/7a1IcQ3IryKP0KPMqtoqew3q89FGUmFa5IfEJ7Z3CHhtG1zaXwBKqP72QkLyA3g==}
'@signozhq/noz-client@1.13.0':
resolution: {integrity: sha512-130L2xomHnQZK8ZtAst34qFz9d2rSF/JYpg9gKvJkZVS9+46CPZeTW8Va9PNS9Oa5owezVHIXZStTEbsHIxnwg==}
peerDependencies:
axios: ^1.20.0
react: ^18.2.0
react-query: ^3.39.3
'@signozhq/ui@0.4.0-rc.5':
resolution: {integrity: sha512-WlJMfeDfvL2hjMpTpHhhND/tuK7X0sfXQlx6E1ZG+6E/DYHpuhYljfvW3E6/BohIlHFlTyCs/ZMl9wnV2k9Zcw==}
peerDependencies:
@@ -12373,6 +12383,12 @@ snapshots:
'@signozhq/icons@0.4.0': {}
'@signozhq/noz-client@1.13.0(axios@1.21.1)(react-query@3.39.3(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react@18.2.0)':
dependencies:
axios: 1.21.1
react: 18.2.0
react-query: 3.39.3(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
'@signozhq/ui@0.4.0-rc.5(@date-fns/tz@1.4.1)(@signozhq/design-tokens@2.8.0)(@signozhq/icons@0.4.0)(@types/react@18.0.26)(date-fns@4.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)':
dependencies:
'@base-ui/react': 1.8.0(@date-fns/tz@1.4.1)(@types/react@18.0.26)(date-fns@4.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)

View File

@@ -11,7 +11,7 @@
* to resume, which each return a new executionId to open a fresh SSE stream.
*
* Types in this file re-use the OpenAPI-generated DTOs in
* `src/api/ai-assistant/sigNozAIAssistantAPI.schemas.ts`.
* `@signozhq/noz-client`.
* Local types are defined only when the UI needs a different shape — for
* example, the SSE event union adds a literal `type` discriminator that the
* generated event DTOs leave loose.
@@ -60,7 +60,7 @@ import type {
PageTypeDTO,
ToolCallEventDTO,
ToolResultEventDTO,
} from './sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import { LOCALSTORAGE } from 'constants/localStorage';
import {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -12,4 +12,5 @@
import '@signozhq/design-tokens';
import '@signozhq/icons';
import '@signozhq/noz-client';
import '@signozhq/ui';

View File

@@ -1,3 +1,4 @@
import { lazy } from 'react';
import { navigate } from 'lib/router/navigation';
import { fireEvent, render, screen } from 'tests/test-utils';
@@ -98,4 +99,30 @@ describe('RouteTab component', () => {
fireEvent.click(screen.getByRole('tab', { name: 'Tab2' }));
expect(onChangeHandler).toHaveBeenCalled();
});
it('keeps the tab bar while a lazy tab loads', async () => {
let resolveTab: (module: { default: () => JSX.Element }) => void = () => {};
const LazyTab = lazy(
() =>
new Promise<{ default: () => JSX.Element }>((resolve) => {
resolveTab = resolve;
}),
);
render(
<RouteTab
routes={[{ ...testRoutes[0], Component: LazyTab }, testRoutes[1]]}
activeKey="Tab1"
/>,
);
expect(screen.getByRole('tab', { name: 'Tab1' })).toBeInTheDocument();
expect(
screen.getByLabelText('loading').closest('.ant-spin')?.parentElement,
).toHaveStyle({ height: '100%' });
resolveTab({ default: DummyComponent1 });
await expect(
screen.findByText('Dummy Component 1'),
).resolves.toBeInTheDocument();
});
});

View File

@@ -1,7 +1,9 @@
import { Suspense } from 'react';
import { Tabs, TabsProps } from 'antd';
import cx from 'classnames';
import HeaderRightSection from 'components/HeaderRightSection/HeaderRightSection';
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
import Spinner from 'components/Spinner';
import { buildRoutePath } from 'lib/router/buildRoutePath';
import { matchRoute } from 'lib/router/matchRoute';
import { navigate } from 'lib/router/navigation';
@@ -58,7 +60,11 @@ function RouteTab({
tabKey: route,
children: (
<OverlayScrollbar>
<Component />
<Suspense
fallback={<Spinner size="large" tip="Loading..." height="100%" />}
>
<Component />
</Suspense>
</OverlayScrollbar>
),
}));

View File

@@ -1,4 +1,4 @@
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { PageTypeDTO } from '@signozhq/noz-client';
import { QueryParams } from 'constants/query';
import ROUTES from 'constants/routes';

View File

@@ -16,11 +16,11 @@ import {
import { v4 as uuidv4 } from 'uuid';
import { Button } from '@signozhq/ui/button';
import { Tooltip } from '@signozhq/ui/tooltip';
import type { MessageActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import type { MessageActionDTO } from '@signozhq/noz-client';
import {
ApplyFilterSignalDTO,
MessageActionKindDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import {
restoreExecution,
revertExecution,

View File

@@ -1,7 +1,4 @@
import {
MessageActionDTO,
MessageActionKindDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { MessageActionDTO, MessageActionKindDTO } from '@signozhq/noz-client';
import logEvent from 'api/common/logEvent';
import { getCurrentLocation, navigate } from 'lib/router/navigation';
import { act, render, screen, userEvent, waitFor } from 'tests/test-utils';

View File

@@ -1,9 +1,9 @@
import { undoExecution } from 'api/ai-assistant/chat';
import type { MessageActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import type { MessageActionDTO } from '@signozhq/noz-client';
import {
ApplyFilterSignalDTO,
MessageActionKindDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import { Querybuildertypesv5RequestTypeDTO } from 'api/generated/services/sigNoz.schemas';
import { QueryParams } from 'constants/query';
import { PANEL_TYPES } from 'constants/queryBuilder';

View File

@@ -1,4 +1,4 @@
import { ApplyFilterSignalDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { ApplyFilterSignalDTO } from '@signozhq/noz-client';
import { Querybuildertypesv5RequestTypeDTO } from 'api/generated/services/sigNoz.schemas';
import { PANEL_TYPES } from 'constants/queryBuilder';

View File

@@ -2,7 +2,7 @@ import {
ApplyFilterSignalDTO,
MessageActionKindDTO,
SavedViewEntityDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import {
getSavedView,
listSavedViews,

View File

@@ -1,7 +1,7 @@
import {
type MessageActionDTO,
MessageActionKindDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import {
isSavedViewOpenAction,

View File

@@ -1,7 +1,7 @@
import {
ApplyFilterSignalDTO,
type MessageActionDTOQuery,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import { Querybuildertypesv5RequestTypeDTO } from 'api/generated/services/sigNoz.schemas';
import { PANEL_TYPES } from 'constants/queryBuilder';

View File

@@ -1,4 +1,4 @@
import type { MessageActionDTOQuery } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import type { MessageActionDTOQuery } from '@signozhq/noz-client';
import { normalizeTimeToMs } from 'utils/timeUtils';
export interface ActionTimeRange {

View File

@@ -1,8 +1,5 @@
import type { MessageActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import {
ApplyFilterSignalDTO,
SavedViewEntityDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import type { MessageActionDTO } from '@signozhq/noz-client';
import { ApplyFilterSignalDTO, SavedViewEntityDTO } from '@signozhq/noz-client';
import { DataSource } from 'types/common/queryBuilder';
import { ResourceType } from './resourceRoute';

View File

@@ -8,7 +8,7 @@ import { Tooltip } from '@signozhq/ui/tooltip';
import type {
ApprovalEventDTO,
ApprovalEventDTODiff,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import {
Check,
Columns2,

View File

@@ -6,11 +6,11 @@ import { Input } from '@signozhq/ui/input';
import { Select } from '@signozhq/ui/select';
import type { SelectItemType } from '@signozhq/ui/select';
import logEvent from 'api/common/logEvent';
import { ClarificationFieldTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { ClarificationFieldTypeDTO } from '@signozhq/noz-client';
import type {
ClarificationEventDTO,
ClarificationFieldEventDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import { CircleHelp, Send, X } from '@signozhq/icons';
import { AIAssistantEvents } from '../../events';

View File

@@ -5,7 +5,7 @@ import remarkGfm from 'remark-gfm';
import { Button } from '@signozhq/ui/button';
import { RotateCw, TriangleAlert } from '@signozhq/icons';
import { RetryActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { RetryActionDTO } from '@signozhq/noz-client';
// Side-effect: registers all built-in block types into the BlockRegistry
import '../blocks';

View File

@@ -1,9 +1,6 @@
import React from 'react';
import { render, screen, userEvent } from 'tests/test-utils';
import {
ErrorCodeDTO,
RetryActionDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { ErrorCodeDTO, RetryActionDTO } from '@signozhq/noz-client';
import { Message } from '../../../types';

View File

@@ -10,7 +10,7 @@ import { useTimezone } from 'providers/Timezone';
import logEvent from 'api/common/logEvent';
import { FeedbackRatingDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { FeedbackRatingDTO } from '@signozhq/noz-client';
import { AIAssistantEvents } from '../../events';
import { useAIAssistantAnalyticsContext } from '../../hooks/useAIAssistantAnalyticsContext';
import { useAIAssistantStore } from '../../store/useAIAssistantStore';

View File

@@ -6,7 +6,7 @@ import remarkGfm from 'remark-gfm';
import type {
ApprovalEventDTO,
ClarificationEventDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import { useVariant } from '../../VariantContext';
import { StreamingEventItem } from '../../types';

View File

@@ -7,7 +7,7 @@ import { ArrowDown } from '@signozhq/icons';
import type {
ApprovalEventDTO,
ClarificationEventDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import logEvent from 'api/common/logEvent';
import { AIAssistantEvents } from '../../events';

View File

@@ -1,4 +1,4 @@
import type { ChipDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import type { ChipDTO } from '@signozhq/noz-client';
/** Static empty-state chips used when the contextual chips API is unavailable. */
export const EMPTY_STATE_CHIPS_FALLBACK: ChipDTO[] = [

View File

@@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { useQuery } from 'react-query';
import { getEmptyStateChips } from 'api/ai-assistant/chat';
import type { ChipDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import type { ChipDTO } from '@signozhq/noz-client';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
import { useResolvePageType } from 'hooks/aiAssistant/useResolvePageType';

View File

@@ -1,4 +1,4 @@
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { PageTypeDTO } from '@signozhq/noz-client';
import { QueryParams } from 'constants/query';
import ROUTES from 'constants/routes';
import { matchRoute } from 'lib/router/matchRoute';

View File

@@ -4,7 +4,7 @@ import {
MessageContextDTOType,
MessageRoleDTO,
RetryActionDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import type {
MessageContext,
SSEEvent,

View File

@@ -7,8 +7,8 @@ import { immer } from 'zustand/middleware/immer';
import type {
MessageActionDTO,
MessageSummaryDTOBlocksAnyOfItem,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { RetryActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import { RetryActionDTO } from '@signozhq/noz-client';
import {
approveExecution,

View File

@@ -1,8 +1,7 @@
/**
* UI types for the AI Assistant.
*
* Wherever the OpenAPI-generated DTOs in
* `src/api/ai-assistant/sigNozAIAssistantAPI.schemas.ts`
* Wherever the OpenAPI-generated DTOs in `@signozhq/noz-client`
* already capture the right shape, this module re-exports them.
*
* A type is defined locally only when the UI needs a different shape than
@@ -20,7 +19,7 @@ import type {
MessageActionDTO,
MessageActionKindDTO,
RetryActionDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import type { MessageContext } from 'api/ai-assistant/chat';
/** Client-only file attachment — no API equivalent (uploads happen via data URLs). */

View File

@@ -1,8 +1,5 @@
import { AxiosError } from 'axios';
import {
ErrorCodeDTO,
RetryActionDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { ErrorCodeDTO, RetryActionDTO } from '@signozhq/noz-client';
import { resolveAssistantError } from '../resolveAssistantError';

View File

@@ -4,7 +4,7 @@ import {
RetryActionDTO,
type ErrorBodyDTO,
type ErrorResponseDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
export interface AssistantErrorResolution {
/** User-facing copy: code-specific FE copy → backend message → caller fallback. */

View File

@@ -1,13 +1,42 @@
import { QueryClient, QueryClientProvider } from 'react-query';
import ROUTES from 'constants/routes';
import { customRoleResponse } from 'mocks-server/__mockdata__/roles';
import { server } from 'mocks-server/server';
import { rest } from 'msw';
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';
import {
act,
render,
screen,
userEvent,
waitFor,
within,
} from 'tests/test-utils';
import {
AUTHZ_CHECK_URL,
authzMockResponse,
setupAuthzAdmin,
} from 'lib/authz/utils/authz-test-utils';
import { getCurrentLocation } from 'lib/router/navigation';
import CreateEditRolePage from '../CreateEditRolePage';
jest.mock('@monaco-editor/react', () => ({
__esModule: true,
default: ({
value,
onChange,
}: {
value: string;
onChange: (next?: string) => void;
}): JSX.Element => (
<textarea
data-testid="monaco-editor"
value={value}
onChange={(e): void => onChange(e.target.value)}
/>
),
}));
const CUSTOM_ROLE_ID = '019c24aa-3333-0001-aaaa-111111111111';
const rolesApiBase = '*/api/v1/roles';
const VIEW_ROLE_URL = `${ROUTES.ROLE_DETAILS.replace(
@@ -408,4 +437,125 @@ describe('EditRolePage', () => {
);
});
});
describe('JSON view opened from the URL', () => {
const roleGrants = roleWithTransactionGroups.data.transactionGroups;
function renderJsonView(client?: QueryClient): ReturnType<typeof render> {
const page = <CreateEditRolePage />;
return render(
client ? (
<QueryClientProvider client={client}>{page}</QueryClientProvider>
) : (
page
),
undefined,
{
initialRoute: `/settings/roles/${CUSTOM_ROLE_ID}/edit?name=Custom%20Role&viewMode=json`,
},
);
}
function readBuffer(editor: HTMLElement): unknown {
return JSON.parse((editor as HTMLTextAreaElement).value);
}
it('shows the role grants when the role loads after the authz check', async () => {
server.use(
rest.get(`${rolesApiBase}/:id`, (_req, res, ctx) =>
res(ctx.delay(300), ctx.status(200), ctx.json(roleWithTransactionGroups)),
),
);
renderJsonView();
const editor = await screen.findByTestId('monaco-editor');
expect(readBuffer(editor)).toStrictEqual(roleGrants);
});
it('shows the role grants when the role loads before the authz check', async () => {
server.use(
rest.post(AUTHZ_CHECK_URL, async (req, res, ctx) => {
const payload = await req.json();
return res(
ctx.delay(300),
ctx.status(200),
ctx.json(
authzMockResponse(
payload,
payload.map(() => true),
),
),
);
}),
);
renderJsonView();
const editor = await screen.findByTestId('monaco-editor');
expect(readBuffer(editor)).toStrictEqual(roleGrants);
});
it('saves what was typed in the buffer even when the role refetches afterwards', async () => {
const updatedBodies: unknown[] = [];
let roleReads = 0;
server.use(
rest.get(`${rolesApiBase}/:id`, (_req, res, ctx) => {
roleReads += 1;
return res(
ctx.status(200),
ctx.json(
roleReads === 1
? roleWithTransactionGroups
: {
...roleWithTransactionGroups,
data: {
...roleWithTransactionGroups.data,
transactionGroups: [
{
objectGroup: {
resource: { kind: 'role', type: 'role' },
selectors: ['*'],
},
relation: 'update',
},
],
},
},
),
);
}),
rest.put(`${rolesApiBase}/:id`, async (req, res, ctx) => {
updatedBodies.push(await req.json());
return res(ctx.status(200), ctx.json({ status: 'success' }));
}),
);
const user = userEvent.setup();
const client = new QueryClient({
defaultOptions: { queries: { retry: false } },
});
renderJsonView(client);
const editor = await screen.findByTestId('monaco-editor');
await user.type(editor, '[[]', {
initialSelectionStart: 0,
initialSelectionEnd: (editor as HTMLTextAreaElement).value.length,
});
await act(async () => {
await client.invalidateQueries();
});
await waitFor(() => {
expect(roleReads).toBeGreaterThan(1);
});
await user.click(screen.getByTestId('save-button'));
await waitFor(() => {
expect(updatedBodies).toHaveLength(1);
});
expect(updatedBodies[0]).toMatchObject({ transactionGroups: [] });
});
});
});

View File

@@ -86,6 +86,9 @@ export function useCreateEditRolePageActions(
const { mutateAsync: updateRole, isLoading: isUpdating } =
useUpdateRolePermissions();
const isSaving = isCreating || isUpdating;
// Editors read their initial value once, so stay loading until the fetched
// role has been copied into local state.
const isSeedingFromRole = !!rolePermissionsData && !isInitialized;
useEffect(() => {
if (rolePermissionsData && !isInitialized) {
@@ -229,7 +232,7 @@ export function useCreateEditRolePageActions(
setEditorMode: handleModeChange,
resources: localResources,
setResources: handleResourcesChange,
isLoading: isLoadingPermissions,
isLoading: isLoadingPermissions || isSeedingFromRole,
isSaving,
hasUnsavedChanges,
handleSave,

View File

@@ -1,5 +1,5 @@
import { renderHook } from '@testing-library/react';
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { PageTypeDTO } from '@signozhq/noz-client';
import type { AIAssistantVariant } from 'container/AIAssistant/VariantContext';
import ROUTES from 'constants/routes';
import { mockAppLocation } from 'tests/router-mocks';

View File

@@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { useAppLocation } from 'lib/router/useAppLocation';
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import { PageTypeDTO } from '@signozhq/noz-client';
import { resolvePageType } from 'container/AIAssistant/resolvePageType';
import { useVariant } from 'container/AIAssistant/VariantContext';

View File

@@ -11,7 +11,7 @@ import type {
MessageSummaryDTO,
ThreadDetailResponseDTO,
ThreadListResponseDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import {
ApplyFilterSignalDTO,
ApprovalActionTypeDTO,
@@ -22,7 +22,7 @@ import {
MessageActionKindDTO,
MessageContentTypeDTO,
MessageRoleDTO,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import type {
Conversation,
ConversationStreamState,

View File

@@ -3,11 +3,11 @@
* Do not hand-edit: regenerate instead.
*/
import type { MessageSummaryDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
import type { MessageSummaryDTO } from '@signozhq/noz-client';
import {
MessageContextDTOSource,
MessageContextDTOType,
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
} from '@signozhq/noz-client';
import type { MessageBlock } from 'container/AIAssistant/types';
/** The opening question's contexts: the thread shows the @-picked ones, not the page it was asked from. */