Skip to content

Conversation

@maxkahan
Copy link
Contributor

@maxkahan maxkahan commented Dec 24, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Enforced even video frame dimensions to ensure reliable H.264 encoding and playback.
  • Improvements

    • Added clearer logging when video or screen-share tracks are added or removed for better observability.
    • Optimized cropping to remove a single pixel when needed, preserving performance and avoiding rescaling.
  • Tests

    • Added unit tests validating even-dimension handling and correct cropping behavior.
  • Chores

    • Minor import and parameter-name cleanups with no user-facing behavior changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

Adds logging for track add/remove events, enforces even frame dimensions by cropping odd-width/height frames before enqueueing, tweaks a Roboflow parameter/import, and adds unit tests for ensure_even_dimensions.

Changes

Cohort / File(s) Summary
Agent track logging
agents-core/vision_agents/core/agents/agents.py
Added log lines on track addition and removal (prints track type and user ID); removed a redundant watch-video log in _on_track_change.
Frame dimension enforcement & tests
agents-core/vision_agents/core/utils/video_track.py, agents-core/vision_agents/core/utils/video_utils.py, tests/test_video_utils.py
Imported ensure_even_dimensions and apply it in QueuedVideoTrack.add_frame() to crop odd dims using numpy slicing; updated ensure_even_dimensions implementation; added unit tests validating cropping and attribute preservation.
Roboflow plugin & example
plugins/roboflow/vision_agents/plugins/roboflow/roboflow_local_processor.py, plugins/roboflow/example/roboflow_example.py
Renamed process_video parameter incoming_tracktrack and added return annotation; changed example Debouncer import from relative to absolute path.

Sequence Diagram(s)

(No sequence diagrams generated: changes are logging, frame preprocessing, tests, and small refactors without new multi-component control flow.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

tests

Suggested reviewers

  • dangusev
  • Nash0x7E2
  • tschellenbach

Poem

The frame submits a small excision, dark as a secret—
one pixel sliced from the world's tidy edge.
Logs name the absent corner, call the source by blood,
while the image keeps its even breath and does not speak.
A clinical mercy: geometry made polite.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main objective: fixing screensharing when screen dimensions are odd pixels. Changes across multiple files implement this fix through dimension normalization and related logging/processing updates.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-screenshare-odd-dimensions

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f87b70a and 912a97b.

📒 Files selected for processing (1)
  • tests/test_video_utils.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_video_utils.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: unit / Test "not integration"
  • GitHub Check: unit / Mypy
  • GitHub Check: unit / Mypy
  • GitHub Check: unit / Test "not integration"

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 515fd64 and 9a4f048.

📒 Files selected for processing (4)
  • agents-core/vision_agents/core/agents/agents.py
  • agents-core/vision_agents/core/utils/video_track.py
  • plugins/roboflow/example/roboflow_example.py
  • plugins/roboflow/vision_agents/plugins/roboflow/roboflow_local_processor.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/python.mdc)

