Skip to content

Fix engagement zone rotation stacking, modal lifecycle bug, and upgrade Rollup to v4#99

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-engagement-zone-rotation-bugs
Draft

Fix engagement zone rotation stacking, modal lifecycle bug, and upgrade Rollup to v4#99
Copilot wants to merge 2 commits intomainfrom
copilot/fix-engagement-zone-rotation-bugs

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

Three reliability and maintainability issues: stacking setInterval calls could cause the engagement zone carousel to accelerate on repeated updateModalOptions calls; handleRootClick calling getModal() could silently recreate a removed modal on any body click; Rollup v2 is EOL with no security patches.

Fixes

  • Interval stacking (modal.ts): Call stopEngagementZoneRotation() at the top of startEngagementZoneRotation() so repeated calls never accumulate concurrent intervals:

    private startEngagementZoneRotation() {
      this.stopEngagementZoneRotation(); // clear before (re)starting
      if (this._engagementZones.length <= 1) return;
      this._engagementZoneRotationIntervalId = setInterval(...);
    }
  • Accidental modal recreation (modal-manager.ts): Replace this.getModal() in handleRootClick with a direct null-guarded check on this.modalElement, so a stray body click after modal removal is a no-op rather than recreating the element:

    private handleRootClick = (event: MouseEvent) => {
      if (this.modalElement && !this.modalElement.contains(event.target as Node)) {
        this.removeModal();
      }
    };
  • Rollup upgrade (package.json): Bump rollup from ^2.73.0^4.60.0, @rollup/plugin-node-resolve from ^13.3.0^16.0.3 (required for Rollup v4 peer compatibility), and rollup-plugin-summary from ^1.4.3^3.0.1.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature][Medium] Fix engagement zone rotation stacking, modal lifecycle bugs, and outdated Rollup</issue_title>
<issue_description>## Summary

Three related code quality and bug findings that affect widget reliability and maintainability:

1. Engagement Zone Rotation Intervals Can Stack (Bug)

File: src/modal/modal.ts, lines 173-179, 224-227

startEngagementZoneRotation() calls setInterval without first clearing any existing interval. handleImageLoad() (line 224) calls startEngagementZoneRotation() without calling stopEngagementZoneRotation() first. If preloadEngagementZoneImages() is called multiple times (via updateModalOptions, line 140), multiple intervals stack, causing increasingly rapid rotation.

Fix: Call stopEngagementZoneRotation() at the beginning of startEngagementZoneRotation().

2. Body Click Handler May Inadvertently Recreate Modal

File: src/modal/modal-manager.ts, lines 93-98

handleRootClick calls this.getModal() which creates a new modal element if one does not exist. Clicking anywhere on the body after modal removal could inadvertently recreate it.

Fix: Use this.modalElement directly with a null check instead of this.getModal():

private handleRootClick = (event: MouseEvent) => {
  if (this.modalElement && !this.modalElement.contains(event.target as Node)) {
    this.removeModal();
  }
};

3. Rollup v2 is Outdated and No Longer Receiving Security Patches

File: package.json, line 62

"rollup": "^2.73.0" — Rollup v2 has been superseded by v4 (stable since late 2023). V2 no longer receives security patches. Several plugins are also at outdated major versions.

Fix: Upgrade to Rollup v4 along with compatible plugin versions (@rollup/plugin-node-resolve, @rollup/plugin-terser, etc.).

Expected Impact

  • Prevents engagement zone carousel from accelerating unexpectedly
  • Eliminates accidental modal recreation on stray body clicks
  • Gains better tree-shaking, faster builds, and security patches via Rollup v4

References

Generated by Heart Beat with Omni</issue_description>

Comments on the Issue (you are @copilot in this section)


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

…de Rollup v2 to v4

Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
Agent-Logs-Url: https://github.com/numbersprotocol/capture-eye/sessions/ce8d7a2a-a77e-48e9-9524-c8682b79874b
Copilot AI changed the title [WIP] Fix engagement zone rotation stacking and modal lifecycle bugs Fix engagement zone rotation stacking, modal lifecycle bug, and upgrade Rollup to v4 Mar 25, 2026
Copilot AI requested a review from numbers-official March 25, 2026 13:49
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.

[Feature][Medium] Fix engagement zone rotation stacking, modal lifecycle bugs, and outdated Rollup

2 participants