Refactor: extract shared utilities, fix handler leak, accessibility#1
Open
finedesignz wants to merge 1 commit into
Open
Refactor: extract shared utilities, fix handler leak, accessibility#1finedesignz wants to merge 1 commit into
finedesignz wants to merge 1 commit into
Conversation
…bility
- Extract generateSecureToken() and hashToken() to hub/src/lib/crypto.ts
(removes 3 duplicate definitions, fixes layering violation where hashToken
lived in ws/channel.ts but was imported by API files)
- Move TIER_LIMITS to hub/src/config.ts (single source of truth)
- Fix profile PATCH to return full profile object (was returning { ok: true })
- Use -1 sentinel for unlimited tier (Infinity is not JSON-serializable)
- Parallelize independent DB queries with Promise.all (sessions, plugin)
- Extract hubFetch/authHeaders to web/src/lib/api.ts (replaces ~30 repetitive
lines across 5 hook files)
- Wrap hook mutation functions in useCallback (prevents unnecessary re-renders)
- Fix handler leak in Layout.tsx (subscribe called every render without
cleanup, handlers accumulated unboundedly)
- Fix Sidebar action buttons: span → button for keyboard accessibility
- Deduplicate LoadingScreen and goToChat in App.tsx
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
subscribe()was called every render without cleanup, accumulating handlers unboundedly. Moved intouseEffectwith proper cleanup return.generateSecureToken()andhashToken()moved tohub/src/lib/crypto.ts. Removes 3 duplicate token-generation functions and fixes layering violation wherehashTokenlived inws/channel.tsbut was imported by 3 unrelated API files.hubFetchutility — Createdweb/src/lib/api.tswithHUB_URL,authHeaders(),hubFetch(). Replaces ~30 repetitive lines across 5 hook files.{ ok: true }, causing client to clobber profile state. Now returns full profile object.TIER_LIMITS.maxwasInfinity(serializes asnullin JSON). Changed to-1sentinel with proper limit checks.Promise.all.useCallback— Prevents unnecessary re-renders downstream.<span>elements changed to<button type="button">for keyboard accessibility.LoadingScreen, removed redundantgoToChat, collapsed duplicate Layout renders.Test plan
tsc --noEmit)🤖 Generated with Claude Code