diff --git a/router/handlers/simulation.go b/router/handlers/simulation.go index c134bc1..94b995b 100644 --- a/router/handlers/simulation.go +++ b/router/handlers/simulation.go @@ -144,13 +144,22 @@ func calculateMetrics(snapshots []*simulation.TickSnapshot, design design.Design totalHealthy := 0 totalNodes := 0 + // Build map of outgoing connections to identify final destinations + outgoingConnections := make(map[string]bool) + for _, conn := range design.Connections { + outgoingConnections[conn.Source] = true + } + // Calculate aggregate metrics across all snapshots for _, snapshot := range snapshots { // Count total requests processed in this tick - for _, requests := range snapshot.Emitted { - totalRequests += len(requests) - for _, req := range requests { - totalLatency += req.LatencyMS + for nodeID, requests := range snapshot.Emitted { + // Only count requests from final destination nodes (no outgoing connections) + if !outgoingConnections[nodeID] { + totalRequests += len(requests) + for _, req := range requests { + totalLatency += req.LatencyMS + } } } diff --git a/static/app.js b/static/app.js index 2040655..75b534f 100644 --- a/static/app.js +++ b/static/app.js @@ -213,41 +213,7 @@ export class CanvasApp { return {}; } - showResults(result) { - const metrics = result.metrics; - let message = ''; - - // Level validation results - if (result.levelName) { - if (result.passed) { - message += `Level "${result.levelName}" PASSED!\n`; - message += `Score: ${result.score}/100\n\n`; - } else { - message += `Level "${result.levelName}" FAILED\n`; - message += `Score: ${result.score}/100\n\n`; - } - - // Add detailed feedback - if (result.Feedback && result.Feedback.length > 0) { - message += result.Feedback.join('\n') + '\n\n'; - } - } else { - message += `Simulation Complete!\n\n`; - } - - // Performance metrics - message += `Performance Metrics:\n`; - message += `• Throughput: ${metrics.throughput} req/sec\n`; - message += `• Avg Latency: ${metrics.latency_avg}ms\n`; - message += `• Availability: ${metrics.availability.toFixed(1)}%\n`; - message += `• Monthly Cost: $${metrics.cost_monthly}\n\n`; - message += `Timeline: ${result.timeline.length} ticks simulated`; - - alert(message); - - // TODO: Later replace with redirect to results page or modal - console.log('Full simulation data:', result); - } + // showResults function removed - now handled by redirect to success/failure pages showError(errorMessage) { alert(`Simulation Error:\n\n${errorMessage}\n\nPlease check your design and try again.`); diff --git a/static/commands.js b/static/commands.js index aae06a4..18e4b69 100644 --- a/static/commands.js +++ b/static/commands.js @@ -292,16 +292,9 @@ export class RunSimulationCommand extends Command { return; } - // Fallback: try to parse as JSON for backward compatibility - const result = await response.json(); - console.log('result', result); - if (result.passed && result.success) { - console.log('Simulation successful:', result); - app.showResults(result); - } else { - console.error('Simulation failed:', result.Error); - app.showError(result.Error || 'Simulation failed'); - } + // If we get here, something went wrong - the server should always redirect + console.error('Unexpected response from server - expected redirect but got:', response.status); + app.showError('Unexpected server response. Please try again.'); } catch (error) { console.error('Network error:', error); diff --git a/static/failure.html b/static/failure.html index 9d5ac89..3c38cd8 100644 --- a/static/failure.html +++ b/static/failure.html @@ -125,6 +125,12 @@ 50% { opacity: 0.8; } } + .header-logo-container { + display: flex; + align-items: center; + gap: 12px; + } + .header-text { font-size: 24px; margin: 0; @@ -132,6 +138,19 @@ transition: all 3s ease-in-out; } + .beta-pill { + background: linear-gradient(45deg, #ff6b35, #f7931e); + color: white; + padding: 4px 8px; + border-radius: 12px; + font-size: 0.7rem; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.5px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); + transition: all 3s ease-in-out; + } + .recovering .header-text { text-shadow: 0 0 10px rgba(0, 255, 136, 0.8) } @@ -636,7 +655,10 @@