-
Notifications
You must be signed in to change notification settings - Fork 42
fix: improve theme preset loading and add tests #2079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Fix race conditions in theme preset loading - Add cleanup for async operations to prevent memory leaks - Simplify theme effect dependencies to avoid unnecessary re-renders - Add comprehensive tests for useConnectionValue hook - Ensure theme falls back correctly when preset is missing or invalid 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Vitest requires all vi.mock() calls to be at the top of the file before any other code execution. This fixes the syntax errors in CI. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Test files using JSX syntax must have .tsx extension for TypeScript to properly parse them. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Apply prettier formatting to pass CI format checks. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Apply prettier formatting to all modified files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
The Window interface with keychain_wallets is already declared in wallets.tsx. Declaring it again with a different type (unknown) causes a TypeScript compilation error. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Move mock variable declarations after vi.mock() calls and use vi.mocked() to get references to the mocked functions. This prevents "Cannot access before initialization" errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
The theme object passed to useThemeEffect is a ControllerTheme, not a VerifiableControllerTheme, so it doesn't have a verified property. Remove the invalid assertions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Set window.controller to undefined instead of creating a partial mock object. This avoids TypeScript type errors while still allowing the tests to run correctly with mocked dependencies.
| setTheme({ | ||
| verified: true, | ||
| ...defaultTheme, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Preset Verification Bypass
When a preset is active but its configuration lacks a theme, the fallback default theme is incorrectly set with verified: true. This bypasses the actual verified state of the preset, potentially hiding security warnings if the preset itself was unverified or failed to load.
Summary
Test plan
🤖 Generated with Claude Code
Note
Refactors preset config loading and theme handling with proper defaults, verification, and cleanup; adds comprehensive tests for isOriginVerified and useConnectionValue.
packages/keychain/src/hooks/connection.ts:preset, adds cancellation guard, setsverifiedfalse andconfigDatanull on missing origin or errors.verifiedviaisOriginVerifiedand gracefully handles absentoriginconfig.preset, immediately apply default theme; when loading, wait; if config hastheme, apply withverified, else fallback to default. Simplifies deps by removingtheme.nameguard.connection.test.tswithconnection.test.tsxadding tests foruseConnectionValue(preset load success, fallback, error) and retainingisOriginVerifiedcases, with necessary mocks for presets/UI, controller, and RPC.Written by Cursor Bugbot for commit 152f01a. This will update automatically on new commits. Configure here.