Skip to content

fix: persist welcome-dismissed flag in database instead of session#1197

Open
scottbuscemi wants to merge 1 commit into
mainfrom
fix/welcome-modal-persists-across-sessions
Open

fix: persist welcome-dismissed flag in database instead of session#1197
scottbuscemi wants to merge 1 commit into
mainfrom
fix/welcome-modal-persists-across-sessions

Conversation

@scottbuscemi
Copy link
Copy Markdown
Contributor

@scottbuscemi scottbuscemi commented May 28, 2026

Problem

The "Welcome to EmDash" modal keeps reappearing on every login. After clicking "Get Started", the modal is dismissed for the current session but shows up again on the next login or when the session expires/rotates.

Root Cause

The hasSeenWelcome flag was stored in the Astro session (session?.set("hasSeenWelcome", true)), which is ephemeral. On Cloudflare, sessions are backed by KV with a TTL. When the session expires and a new one is created on the next login, the flag is lost and GET /auth/me reports isFirstLogin: true, causing the modal to reappear.

Fix

Persist the welcomeDismissed flag in the user's data JSON column in the database instead of the session. The data column already exists on the users table as a general-purpose JSON store.

GET handler: reads user.data?.welcomeDismissed instead of session?.get("hasSeenWelcome")
POST handler: writes { welcomeDismissed: true } to the user's data column via UserRepository.update() instead of session?.set()

Changes

  • packages/core/src/astro/routes/api/auth/me.ts — switch from session to database persistence
  • packages/core/tests/unit/auth/me-welcome-dismiss.test.ts — regression test that creates a user, dismisses the welcome, simulates a fresh session, and verifies isFirstLogin remains false

Playground preview won't show this being resolved since it creates a new user each time...

The welcome modal kept reappearing because the hasSeenWelcome flag was
stored in the Astro session, which is ephemeral. When the session
expired or rotated, the flag was lost and the modal showed again.

Persist the welcomeDismissed flag in the user's data JSON column so it
survives session expiry. Add a regression test that simulates a fresh
session after dismissal and verifies isFirstLogin remains false.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

⚠️ No Changeset found

Latest commit: 5a0ebfb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

PR template validation failed

Please fix the following issues by editing your PR description:

  • This PR does not use the required PR template. Please edit the description to use the PR template. Copy it into your PR description and fill out all sections.

See CONTRIBUTING.md for the full contribution policy.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 5a0ebfb May 28 2026, 07:03 PM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 28, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1197

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1197

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1197

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1197

emdash

npm i https://pkg.pr.new/emdash@1197

create-emdash

npm i https://pkg.pr.new/create-emdash@1197

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1197

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1197

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1197

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1197

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1197

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1197

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1197

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1197

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1197

commit: 5a0ebfb

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 5a0ebfb May 28 2026, 07:04 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 5a0ebfb May 28 2026, 07:06 PM

Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

You'll need to use the PR template and sign the CLA

import { authMeActionBody } from "#api/schemas.js";

export const GET: APIRoute = async ({ locals, session }) => {
import { UserRepository } from "../../../../database/repositories/user.js";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import { UserRepository } from "../../../../database/repositories/user.js";
import { UserRepository } from "#db/repositories/user.js";

@scottbuscemi
Copy link
Copy Markdown
Contributor Author

recheck

@github-actions github-actions Bot added cla: signed review/awaiting-author Reviewed; waiting on the author to respond and removed cla: needed labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core cla: signed review/awaiting-author Reviewed; waiting on the author to respond size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants