Skip to content

Add tab presence support to track user activity across sessions - #8182

Open
cstns wants to merge 1 commit into
mainfrom
feat/8158_store-browser-sessions-scaffolding
Open

Add tab presence support to track user activity across sessions#8182
cstns wants to merge 1 commit into
mainfrom
feat/8158_store-browser-sessions-scaffolding

Conversation

@cstns

@cstns cstns commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

  • Add MQTT-based browser session presence so third-party MCP agents can discover which tabs a user has exposed
  • Forge stores presence in a Redis cache bucket (browserSessions) with a 135s TTL, auto-expired when heartbeats stop
  • Browser tabs publish on ff/v1/tab-presence///heartbeat and .../context using the existing fe-team MQTT connection
  • Forge subscribes via a shared subscription ($share/platform/...) so only one replica handles each message, avoiding redundant Redis writes

The browser sends two types of messages over MQTT:

  • Heartbeat (periodic, ~45s): extends TTL, carries visibility/focus state
  • Context (on route change): carries the full contextStore.expert payload so the gateway can reconstitute in-flight MQTT topics with the correct entity info

Both message types call cache.set() which resets the TTL. If heartbeats stop (browser crash, tab close), the entry auto-expires after ~135s.

app.comms.browserSessions.getSessionsByUser(userId) retrieves all active sessions for a user, for the future list_browser_sessions MCP tool (#8161).

Related Issue(s)

closes #8158

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@cstns
cstns requested review from Steve-Mcl and n-lark August 11, 2026 04:33
@cstns
cstns deployed to staging August 11, 2026 04:36 — with GitHub Actions Active
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.47170% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.19%. Comparing base (2af687c) to head (bc151d0).

Files with missing lines Patch % Lines
forge/comms/commsClient.js 0.00% 10 Missing ⚠️
forge/comms/aclManager.js 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8182      +/-   ##
==========================================
- Coverage   76.19%   76.19%   -0.01%     
==========================================
  Files         441      442       +1     
  Lines       23619    23672      +53     
  Branches     6289     6298       +9     
==========================================
+ Hits        17996    18036      +40     
- Misses       5623     5636      +13     
Flag Coverage Δ
backend 76.19% <75.47%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

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.

Store browser session presence in Forge's Redis cache

1 participant