-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsidepanel.js
More file actions
45 lines (40 loc) · 1.34 KB
/
sidepanel.js
File metadata and controls
45 lines (40 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { initSettingsUI, initMenu, startLogStreaming, getEls, setRunning, logToUI, stopStreaming, streamText } from './lib/ui.js';
import { loadSettings, state } from './lib/state.js';
import { startAutoRun } from './lib/agent.js';
document.addEventListener('DOMContentLoaded', async () => {
await loadSettings();
initSettingsUI();
initMenu();
startLogStreaming();
const els = getEls();
if (els.sendBtn) {
els.sendBtn.addEventListener("click", async () => {
const running = document.body.classList.contains("running");
if (running) {
state.autoStop = true;
stopStreaming();
// streamText("\nStopped in middle.\n"); // Deprecated
import('./lib/ui.js').then(m => m.showStopped("Stopped manually"));
await setRunning(false);
return;
}
await startAutoRun();
});
}
if (els.instruction) {
els.instruction.addEventListener("keydown", async (e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
const running = document.body.classList.contains("running");
if (running) {
state.autoStop = true;
stopStreaming();
import('./lib/ui.js').then(m => m.showStopped("Stopped manually"));
await setRunning(false);
} else {
await startAutoRun();
}
}
});
}
});