Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions static/app/components/events/autofix/useExplorerAutofix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {trackAnalytics} from 'sentry/utils/analytics';
import {apiOptions} from 'sentry/utils/api/apiOptions';
import {getApiUrl} from 'sentry/utils/api/getApiUrl';
import {defined} from 'sentry/utils/defined';
import {isDemoModeActive} from 'sentry/utils/demoMode';
import {useApi} from 'sentry/utils/useApi';
import {useOrganization} from 'sentry/utils/useOrganization';
import {useUser} from 'sentry/utils/useUser';
Expand Down Expand Up @@ -854,10 +855,9 @@ export function useExplorerAutofix(
await invalidation;
}

if (
organization.features.includes('autofix-browser-notifications') &&
serviceWorker.isServiceWorkerSupported
) {
// The sandbox can start Seer runs to showcase AI, but announcing them
// to a demo visitor's OS is not part of that pitch.
if (!isDemoModeActive() && serviceWorker.isServiceWorkerSupported) {
serviceWorker.controller
.postMessage({
type: 'event',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {render, screen} from 'sentry-test/reactTestingLibrary';

import {SeerEnableNotifications} from 'sentry/components/events/autofix/v3/seerEnableNotifications';
import {AutofixChatProvider} from 'sentry/components/seer/autofixChatContext';
import {isDemoModeActive} from 'sentry/utils/demoMode';

jest.mock('sentry/utils/demoMode');

// Service workers and the Notification API do not exist in jsdom, and
// `supportsNotifications` is read once at module scope, so there is no store or
Expand Down Expand Up @@ -33,35 +36,39 @@ describe('SeerEnableNotifications', () => {

beforeEach(() => {
MockApiClient.clearMockResponses();
jest.mocked(isDemoModeActive).mockReturnValue(false);
promptsRequest = MockApiClient.addMockResponse({
url: '/organizations/org-slug/prompts-activity/',
body: {data: {}},
});
});

it('offers to notify while a run is processing', async () => {
render(<SeerEnableNotifications status="processing" />, {
organization: OrganizationFixture({features: ['autofix-browser-notifications']}),
});
render(<SeerEnableNotifications status="processing" />);

expect(await screen.findByRole('button', {name: NOTIFY_BUTTON})).toBeInTheDocument();
expect(promptsRequest).toHaveBeenCalled();
});

it('stays quiet in the demo sandbox', () => {
jest.mocked(isDemoModeActive).mockReturnValue(true);

render(<SeerEnableNotifications status="processing" />);

expect(promptsRequest).not.toHaveBeenCalled();
expect(screen.queryByRole('button', {name: NOTIFY_BUTTON})).not.toBeInTheDocument();
});

it('stays quiet in code mode, where the agent owns the run', () => {
render(
<AutofixChatProvider sendMessage={jest.fn()}>
<SeerEnableNotifications status="processing" />
</AutofixChatProvider>,
{
// Code mode needs the Explorer's own prerequisites alongside its flag,
// and a chat that can take the run.
// Code mode needs the Explorer's own prerequisites, and a chat that can
// take the run.
organization: OrganizationFixture({
features: [
'autofix-browser-notifications',
'seer-explorer-code-mode-tools',
'seer-explorer',
],
features: ['seer-explorer-code-mode-tools', 'seer-explorer'],
openMembership: true,
hideAiFeatures: false,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {useServiceWorker} from 'sentry/serviceWorker/client/serviceWorkerContext
import {useNotificationPermission} from 'sentry/serviceWorker/client/useNotificationPermission';
import type {RequestMessage} from 'sentry/serviceWorker/types';
import {trackAnalytics} from 'sentry/utils/analytics';
import {isDemoModeActive} from 'sentry/utils/demoMode';
import {useOrganization} from 'sentry/utils/useOrganization';

const SUCCESS_VISIBLE_DURATION_MS = 25_000;
Expand Down Expand Up @@ -47,7 +48,9 @@ export function SeerEnableNotifications({status}: Props) {
const analyticsArea = useAnalyticsArea();

const isEligible =
organization.features.includes('autofix-browser-notifications') &&
// The sandbox can start Seer runs to showcase AI, but asking a demo visitor
// for browser notification permission is not part of that pitch.
!isDemoModeActive() &&
// In code mode the run is handed to the agent and followed in chat, so an
// offer to announce it from here would point at the wrong surface.
!isCodeMode &&
Expand Down
Loading