fix(autostart): Windows self-healing and plugin-first call order#27
fix(autostart): Windows self-healing and plugin-first call order#27shiqkuangsan merged 2 commits intomainfrom
Conversation
…acOS Windows lacks macOS hudWindow effect, leaving the HUD fully transparent. Add platform-conditional rendering: macOS keeps native frosted glass, Windows gets self-drawn bg-black/50-60 + backdrop-blur-xl fallback. Closes: https://gitee.com/shiqkuangsan/Recopy/issues/IG02HT
- Rust setup(): re-register autostart on Windows if DB says enabled, compensating for registry entries lost after reboot (upstream bug) - settings-store: call enable()/disable() BEFORE persisting to DB, so plugin failure prevents stale UI state - settings-store: verify with isEnabled() after enable, warn on mismatch - Add test for plugin failure preventing DB write Closes #25
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR addresses Windows autostart failures by implementing startup self-healing (re-enabling autostart on app launch), reordering plugin operations to precede database persistence, and applying OS-specific UI styling adjustments for non-macOS platforms. Changes
Sequence Diagram(s)sequenceDiagram
participant App as App Startup
participant DB as Database
participant Plugin as Autostart Plugin
participant Log as Logger
App->>DB: Query auto_start setting
DB-->>App: Returns "true" or "false"
alt auto_start = "true"
App->>Plugin: Call enable()
Plugin-->>App: Success/Error
alt Enable succeeded
App->>Log: Log info message
else Enable failed
App->>Log: Log warn message
end
else auto_start = "false"
Note over App: No action taken
end
sequenceDiagram
participant UI as Settings UI
participant Store as Zustand Store
participant Plugin as Autostart Plugin
participant DB as Database
UI->>Store: updateSetting("auto_start", value)
alt auto_start = "true"
Store->>Plugin: Call enableAutostart()
Plugin-->>Store: Success/Error
alt Enable succeeded
Store->>Plugin: Call isAutostartEnabled()
Plugin-->>Store: Enabled state
alt State matches
Store->>DB: invoke("set_setting", {key, value})
DB-->>Store: Persisted
Store->>Store: Update local state
else State mismatch
Store->>Store: console.warn()
Note over Store: State persisted but system mismatch
end
else Enable failed
Store->>Store: console.error()
Note over Store: Return without persistence
end
else auto_start = "false"
Store->>Plugin: Call disableAutostart()
Plugin-->>Store: Success/Error
alt Disable succeeded
Store->>DB: invoke("set_setting", {key, value})
DB-->>Store: Persisted
Store->>Store: Update local state
else Disable failed
Store->>Store: console.error()
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/App.tsx (1)
244-244: Consider hoistingplatform()call outside the component or memoizing it.
platform()is synchronous and returns a constant value that never changes during the app's lifetime. Calling it on every render is wasteful, albeit cheap. Consider moving it outside the component:♻️ Suggested refactor
+const isMac = platform() === "macos"; + function HudApp() { const { t } = useTranslation(); const loadSettings = useSettingsStore((s) => s.loadSettings); - const isMac = platform() === "macos";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/App.tsx` at line 244, The call to platform() is being invoked on every render to compute const isMac = platform() === "macos"; — hoist this call outside the React component (e.g., compute a top-level const PLATFORM = platform(); const isMac = PLATFORM === "macos";) or memoize it with useMemo if it must stay inside the component; update references to use the new top-level PLATFORM/isMac variable so platform() is not executed on each render and behavior remains identical.src/stores/__tests__/settings-store.test.ts (1)
33-46: Consider addingshow_tray_iconto test DEFAULT_SETTINGS for consistency.The test's
DEFAULT_SETTINGSis missing theshow_tray_iconproperty that exists in the actual store defaults (line 41 insettings-store.ts). While this doesn't break tests due tobeforeEachstate reset, keeping them in sync improves maintainability.🔧 Suggested fix
const DEFAULT_SETTINGS: Settings = { shortcut: "CommandOrControl+Shift+V", auto_start: "false", theme: "system", language: "system", retention_policy: "unlimited", retention_days: "0", retention_count: "0", max_item_size_mb: "10", close_on_blur: "true", update_check_interval: "weekly", panel_position: "bottom", flat_mode_tb: "false", + show_tray_icon: "true", };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/stores/__tests__/settings-store.test.ts` around lines 33 - 46, The DEFAULT_SETTINGS object used in the test is missing the show_tray_icon property present in the real store defaults; update the test's DEFAULT_SETTINGS constant to include show_tray_icon with the same default value used in settings-store.ts so the test defaults mirror the store (locate DEFAULT_SETTINGS in src/stores/__tests__/settings-store.test.ts and add the show_tray_icon key/value to match the store).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/App.tsx`:
- Line 244: The call to platform() is being invoked on every render to compute
const isMac = platform() === "macos"; — hoist this call outside the React
component (e.g., compute a top-level const PLATFORM = platform(); const isMac =
PLATFORM === "macos";) or memoize it with useMemo if it must stay inside the
component; update references to use the new top-level PLATFORM/isMac variable so
platform() is not executed on each render and behavior remains identical.
In `@src/stores/__tests__/settings-store.test.ts`:
- Around line 33-46: The DEFAULT_SETTINGS object used in the test is missing the
show_tray_icon property present in the real store defaults; update the test's
DEFAULT_SETTINGS constant to include show_tray_icon with the same default value
used in settings-store.ts so the test defaults mirror the store (locate
DEFAULT_SETTINGS in src/stores/__tests__/settings-store.test.ts and add the
show_tray_icon key/value to match the store).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6fdcb16e-e8c0-4fd9-87e9-c06a5050c742
📒 Files selected for processing (4)
src-tauri/src/lib.rssrc/App.tsxsrc/stores/__tests__/settings-store.test.tssrc/stores/settings-store.ts
Summary
enable()if DB hasauto_start=trueto repair registry entries silently deleted after first boot (upstream plugins-workspace#771)auto_start, call platform plugin first; only write DB/UI on success — prevents false "enabled" stateenable(), verify withisEnabled()and warn if verification failsisEnabledmock, assert DB not updated when plugin fails, verify UI state consistencyTest plan
npx tsc --noEmitpassesnpx vitest run— 270 tests pass (1 new)cargo test— 38 tests passFixes #25
Summary by CodeRabbit
Bug Fixes
New Features