Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
Workflow,
ArrowRight,
Expand Down Expand Up @@ -148,6 +148,10 @@ export default function AlgorithmPage() {
const [docNote, setDocNote] = useState("");

const [regenerating, setRegenerating] = useState(false);
// The regenerate poll starts in a click handler, not an effect — hold its id
// so unmount can clear it (it otherwise runs for up to 15 minutes).
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
useEffect(() => () => { if (pollRef.current) clearInterval(pollRef.current); }, []);

const load = useCallback(() => {
fetch("/api/algorithm-tab")
Expand Down Expand Up @@ -278,10 +282,12 @@ export default function AlgorithmPage() {
setData(d);
if (!d.generating || Date.now() - startedAt > 15 * 60_000) {
clearInterval(poll);
pollRef.current = null;
setRegenerating(false);
}
} catch { /* keep polling */ }
}, 5000);
pollRef.current = poll;
} catch (e: any) {
setError(String(e?.message ?? e));
setRegenerating(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function LedgerPage() {
const load = () =>
fetch("/api/ledger")
.then((r) => (r.ok ? r.json() : Promise.reject(new Error(`HTTP ${r.status}`))))
.then((j) => alive && setData(j))
.then((j) => { if (alive) { setData(j); setError(null); } })
.catch((e) => alive && setError(String(e)));
load();
const t = setInterval(load, 60_000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { Network, Search, ArrowLeft, CornerDownRight, ExternalLink, Tag, X } fro
interface MemNode { id: string; title: string; category: string; backlinkCount: number; silo: string; type: string; tags: string[]; pagerank: number }
interface MemEdge { source: string; target: string; kind: string }
interface Theme { tag: string; count: number }
interface MemGraph { nodes: MemNode[]; edges: MemEdge[]; themes: Theme[]; built: string | null; nodeCount?: number; edgeCount?: number }
// themes is optional: the no-graph fallback answers 200 with nodes/edges only.
interface MemGraph { nodes: MemNode[]; edges: MemEdge[]; themes?: Theme[]; built: string | null; nodeCount?: number; edgeCount?: number }

// Every silo's nodes are wiki-indexed, so a focused node can open as a note.
function noteUrl(node: MemNode): string | null {
Expand Down Expand Up @@ -254,7 +255,7 @@ export default function MemoryGraphPage() {
A theme is a tag running through your notes. Click one to see its members and how they connect.
</div>
<div className="flex flex-wrap gap-1.5">
{data.themes.map((t) => (
{(data.themes ?? []).map((t) => (
<button key={t.tag} onClick={() => { setTheme(theme === t.tag ? null : t.tag); setFocus(null); setTrail([]); }}
className={"px-2 py-0.5 rounded-full border text-[11px] transition-colors " + (theme === t.tag ? "border-sky-500/50 bg-sky-500/10 text-sky-300" : "border-line-2 bg-surface-2 text-ink-2 hover:border-line-3 hover:text-ink-1")}
style={font}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,25 @@ export default function CapabilityStrip() {
const [data, setData] = useState<CapabilitiesData | null>(null);
const [windowMin, setWindowMin] = useState(60);

const fetchData = useCallback(async () => {
const fetchData = useCallback(async (signal?: AbortSignal) => {
try {
const d = await localOnlyApiCall<CapabilitiesData>(
`/api/capabilities?window=${windowMin}`,
{ signal },
);
setData(d);
if (!signal?.aborted) setData(d);
} catch {
// strip stays hidden until data arrives
}
}, [windowMin]);

useEffect(() => {
fetchData();
const interval = setInterval(fetchData, 10000);
return () => clearInterval(interval);
// Aborted on window switch, so a slower response for the old window can
// never land on top of the newer one.
const ac = new AbortController();
fetchData(ac.signal);
const interval = setInterval(() => fetchData(ac.signal), 10000);
return () => { ac.abort(); clearInterval(interval); };
}, [fetchData]);

const { active, quiet } = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,8 @@ export default function WorkBoard() {
<BoardRow
key={s.sessionId}
s={s}
expanded={false}
onToggle={() => {}}
expanded={expandedId === s.sessionId}
onToggle={() => setExpandedId(expandedId === s.sessionId ? null : s.sessionId)}
/>
))}
</div>
Expand Down