**/*.py: Never adjust sys.path in Python code
Never write except Exception as e - use specific exception handling
Avoid using getattr, hasattr, delattr and setattr; prefer normal attribute access in Python
Docstrings should follow the Google style guide for docstrings

Files:

  • agents-core/vision_agents/core/agents/agents.py
  • plugins/roboflow/example/roboflow_example.py
  • agents-core/vision_agents/core/utils/video_track.py
  • plugins/roboflow/vision_agents/plugins/roboflow/roboflow_local_processor.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: dangusev
Repo: GetStream/Vision-Agents PR: 249
File: agents-core/vision_agents/core/agents/agents.py:1032-1042
Timestamp: 2025-12-10T19:35:39.238Z
Learning: In `agents-core/vision_agents/core/agents/agents.py`, when using `video_track_override_path`, creating a new `VideoFileTrack` for each participant (each call to `_on_track_added`) is intentional to maintain proper track lifecycle semantics tied to each participant.
📚 Learning: 2025-12-10T19:35:39.238Z
Learnt from: dangusev
Repo: GetStream/Vision-Agents PR: 249
File: agents-core/vision_agents/core/agents/agents.py:1032-1042
Timestamp: 2025-12-10T19:35:39.238Z
Learning: In `agents-core/vision_agents/core/agents/agents.py`, when using `video_track_override_path`, creating a new `VideoFileTrack` for each participant (each call to `_on_track_added`) is intentional to maintain proper track lifecycle semantics tied to each participant.

Applied to files:

  • agents-core/vision_agents/core/agents/agents.py
  • agents-core/vision_agents/core/utils/video_track.py
  • plugins/roboflow/vision_agents/plugins/roboflow/roboflow_local_processor.py
🧬 Code graph analysis (3)
agents-core/vision_agents/core/agents/agents.py (3)
agents-core/vision_agents/core/edge/sfu_events.py (19)
  • track_type (579-583)
  • track_type (1193-1197)
  • track_type (2289-2293)
  • user_id (489-493)
  • user_id (856-860)
  • user_id (901-905)
  • user_id (1186-1190)
  • user_id (2093-2097)
  • user_id (2142-2146)
  • participant (1496-1501)
  • participant (1504-1507)
  • participant (1545-1550)
  • participant (1553-1556)
  • participant (1625-1630)
  • participant (1633-1636)
  • participant (2100-2105)
  • participant (2108-2111)
  • participant (2156-2161)
  • participant (2164-2167)
agents-core/vision_agents/core/events/base.py (1)
  • user_id (45-48)
conftest.py (1)
  • participant (187-189)
plugins/roboflow/example/roboflow_example.py (1)
plugins/roboflow/example/utils.py (1)
  • Debouncer (4-19)
plugins/roboflow/vision_agents/plugins/roboflow/roboflow_local_processor.py (1)
agents-core/vision_agents/core/utils/video_forwarder.py (1)
  • VideoForwarder (25-185)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: unit / Mypy
  • GitHub Check: unit / Test "not integration"
  • GitHub Check: unit / Mypy
  • GitHub Check: unit / Test "not integration"
🔇 Additional comments (6)
agents-core/vision_agents/core/agents/agents.py (2)

974-978: LGTM: Enhanced video track observability.

The logging addition provides valuable visibility into which source track is selected and its priority. The distinction between "SCREEN_SHARE" and "VIDEO" track types will aid in debugging track selection logic.

Minor note: Line 977 uses the module-level logger rather than self.logger. While both work, consider using self.logger for consistency with the rest of the agent class (e.g., lines 1010, 1022) and to include the agent_id context from the LoggerAdapter.


1007-1011: LGTM: Valuable track lifecycle logging.

This logging provides essential visibility into video track additions, including the track type and contributing user. The fallback to "unknown" for missing participants is appropriate defensive coding.

agents-core/vision_agents/core/utils/video_track.py (2)

78-79: LGTM: Correct application in frame queuing.

The ensure_even_dimensions call is properly placed before queuing frames, ensuring all buffered frames comply with H.264 encoding requirements. The comment clearly explains the rationale.


232-233: LGTM: Consistent application in file track.

The ensure_even_dimensions call is correctly placed to ensure frames from video files also have even dimensions. This is especially important for the video override path mentioned in the learnings, where VideoFileTrack is used for testing/debugging.

plugins/roboflow/vision_agents/plugins/roboflow/roboflow_local_processor.py (2)

161-166: LGTM: Cleaner parameter naming.

The renaming from incoming_track to track simplifies the method signature and improves readability. Since the VideoForwarder is called with a positional argument (line 182), this change doesn't affect functionality.


182-182: LGTM: Consistent with parameter renaming.

The updated reference to track is consistent with the method signature change.

@maxkahan maxkahan force-pushed the fix-screenshare-odd-dimensions branch from 9a4f048 to 60cdcf1 Compare December 24, 2025 15:34
Copy link
Contributor

@dangusev dangusev left a comment

Choose a reason for hiding this comment

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

One more thing:
Right now, ensure_even_dimensions scales the image instead of cropping it.
And rescaling is a more expensive operation.

Can you please change it to crop the frame and add tests?
Thanks.

@Nash0x7E2
Copy link
Member

@maxkahan what's the status of this PR?

@maxkahan
Copy link
Contributor Author

@dangusev @Nash0x7E2 made Daniil's edits, ready for re-review

@maxkahan maxkahan requested a review from dangusev December 29, 2025 20:51
Copy link
Contributor

@d3xvn d3xvn left a comment

Choose a reason for hiding this comment

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

LGTM

@d3xvn d3xvn dismissed dangusev’s stale review December 30, 2025 13:41

Dismissing to merge since changes were complete.

@maxkahan maxkahan merged commit 9c39d07 into main Dec 30, 2025
10 checks passed
@maxkahan maxkahan deleted the fix-screenshare-odd-dimensions branch December 30, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants