MCPcopy Create free account
hub / github.com/Microck/opencode-studio / connect

Function connect

client-next/src/app/logs/page.tsx:29–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 useEffect(() => {
28 let active = true;
29 const connect = async () => {
30 try {
31 const base = await getApiBaseUrl();
32 if (!active) return;
33 const source = new EventSource(`${base}/logs/stream`);
34 eventSourceRef.current = source;
35
36 source.onmessage = (event) => {
37 if (paused) return;
38 try {
39 const entry = JSON.parse(event.data) as LogEntry;
40 setLogs((prev) => [...prev.slice(-500), entry]);
41 } catch {
42 // ignore parse errors
43 }
44 };
45
46 source.onerror = () => {
47 toast.error("Log stream disconnected");
48 };
49 } catch (err: any) {
50 toast.error(err?.message || "Failed to connect to logs");
51 }
52 };
53
54 connect();
55 return () => {

Callers 1

LogsPageFunction · 0.85

Calls 1

getApiBaseUrlFunction · 0.90

Tested by

no test coverage detected