-
-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: extract UI timeout magic numbers into src/panel/constants.ts #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hoainho
merged 1 commit into
hoainho:main
from
Kunall7890:refactor/extract-timeout-constants
Jun 7, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /** | ||
| * Timeout constants for UI feedback (spinners, toast-like states). | ||
| * Values tuned for perceived responsiveness without flicker. | ||
| */ | ||
|
|
||
| /** Feedback duration for short UI actions (scan toggle, dispatch button) */ | ||
| export const UI_FEEDBACK_SHORT_MS = 800; | ||
|
|
||
| /** Feedback duration for medium UI actions (refresh, monitor toggle) */ | ||
| export const UI_FEEDBACK_MEDIUM_MS = 1000; | ||
|
|
||
| /** Feedback for debugger enable/disable — longer because background work continues */ | ||
| export const DEBUGGER_TOGGLE_FEEDBACK_MS = 3000; | ||
|
|
||
| /** Time to wait for Redux store auto-detection */ | ||
| export const REDUX_SEARCH_TIMEOUT_MS = 5000; | ||
|
|
||
| /** Correlation analysis feedback */ | ||
| export const CORRELATION_FEEDBACK_MS = 3000; | ||
|
|
||
| /** Snapshot creation feedback (short — operation is fast) */ | ||
| export const SNAPSHOT_CREATE_FEEDBACK_MS = 500; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||||
| import { useState, useMemo, useCallback, useRef, useEffect } from 'react'; | ||||||||||||||||||||||||||||||||||||||||
| import type { TimelineEvent, TimelineEventType, RenderEventPayload, StateChangeEventPayload, EffectEventPayload, ErrorEventPayload, MemoryEventPayload, CorrelationResult, ContextChangeEventPayload } from '@/types'; | ||||||||||||||||||||||||||||||||||||||||
| import { CORRELATION_FEEDBACK_MS, SNAPSHOT_CREATE_FEEDBACK_MS } from '../constants'; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| interface TimelineTabProps { | ||||||||||||||||||||||||||||||||||||||||
| events: TimelineEvent[]; | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -89,7 +90,7 @@ export function TimelineTab({ events, tabId, onClear }: TimelineTabProps) { | |||||||||||||||||||||||||||||||||||||||
| setIsCorrelating(false); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => setIsCorrelating(false), 3000); | ||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => setIsCorrelating(false), CORRELATION_FEEDBACK_MS); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
90
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clear any existing correlation timeout before starting a new one, and also clear it when the response successfully arrives. This prevents older timeouts from prematurely setting
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| }, [tabId]); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const clearCorrelation = useCallback(() => { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -139,7 +140,7 @@ export function TimelineTab({ events, tabId, onClear }: TimelineTabProps) { | |||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| setSnapshots(prev => [...prev, newSnapshot]); | ||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => setIsCreatingSnapshot(false), 500); | ||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => setIsCreatingSnapshot(false), SNAPSHOT_CREATE_FEEDBACK_MS); | ||||||||||||||||||||||||||||||||||||||||
| }, [events]); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const exportSnapshot = useCallback((snapshot: TimelineSnapshot) => { | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent race conditions when rapidly clicking different events to correlate, we should track and clear the pending timeout. We can declare a module-level variable to hold the timeout ID.