Skip to content

refactor: convert tutorials.js to TypeScript#746

Merged
Nihal4777 merged 10 commits intoCircuitVerse:mainfrom
abhiraj75:abhiraj_branch
Jan 25, 2026
Merged

refactor: convert tutorials.js to TypeScript#746
Nihal4777 merged 10 commits intoCircuitVerse:mainfrom
abhiraj75:abhiraj_branch

Conversation

@abhiraj75
Copy link
Contributor

@abhiraj75 abhiraj75 commented Jan 8, 2026

Part Of #661

Converted src/simulator/src/tutorials.js to TypeScript(tutorials.ts).
No logic or runtime behaviour changes , only type annotations and interfaces added.

Frontend build passes locally.

Summary by CodeRabbit

  • Bug Fixes

    • Improved stability of the tutorial guide with additional runtime guards and safer DOM interaction handling to prevent errors during walkthroughs.
  • Refactor

    • Tightened typing and signatures for tutorial APIs to make behavior more predictable and maintainable.
  • Documentation

    • Added descriptive comments and JSDoc to clarify tutorial flows and usage.

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

@netlify
Copy link

netlify bot commented Jan 8, 2026

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit a45f99c
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/69760a14c7c8fa00084e8620
😎 Deploy Preview https://deploy-preview-746--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: 43 (🟢 up 10 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 Jan 8, 2026

Walkthrough

The file src/simulator/src/tutorials.ts was updated to add JSDoc and explicit typings: tour is now Driver.Step[]. tutorialWrapper and showTourGuide were refactored with explicit void return types and JSDoc. Runtime guards and null checks were added for DOM interactions (e.g., .panelHeader, .icon, maximize button) and localStorage access; tutorialWrapper computes offsets and builds a local Driver.Step before highlighting. The first tour step’s className was moved into popover.className, and the localStorage key was changed to tutorials_tour_done.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main objective: converting a JavaScript file (tutorials.js) to TypeScript (tutorials.ts) with type annotations and JSDoc improvements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/simulator/src/tutorials.ts (1)

106-131: Add runtime safety checks for DOM queries and type casts.

Multiple unsafe operations that could cause runtime errors:

  1. Line 106: Non-null assertion on .querySelector('.panelHeader') assumes the element exists
  2. Line 108: e.target as HTMLElement cast without validation - the target could be a text node or other non-HTMLElement
  3. Lines 118-119: nextElementSibling as HTMLElement cast without checking if it exists
  4. Line 128: Non-null assertion on .querySelector('.icon') without validation

If any element is missing or the wrong type, these will throw TypeError at runtime.

