-
Notifications
You must be signed in to change notification settings - Fork 1
feat: test environment mode for historical pathfinding #16
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
base: main
Are you sure you want to change the base?
Changes from all commits
ebf6126
58b39b6
b8b66fa
c57b1b3
153f6b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { usePerformance } from '@/contexts/PerformanceContext'; | |
| import { useKeyboardShortcuts } from '@/hooks/useKeyboardShortcuts'; | ||
| import { decomposeFlow, transfersFromRoutes } from '@/utils/flowDecomposition'; | ||
| import { parseAddressList } from '@/services/circlesApi'; | ||
| import { getOrCreateSession, destroySession } from '@/services/testEnvService'; | ||
| import Header from '@/components/ui/header'; | ||
| import CollapsibleLeftPanel from '@/components/CollapsibleLeftPanel'; | ||
| import CytoscapeVisualization from '@/components/CytoscapeVisualization'; | ||
|
|
@@ -49,6 +50,9 @@ const FlowVisualization = () => { | |
| handleTokensChange, | ||
| handleWithWrapToggle, | ||
| handleStagingToggle, | ||
| handleTestEnvToggle, | ||
| handleTestEnvUrlChange, | ||
| handleTestEnvBlockNumberChange, | ||
| handleQuantizedModeToggle, | ||
| handleDebugIntermediateToggle, | ||
| handleFromTokensExclusionToggle, | ||
|
|
@@ -58,7 +62,13 @@ const FlowVisualization = () => { | |
| validateFormData, | ||
| } = useFormData(); | ||
| const [formWarnings, setFormWarnings] = useState([]); | ||
|
|
||
| const [testEnvSession, setTestEnvSession] = useState(null); | ||
|
|
||
| const handleDestroySession = useCallback(async () => { | ||
| await destroySession(); | ||
| setTestEnvSession(null); | ||
| }, []); | ||
|
|
||
| const { | ||
| pathData, | ||
| rawPathData, | ||
|
|
@@ -337,8 +347,35 @@ const FlowVisualization = () => { | |
| setSelectedTransactionId(null); | ||
| clearHighlights(); | ||
|
|
||
| // If test-env mode, ensure we have a valid session attached | ||
| if (requestData.UseTestEnv) { | ||
| if (!requestData.TestEnvBlockNumber) { | ||
| setFormWarnings(['Enter a block number for test environment mode']); | ||
| return; | ||
| } | ||
| const parsedBlock = Number(requestData.TestEnvBlockNumber); | ||
| if (!Number.isInteger(parsedBlock) || parsedBlock < 0) { | ||
| setFormWarnings(['Block number must be a non-negative integer']); | ||
| return; | ||
| } | ||
| try { | ||
| const session = await getOrCreateSession(requestData.TestEnvUrl, parsedBlock); | ||
| setTestEnvSession(session); | ||
| await loadPathData({ ...requestData, testEnvSession: session }); | ||
| } catch (err) { | ||
| const isMaxSessions = err.message.includes('Maximum concurrent sessions'); | ||
| const hint = isMaxSessions | ||
| ? ' — close unused sessions or wait for them to expire (30 min TTL).' | ||
| : ''; | ||
| setFormWarnings([`Test-env session error: ${err.message}${hint}`]); | ||
| setTestEnvSession(null); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| setTestEnvSession(null); | ||
| await loadPathData(requestData); | ||
|
Comment on lines
+376
to
377
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. Destroy the live session when leaving test-env mode. This branch only clears the local reference. Because 🤖 Prompt for AI Agents |
||
| }, [loadPathData, clearHighlights]); | ||
| }, [loadPathData, clearHighlights, setFormWarnings, setTestEnvSession]); | ||
|
|
||
| const selectQuickTokensByPredicate = useCallback(async (predicate) => { | ||
| const allTokens = Array.from(new Set( | ||
|
|
@@ -416,6 +453,7 @@ const FlowVisualization = () => { | |
| if (!validation.isValid) { | ||
| return; | ||
| } | ||
|
|
||
| await executeFindPath(baseData); | ||
| }, [formData, executeFindPath, validateFormData]); | ||
|
|
||
|
|
@@ -836,6 +874,11 @@ const FlowVisualization = () => { | |
| handleTokensChange={handleTokensChange} | ||
| handleWithWrapToggle={handleWithWrapToggle} | ||
| handleStagingToggle={handleStagingToggle} | ||
| handleTestEnvToggle={handleTestEnvToggle} | ||
| handleTestEnvUrlChange={handleTestEnvUrlChange} | ||
| handleTestEnvBlockNumberChange={handleTestEnvBlockNumberChange} | ||
| testEnvSession={testEnvSession} | ||
| onDestroySession={handleDestroySession} | ||
| handleQuantizedModeToggle={handleQuantizedModeToggle} | ||
| handleDebugIntermediateToggle={handleDebugIntermediateToggle} | ||
| handleFromTokensExclusionToggle={handleFromTokensExclusionToggle} | ||
|
|
||
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.
Separate session creation failures from query failures.
loadPathData(...)is inside the sametryasgetOrCreateSession(...), so any downstream RPC/pathfinder failure is reported as a test-env session error andtestEnvSessionis cleared even though the session was created successfully. Catch only the session acquisition step here and let query failures surface through the normal request error path.🤖 Prompt for AI Agents