Skip to content

Commit ec5ed20

Browse files
authored
ref(explorer): useSessionStorage to persist current run id (#103467)
Keep track of the last active explorer conversation for each web session, so it can be restored on reload or the state is lost for some other reason https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage closes [AIML-1616: QoL: restore previous active session after hard reloading](https://linear.app/getsentry/issue/AIML-1616/qol-restore-previous-active-session-after-hard-reloading)
1 parent 701ad1e commit ec5ed20

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

static/app/views/seerExplorer/explorerPanel.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('ExplorerPanel', () => {
1919

2020
beforeEach(() => {
2121
MockApiClient.clearMockResponses();
22+
sessionStorage.clear();
2223

2324
// This matches the real behavior when no run ID is provided.
2425
MockApiClient.addMockResponse({

static/app/views/seerExplorer/hooks/useSeerExplorer.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {useSeerExplorer} from './useSeerExplorer';
77
describe('useSeerExplorer', () => {
88
beforeEach(() => {
99
MockApiClient.clearMockResponses();
10+
sessionStorage.clear();
1011
});
1112

1213
const organization = OrganizationFixture({

static/app/views/seerExplorer/hooks/useSeerExplorer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import type RequestError from 'sentry/utils/requestError/requestError';
1111
import useApi from 'sentry/utils/useApi';
1212
import useOrganization from 'sentry/utils/useOrganization';
13+
import {useSessionStorage} from 'sentry/utils/useSessionStorage';
1314
import useAsciiSnapshot from 'sentry/views/seerExplorer/hooks/useAsciiSnapshot';
1415
import type {Block} from 'sentry/views/seerExplorer/types';
1516

@@ -94,7 +95,10 @@ export const useSeerExplorer = () => {
9495
const orgSlug = organization?.slug;
9596
const captureAsciiSnapshot = useAsciiSnapshot();
9697

97-
const [runId, setRunId] = useState<number | null>(null);
98+
const [runId, setRunId] = useSessionStorage<number | null>(
99+
'seer-explorer-run-id',
100+
null
101+
);
98102
const [waitingForResponse, setWaitingForResponse] = useState<boolean>(false);
99103
const [deletedFromIndex, setDeletedFromIndex] = useState<number | null>(null);
100104
const [interruptRequested, setInterruptRequested] = useState<boolean>(false);

0 commit comments

Comments
 (0)