Skip to content

fix(desktop): load designs on app startup so persisted work reappears#99

Merged
hqhq1025 merged 1 commit intomainfrom
wt/fix-app-load-designs
Apr 19, 2026
Merged

fix(desktop): load designs on app startup so persisted work reappears#99
hqhq1025 merged 1 commit intomainfrom
wt/fix-app-load-designs

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Symptom

Users reported "退出再进来 design 都没了" — generated designs were correctly persisted to SQLite (design_snapshots rows confirmed present), but on relaunch the hub appeared empty.

Root cause

apps/desktop/src/renderer/src/App.tsx only invoked loadConfig() in the startup useEffect. The store already had loadDesigns() (which calls window.codesign.snapshots.listDesigns() and populates designs), but nothing in the renderer ever called it on mount. So the in-memory list stayed empty even though the DB had rows.

Fix

  • App startup effect now runs loadConfig and loadDesigns in parallel.
  • After they resolve, if currentDesignId is null and at least one persisted design exists, auto-switchDesign to the most recent one (first item — listDesigns is already sorted by activity), so users land back on their last work.
  • Added a Vitest case in store.test.ts that stubs listDesigns to return 2 rows and verifies state.designs.length === 2 plus designsLoaded === true.

This completes the persistence flow opened by #93.

Four checks

  • Compatibility: green — no IPC / schema changes, only renderer wiring.
  • Upgradeability: green — uses existing loadDesigns / switchDesign actions.
  • No bloat: green — no new deps, ~10 lines added in App.tsx.
  • Elegance: green — reuses existing store actions; explicit, no factories.

Test plan

  • pnpm test — 293 passed (was 292; +1 new case).
  • pnpm lint — passes (existing warnings only).
  • Manual: start app → create design → quit → relaunch → confirm design appears in hub and last design is restored.

@hqhq1025 hqhq1025 merged commit f491b22 into main Apr 19, 2026
4 of 5 checks passed
@hqhq1025 hqhq1025 deleted the wt/fix-app-load-designs branch April 19, 2026 08:00
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No high-confidence issues found in added/modified lines.

Summary

  • Review mode: initial
  • No issues found in the latest diff.
  • Residual risks/testing gaps: docs/VISION.md and docs/PRINCIPLES.md are Not found in repo/docs in this checkout, so principle-level conformance could not be fully verified from local files; added coverage validates loadDesigns() state population but does not include an integration-level assertion for App startup bootstrap ordering (loadConfig + loadDesigns + auto-switchDesign).

Testing

  • Not run (automation)

open-codesign Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant