Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 49 additions & 52 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
.btn-primary { padding: 6px 16px; background: #0e639c; color: #fff; border: none; border-radius: 3px; cursor: pointer; font-size: 12px; }
.btn-primary:hover { background: #1177bb; }
.btn-primary:disabled { background: #333; color: #666; cursor: default; }
.version-alert-status { font-size: 12px; color: #808080; }

.overview-bar { display: flex; gap: 16px; margin-bottom: 20px; }
.overview-item { flex: 1; background: #252526; border: 1px solid #3e3e3e; border-radius: 6px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.overview-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
Expand Down Expand Up @@ -420,7 +420,7 @@ <h2>Watcher Status</h2>
watcherDot.className = 'overview-dot dot-green';
watcherDetail.textContent = `Active${hash} \u00b7 ${files} files, ${assets} assets ingested`;
}
watcherAction.innerHTML = '';
watcherAction.innerHTML = '<button class="action-btn action-btn-warn" onclick="overviewRestartWatcher(this)">Restart</button>';
} else {
watcherDot.className = 'overview-dot dot-red';
watcherDetail.textContent = 'No watcher connected \u2014 file changes won\'t be indexed';
Expand All @@ -442,8 +442,7 @@ <h2>Watcher Status</h2>
`Service (${serviceGitHash}) \u00b7 Watcher (${watcherGitHash})`;
const actionsEl = document.getElementById('version-alert-actions');
actionsEl.innerHTML = `
<button class="btn-primary" onclick="stopAndRestartWatcher(this)">Restart Watcher</button>
<span class="version-alert-status" id="version-alert-status"></span>`;
<button class="btn-primary" onclick="overviewRestartWatcher(this)">Restart Watcher</button>`;
} else {
versionAlert.classList.remove('visible');
}
Expand Down Expand Up @@ -476,54 +475,6 @@ <h2>Watcher Status</h2>
}
}

async function stopAndRestartWatcher(btn) {
const status = document.getElementById('version-alert-status');
btn.disabled = true;
btn.textContent = 'Stopping watcher...';
status.textContent = '';
try {
await fetch('/api/watcher/stop', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ workspace: WorkspaceContext.active })
});
status.textContent = 'Waiting for watcher to stop...';
const stopped = await waitForWatcherState(false, { maxAttempts: 20, intervalMs: 1000 });
if (!stopped) {
status.textContent = 'Watcher did not stop in time. Try closing it manually.';
btn.textContent = 'Restart Watcher';
btn.disabled = false;
return;
}
btn.textContent = 'Starting watcher...';
status.textContent = '';
const startResp = await fetch('/api/watcher/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ workspace: WorkspaceContext.active })
});
if (!startResp.ok) {
const err = await startResp.json();
status.textContent = err.error || 'Failed to start watcher';
btn.textContent = 'Restart Watcher';
btn.disabled = false;
return;
}
status.textContent = 'Waiting for new watcher...';
const started = await waitForWatcherState(true);
if (started) {
loadAllWithOverview();
} else {
status.textContent = 'Watcher started but still reconciling. Refresh shortly.';
btn.textContent = 'Restart Watcher';
btn.disabled = false;
}
} catch (err) {
status.textContent = 'Error: ' + err.message;
btn.textContent = 'Restart Watcher';
btn.disabled = false;
}
}

async function overviewStartWatcher(btn) {
btn.disabled = true;
Expand Down Expand Up @@ -555,6 +506,52 @@ <h2>Watcher Status</h2>
}
}

async function overviewRestartWatcher(btn) {
const originalText = btn.textContent;
btn.disabled = true;
btn.textContent = 'Restarting...';
try {
const stopResp = await fetch('/api/watcher/stop', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ workspace: WorkspaceContext.active })
});
if (!stopResp.ok) {
const data = await stopResp.json().catch(() => ({}));
btn.textContent = data.error || 'Stop failed';
setTimeout(() => { btn.textContent = originalText; btn.disabled = false; }, 5000);
return;
}
const stopped = await waitForWatcherState(false, { maxAttempts: 20, intervalMs: 1000 });
if (!stopped) {
btn.textContent = 'Stop timed out';
setTimeout(() => { btn.textContent = originalText; btn.disabled = false; }, 5000);
return;
}
const startResp = await fetch('/api/watcher/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ workspace: WorkspaceContext.active })
});
if (!startResp.ok) {
const data = await startResp.json().catch(() => ({}));
btn.textContent = data.error || 'Failed';
setTimeout(() => { btn.textContent = originalText; btn.disabled = false; }, 5000);
return;
}
const started = await waitForWatcherState(true);
if (started) {
loadAllWithOverview();
} else {
btn.textContent = 'Timed out';
setTimeout(() => { btn.textContent = originalText; btn.disabled = false; }, 5000);
}
} catch (err) {
btn.textContent = 'Error';
setTimeout(() => { btn.textContent = originalText; btn.disabled = false; }, 5000);
}
}

async function overviewRestartZoekt(btn) {
btn.disabled = true;
btn.textContent = 'Restarting...';
Expand Down
Loading