this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Nits: align SSE hook filename, tighten provider comment, correct client.tsx claim

Three unrelated cleanups from the review's nit pile.

use-sse-consumer.ts exported useStartSseConsumer but kept its pre-rename
filename, so the import path still read .../use-sse-consumer while the
symbol read useStartSseConsumer. Rename the file to match.

provider.tsx carried a ~10-line explanation of why it doesn't delegate
to useStartSseConsumer. The reasoning is sound, but the explanation was
longer than the code it described. Trim to the essentials.

client.tsx claimed the unauthenticated routes "don't need a WASM
context" — which is wrong. /devices/login loads WASM for seed-phrase
derivation, key generation, and OAuth. What those routes actually
skip is the OpakeProvider (FileManagerCache + SSE). Fix the comment
to say so.

+17 -20
+7 -4
apps/web/src/client.tsx
··· 1 1 // Client entry — TanStack Start hydrates the app from here. 2 2 // 3 - // Opake initialization and the OpakeProvider live in the cabinet route 4 - // layout (apps/web/src/routes/cabinet/route.lazy.tsx), not here — 5 - // unauthenticated routes (/devices/login, public /docs) don't need a 6 - // WASM context. `getOpake()` from stores/auth is the singleton bridge. 3 + // The OpakeProvider (FileManagerCache + auto-started SSE consumer) is 4 + // mounted at the cabinet route layout (apps/web/src/routes/cabinet/ 5 + // route.lazy.tsx), not here. Unauthenticated routes (/devices/login, 6 + // public /docs) still load WASM via `getOpake()` for seed-phrase 7 + // derivation, key generation, and OAuth login — they just don't need 8 + // the file-browsing context. `getOpake()` from stores/auth is the 9 + // singleton bridge. 7 10 8 11 9 12 import { StrictMode, startTransition } from "react";
packages/opake-react/src/hooks/use-sse-consumer.ts packages/opake-react/src/hooks/use-start-sse-consumer.ts
+1 -1
packages/opake-react/src/index.ts
··· 9 9 // Subscription hooks (SSE-driven, live updates) — preferred for reads 10 10 export { useFileManager } from "./hooks/use-file-manager"; 11 11 export { useDirectory } from "./hooks/use-directory"; 12 - export { useStartSseConsumer } from "./hooks/use-sse-consumer"; 12 + export { useStartSseConsumer } from "./hooks/use-start-sse-consumer"; 13 13 14 14 // Query hooks (react-query cache) — kept for mutation invalidation 15 15 // paths and workspace list. New consumers should prefer `useDirectory`
+9 -15
packages/opake-react/src/provider.tsx
··· 130 130 }; 131 131 }, [cache]); 132 132 133 - // Auto-start the WASM SSE consumer on mount. On unmount, stop the 134 - // stream and wipe the in-memory keepers so a previous user's 135 - // `ContentKey`s and decrypted directory names don't linger across 136 - // an account switch. The stop + wipe pair is intentional: stopping 137 - // the stream alone leaves the tree cached (correct for a user who's 138 - // briefly offline), while wiping alone would race against in-flight 139 - // SSE event application. 133 + // Auto-start the WASM SSE consumer on mount; on unmount, stop the 134 + // stream then wipe the keepers so a previous user's ContentKeys and 135 + // decrypted names don't linger across account switches. Separate 136 + // calls (not a single shutdown) because callers that briefly lose 137 + // network want to stop streaming without evicting decrypted state. 140 138 // 141 - // This effect intentionally duplicates part of `useStartSseConsumer` 142 - // rather than delegating. The two have different semantics: the 143 - // hook is start-only with no cleanup (so it's safe to call from 144 - // consumers that come and go), while the provider owns the full 145 - // start+stop+wipe lifecycle bound to its own mount. Unifying would 146 - // need either an option flag (sprawl) or refcounting across possible 147 - // competing callers (lifetime complexity). The ~10-line duplication 148 - // wins. 139 + // Doesn't delegate to `useStartSseConsumer` — that hook is a start- 140 + // only primitive with no cleanup (safe for ad-hoc consumers), while 141 + // the provider owns the full start+stop+wipe lifecycle bound to the 142 + // React tree. 149 143 useEffect(() => { 150 144 if (disableSseAutoStart) return; 151 145 void opake.startSseConsumer().catch((err: unknown) => {