🛡️ Recommended defensive checks
 export const tutorialWrapper = (): void => {
     const panelHighlight = new Driver()
-    document.querySelector('.panelHeader')!.addEventListener('click', (e:Event) => {
+    const panelHeader = document.querySelector('.panelHeader')
+    if (!panelHeader) return
+    
+    panelHeader.addEventListener('click', (e:Event) => {
         if (localStorage.tutorials === 'next') {
-            const target = e.target as HTMLElement
+            const target = e.target
+            if (!(target instanceof HTMLElement)) return
+            
+            const nextSibling = target.nextElementSibling
+            if (!(nextSibling instanceof HTMLElement)) return
+            
             panelHighlight.highlight({
                 element: '#guide_1',
                 showButtons: false,
                 popover: {
                     title: 'Here are the elements',
                     description:
                         'Select any element by clicking on it & then click anywhere on the grid to place the element.',
                     position: 'right',
                     offset:
-                        (target.nextElementSibling as HTMLElement).offsetHeight +
+                        nextSibling.offsetHeight +
                         target.offsetTop -
                         45,
                 },
             })
             localStorage.setItem('tutorials', 'done')
         }
     }, {
         once: true,
       })
-    document.querySelector('.icon')!.addEventListener('click', () => {
+    const icon = document.querySelector('.icon')
+    if (icon) {
+        icon.addEventListener('click', () => {
-        panelHighlight.reset(true)
-    })
+            panelHighlight.reset(true)
+        })
+    }
 }
🤖 Fix all issues with AI agents
In @src/simulator/src/tutorials.ts:
- Line 141: The direct cast and .click() on
(document.querySelector('.draggable-panel .maximize') as HTMLElement).click()
can throw if the selector returns null; update the call to safely query the
element into a nullable variable (e.g., const el =
document.querySelector('.draggable-panel .maximize') as HTMLElement | null) and
only call el.click() when el is non-null (optionally handle the null case with a
safe fallback or a log message) so the runtime won't raise a TypeError.
- Line 144: The code stores the flag using
localStorage.setItem('tutorials_tour_done', String(true)) which is inconsistent
with earlier versions; change this to store the boolean-style value consistently
(e.g., localStorage.setItem('tutorials_tour_done', true) or use the agreed
string token like 'done') so it matches the pattern used for other tutorial keys
and the truthiness checks in setup.js; update the call that sets
'tutorials_tour_done' accordingly.
🧹 Nitpick comments (1)
src/simulator/src/tutorials.ts (1)

1-1: Consider upgrading driver.js from 0.9.8 to 1.4.0.

The codebase uses driver.js version 0.9.8. While no security vulnerabilities were found, the latest available version is 1.4.0 (released Nov 2025), representing four major versions of improvements and updates. However, this is a major version upgrade and should be tested thoroughly for breaking changes before merging.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f071795 and 209a5b6.

📒 Files selected for processing (1)
  • src/simulator/src/tutorials.ts
🔇 Additional comments (2)
src/simulator/src/tutorials.ts (2)

3-15: LGTM! Well-structured type definitions.

The interfaces correctly capture the structure of the tour data with appropriate optional/required fields and a constrained position type.


17-17: LGTM! Explicit typing enhances type safety.

The explicit TourStep[] type annotation properly constrains the tour array structure.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/simulator/src/tutorials.ts (1)

116-140: Non-null assertions and unsafe casts may cause runtime errors.

Several DOM access patterns here could fail:

  1. Lines 116, 138: Non-null assertions (!) on querySelector will throw if elements don't exist.
  2. Line 128: nextElementSibling can be null, and casting it directly to HTMLElement before accessing offsetHeight will fail.

Consider adding null guards or optional chaining for robustness:

Proposed safer implementation
 export const tutorialWrapper = (): void => {
     const panelHighlight = new Driver()
-    document.querySelector('.panelHeader')!.addEventListener('click', (e:Event) => {
+    const panelHeader = document.querySelector('.panelHeader')
+    if (!panelHeader) return
+    
+    panelHeader.addEventListener('click', (e: Event) => {
         if (localStorage.tutorials === 'next') {
             const target = e.target as HTMLElement
+            const sibling = target.nextElementSibling as HTMLElement | null
+            if (!sibling) return
+            
             panelHighlight.highlight({
                 element: '#guide_1',
                 showButtons: false,
                 popover: {
                     title: 'Here are the elements',
                     description:
                         'Select any element by clicking on it & then click anywhere on the grid to place the element.',
                     position: 'right',
                     offset:
-                        (target.nextElementSibling as HTMLElement).offsetHeight +
-                        target.offsetTop -
+                        sibling.offsetHeight + target.offsetTop -
                         45,
                 },
             })
             localStorage.setItem('tutorials', 'done')
         }
     }, {
         once: true,
       })
-    document.querySelector('.icon')!.addEventListener('click', () => {
-        panelHighlight.reset(true)
-    })
+    const icon = document.querySelector('.icon')
+    if (icon) {
+        icon.addEventListener('click', () => {
+            panelHighlight.reset(true)
+        })
+    }
 }
🧹 Nitpick comments (1)
src/simulator/src/tutorials.ts (1)

153-162: Good null handling; consider simplifying the string conversion.

The null check for maximizeButton is the correct pattern. However, String(true) is verbose—consider using the string literal 'true' directly for clarity.

-    localStorage.setItem('tutorials', String(true))
+    localStorage.setItem('tutorials', 'true')
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 485bf7f and d941647.

📒 Files selected for processing (1)
  • src/simulator/src/tutorials.ts
🔇 Additional comments (3)
src/simulator/src/tutorials.ts (3)

3-15: Well-structured type definitions.

The interfaces accurately model the Driver.js tour step structure with appropriate optional properties and a union type for position.


22-106: LGTM!

The tour array is properly typed and all steps conform to the TourStep interface.


1-1: The project is already correctly pinned to Driver.js 0.9.x via "driver.js": "^0.9.8" in package.json, which prevents accidental upgrades to the incompatible 1.x release. The code uses the correct 0.9.x API (import Driver from 'driver.js', popover className, position, offset properties). No changes needed.

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: 2

🤖 Fix all issues with AI agents
In @src/simulator/src/tutorials.ts:
- Around line 128-130: The code accesses target.nextElementSibling as
HTMLElement without checking for null, so calling .offsetHeight may throw;
update the calculation that uses (target.nextElementSibling as
HTMLElement).offsetHeight to first test if target.nextElementSibling exists
(e.g., const sibling = target.nextElementSibling as HTMLElement | null) and use
sibling ? sibling.offsetHeight : 0 (or bail out/handle missing sibling) when
computing target.offsetTop - 45 to avoid runtime exceptions in the function that
performs this positioning.
- Line 161: The tutorial state uses two different localStorage keys ('tutorials'
and 'tutorials_tour_done'), causing inconsistent checks; standardize to the key
used by setup.js ('tutorials_tour_done') by changing all
localStorage.getItem/setItem calls in tutorials.ts that reference 'tutorials'
(the reads/writes around the functions that check/update tutorial state) to use
'tutorials_tour_done' instead, and remove any leftover writes of the old
'tutorials' key so all tutorial state reads and writes consistently use
'tutorials_tour_done'.
🧹 Nitpick comments (3)
src/simulator/src/tutorials.ts (3)

117-117: Use localStorage.getItem() for type safety.

Direct property access (localStorage.tutorials) works but is less type-safe. Prefer localStorage.getItem('tutorials') for explicit null handling.

♻️ Suggested refactor
-        if (localStorage.tutorials === 'next') {
+        if (localStorage.getItem('tutorials') === 'next') {

138-140: Apply defensive check pattern for consistency and safety.

The tutorialWrapper function uses non-null assertions on DOM selectors, but the .icon element doesn't exist in the codebase. Additionally, this approach inconsistently differs from the defensive pattern used in showTourGuide, which safely queries and checks for element existence before use.

♻️ Suggested defensive check
-    document.querySelector('.icon')!.addEventListener('click', () => {
-        panelHighlight.reset(true)
-    })
+    const iconElement = document.querySelector('.icon')
+    if (iconElement) {
+        iconElement.addEventListener('click', () => {
+            panelHighlight.reset(true)
+        })
+    }

116-116: Fix type annotation spacing and verify DOM selectors match actual element classes.

The type annotation (e:Event) should be (e: Event) per TypeScript conventions. Additionally, the non-null assertions on .panelHeader and .icon are risky—these selectors won't find elements if they don't exist. Note that the PanelHeader.vue component uses the class panel-header (kebab-case), not panelHeader, so the querySelector will fail. Since this function is currently unused but retained for future use, consider either updating the selectors to match the actual DOM structure or adding defensive null checks.

♻️ Suggested improvements
-    document.querySelector('.panelHeader')!.addEventListener('click', (e:Event) => {
+    const panelHeader = document.querySelector('.panel-header')
+    if (!panelHeader) return
+    panelHeader.addEventListener('click', (e: Event) => {
-    document.querySelector('.icon')!.addEventListener('click', () => {
+    const iconElement = document.querySelector('.icon')
+    if (!iconElement) return
+    iconElement.addEventListener('click', () => {
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d941647 and 9556063.

📒 Files selected for processing (1)
  • src/simulator/src/tutorials.ts
🔇 Additional comments (3)
src/simulator/src/tutorials.ts (3)

3-15: LGTM! Well-structured type definitions.

The TourPopover and TourStep interfaces accurately model the Driver.js tour configuration. The position union type properly constrains values, and optional fields are correctly marked.


22-22: LGTM! Proper type annotation for tour configuration.

Typing tour as TourStep[] provides compile-time safety and IDE support.


154-158: LGTM! Excellent defensive null check pattern.

The defensive check for the maximize button is well-implemented with proper type casting. This pattern prevents runtime errors and should serve as a model for other DOM queries in this file.

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: 3

🤖 Fix all issues with AI agents
In @src/simulator/src/tutorials.ts:
- Around line 139-141: The code uses a non-null assertion on
document.querySelector('.icon') before calling addEventListener, which will
throw if the element is missing; update the snippet that calls
document.querySelector('.icon')! and instead first check the returned element
(e.g., const icon = document.querySelector('.icon')) and only call
icon.addEventListener('click', ...) or use optional chaining to safely attach
the listener and then call panelHighlight.reset(true) inside that guarded block
so the listener is only added when the element exists.
- Line 116: The current use of the non-null assertion on
document.querySelector('.panelHeader') before calling addEventListener can throw
if the element is absent; change it to first get the element into a variable
(e.g., panelHeaderEl via document.querySelector('.panelHeader')) and then guard
with an existence check before calling panelHeaderEl.addEventListener(...), or
use optional chaining
(document.querySelector('.panelHeader')?.addEventListener(...)); ensure the
click handler callback remains the same.
- Line 162: The code currently sets localStorage.setItem('tutorials_tour_done',
'done') immediately when the tour starts, so users who close midway never see
the tour again; move this flag to run only when the tour is actually completed
or closed by attaching a handler to the Driver callbacks instead of setting it
at start: after calling animatedTourDriver.defineSteps(tour) and
animatedTourDriver.start(), override or wrap animatedTourDriver.onCloseClick
(and/or detect completion by wrapping animatedTourDriver.onNextClick/onPrevClick
to detect the last step) to call localStorage.setItem('tutorials_tour_done',
'done') only when the tour finishes/closed, and ensure you call the original
handlers (e.g., originalOnCloseClick) after setting the flag.
🧹 Nitpick comments (1)
src/simulator/src/tutorials.ts (1)

108-114: Consider removing or fixing unused exported function.

The function is marked as "Not used currently" but remains exported. Combined with the dead code path issue (line 117), consider either:

  1. Removing it if not needed
  2. Fixing the localStorage logic and documenting when it will be used
  3. Making it private if it's only for future internal use
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9556063 and 1ae85c9.

📒 Files selected for processing (1)
  • src/simulator/src/tutorials.ts
🔇 Additional comments (4)
src/simulator/src/tutorials.ts (4)

3-15: LGTM! Well-structured TypeScript interfaces.

The interfaces properly type the Driver.js tour structure with appropriate optional fields and constrained string literals for positioning.


22-106: LGTM! Tour array properly typed.

The tour array is correctly typed as TourStep[] and all steps conform to the interface definitions.


155-159: LGTM! Proper null checking for DOM element.

The maximizeButton access correctly guards against null with type casting and a conditional check.


117-135: Dead code: localStorage condition never satisfied.

The condition checks for 'next' but this value is never set anywhere in the codebase. The only value set is 'done' (lines 134, 162), meaning this entire code block will never execute. The function tutorialWrapper is explicitly marked as "Not used currently" and "retained for future onboarding flows", confirming this is incomplete/abandoned logic.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/simulator/src/tutorials.ts (1)

114-147: Dead code: 'next' value is never set, making the function unused.

Line 119 checks if localStorage.getItem('tutorials_tour_done') === 'next', but this value is never set anywhere in the codebase. Only 'done' (lines 136, 164) and 'true' (in legacy versions) are assigned. This means the condition will always be false.

While the code comments acknowledge this function is "Not used currently" and "retained for future onboarding flows," the dead code should either be removed or completed if intended for future use. If keeping it for future implementation, set the 'next' value appropriately in showTourGuide to make the feature functional.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ae85c9 and 43a2782.

📒 Files selected for processing (1)
  • src/simulator/src/tutorials.ts
🔇 Additional comments (3)
src/simulator/src/tutorials.ts (3)

3-15: LGTM! Well-structured TypeScript interfaces.

The interfaces provide clear type definitions for the tour configuration. The position union type properly restricts values to valid placements.


17-22: LGTM! Clear documentation and explicit typing.

The documentation comment and explicit TourStep[] typing improve code clarity and type safety.


152-170: I was unable to verify the claims in this review comment because the repository could not be accessed to search for localStorage references. To properly validate the breaking change assertion, I would need to confirm:

  1. Whether the old 'tutorials' key is actually used elsewhere in the codebase
  2. Whether the new 'tutorials_tour_done' key has migration logic already in place
  3. What the actual scope of user impact is

The review identifies a potential breaking change in the localStorage key and value format change, but without access to the full codebase context, I cannot confirm whether this migration is addressed elsewhere or if the suggested migration logic is necessary.

@abhiraj75
Copy link
Contributor Author

abhiraj75 commented Jan 8, 2026

Summary of coderabbitai requested changes

  1. TypeScript safety & doc coverage
    Added TypeScript interfaces for tutorial steps and popovers.
    Added JSDoc comments for exported constants and functions to satisfy docstring coverage requirements.
    No logic or runtime behavior changes introduced as part of the initial JS to TS conversion.

  2. Safe DOM access (runtime crash prevention)
    Removed all non-null assertions (!) on document.querySelector(...).
    Guarded DOM queries (.panelHeader, .icon, .maximize) with existence checks before calling addEventListener or .click().
    Ensured event handlers are only attached when elements exist, preventing potential TypeErrors.

  3. Safe layout calculations
    Replaced unsafe access to target.nextElementSibling.offsetHeight.
    Added a null-safe fallback (sibling ? sibling.offsetHeight : 0) when computing offsets to avoid runtime exceptions during positioning.

  4. Consistent tutorial state handling
    Standardized tutorial state storage to use a single key:
    tutorials_tour_done
    Removed all reads/writes to the legacy tutorials key.
    Aligned state handling with the expectations in setup.js.

  5. Correct tutorial completion logic
    Removed premature setting of the tutorial completion flag at tour start.
    Updated logic so tutorials_tour_done is set only when the tour is actually closed or finished, using Driver.js’s supported lifecycle callback (onReset).
    Ensures users who exit the tour early can still see it again later.

  6. Cleanup & correctness
    Removed unused Driver instance to avoid dead code.
    Ensured all changes follow Driver.js’s public API and are TypeScript-safe.
    Preserved existing behavior where not explicitly requested to change it.

@abhiraj75
Copy link
Contributor Author

abhiraj75 commented Jan 10, 2026

Greetings @Nihal4777 , please review the changes and suggest if any changes are required. Thanks.

Copy link
Member

@Nihal4777 Nihal4777 left a comment

Choose a reason for hiding this comment

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

@abhiraj75, Thanks for the TS migration!

The library driver.js already bundles its own typings. We can probably remove the manual type declarations and rely on the bundled ones.

@abhiraj75
Copy link
Contributor Author

Sure @Nihal4777 , will look into it and get back to you!

@abhiraj75
Copy link
Contributor Author

@Nihal4777 , this migration uses Driver.js's built-in types (Driver.Step, Driver.PopoverOptions) as requested. However, the original code uses className at the Step level and showButtons in the highlight method, which aren't included in the library's type definitions. I've used intersection types (Driver.Step & { className?: string }) to preserve the original functionality while maintaining type safety. The original logic remains unchanged.

@abhiraj75 abhiraj75 requested a review from Nihal4777 January 14, 2026 15:42
@abhiraj75
Copy link
Contributor Author

Hey @Nihal4777 , I have made the changes suggested by you , please review it once and suggest if something else needs to be implemented . Thanks

@abhiraj75
Copy link
Contributor Author

Hey @Nihal4777 , please let me know if there needs to be any change with the implementation . Thanks!

@Nihal4777
Copy link
Member

Nihal4777 commented Jan 24, 2026

Hi @abhiraj75, Can you please confirm whether className in Driver.Step is actually required? If it's not required then we can remove intersection.

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: 1

🤖 Fix all issues with AI agents
In `@package.json`:
- Line 64: The package currently depends on jsdom and cross-env versions that
require Node >=20; either update the project's Node requirement or revert these
deps to Node18-compatible releases: update the package.json "engines" entry to
>=20 (and adjust CI) if you want to move to Node 20+, or pin "jsdom" to a
Node‑18 compatible version and set "cross-env" back to ^7.x so they work with
Node 18; modify the "jsdom" and "cross-env" entries (or the "engines" field)
accordingly and run install/CI to verify.
♻️ Duplicate comments (1)
src/simulator/src/tutorials.ts (1)

143-151: **Tutorial completion flag is still set at tour start, not on completion.**The PR description states that tutorials_tour_done is "now set only when tour is closed/finished using Driver.js's onReset callback," but the implementation still sets this flag immediately when start() is called (line 150). This means users who exit the tour early will never see it again.

For Driver.js 0.9.x, the onReset callback was available and would be triggered when the tour closes or resets. You should move the localStorage write into the onReset configuration option:

🐛 Proposed fix
 const animatedTourDriver = new Driver({
     animate: true,
     opacity: 0.8,
     padding: 5,
     showButtons: true,
+    onReset: () => {
+        localStorage.setItem('tutorials_tour_done', 'true')
+    },
 })

 /**
  * Launches the interactive tutorial tour for the simulator UI.
  */
 export function showTourGuide(): void {
     const maximizeButton = document.querySelector('.draggable-panel .maximize') as HTMLElement | null
     if (maximizeButton) {
         maximizeButton.click()
     }
     animatedTourDriver.defineSteps(tour)
     animatedTourDriver.start()
-    localStorage.setItem('tutorials_tour_done', 'true')
 }

@abhiraj75
Copy link
Contributor Author

hey @Nihal4777 , I've made the following changes =>
Moved className from step level into popover.className (where it belongs according to the Driver.js API)
Moved showButtons into popover.showButtons and removed the StepWithButtons type definition

Copy link
Member

@Nihal4777 Nihal4777 left a comment

Choose a reason for hiding this comment

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

Thanks @abhiraj75 for the changes. Just apply the changes in v1 as well.

@abhiraj75
Copy link
Contributor Author

Sure @Nihal4777

@abhiraj75
Copy link
Contributor Author

@Nihal4777 , Final implementation has been done as suggested by you . Please review it . Thanks!

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: 2

🤖 Fix all issues with AI agents
In `@v1/src/simulator/src/tutorials.ts`:
- Around line 98-121: The function tutorialWrapper is unused and reads/writes
localStorage keys using 'tutorials', causing inconsistent state with the active
showTourGuide() flow which uses 'tutorials_tour_done'; either remove
tutorialWrapper entirely or update its localStorage calls (both
localStorage.getItem('tutorials') and localStorage.setItem('tutorials','done'))
to use 'tutorials_tour_done' so the key matches showTourGuide(), and ensure any
future use of tutorialWrapper is actually invoked or documented.
- Around line 133-150: The completion marker is being set immediately after
animatedTourDriver.start(), so early exits are falsely recorded; instead, add an
onReset callback to the Driver options (where animatedTourDriver is constructed)
that calls localStorage.setItem('tutorials_tour_done','true') and remove the
existing localStorage.setItem call from showTourGuide; update the Driver
instantiation (the new Driver({...}) for animatedTourDriver) to include onReset:
() => { localStorage.setItem('tutorials_tour_done','true') } so the key is
written only when the tour is actually closed/reset.

@Nihal4777 Nihal4777 enabled auto-merge (squash) January 25, 2026 12:17
@Nihal4777 Nihal4777 disabled auto-merge January 25, 2026 12:18
Copy link
Member

@Nihal4777 Nihal4777 left a comment

Choose a reason for hiding this comment

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

Thanks @abhiraj75 🙌

@Nihal4777 Nihal4777 merged commit 655303c into CircuitVerse:main Jan 25, 2026
13 of 14 checks passed
@abhiraj75
Copy link
Contributor Author

abhiraj75 commented Jan 25, 2026

Thanks @Nihal4777 ! Do let me know if there is something else that I can take up ! Should I refactor the other js files in the src folder as well?

@abhiraj75 abhiraj75 deleted the abhiraj_branch branch January 26, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants