From 13dd7915bdc12132830f4770d785ffd422732661 Mon Sep 17 00:00:00 2001 From: lefarcen <935902669@qq.com> Date: Wed, 25 Mar 2026 19:56:34 +0800 Subject: [PATCH] fix: prevent nexu modal from re-showing on SPA navigation and rename button text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use sessionStorage to ensure the modal only appears once per browser session, preventing it from popping up when switching sidebar tabs. Also rename "Download nexu" to "Get nexu" (en) / "前往 nexu" (zh-Hans). Co-Authored-By: Claude Opus 4.6 (1M context) --- .../src/components/nexu-promotion/NexuModal.tsx | 10 +++++++++- packages/i18n/src/en-US/ui.ts | 2 +- packages/i18n/src/zh-Hans/ui.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/ai-workspace-common/src/components/nexu-promotion/NexuModal.tsx b/packages/ai-workspace-common/src/components/nexu-promotion/NexuModal.tsx index d5c9bd57a..a1904d24f 100644 --- a/packages/ai-workspace-common/src/components/nexu-promotion/NexuModal.tsx +++ b/packages/ai-workspace-common/src/components/nexu-promotion/NexuModal.tsx @@ -8,6 +8,7 @@ import { LuMessageSquare, LuShield, LuGitFork } from 'react-icons/lu'; const NEXU_URL = 'https://nexu.io'; const STORAGE_KEY = 'nexu_modal_dismissed'; +const SESSION_KEY = 'nexu_modal_shown_this_session'; interface NexuModalProps { open?: boolean; @@ -19,15 +20,22 @@ export const NexuModal = memo(({ open: controlledOpen }: NexuModalProps) => { const [neverShow, setNeverShow] = useState(false); useEffect(() => { - // Check if user has dismissed the modal before + // Check if user has permanently dismissed the modal const dismissed = localStorage.getItem(STORAGE_KEY); if (dismissed === 'true') { return; } + // Only show once per browser session (avoid re-showing on SPA navigation) + const shownThisSession = sessionStorage.getItem(SESSION_KEY); + if (shownThisSession === 'true') { + return; + } + // Show modal after a short delay const timer = setTimeout(() => { setVisible(true); + sessionStorage.setItem(SESSION_KEY, 'true'); logEvent('refly_nexu_workbench_modal_shown'); }, 1000); diff --git a/packages/i18n/src/en-US/ui.ts b/packages/i18n/src/en-US/ui.ts index 58b5abe7b..3e0812474 100644 --- a/packages/i18n/src/en-US/ui.ts +++ b/packages/i18n/src/en-US/ui.ts @@ -4995,7 +4995,7 @@ const translations = { feature1: 'Connect WeChat / Feishu / Slack / Discord', feature2: 'Runs locally, data stays on your machine', feature3: 'MIT open source, fork and self-host friendly', - downloadBtn: 'Download nexu', + downloadBtn: 'Get nexu', neverShow: "Got it, don't show again", }, guest: { diff --git a/packages/i18n/src/zh-Hans/ui.ts b/packages/i18n/src/zh-Hans/ui.ts index a05b2cbbc..769735353 100644 --- a/packages/i18n/src/zh-Hans/ui.ts +++ b/packages/i18n/src/zh-Hans/ui.ts @@ -5005,7 +5005,7 @@ const translations = { feature1: '连接微信 / 飞书 / Slack / Discord', feature2: '本机运行,数据以本机为主', feature3: 'MIT 开源,可 fork 与自托管', - downloadBtn: '去 nexu 下载', + downloadBtn: '前往 nexu', neverShow: '我已知晓,不再弹出', }, guest: {