Skip to content

fix(embed): isolate browser chat sessions#2335

Merged
RockChinQ merged 2 commits into
masterfrom
fix/embed-session-isolation
Jul 13, 2026
Merged

fix(embed): isolate browser chat sessions#2335
RockChinQ merged 2 commits into
masterfrom
fix/embed-session-isolation

Conversation

@RockChinQ

Copy link
Copy Markdown
Member

Overview

Isolate embedded web-chat conversations by browser-tab session so visitors using the same pipeline cannot see or receive each other's messages.

  • Generate a cryptographically random UUID v4 per embed tab and persist it in sessionStorage across refreshes.
  • Send the session identifier with WebSocket, history, and reset requests, and validate it server-side.
  • Scope person/group history, streaming indexes, resets, and live broadcasts by pipeline and client session.
  • Use stable pipeline/session launcher IDs so reconnects and late replies retain the correct LangBot provider session.
  • Preserve legacy dashboard/non-embed WebSocket behavior, including the dashboard group launcher.
  • Prevent duplicate client session UUIDs on different pipelines from cross-routing replies.

Closes #2334

Screenshots

Not applicable; this is a WebSocket/session-isolation fix. Regression behavior is covered by unit and API integration tests.

Verification

  • 106 passed — platform unit tests (excluding the unrelated existing DingTalk collection conflict)
  • 17 passedtests/integration/api/test_embed.py
  • 30 passed — focused WebSocket isolation, attachment, and embed API suite
  • Ruff lint and format checks passed
  • node --check src/langbot/templates/embed/widget.js passed
  • git diff --check passed
  • Independent staged-diff review passed with no remaining blockers

Checklist

  • I have read the contribution guide.
  • I have signed or will sign the CLA when prompted.
  • The related issue documents the requested behavior.
  • I have tested the changes and confirmed the expected behavior.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. eh: Improve enhance: 现有功能的改进 / improve current features javascript Pull requests that update Javascript code m: Platform 机器人管理相关 / Bots management m: Session 会话和消息模块 / Sessions management labels Jul 13, 2026
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.78947% with 39 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../langbot/pkg/platform/sources/websocket_adapter.py 67.46% 27 Missing ⚠️
.../pkg/api/http/controller/groups/pipelines/embed.py 7.69% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

@RockChinQ RockChinQ force-pushed the fix/embed-session-isolation branch from e04582b to a980aff Compare July 13, 2026 07:04
@RockChinQ RockChinQ merged commit bd35b79 into master Jul 13, 2026
13 checks passed
@RockChinQ RockChinQ deleted the fix/embed-session-isolation branch July 13, 2026 07:08
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

eh: Improve enhance: 现有功能的改进 / improve current features javascript Pull requests that update Javascript code m: Platform 机器人管理相关 / Bots management m: Session 会话和消息模块 / Sessions management size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 页面机器人会话不独立,不同的地方打开同一个页面机器人,能看到对方的对话内容

1 participant