MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / readReaderLevel

Function readReaderLevel

graph-ui/src/twin/reader-level-store.ts:42–60  ·  view source on GitHub ↗
(store: KeyValueStore)

Source from the content-addressed store, hash-verified

40
41/** What this browser last said, or the default when it said nothing usable. */
42export function readReaderLevel(store: KeyValueStore): DepthLevel {
43 let raw: string | null;
44 try {
45 raw = store.getItem(READER_LEVEL_KEY);
46 } catch {
47 return READER_LEVEL_DEFAULT;
48 }
49 // An empty entry is not a zero. `Number('')` is 0, and a browser that
50 // wrote a blank would otherwise hand every reader the vibe coder's level
51 // and call it their choice.
52 if (raw === null || raw.trim().length === 0) {
53 return READER_LEVEL_DEFAULT;
54 }
55 const value = Number(raw);
56 if (!Number.isInteger(value) || value < 0 || value > MAX_DEPTH) {
57 return READER_LEVEL_DEFAULT;
58 }
59 return clampDepth(value);
60}
61
62/**
63 * Remember the level. A storage that refuses is not an error worth showing.

Callers 2

TwinPanelFunction · 0.90

Calls 2

clampDepthFunction · 0.90
getItemMethod · 0.65

Tested by

no test coverage detected