Skip to content

fix(llc): fix stream header client details#1262

Open
Brazol wants to merge 5 commits into
mainfrom
fix/fix-stream-header-client-details
Open

fix(llc): fix stream header client details#1262
Brazol wants to merge 5 commits into
mainfrom
fix/fix-stream-header-client-details

Conversation

@Brazol

@Brazol Brazol commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Improved device and app environment reporting for the SDK, including browser and WebRTC details where available.
    • Added a more consistent client header generated from the current runtime environment.
  • Bug Fixes

    • Made startup environment collection more reliable before connecting.
    • Reduced the risk of missing or outdated client details by centralizing environment updates.

@Brazol Brazol requested a review from a team as a code owner June 24, 2026 10:06
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Brazol, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 58 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d164bac-9a31-4500-9819-061ecf694d27

📥 Commits

Reviewing files that changed from the base of the PR and between ffd55e8 and eeaa189.

📒 Files selected for processing (3)
  • packages/stream_video/CHANGELOG.md
  • packages/stream_video/lib/src/stream_video.dart
  • packages/stream_video_flutter/CHANGELOG.md
📝 Walkthrough

Walkthrough

Introduces a VideoEnvironment immutable data model and a VideoEnvironmentManager class to centralize SDK runtime environment state. Replaces scattered nullable module-level globals in globals.dart with delegating getters backed by the manager. Refactors StreamVideo's _setClientDetails() into _collectEnvironment() that returns a VideoEnvironment.

VideoEnvironment model and manager refactor

Layer / File(s) Summary
VideoEnvironment data model and header extension
packages/stream_video/lib/src/video_environment.dart
Defines the immutable VideoEnvironment class with required sdkVersion/osName, optional metadata fields, a copyWith method, and a VideoEnvironmentHeader extension getter that computes the `
VideoEnvironmentManager implementation
packages/stream_video/lib/src/video_environment_manager.dart
Introduces VideoEnvironmentManager storing a VideoEnvironment, exposing updateEnvironment(), delegating xStreamClientHeader to the environment extension, and building the SFU ClientDetails proto by parsing sdkVersion and mapping optional OS/device/browser fields.
StreamVideo initialization and globals wiring
packages/stream_video/lib/globals.dart, packages/stream_video/lib/src/stream_video.dart
Replaces _setClientDetails() with _collectEnvironment() that gathers per-platform app/device/browser/WebRTC data into a VideoEnvironment; updates the init path to call videoEnvironmentManager.updateEnvironment() then optionally connect(); rewires globals.dart to expose a top-level videoEnvironmentManager with non-nullable delegating getters replacing the old nullable clientDetails/clientVersionDetails variables.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hop hop, the globals are tidy now,
No nullable fields left to furrow my brow!
VideoEnvironment carries the facts,
The manager wraps them in clean little stacks.
One updateEnvironment call does the trick —
Headers and protos, assembled so quick! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning No PR description was provided, so the required Goal, Implementation, Testing, and checklist sections are missing. Add the repository template sections with a goal, implementation details, testing notes, and checklist items, plus screenshots if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change to stream header/client details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fix-stream-header-client-details

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/stream_video/lib/src/stream_video.dart`:
- Around line 237-257: The manual connect path in StreamVideo can still run
before _collectEnvironment() finishes, so the SDK may use stale defaults from
videoEnvironmentManager in globals.dart. Add a shared initialization future (for
example, _environmentReady) that is completed after _updateVideoEnvironment()
runs, and make connect() await it before building headers/client details so both
autoConnect and manual connect see the populated environment.

In `@packages/stream_video/lib/src/video_environment.dart`:
- Around line 38-63: The VideoEnvironment.copyWith method cannot clear optional
fields because every parameter uses null-coalescing to fall back to the existing
value. Update copyWith so callers can explicitly set fields like appName,
browserName, deviceModel, and the other optional metadata fields to null when
needed, while still preserving old values only when no override is provided. Use
VideoEnvironment.copyWith and the affected fields in the constructor call to
implement a nullable-aware pattern that distinguishes “not passed” from “passed
null.”
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 75d6615e-5eba-4ac5-8a06-878acf1bfbc9

📥 Commits

Reviewing files that changed from the base of the PR and between 7cb5125 and ffd55e8.

📒 Files selected for processing (4)
  • packages/stream_video/lib/globals.dart
  • packages/stream_video/lib/src/stream_video.dart
  • packages/stream_video/lib/src/video_environment.dart
  • packages/stream_video/lib/src/video_environment_manager.dart

Comment thread packages/stream_video/lib/src/stream_video.dart
Comment thread packages/stream_video/lib/src/video_environment.dart
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.85106% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.78%. Comparing base (32a1181) to head (eeaa189).

Files with missing lines Patch % Lines
packages/stream_video/lib/src/stream_video.dart 26.82% 30 Missing ⚠️
...tream_video/lib/src/video_environment_manager.dart 23.07% 20 Missing ⚠️
...ckages/stream_video/lib/src/video_environment.dart 41.66% 14 Missing ⚠️
packages/stream_video/lib/globals.dart 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1262      +/-   ##
========================================
+ Coverage   9.71%   9.78%   +0.07%     
========================================
  Files        676     678       +2     
  Lines      49695   49732      +37     
========================================
+ Hits        4826    4866      +40     
+ Misses     44869   44866       -3     

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

() =>
'[StreamVideo] failed to set client details: $error with stackTrace: $stackTrace',
);
_collectEnvironment().then((env) {

@xsahil03x xsahil03x Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure, but can you make sure we get the .then callback and calls connect even if the _collectEnvironment throws?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe better to add a test for this

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