Skip to content

fix: show one automatic modal per startup#150

Open
AlejandroAkbal wants to merge 1 commit into
mainfrom
fix/one-startup-modal
Open

fix: show one automatic modal per startup#150
AlejandroAkbal wants to merge 1 commit into
mainfrom
fix/one-startup-modal

Conversation

@AlejandroAkbal

@AlejandroAkbal AlejandroAkbal commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

  • prevent visit-count prompts from cascading after one closes
  • keep the consumed state for the current app startup
  • preserve premium prompt priority before and after automatic prompts
  • add focused regression coverage for close, recreation, and premium flows

Verification

  • pnpm format:check
  • pnpm lint
  • pnpm typecheck
  • pnpm test (148 passed, 2 todo)

Summary by CodeRabbit

  • Bug Fixes

    • Improved dialog sequencing to prevent automatic dialogs from appearing repeatedly or cascading during the same startup.
    • Premium dialogs can now temporarily take priority and correctly restore the pending automatic dialog afterward.
    • Dialog state now returns to an empty state after dialogs are consumed and closed.
  • Tests

    • Added coverage for dialog selection, opening, closing, and recreation scenarios.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0629a99a-1c0d-4fe0-912a-24d8256a4220

📥 Commits

Reviewing files that changed from the base of the PR and between d2bfd14 and cf59cf5.

📒 Files selected for processing (2)
  • app/composables/useDialogManagerState.ts
  • test/assets/dialog-manager-state.test.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (6)
test/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

test/**/*.{test,spec}.{ts,tsx}: Use Vitest with @nuxt/test-utils and Playwright browser mode for testing
Use @nuxt/test-utils with Playwright inside describe blocks calling await setup({ browser: true })
Mock server-side API calls via test-only Nitro plugin at test/server-mocks/plugin.ts injected through nuxt.config.ts $test.nitro.plugins
Use debugBrowserOptions from test/helper.ts for headful Playwright playback with slowMo in tests
Keep repository/pure modules importable through relative paths in plain Vitest suites that do not get Nuxt's runtime alias resolution
Use fetch from @nuxt/test-utils with { redirect: 'manual' } to access redirect status and Location headers; @nuxt/test-utils $fetch has no .raw method
Import localeCodes, prefixedLocaleCodes, and removedLocaleCodes from config/i18n in tests instead of hardcoding locale lists

Files:

  • test/assets/dialog-manager-state.test.ts
**/*.{vue,ts,tsx,js,jsx,json,css,scss}

📄 CodeRabbit inference engine (AGENTS.md)

Use Prettier for formatting with 120-char print width, no semicolons, single quotes, trailing commas removed, and single attribute per line in Vue templates

Files:

  • test/assets/dialog-manager-state.test.ts
  • app/composables/useDialogManagerState.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (AGENTS.md)

Use Nuxt flat ESLint via @nuxt/eslint for linting

Files:

  • test/assets/dialog-manager-state.test.ts
  • app/composables/useDialogManagerState.ts
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,vue}: Define locales in config/i18n.ts as the single source of truth; do not hardcode locale lists in application code
Use PocketBase batch writes for multi-record replacement/reorder operations instead of one HTTP write per changed row

Files:

  • test/assets/dialog-manager-state.test.ts
  • app/composables/useDialogManagerState.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: For URL validation/parsing, prefer URL.canParse() or URL.parse() over constructor try/catch
Use URL.parse() when the parsed URL object is needed, with URL.canParse() fallback in browser code if compatibility matters

Files:

  • test/assets/dialog-manager-state.test.ts
  • app/composables/useDialogManagerState.ts
app/**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

app/**/*.{vue,ts,tsx}: Use Nuxt 4 with Vue 3 and TypeScript for the frontend application
Use useLazyToast() to lazy-load vue-sonner; wait for ClientToaster to mount before calling toast.* using a proper async wait instead of plain nextTick()
Build reordered array synchronously instead of reading VueUse moveArrayElement() result before nextTick for state immediately persisted

Files:

  • app/composables/useDialogManagerState.ts
🧠 Learnings (1)
📚 Learning: 2026-06-22T07:50:54.935Z
Learnt from: AlejandroAkbal
Repo: Rule-34/App PR: 144
File: test/server/fix-canonical-queries.test.ts:174-178
Timestamp: 2026-06-22T07:50:54.935Z
Learning: In this Nuxt 3/4 project using `nuxt-schema-org` (v6.2.1), breadcrumb `source`/`itemListElement` URL values may be provided via `localePath()` (locale-relative in source code), but `nuxt-schema-org` renders JSON-LD with production-absolute URLs using `site.url` during schema rendering. When asserting JSON-LD breadcrumb `itemListElement` URLs in tests, expect production-absolute URLs (e.g., prefix with `project.urls.production.origin`), not the locale-relative `localePath()` forms. Do not flag production-absolute URL strings in JSON-LD breadcrumb tests as incorrect.

Applied to files:

  • test/assets/dialog-manager-state.test.ts
🔇 Additional comments (5)
app/composables/useDialogManagerState.ts (4)

2-14: LGTM!


28-29: LGTM!


46-48: LGTM!


58-73: LGTM!

test/assets/dialog-manager-state.test.ts (1)

1-89: LGTM!


📝 Walkthrough

Walkthrough

Changes

The dialog manager now tracks whether an automatic dialog was consumed, gives premium dialogs precedence, and restores unconsumed automatic dialogs after premium closes. Tests cover helper selection and lifecycle state transitions.

Dialog resolution state

Layer / File(s) Summary
Dialog resolution and consumption state
app/composables/useDialogManagerState.ts
Adds resolvePendingDialog, separates automatic dialog selection, tracks consumption, and updates close behavior for non-premium dialogs.
Dialog state-flow validation
test/assets/dialog-manager-state.test.ts
Adds mocked composable state and tests automatic-dialog consumption, premium preemption, restoration, and clearing.

Sequence Diagram(s)

sequenceDiagram
  participant useDialogManagerState
  participant usePremiumDialog
  participant AutomaticDialogState
  useDialogManagerState->>usePremiumDialog: read premium open state
  useDialogManagerState->>AutomaticDialogState: read automatic dialog and consumed state
  useDialogManagerState->>useDialogManagerState: resolve pending dialog
  useDialogManagerState->>AutomaticDialogState: mark automatic dialog consumed on close
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: limiting automatic modals to one per startup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/one-startup-modal
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/one-startup-modal

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.

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