Skip to content

Conversation

@akritah
Copy link

@akritah akritah commented Dec 2, 2025

Fix: Prevent Duplicate Confirmation Popup When Creating New Project (#399)
resolves the issue where users were seeing two confirmation dialogs when creating a new project.

Summary of Fixes

  • Added a skipConfirm parameter to clearProject() to ensure only one confirm dialog is shown when newProject() calls it.
  • Set projectSaved = true before window.location.assign() to prevent the browser’s native “Leave site?” alert.
  • Added a test to ensure newProject() triggers only one confirmation.

Files Updated

  • src/simulator/src/data/project.ts
  • v0/src/simulator/src/data/project.ts
  • v1/src/simulator/src/data/project.ts
  • Added test for confirmation behavior

CircuitVerse - Google Chrome 2025-12-03 00-16-47

Summary by CodeRabbit

  • Bug Fixes
    • New project creation streamlined: users can now initiate new projects without confirmation prompts, enabling faster workflow transitions
    • Unsaved data experience: removed browser confirmation dialogs when leaving pages with unsaved changes for cleaner navigation
    • Data protection maintained: automatic recovery mechanism for unsaved work continues functioning reliably in the background
    • Project management: enhanced transitions between projects with reduced confirmation requirements

✏️ Tip: You can customize this high-level summary in your review settings.

…ct (CircuitVerse#399)

- add optional skipConfirm parameter to clearProject()
- set projectSaved = true before window.location.assign() in newProject()
- add unit test to assert confirmOption is called only once
@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 045385c
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/692f4bf7e7675f0008fe7604
😎 Deploy Preview https://deploy-preview-683--circuitverse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 44 (no change from production)
Accessibility: 73 (no change from production)
Best Practices: 92 (no change from production)
SEO: 82 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Walkthrough

Three variants of project.ts have been updated to modify the clearProject() function signature to accept an optional skipConfirm parameter (default false). When true, it skips the confirmation dialog. The newProject() function now calls clearProject(true) and sets related state values including projectSaved to true.

Changes

Cohort / File(s) Change Summary
Project state management updates
src/simulator/src/data/project.ts, v0/src/simulator/src/data/project.ts, v1/src/simulator/src/data/project.ts
Modified clearProject() to accept optional skipConfirm: boolean = false parameter; confirmation dialog is skipped when parameter is true. Updated newProject() to call clearProject(true) instead of clearProject(). Added state updates: projectSaved = true and onbeforeunload handler reset. Changed onbeforeunload behavior to return undefined in both branches, removing user prompt flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Review consistency of parameter implementation across all three file variants
  • Verify conditional logic correctly skips confirmation when skipConfirm is true
  • Confirm state management updates (projectSaved, onbeforeunload reset) are applied in correct order within newProject flow

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main fix: preventing duplicate confirmation modals when creating a new project, which directly addresses the primary change across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
v1/src/simulator/src/data/project.ts (2)

141-153: Same skipConfirm behavior as v0 — looks good

This matches the v0 implementation; see the v0 comment on clearProject for details. No additional issues here.


158-170: Same newProject flow as v0 — consider await clearProject(true)

This is identical to the v0 newProject changes; the same suggestion about awaiting clearProject(true) for future‑proofing applies.

🧹 Nitpick comments (3)
v0/src/simulator/src/data/project.ts (1)

158-170: Consider awaiting clearProject(true) for clarity/future‑proofing

Right now clearProject(true) executes synchronously on this path, so not awaiting it is functionally safe. However, since clearProject is async, a future change that adds await to its skipConfirm path could introduce subtle ordering bugs (e.g., if more async cleanup is added).

I’d recommend:

-        clearProject(true)
+        await clearProject(true)

to make the intent explicit and robust to future changes.

src/simulator/src/data/project.ts (2)

123-132: onbeforeunload no longer warns users about unsaved changes

Changing onbeforeunload to always return undefined removes both the explicit alert and the browser’s native “Leave site?” prompt. Unsaved data is still written to localStorage for recovery, but users now leave the page without any warning if recovery fails or is unexpected.

If the goal was only to avoid extra dialogs when starting a new project, this is a broader UX change that affects all navigation paths (tab close, URL change, back/forward, etc.). Please confirm this is intentional; otherwise you may want to keep a lightweight warning here or gate this behavior specifically for the new‑project flow (where you already set projectSaved = true and clear onbeforeunload).


136-164: clearProject skipConfirm and newProject flow look correct; consider awaiting

The skipConfirm parameter and its usage in newProject behave as intended: newProject now shows a single confirmation and then calls clearProject(true) without triggering a second dialog, while also clearing recover, marking projectSaved = true, and disabling onbeforeunload before navigating.

As in v0/v1, I’d recommend:

-        clearProject(true)
+        await clearProject(true)

in newProject (Line 160) to keep the order of operations robust if clearProject later gains additional async work in the skipConfirm path.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11b4883 and 045385c.

📒 Files selected for processing (3)
  • src/simulator/src/data/project.ts (2 hunks)
  • v0/src/simulator/src/data/project.ts (2 hunks)
  • v1/src/simulator/src/data/project.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
v1/src/simulator/src/data/project.ts (2)
src/simulator/src/data/project.ts (1)
  • clearProject (138-146)
v0/src/simulator/src/data/project.ts (1)
  • clearProject (145-153)
🔇 Additional comments (1)
v0/src/simulator/src/data/project.ts (1)

141-153: clearProject skipConfirm behavior looks correct

The skipConfirm parameter with short‑circuiting (skipConfirm || await confirmOption(...)) cleanly preserves existing behavior while allowing callers (like newProject) to bypass the dialog. No functional issues spotted here.

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