Proxy storage: flows table, bodies in blobs.sqlite, settings (#751)

This commit is contained in:
Gregory Schier authored and GitHub committed 2026-10-14 13:50:26 -07:00
1 parent 694c0272cd
commit b5508e6bb1
25 files changed
+942 -289

No files matched your search

@@ -1,4 +1,4 @@
import type { HttpExchange, ProxyHeader } from "@yaakapp-internal/proxy-lib";
import type { Flow } from "@yaakapp-internal/proxy-lib";
import {
Table,
TableBody,
@@ -11,7 +11,7 @@ import {
import classNames from "classnames";
interface Props {
exchanges: HttpExchange[];
exchanges: Flow[];
style?: React.CSSProperties;
className?: string;
}
@@ -40,10 +40,10 @@ export function ExchangesTable({ exchanges, style, className }: Props) {
{ex.url}
</TruncatedWideTableCell>
<TableCell>
<StatusBadge status={ex.resStatus} error={ex.error} />
<StatusBadge status={ex.status} error={ex.error} />
</TableCell>
<TableCell className="text-text-subtle text-xs">
{getContentType(ex.resHeaders)}
{getContentType(ex.contentType)}
</TableCell>
</TableRow>
))}
@@ -69,8 +69,7 @@ function StatusBadge({ status, error }: { status: number | null; error: string |
return <span className={classNames("text-xs font-mono", color)}>{status}</span>;
}
function getContentType(headers: ProxyHeader[]): string {
const ct = headers.find((h) => h.name.toLowerCase() === "content-type")?.value;
function getContentType(ct: string | null): string {
if (ct == null) return "—";
// Strip parameters (e.g. "; charset=utf-8")
return ct.split(";")[0]?.trim() ?? ct;
+5 -5
View File
@@ -1,10 +1,10 @@
import type { HttpExchange } from "@yaakapp-internal/proxy-lib";
import type { Flow } from "@yaakapp-internal/proxy-lib";
import type { TreeNode } from "@yaakapp-internal/ui";
import { selectedIdsFamily, Tree } from "@yaakapp-internal/ui";
import { atom, useAtomValue } from "jotai";
import { atomFamily } from "jotai-family";
import { useCallback } from "react";
import { httpExchangesAtom } from "../lib/store";
import { flowsAtom } from "../lib/store";
/** A node in the sidebar tree — either a domain or a path segment. */
export type SidebarItem = {
@@ -18,13 +18,13 @@ const collapsedAtom = atomFamily((_treeId: string) => atom<Record<string, boolea
export const SIDEBAR_TREE_ID = "proxy-sidebar";
const sidebarTreeAtom = atom<TreeNode<SidebarItem>>((get) => {
const exchanges = get(httpExchangesAtom);
const exchanges = get(flowsAtom);
return buildTree(exchanges);
});
/** Exchanges filtered by the currently selected sidebar node(s). */
export const filteredExchangesAtom = atom((get) => {
const exchanges = get(httpExchangesAtom);
const exchanges = get(flowsAtom);
const tree = get(sidebarTreeAtom);
const selectedIds = get(selectedIdsFamily(SIDEBAR_TREE_ID));
@@ -72,7 +72,7 @@ function collectNodes(node: TreeNode<SidebarItem>, map: Map<string, SidebarItem>
* /123
* /orders
*/
function buildTree(exchanges: HttpExchange[]): TreeNode<SidebarItem> {
function buildTree(exchanges: Flow[]): TreeNode<SidebarItem> {
const root: SidebarItem = { id: "root", label: "All Traffic", exchangeIds: [] };
const rootNode: TreeNode<SidebarItem> = {
item: root,
+4 -4
View File
@@ -1,11 +1,11 @@
import { createModelStore } from "@yaakapp-internal/model-store";
import type { HttpExchange } from "@yaakapp-internal/proxy-lib";
import type { Flow } from "@yaakapp-internal/proxy-lib";
type ProxyModels = {
http_exchange: HttpExchange;
flow: Flow;
};
export const { dataAtom, applyChange, replaceAll, listAtom, orderedListAtom } =
createModelStore<ProxyModels>(["http_exchange"]);
createModelStore<ProxyModels>(["flow"]);
export const httpExchangesAtom = orderedListAtom("http_exchange", "createdAt", "desc");
export const flowsAtom = orderedListAtom("flow", "startedAt", "desc");
+2 -4
View File
@@ -14,7 +14,7 @@ const jotaiStore = createStore();
// Load initial models from the database
void rpc("list_models", {}).then((res) => {
jotaiStore.set(dataAtom, (prev) => replaceAll(prev, "http_exchange", res.httpExchanges));
jotaiStore.set(dataAtom, (prev) => replaceAll(prev, "flow", res.flows));
});
// Register hotkeys from action metadata
@@ -22,9 +22,7 @@ void initHotkeys();
// Subscribe to model change events from the backend
void listen("model_write", (payload) => {
jotaiStore.set(dataAtom, (prev) =>
applyChange(prev, "http_exchange", payload.model, payload.change),
);
jotaiStore.set(dataAtom, (prev) => applyChange(prev, "flow", payload.model, payload.change));
});
const motionFeatures = () => import("framer-motion").then((mod) => mod.domAnimation);