// Simple client-side router const router = { currentRoute: '/', init() { // Handle browser back/forward window.addEventListener('popstate', () => { this.handleRoute(window.location.pathname); }); // Handle initial route this.handleRoute(window.location.pathname); }, navigate(path) { window.history.pushState({}, '', path); this.handleRoute(path); }, async handleRoute(path) { this.currentRoute = path; const container = document.getElementById('page-container'); if (path === '/' || path === '') { await this.renderHome(container); } else if (path.startsWith('/instance/')) { const id = path.split('/')[2]; await this.renderDetail(container, id); } else { container.innerHTML = components.error('Page not found'); } }, async renderHome(container) { container.innerHTML = components.spinner('Loading instances...'); try { const instances = await api.getInstances(); if (instances.length === 0) { container.innerHTML = components.emptyState( 'No running instances. Click "+ New Run" to start one.' ); return; } let html = '
No tool calls yet
'; } html += `