fix: nexu modal SPA navigation fix and button text update#2273
Conversation
…button text 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) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughAdded browser-session gating to the Nexu promotion modal using sessionStorage to prevent repeated displays within the same session. Updated accompanying UI translation strings in English and Simplified Chinese for the feature button label. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Deploying refly-branch-test with
|
| Latest commit: |
13dd791
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a485094b.refly-branch-test.pages.dev |
| Branch Preview URL: | https://fix-nexu-modal-improvements.refly-branch-test.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/ai-workspace-common/src/components/nexu-promotion/NexuModal.tsx`:
- Line 11: Replace the sessionStorage-based session tracking with a
module-scoped in-memory boolean so the modal can reappear after a full page
reload: remove uses of SESSION_KEY and any sessionStorage.getItem/setItem in the
NexuModal component and instead introduce a module-level flag (e.g.,
shownThisSession) that is checked/updated by the same logic currently in
NexuModal (the component/handler that reads/writes SESSION_KEY); this flag
should default to false on page load and be set to true when the modal is shown
to prevent repeats during SPA navigation while allowing re-display after a full
refresh.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 59079071-1bea-4ac4-9404-629363781958
📒 Files selected for processing (3)
packages/ai-workspace-common/src/components/nexu-promotion/NexuModal.tsxpackages/i18n/src/en-US/ui.tspackages/i18n/src/zh-Hans/ui.ts
|
|
||
| const NEXU_URL = 'https://nexu.io'; | ||
| const STORAGE_KEY = 'nexu_modal_dismissed'; | ||
| const SESSION_KEY = 'nexu_modal_shown_this_session'; |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does window.sessionStorage persist across full page reloads in the same tab, and when is it cleared?
💡 Result:
Yes, window.sessionStorage persists across full page reloads in the same tab. It is cleared when the tab or browser window is closed.
Citations:
- 1: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
- 2: https://developer.mozilla.org/en-US/docs/Web/API/Window.sessionStorage
- 3: https://stackoverflow.com/questions/36604747/when-is-sessionstorage-actually-cleared
- 4: https://developer.mozilla.org/en/dom/storage
- 5: https://html.spec.whatwg.org/multipage/webstorage.html
Replace sessionStorage with an in-memory flag to allow modal re-display on page refresh.
sessionStorage persists across full page reloads within the same tab, so once the modal is marked as shown via sessionStorage.setItem(SESSION_KEY, 'true'), it will not display again even after refresh. Use an in-memory flag instead to reset on each page load while still preventing repeated displays during single-page navigation.
Proposed fix
const NEXU_URL = 'https://nexu.io';
const STORAGE_KEY = 'nexu_modal_dismissed';
-const SESSION_KEY = 'nexu_modal_shown_this_session';
+let hasShownInCurrentPageLoad = false;
interface NexuModalProps {
open?: boolean;
}
export const NexuModal = memo(({ open: controlledOpen }: NexuModalProps) => {
const [visible, setVisible] = useState(false);
- // Only show once per browser session (avoid re-showing on SPA navigation)
- const shownThisSession = sessionStorage.getItem(SESSION_KEY);
- if (shownThisSession === 'true') {
+ // Only show once per current page load (avoid re-showing on SPA navigation)
+ if (hasShownInCurrentPageLoad) {
return;
}
const timer = setTimeout(() => {
setVisible(true);
- sessionStorage.setItem(SESSION_KEY, 'true');
+ hasShownInCurrentPageLoad = true;
logEvent('refly_nexu_workbench_modal_shown');
}, 1000);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/ai-workspace-common/src/components/nexu-promotion/NexuModal.tsx` at
line 11, Replace the sessionStorage-based session tracking with a module-scoped
in-memory boolean so the modal can reappear after a full page reload: remove
uses of SESSION_KEY and any sessionStorage.getItem/setItem in the NexuModal
component and instead introduce a module-level flag (e.g., shownThisSession)
that is checked/updated by the same logic currently in NexuModal (the
component/handler that reads/writes SESSION_KEY); this flag should default to
false on page load and be set to true when the modal is shown to prevent repeats
during SPA navigation while allowing re-display after a full refresh.
Summary
sessionStorageto ensure the modal only shows once per browser session, while still showing on actual page refreshes.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
UI Updates