feat: right-click menus everywhere, workspace/session cost, long-term DB safety

Right-click menus: one portal shell (components/ContextMenu.tsx) for every
item with actions - sidebar/Recents/archived session rows (SessionMenu),
console tabs, pane headers, the Changes panel's files/tree/commits, the
workspace home, sessions outside a workspace (SessionRowMenu: Sessions
table, Dashboard, Activity, Workflow runs), prompt images, every Settings
list and every Claude Code/Codex config list (FileItemMenu). Buttons stay;
a delete keeps its button's confirm; the shell stops portal clicks from
reaching the card that opened it.

Status bar: Workspace $ and Session $ on the Workspace page, from
?lane= on GET /api/pricing/cost and the focused/replayed session's cost.

Database, no data dropped: synchronous=NORMAL, journal_size_limit 64 MB,
hourly PASSIVE checkpoint + PRAGMA optimize, idx_events_session_created
(replacing the redundant idx_events_session), watchdog reads
sessions.transcript_path, transcript parsed before the hook's write
transaction, GET /api/sessions/:id?events=0 for the web page (reloads only
on its own session, debounced), streamed export, transactional clear-data
and chunked cleanup, subagent import reads tool_use_ids once, runtime logs
rotated past 5 MB.
This commit is contained in:
2026-10-05 09:37:48 +07:00
parent 65fe680d38
commit ad6e80192d
80 changed files with 2914 additions and 489 deletions
+16 -3
View File
@@ -185,6 +185,7 @@ export function SessionDetail() {
const eventApiParamsRef = useRef<Record<string, unknown> | null>(null);
const eventsLoadedCountRef = useRef(0);
const eventsRefreshTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const loadTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
eventsLoadedCountRef.current = events.length;
const goBack = useCallback(() => {
const historyState =
@@ -240,7 +241,9 @@ export function SessionDetail() {
if (!id) return;
try {
const [data, costData] = await Promise.all([
api.sessions.get(id),
// The page reads its timeline through the paginated events call; the
// whole-session list (MBs on a long session) is not shipped here.
api.sessions.get(id, { events: false }),
api.pricing.sessionCost(id).catch(() => null),
]);
setSession(data.session);
@@ -505,12 +508,21 @@ export function SessionDetail() {
}, EVENTS_REFRESH_DEBOUNCE_MS);
return;
}
// Only this session's messages: every hook of every session broadcasts,
// and a reload per message re-read this page's whole session each time.
const d = msg.data as { id?: string; session_id?: string } | undefined;
const mine = d?.session_id === id || (msg.type === "session_updated" && d?.id === id);
if (!mine) return;
if (
msg.type === "agent_created" ||
msg.type === "agent_updated" ||
msg.type === "session_updated"
) {
load();
if (loadTimerRef.current) clearTimeout(loadTimerRef.current);
loadTimerRef.current = setTimeout(() => {
loadTimerRef.current = null;
load();
}, EVENTS_REFRESH_DEBOUNCE_MS);
}
if (msg.type === "new_event") {
// Debounce bursts into one filter-aware refetch that preserves the
@@ -524,12 +536,13 @@ export function SessionDetail() {
});
return () => {
unsubscribe();
if (loadTimerRef.current) clearTimeout(loadTimerRef.current);
if (eventsRefreshTimerRef.current) {
clearTimeout(eventsRefreshTimerRef.current);
eventsRefreshTimerRef.current = null;
}
};
}, [load, refreshEventsWithPagination]);
}, [id, load, refreshEventsWithPagination]);
if (loading) {
return (