Skip to content

🐛 fix: prevent full page reload when switching topics during agent execution#13309

Merged
arvinxx merged 1 commit into
canaryfrom
fix/nav-item-prevent-default-on-disabled
Mar 26, 2026
Merged

🐛 fix: prevent full page reload when switching topics during agent execution#13309
arvinxx merged 1 commit into
canaryfrom
fix/nav-item-prevent-default-on-disabled

Conversation

@arvinxx

@arvinxx arvinxx commented Mar 26, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • 🐛 fix

🔗 Related Issue

N/A

🔀 Description of Change

When switching between topics within the same agent while agent execution is in progress, the entire page would do a full browser navigation (reload) instead of SPA routing.

Root cause: In NavItem.tsx, the onClick handler had an early return for disabled || loading states that skipped e.preventDefault(). Since NavItem renders as an <a> tag with href (for cmd+click support), the browser's default link navigation would fire, causing a full page load to the href URL instead of React Router handling it.

Fix: Move e.preventDefault() before the disabled || loading check so the default <a> navigation is always prevented, regardless of component state.

🧪 How to Test

  1. Open an agent with multiple topics
  2. Send a message to start agent execution in one topic
  3. Switch to another topic and start a second execution
  4. Switch back to the first topic while both are executing
  5. Verify the page does not fully reload (no flash, no loss of JS state)
  • Tested locally
  • Added/updated tests
  • No tests needed

📝 Additional Information

Confirmed via agent-browser + CDP that performance.getEntriesByType('navigation')[0].type was "navigate" (full browser navigation) before the fix, and the injected window.__monitorActive variable survived after the fix (proving no reload occurred).

…ecution

Move `e.preventDefault()` before the `disabled || loading` early return
in NavItem's onClick handler. Previously, when a NavItem was in disabled
or loading state, the early return skipped `preventDefault()`, allowing
the underlying `<a>` tag's default navigation to trigger a full browser
page load instead of SPA routing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Mar 26, 2026 1:17pm

Request Review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@lobehubbot

Copy link
Copy Markdown
Member

@ONLY-yours - This is a topic/navigation fix. Please take a look.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d11c3cadfb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 107 to 111
if (href && !isModifierClick(e)) {
e.preventDefault();
}
if (disabled || loading) return;
onClick?.(e);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not swallow navigation when item is loading

When href is set and loading is true, this handler now calls preventDefault() and then returns before onClick, so the click does nothing. Topic rows are marked loading for the full agent run (conversationLifecycle.ts sets internal_updateTopicLoading(topicId, true/false)), which means users can no longer switch back to an executing topic via normal click; previously they at least navigated (with a full reload). This turns the original reload bug into a navigation dead-end for running topics.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.69%. Comparing base (4e60d87) to head (d11c3ca).
⚠️ Report is 3 commits behind head on canary.

Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #13309      +/-   ##
==========================================
- Coverage   66.69%   66.69%   -0.01%     
==========================================
  Files        1885     1885              
  Lines      150971   150971              
  Branches    17942    17231     -711     
==========================================
- Hits       100686   100684       -2     
- Misses      50173    50175       +2     
  Partials      112      112              
Flag Coverage Δ
app 58.06% <0.00%> (-0.01%) ⬇️
database 96.64% <ø> (ø)
packages/agent-runtime 89.61% <ø> (ø)
packages/context-engine 83.22% <ø> (ø)
packages/conversation-flow 92.36% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 66.68% <ø> (ø)
packages/model-bank 99.85% <ø> (ø)
packages/model-runtime 84.48% <ø> (ø)
packages/prompts 67.76% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 90.41% <ø> (ø)
packages/web-crawler 88.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 66.07% <ø> (ø)
Services 49.56% <ø> (ø)
Server 67.37% <ø> (-0.01%) ⬇️
Libs 45.46% <ø> (ø)
Utils 91.01% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arvinxx arvinxx merged commit 0724d8c into canary Mar 26, 2026
35 checks passed
@arvinxx arvinxx deleted the fix/nav-item-prevent-default-on-disabled branch March 26, 2026 13:30
@lobehubbot

Copy link
Copy Markdown
Member

❤️ Great PR @arvinxx ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

arvinxx added a commit that referenced this pull request Mar 26, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: #13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ONLY-yours added a commit that referenced this pull request Mar 27, 2026
# 🚀 release: 20260326

This release includes **91 commits**. Key updates are below.


