<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temporal Reliability: Workflow Simulation</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,500;0,700;1,400&display=swap" rel="stylesheet">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- Tailwind Config -->
<script>
tailwind.config = {
theme: {
extend: {
colors: {
background: '#050505',
surface: '#0f0f11',
surface2: '#1a1a1e',
primary: '#3b82f6', // Blue
secondary: '#8b5cf6', // Purple (V2)
accent: '#06b6d4', // Cyan
danger: '#f43f5e',
success: '#10b981',
text: '#e5e5e5',
textMuted: '#9ca3af'
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
mono: ['"Fira Code"', 'monospace']
},
animation: {
'pulse-fast': 'pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite',
}
}
}
}
</script>
<style>
/* Custom Base Styles */
body {
background-color: #050505;
color: #e5e5e5;
overflow-x: hidden;
-webkit-font-smoothing: antialiased;
}
/* Glassmorphism Utilities */
.glass-panel {
background: rgba(15, 15, 17, 0.6);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}
.glass-panel-light {
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.05);
}
/* Scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #0a0a0a;
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Range Slider */
input[type=range] {
-webkit-appearance: none;
width: 100%;
background: transparent;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #e5e5e5;
cursor: pointer;
margin-top: -6px;
box-shadow: 0 0 10px rgba(255,255,255,0.5);
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 4px;
cursor: pointer;
background: #333;
border-radius: 2px;
}
/* Glitch/Gradient Text */
.gradient-text {
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
/* Terminal Window */
.terminal {
font-family: 'Fira Code', monospace;
font-size: 0.85rem;
line-height: 1.4;
color: #d1d5db;
}
/* Worker Nodes */
.worker-node {
transition: all 0.3s ease;
}
.worker-node.busy {
box-shadow: 0 0 15px rgba(6, 182, 212, 0.6);
border-color: #06b6d4;
}
/* Activity Packet */
.packet {
position: absolute;
width: 24px;
height: 24px;
border-radius: 6px;
transform: translateX(-50%);
display: flex;
align-items: center;
justify-content: center;
font-size: 10px;
font-weight: bold;
z-index: 10;
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.packet.v1 { background: #3b82f6; color: white; }
.packet.v2 { background: #8b5cf6; color: white; }
.packet.retry { background: #f43f5e; color: white; animation: shake 0.5s; }
.packet.success { box-shadow: 0 0 20px #10b981; border: 1px solid #fff; }
/* Shake Animation */
@keyframes shake {
0% { transform: translateX(-50%) rotate(0deg); }
25% { transform: translateX(-40%) rotate(-5deg); }
75% { transform: translateX(-60%) rotate(5deg); }
100% { transform: translateX(-50%) rotate(0deg); }
}
/* ThreeJS Canvas */
#bg-canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
opacity: 0.6;
pointer-events: none;
}
/* UI Utils */
.magnetic-btn {
transition: transform 0.2s ease-out;
}
</style>
</head>
<body class="selection:bg-primary selection:text-white">
<!-- Three.js Background -->
<canvas id="bg-canvas"></canvas>
<!-- Main Content -->
<main class="relative z-10 container mx-auto px-6 py-12 max-w-7xl">
<!-- Header -->
<header class="flex flex-col md:flex-row justify-between items-end md:items-center mb-24 border-b border-white/10 pb-6">
<div>
<h1 class="text-xs uppercase tracking-[0.3em] text-accent mb-2 font-mono">Distributed Systems Lab</h1>
<h2 class="text-4xl md:text-5xl font-serif font-bold text-white">Temporal <span class="italic font-light">Dynamics</span></h2>
</div>
<nav class="mt-4 md:mt-0 flex gap-6 text-sm font-mono text-textMuted">
<a href="#" class="hover:text-white transition-colors">Concept</a>
<a href="#" class="hover:text-white transition-colors">Architecture</a>
<a href="#" class="hover:text-white transition-colors">Docs</a>
</nav>
</header>
<!-- Intro Section -->
<section class="mb-32 grid md:grid-cols-2 gap-16 items-center" id="hero-text">
<div class="space-y-8">
<h3 class="text-3xl md:text-4xl font-serif leading-tight">
Orchestrating <span class="text-primary">Reliability</span> in the Face of Failure.
</h3>
<p class="text-textMuted text-lg leading-relaxed font-light">
Temporal decouples workflow logic from implementation concerns. It provides built-in <strong>Activity Retries</strong>, <strong>Versioning</strong> (Workflow Update), and <strong>Worker Autoscaling</strong>. Watch the system adapt in real-time.
</p>
<div class="flex gap-4 text-sm font-mono text-textMuted pt-4">
<div class="flex items-center gap-2">
<span class="w-3 h-3 rounded-full bg-primary"></span> Retry Logic
</div>
<div class="flex items-center gap-2">
<span class="w-3 h-3 rounded-full bg-secondary"></span> Version Switch
</div>
<div class="flex items-center gap-2">
<span class="w-3 h-3 rounded-full bg-accent"></span> Scalable Workers
</div>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="glass-panel-light p-6 rounded-2xl">
<div class="text-4xl font-serif text-white mb-2" id="stat-uptime">99.99%</div>
<div class="text-xs text-textMuted uppercase tracking-widest">System Uptime</div>
</div>
<div class="glass-panel-light p-6 rounded-2xl">
<div class="text-4xl font-serif text-white mb-2" id="stat-total">0</div>
<div class="text-xs text-textMuted uppercase tracking-widest">Total Executions</div>
</div>
</div>
</section>
<!-- Simulation Dashboard (Bento Grid) -->
<section class="space-y-6 mb-32">
<!-- Control Bar -->
<div class="glass-panel rounded-2xl p-6 flex flex-col md:flex-row items-center justify-between gap-6">
<div class="flex items-center gap-4 w-full md:w-auto">
<button id="btn-spawn" class="magnetic-btn bg-white text-black px-8 py-3 rounded-full font-semibold hover:bg-accent hover:text-white transition-colors flex-1 md:flex-none flex items-center justify-center gap-2 group">
<span>Trigger Workflow</span>
<svg class="w-4 h-4 group-hover:translate-x-1 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 5l7 7-7 7M5 5l7 7-7 7"></path></svg>
</button>
</div>
<div class="w-full md:w-auto flex flex-col gap-1">
<div class="flex justify-between text-xs font-mono text-textMuted">
<span>Worker Pool Size</span>
<span id="worker-count-display" class="text-accent">3</span>
</div>
<input type="range" id="slider-workers" min="1" max="15" value="3" step="1">
</div>
<div class="w-full md:w-auto flex items-center gap-4 bg-surface/50 p-3 rounded-xl border border-white/5">
<span class="text-xs font-mono text-textMuted">Deployed Version</span>
<!-- Toggle Switch -->
<button id="btn-version" class="relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:ring-offset-surface">
<span class="inline-block h-4 w-4 transform rounded-full bg-white transition-all duration-200 ease-in-out translate-x-1" id="version-switch-circle"></span>
<span class="absolute left-1 text-[10px] font-bold text-white/70" style="top:2px">V1</span>
<span class="absolute right-1 text-[10px] font-bold text-white/70" style="top:2px">V2</span>
</button>
<span id="current-version-text" class="font-mono text-sm font-bold text-primary">V1 (Stable)</span>
</div>
</div>
<!-- Visualization Area -->
<div class="grid md:grid-cols-3 gap-6 auto-rows-min">
<!-- Left: Worker Scaling Visual -->
<div class="glass-panel rounded-2xl p-6 flex flex-col relative overflow-hidden">
<div class="flex justify-between items-center mb-6 z-10">
<h4 class="font-mono text-sm text-textMuted uppercase tracking-wider">Worker Pool</h4>
<div class="text-xs font-mono bg-surface px-2 py-1 rounded text-accent" id="worker-status-text">3 Active</div>
</div>
<!-- Worker Grid -->
<div id="worker-grid" class="grid grid-cols-3 gap-3 flex-grow content-start">
<!-- Workers injected by JS -->
</div>
<!-- Decorative Background -->
<div class="absolute -right-10 -bottom-10 w-40 h-40 bg-accent/10 blur-[50px] rounded-full pointer-events-none"></div>
</div>
<!-- Center: Retry & Flow Pipeline -->
<div class="glass-panel rounded-2xl p-6 flex flex-col relative overflow-hidden">
<div class="flex justify-between items-center mb-6 z-10">
<h4 class="font-mono text-sm text-textMuted uppercase tracking-wider">Activity Pipeline</h4>
<div class="text-xs font-mono bg-surface px-2 py-1 rounded" id="retry-stats">Retries: 0</div>
</div>
<!-- The Pipeline Track -->
<div class="relative w-full flex-grow min-h-[300px] bg-surface/50 rounded-xl border border-white/5 flex items-center px-4" id="pipeline-container">
<!-- Stages markers -->
<div class="absolute left-4 top-1/2 -translate-y-1/2 w-2 h-2 rounded-full bg-textMuted/50"></div>
<div class="absolute right-4 top-1/2 -translate-y-1/2 w-2 h-2 rounded-full bg-textMuted/50"></div>
<div class="absolute left-1/4 top-1/2 -translate-y-1/2 w-2 h-2 rounded-full bg-textMuted/30"></div>
<div class="absolute right-1/4 top-1/2 -translate-y-1/2 w-2 h-2 rounded-full bg-textMuted/30"></div>
<div class="w-full relative h-1 bg-gradient-to-r from-primary/20 via-accent/20 to-secondary/20"></div>
<!-- Packets will be injected here via JS -->
</div>
<div class="absolute -left-10 -top-10 w-40 h-40 bg-primary/10 blur-[50px] rounded-full pointer-events-none"></div>
</div>
<!-- Right: Versioning Swap -->
<div class="glass-panel rounded-2xl p-6 flex flex-col">
<div class="mb-6">
<h4 class="font-mono text-sm text-textMuted uppercase tracking-wider mb-1">Deployment Version</h4>
<p class="text-xl font-serif text-white" id="version-desc">Stable (v1.0)</p>
</div>
<div class="space-y-4 flex-grow">
<!-- Code Diff Simulation -->
<div class="bg-surface/80 rounded-lg p-4 border border-white/5">
<div class="text-xs font-mono text-textMuted mb-2">Worker Code Diff</div>
<pre class="text-xs font-mono leading-relaxed"><code><span class="text-blue-400">def</span> <span class="text-green-400">execute_payment</span>(order):<br><span class="text-gray-500">// V1 logic</span><br> charge_card(order.amount)<br><br><span class="text-purple-400">+def</span> <span class="text-green-400">execute_payment</span>(order):<br><span class="text-gray-500">// V2 logic (idempotency key)</span><br>+ ensure_idempotency(order.id)<br>+ charge_card(order.amount)</code></pre>
</div>
</div>
</div>
</div>
<!-- Bottom: Log Stream -->
<div class="glass-panel rounded-2xl p-1 font-mono text-xs md:text-sm overflow-hidden flex flex-col h-64">
<div class="bg-surface px-4 py-2 border-b border-white/5 flex justify-between items-center">
<span class="text-textMuted flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-success animate-pulse"></span> System Events
</span>
<span class="text-textMuted/50">Real-time Stream</span>
</div>
<div id="terminal-output" class="flex-grow overflow-y-auto p-4 terminal scroll-smooth space-y-1">
<!-- Logs go here -->
</div>
</div>
</section>
<!-- Final CTA -->
<section class="py-20 border-t border-white/10 text-center">
<p class="text-xl text-textMuted font-light">Ready to implement reliability in your stack?</p>
<button class="mt-6 px-8 py-4 border border-white/20 rounded-full text-sm font-mono hover:bg-white hover:text-black transition-all duration-300">
READ THE DOCUMENTATION
</button>
</section>
</main>
<!-- Scripts -->
<script>
/**
* 1. Three.js Background: Particle Network
*/
const initThree = () => {
const canvas = document.getElementById('bg-canvas');
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ canvas, alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
// Particles
const particleCount = 400;
const geometry = new THREE.BufferGeometry();
const positions = new Float32Array(particleCount * 3);
const velocities = [];
for(let i=0; i<particleCount * 3; i++) {
positions[i] = (Math.random() - 0.5) * 20; // Spread
}
for(let i=0; i<particleCount; i++) {
velocities.push({
x: (Math.random() - 0.5) * 0.005,
y: (Math.random() - 0.5) * 0.005,
z: (Math.random() - 0.5) * 0.005
});
}
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
const material = new THREE.PointsMaterial({
color: 0x3b82f6,
size: 0.05,
transparent: true,
opacity: 0.6
});
const particleSystem = new THREE.Points(geometry, material);
scene.add(particleSystem);
// Lines (Constellation)
const lineGeometry = new THREE.BufferGeometry();
const lineMaterial = new THREE.LineBasicMaterial({
color: 0x8b5cf6,
transparent: true,
opacity: 0.15
});
const linePositions = new Float32Array(particleCount * 6); // max possible lines
lineGeometry.setAttribute('position', new THREE.BufferAttribute(linePositions, 3));
const lines = new THREE.LineSegments(lineGeometry, lineMaterial);
scene.add(lines);
camera.position.z = 5;
// Interaction
let mouseX = 0, mouseY = 0;
document.addEventListener('mousemove', (e) => {
mouseX = (e.clientX / window.innerWidth) * 2 - 1;
mouseY = -(e.clientY / window.innerHeight) * 2 + 1;
});
// Animation
const animate = () => {
requestAnimationFrame(animate);
// Move particles
const posAttr = geometry.attributes.position;
for(let i=0; i<particleCount; i++) {
posAttr.array[i*3] += velocities[i].x;
posAttr.array[i*3+1] += velocities[i].y;
posAttr.array[i*3+2] += velocities[i].z;
// Boundary check
if(Math.abs(posAttr.array[i*3]) > 10) velocities[i].x *= -1;
if(Math.abs(posAttr.array[i*3+1]) > 10) velocities[i].y *= -1;
if(Math.abs(posAttr.array[i*3+2]) > 10) velocities[i].z *= -1;
}
geometry.attributes.position.needsUpdate = true;
// Connect lines
let lineIdx = 0;
for(let i=0; i<particleCount; i++) {
for(let j=i+1; j<particleCount; j++) {
const x1 = posAttr.array[i*3], y1 = posAttr.array[i*3+1], z1 = posAttr.array[i*3+2];
const x2 = posAttr.array[j*3], y2 = posAttr.array[j*3+1], z2 = posAttr.array[j*3+2];
const dist = Math.sqrt((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2);
if(dist < 2.5) {
linePositions[lineIdx++] = x1;
linePositions[lineIdx++] = y1;
linePositions[lineIdx++] = z1;
linePositions[lineIdx++] = x2;
linePositions[lineIdx++] = y2;
linePositions[lineIdx++] = z2;
}
}
}
lineGeometry.setDrawRange(0, lineIdx);
lines.geometry.attributes.position.needsUpdate = true;
// Parallax
particleSystem.rotation.x += 0.0005;
particleSystem.rotation.y += 0.0005;
lines.rotation.x += 0.0005;
lines.rotation.y += 0.0005;
camera.position.x += (mouseX * 0.5 - camera.position.x) * 0.05;
camera.position.y += (mouseY * 0.5 - camera.position.y) * 0.05;
camera.lookAt(scene.position);
renderer.render(scene, camera);
};
animate();
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
};
/**
* 2. Simulation Engine (The Logic)
*/
const Log = {
el: document.getElementById('terminal-output'),
add: function(msg, type='info') {
const div = document.createElement('div');
const time = new Date().toLocaleTimeString('en-US', {hour12:false});
let color = 'text-gray-400';
if(type === 'error') color = 'text-danger';
if(type === 'success') color = 'text-success';
if(type === 'warn') color = 'text-accent';
div.innerHTML = `<span class="opacity-50">[${time}]</span> <span class="${color}">${msg}</span>`;
this.el.appendChild(div);
this.el.scrollTop = this.el.scrollHeight;
},
clear: function() {
this.el.innerHTML = '';
}
};
const Sim = {
config: {
totalWorkers: 3,
currentVersion: 1, // 1 or 2
failureRate: 0.3, // 30% chance to fail an activity
maxRetries: 2,
spawnRate: 600 // ms between spawns if auto-spawning (optional)
},
state: {
workflows: [],
workers: [],
stats: {
totalSpawned: 0,
retriesTriggered: 0
}
},
// Classes
Worker: function(id) {
this.id = id;
this.status = 'IDLE'; // IDLE, BUSY
this.currentTask = null;
this.element = this.createDOM();
},
Workflow: function(id, version) {
this.id = id;
this.version = version; // 1 or 2
this.state = 'PENDING'; // PENDING, RUNNING, COMPLETED, FAILED
this.currentStep = 0; // index in steps
this.retryCount = 0;
this.packetElement = null;
this.totalSteps = 4; // Simulate 4 activities
},
init: function() {
// Initialize Workers
this.state.workers = [];
for(let i=0; i<this.config.totalWorkers; i++) {
this.state.workers.push(new Sim.Worker(i+1));
}
this.renderWorkerGrid();
this.updateWorkerDisplay();
// Start Loop
this.loop();
// Spawn Initial Workflows
setTimeout(() => this.spawnWorkflow(), 1000);
setTimeout(() => this.spawnWorkflow(), 2000);
},
createDOM: function() {
const div = document.createElement('div');
div.className = `worker-node glass-panel-light aspect-square rounded-xl flex items-center justify-center flex-col cursor-pointer transition-all duration-300 border border-transparent`;
div.innerHTML = `
<div class="w-2 h-2 rounded-full bg-textMuted relative">
<div class="absolute inset-0 rounded-full bg-accent animate-ping hidden opacity-75"></div>
</div>
<span class="text-[10px] font-mono mt-1 text-textMuted">W-<span class="id">1</span></span>
`;
return div;
},
renderWorkerGrid: function() {
const grid = document.getElementById('worker-grid');
grid.innerHTML = '';
this.state.workers.forEach(worker => {
worker.element.querySelector('.id').textContent = worker.id;
grid.appendChild(worker.element);
});
},
adjustWorkerCount: function(newCount) {
const diff = newCount - this.state.workers.length;
const grid = document.getElementById('worker-grid');
if(diff > 0) {
for(let i=0; i<diff; i++) {
const newId = this.state.workers.length + 1;
const w = new Sim.Worker(newId);
w.element.querySelector('.id').textContent = newId;
this.state.workers.push(w);
grid.appendChild(w.element);
Log.add(`Worker node W-${newId} provisioned.`, 'success');
}
} else if(diff < 0) {
for(let i=0; i<Math.abs(diff); i++) {
const w = this.state.workers.pop();
w.element.style.opacity = '0';
setTimeout(() => w.element.remove(), 300);
Log.add(`Worker node W-${w.id} deprovisioned.`, 'warn');
}
}
this.config.totalWorkers = newCount;
this.updateWorkerDisplay();
},
updateWorkerDisplay: function() {
// Update count badge
document.getElementById('worker-count-display').textContent = this.config.totalWorkers;
document.getElementById('worker-status-text').textContent = `${this.getActiveWorkers()} Active`;
},
getActiveWorkers: function() {
return this.state.workers.filter(w => w.status === 'BUSY').length;
},
spawnWorkflow: function() {
const id = 'WF-' + Math.floor(Math.random() * 10000);
const version = this.config.currentVersion;
const wf = new Sim.Workflow(id, version);
this.state.workflows.push(wf);
this.state.stats.totalSpawned++;
// Create Packet DOM
const container = document.getElementById('pipeline-container');
const packet = document.createElement('div');
packet.className = `packet v${version}`;
packet.innerHTML = version;
// Initial position (left)
packet.style.left = '4%';
container.appendChild(packet);
wf.packetElement = packet;
Log.add(`Workflow ${id} started using Worker code V${version}.`, 'info');
// Update Stats
document.getElementById('stat-total').textContent = this.state.stats.totalSpawned;
},
loop: function() {
// 1. Assign idle workers to pending workflows
this.state.workers.forEach(worker => {
if(worker.status === 'IDLE') {
const pending = this.state.workflows.find(w => w.state === 'RUNNING' && w.currentStep < w.totalSteps && !w.assignedWorker);
if(pending) {
worker.status = 'BUSY';
worker.currentTask = pending;
pending.assignedWorker = worker; // link
}
}
});
// 2. Process tasks
this.state.workflows.forEach(wf => {
if(wf.state === 'PENDING') {
// Wait for a worker to pick it up (instant assignment in loop above, but needs state transition)
const assigned = this.state.workers.find(w => w.currentTask === wf);
if(assigned) {
wf.state = 'RUNNING';
wf.startTime = Date.now();
gsap.to(wf.packetElement, {
left: `${4 + ((wf.currentStep) / wf.totalSteps) * 90}%`,
duration: 2, // simulate activity duration
ease: 'none',
onUpdate: function() {
// Visual progress indicator internal to packet could go here
}
});
}
} else if (wf.state === 'RUNNING') {
const assignedWorker = this.state.workers.find(w => w.currentTask === wf);
if(!assignedWorker) return; // edge case
const elapsed = Date.now() - wf.startTime;
const duration = 2000;
if(elapsed >= duration) {
// Activity "Completed" (or failed)
const success = Math.random() > Sim.config.failureRate;
if(success) {
// Success
wf.currentStep++;
wf.startTime = Date.now(); // reset timer for next step
if(wf.currentStep >= wf.totalSteps) {
// Workflow Complete
wf.state = 'COMPLETED';
assignedWorker.status = 'IDLE';
assignedWorker.currentTask = null;
wf.packetElement.classList.add('success');
Log.add(`Workflow ${wf.id} completed successfully.`, 'success');
// Remove packet after delay
gsap.to(wf.packetElement, { opacity: 0, delay: 1, onComplete: () => wf.packetElement.remove() });
} else {
// Move to next step visual
gsap.to(wf.packetElement, {
left: `${4 + ((wf.currentStep) / wf.totalSteps) * 90}%`,
duration: 2,
ease: 'none'
});
}
} else {
// Failure (Retry)
wf.retryCount++;
this.state.stats.retriesTriggered++;
document.getElementById('retry-stats').textContent = `Retries: ${this.state.stats.retriesTriggered}`;
Log.add(`Activity failed in ${wf.id}. Retry #${wf.retryCount}...`, 'error');
// Visual feedback
wf.packetElement.classList.remove(wf.version === 1 ? 'v1' : 'v2');
wf.packetElement.classList.add('retry');
// Halt briefly then retry
gsap.to(wf.packetElement, {
left: `${4 + ((wf.currentStep) / wf.totalSteps) * 90}%`, // stay in place
duration: 0.5,
onComplete: () => {
wf.packetElement.classList.remove('retry');
wf.packetElement.classList.add(wf.version === 1 ? 'v1' : 'v2');
wf.startTime = Date.now(); // retry timer starts now
}
});
}
} else {
// Update packet position based on progress
const progress = elapsed / duration;
const baseLeft = 4 + ((wf.currentStep) / wf.totalSteps) * 90;
const sectionLen = (1 / wf.totalSteps) * 90;
const currentLeft = baseLeft + (progress * sectionLen);
wf.packetElement.style.left = `${currentLeft}%`;
}
}
});
this.updateWorkerDisplay();
requestAnimationFrame(() => this.loop());
}
};
/**
* 3. Interaction & UI Binding
*/
document.addEventListener('DOMContentLoaded', () => {
// Init 3D Background
initThree();
// Init Simulation
Sim.init();
Log.add('System initialized. Worker pool active.', 'success');
// Spawn Button
document.getElementById('btn-spawn').addEventListener('click', () => {
Sim.spawnWorkflow();
});
// Worker Slider
const slider = document.getElementById('slider-workers');
slider.addEventListener('input', (e) => {
const val = parseInt(e.target.value);
document.getElementById('worker-count-display').textContent = val;
Sim.adjustWorkerCount(val);
});
// Version Toggle
const versionBtn = document.getElementById('btn-version');
const versionText = document.getElementById('current-version-text');
const versionDesc = document.getElementById('version-desc');
const switchCircle = document.getElementById('version-switch-circle');
let isV2 = false;
versionBtn.addEventListener('click', () => {
isV2 = !isV2;
// Animate the toggle switch
if(isV2) {
switchCircle.classList.add('translate-x-5', 'bg-secondary');
switchCircle.classList.remove('translate-x-1', 'bg-white');
versionText.textContent = 'V2 (Canary)';
versionText.classList.remove('text-primary');
versionText.classList.add('text-secondary');
versionDesc.textContent = "Canary (v2.0 - Idempotency)";
// Trigger "Deployment" wave effect
gsap.fromTo('.glass-panel',
{ borderColor: 'rgba(139, 92, 246, 0.5)' },
{ borderColor: 'rgba(255,255,255,0.08)', duration: 1, delay: 0.2 }
);
Log.add('Deployment pipeline shifted to V2 (Canary). Old flows persist.', 'warn');
} else {
switchCircle.classList.remove('translate-x-5', 'bg-secondary');
switchCircle.classList.add('translate-x-1', 'bg-white');
versionText.textContent = 'V1 (Stable)';
versionText.classList.add('text-primary');
versionText.classList.remove('text-secondary');
versionDesc.textContent = "Stable (v1.0)";
gsap.fromTo('.glass-panel',
{ borderColor: 'rgba(59, 130, 246, 0.5)' },
{ borderColor: 'rgba(255,255,255,0.08)', duration: 1, delay: 0.2 }
);
Log.add('Rolled back to V1 (Stable).', 'info');
}
Sim.config.currentVersion = isV2 ? 2 : 1;
});
// Magnetic Button Effect
const magneticBtns = document.querySelectorAll('.magnetic-btn');
magneticBtns.forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width/2;
const y = e.clientY - rect.top - rect.height/2;
gsap.to(btn, { x: x*0.2, y: y*0.2, duration: 0.2 });
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn, { x: 0, y: 0, duration: 0.2 });
});
});
// GSAP Scroll Trigger for Fade-ins
gsap.from("#hero-text", {
scrollTrigger: {
trigger: "#hero-text",
start: "top 80%",
toggleActions: "play none none reverse"
},
y: 50,
opacity: 0,
duration: 1,
ease: "power3.out"
});
gsap.from(".glass-panel", {
scrollTrigger: {
trigger: "#simulator",
start: "top 80%",
},
y: 30,
opacity: 0,
duration: 0.8,
stagger: 0.2,
ease: "power2.out"
});
});
</script>
</body>
</html>