mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-18 22:48:23 +01:00
The app held every flow in memory and redid all of its work for each new one: the sidebar mounted every domain and path node (its tree scrolled inside a container that never bounded it), every tree row looked up its atoms by scanning every atom the family had made, and the layout, detail pane and list rows re-rendered per flow. At 3,000 flows each new one cost about 90 ms of main thread, more than the traffic left time for. The app now holds a window of the newest 2,000 flows, applies new ones in batches, and loads older ones in pages from the database on scrolling to the top, through a new list_flows RPC that pages in SQL. The database keeps every flow. Also adds clear_flows: an RPC, POST /flows/clear on the control API, and a Clear button in the header that Cmd+K opens, confirming first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 lines
737 B
TypeScript
16 lines
737 B
TypeScript
import type { Flow } from "@yaakapp-internal/proxy-lib";
|
|
import type { SplitLayoutLayout } from "@yaakapp-internal/ui";
|
|
import { atom } from "jotai";
|
|
import { atomWithStorage } from "jotai/utils";
|
|
|
|
/** The selected flow as last seen, kept once the window has dropped it so the detail stays */
|
|
export const selectedFlowAtom = atom<Flow | null>(null);
|
|
|
|
export const selectedFlowIdAtom = atom((get) => get(selectedFlowAtom)?.id ?? null);
|
|
|
|
/** The list follows new traffic, rather than being held where it was scrolled or selected */
|
|
export const followingAtom = atom(true);
|
|
|
|
/** Stacked by default; the header's toggle switches to side by side */
|
|
export const flowLayoutAtom = atomWithStorage<SplitLayoutLayout>("flow_layout", "vertical");
|