- **Agent can now execute background tasks** — Agents can perform
long-running operations without blocking your conversation.
[#13289](#13289)
- **Better error messages** — Redesigned error UI across chat and image
generation with clearer explanations and recovery options.
[#13302](#13302)
- **Smoother topic switching** — No more full page reloads when
switching topics while an agent is responding.
[#13309](#13309)
- **Faster image uploads** — Large images are now automatically
compressed to 1920px before upload, reducing wait times.
[#13224](#13224)
- **Improved knowledge base** — Documents are now properly parsed before
chunking, improving retrieval accuracy.
[#13221](#13221)

### Bot Platform

- **WeChat Bot support** — You can now connect LobeChat to WeChat, in
addition to Discord.
[#13191](#13191)
- **Richer bot responses** — Bots now support custom markdown rendering
and context injection.
[#13294](#13294)
- **New bot commands** — Added `/new` to start fresh conversations and
`/stop` to halt generation.
[#13194](#13194)
- **Discord stability fixes** — Fixed thread creation issues and Redis
connection drops.
[#13228](#13228)
[#13205](#13205)

### Models & Providers

- **GLM-5** is now available in the LobeHub model list.
[#13189](#13189)
- **Coding Plan providers** — Added support for code planning assistant
providers. [#13203](#13203)
- **Tencent Hunyuan 3.0 ImageGen** — New image generation model from
Tencent. [#13166](#13166)
- **Gemini content handling** — Better handling when Gemini blocks
content due to safety filters.
[#13270](#13270)
- **Claude token limits fixed** — Corrected max window tokens for
Anthropic Claude models.
[#13206](#13206)

### Skills & Tools

- **Auto credential injection** — Skills can now automatically request
and use required credentials.
[#13124](#13124)
- **Smarter tool permissions** — Built-in tools skip confirmation for
safe paths like `/tmp`.
[#13232](#13232)
- **Model switcher improvements** — Quick access to provider settings
and visual highlight for default model.
[#13220](#13220)

### Memory

- **Bulk delete memories** — You can now delete all memory entries at
once. [#13161](#13161)
- **Per-agent memory control** — Memory injection now respects
individual agent settings.
[#13265](#13265)

### Desktop App

- **Gateway connection** — Desktop app can now connect to LobeHub
Gateway for enhanced features.
[#13234](#13234)
- **Connection status indicator** — See gateway connection status in the
titlebar. [#13260](#13260)
- **Settings persistence** — Gateway toggle state now persists across
app restarts. [#13300](#13300)

### CLI

- **API key authentication** — CLI now supports API key auth for
programmatic access.
[#13190](#13190)
- **Shell completion** — Tab completion for bash/zsh/fish shells.
[#13164](#13164)
- **Man pages** — Built-in manual pages for CLI commands.
[#13200](#13200)

### Security

- **XSS protection** — Sanitized search result image titles to prevent
script injection.
[#13303](#13303)
- **Workflow hardening** — Fixed potential shell injection in release
automation. [#13319](#13319)
- **Dependency update** — Updated nodemailer to address security
advisory. [#13326](#13326)

### Bug Fixes

- Fixed skill page not redirecting correctly after import.
[#13255](#13255)
[#13261](#13261)
- Fixed token counting in group chats.
[#13247](#13247)
- Fixed editor not resetting when switching to empty pages.
[#13229](#13229)
- Fixed manual tool toggle not working.
[#13218](#13218)
- Fixed Search1API response parsing.
[#13207](#13207)
[#13208](#13208)
- Fixed mobile topic menus rendering issues.
[#12477](#12477)
- Fixed history count calculation for accurate context.
[#13051](#13051)
- Added missing Turkish translations.
[#13196](#13196)

### Credits

Huge thanks to these contributors:

@bakiburakogun @hardy-one @Zhouguanyang @sxjeru @hezhijie0327 @arvinxx
@cy948 @CanisMinor @Innei @lijian @lobehubbot @neko @rdmclin2
@rivertwilight @tjx666
github-actions Bot added a commit to koo14/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to JinfengX/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to fenoh3ry/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to JinfengX/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to b19990812/lobe that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to hututtt/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to fenoh3ry/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to b19990812/lobe that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to hututtt/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to andreeyang55/lobechat that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to fishylife/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to TrivCodez/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to andreeyang55/lobechat that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to fishylife/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to TrivCodez/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to zhang-zhonggui/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to qydxyx/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to zhang-zhonggui/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to qydxyx/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to emaxlele/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to EvenZ2001/lobechat that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to emaxlele/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to EvenZ2001/lobechat that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to NoobPlus/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to NoobPlus/lobehub that referenced this pull request May 18, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to Innei/lobehub that referenced this pull request May 19, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot added a commit to Innei/lobehub that referenced this pull request May 19, 2026
Add a regression test to verify that switching topics within the same
agent does not trigger a full browser page reload. The test injects a
window marker before switching and verifies it survives after the switch.

Related: lobehub#13309

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants