Skip to content

ref(seer-explorer): Replace useSeerExplorerRunId with chat state context#115631

Merged
JonasBa merged 6 commits into
masterfrom
jonasba/ref/seer-explorer-chat-state-context
May 15, 2026
Merged

ref(seer-explorer): Replace useSeerExplorerRunId with chat state context#115631
JonasBa merged 6 commits into
masterfrom
jonasba/ref/seer-explorer-chat-state-context

Conversation

@JonasBa
Copy link
Copy Markdown
Member

@JonasBa JonasBa commented May 15, 2026

Removes polling hook in favor of context and global state management

Replace the module-level useSyncExternalStore pattern with a React
context using a reducer with split dispatch and state. The context
stores Record<number, ChatState> for per-run polling state and
manages the active runId with session storage persistence.

useSeerExplorerPolling now dispatches polling state updates to the
parent context, centralizing chat state management.

Co-Authored-By: Claude <noreply@anthropic.com>
@JonasBa JonasBa requested review from a team as code owners May 15, 2026 15:04
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.53%

Comment thread static/app/views/seerExplorer/hooks/useSeerExplorerPolling.tsx Outdated
The override was redundant — mutations already set optimistic
status to 'processing' with a fresh updated_at, so getPollingState
computes 'polling' without it.

Polling now runs exclusively in SeerExplorerChatStateProvider via
a child component that dispatches to the reducer. Consumers read
isPolling/isTimedOut from chatStates instead of calling
useSeerExplorerPolling directly.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread static/app/views/seerExplorer/seerExplorerChatStateContext.tsx Outdated
Comment thread static/app/views/seerExplorer/hooks/useSeerExplorer.tsx
Move SeerExplorerResponse and PendingUserInput types to types.tsx to
break circular dependency (useSeerExplorer → seerExplorerChatStateContext
→ useSeerExplorerPolling → useSeerExplorer). Update all external
consumers to import from the new location.

Switch test mocks from jest.mock with jest.requireActual (which fails
due to module initialization ordering) to jest.spyOn for utils and
llmContext hooks. Un-export ChatState and ChatStateAction types that
have no external consumers.

Co-Authored-By: Claude <noreply@anthropic.com>
When runId is null (new session), pollingState was undefined and
isPolling was always false, causing the processedSessionData memo to
skip optimistic block construction. Users saw nothing while the first
mutation was in-flight.

Gate the early return on an awaitingResponse signal that checks
isSendingMessage, whether we're waiting for initial API data, or
whether the session is still processing (excluding timeouts). This
bridges the gap between mutation resolve and polling state propagation
through the context.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread static/app/views/seerExplorer/seerExplorerChatStateContext.tsx Outdated
Drop the dead 'remove' action variant and reducer case that had no
dispatch site. Type the JSON.parse result as unknown instead of any.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5c259e4. Configure here.

Comment thread static/app/views/seerExplorer/hooks/useSeerExplorer.tsx
Copy link
Copy Markdown
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean refactor, nice job!

@JonasBa JonasBa merged commit 7286d97 into master May 15, 2026
74 checks passed
@JonasBa JonasBa deleted the jonasba/ref/seer-explorer-chat-state-context branch May 15, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants