Skip to content

Conversation

@hermannakos
Copy link
Collaborator

@hermannakos hermannakos commented Nov 21, 2025

Summary

This PR implements support for opening Studio embedded media in immersive view from within content loaded in CanvasWebView. When users encounter Studio LTI embeds in course content (assignments, pages, discussions, etc.), they can now open the media in a full immersive viewing experience.

Changes

Core Implementation

  • Added CanvasLTIPostMessageHandler.js: JavaScript file that handles LTI postMessage events in mobile WebViews, supporting both Android and iOS platforms
  • Enhanced CanvasWebView:
    • Evaluates the LTI handler script after page loads for HTML content containing Studio embeds
    • Added StudioMessageHandler JavaScript interface to receive fullWindowLaunch messages from embedded iframes
    • Implements smart detection to only inject the script when HTML contains Studio/LTI content
    • Added helper methods to extract context URLs and build Studio immersive view URLs

Infrastructure Changes

  • Added toBaseUrl() extension for CanvasContext: Generates base URLs for context (e.g., https://domain.com/courses/123)
  • Updated all loadHtml() calls across Student, Teacher, and Parent apps to include baseUrl parameter, enabling proper URL context for the Studio handler

Router Updates

  • Student & Teacher RouteMatcher: Added routing logic to handle Studio immersive view URLs and open them appropriately

Test Fixes

  • Fixed FrontPageViewModelTest in Parent app to accommodate the new baseUrl parameter and proper mocking

Test Plan

Student App

  1. Navigate to an assignment, page, or discussion that contains a Studio video embed
  2. Verify the video displays correctly in the WebView
  3. If the embed supports immersive view, verify a button/link appears to open in immersive view
  4. Tap the immersive view button
  5. Verify the Studio content opens in full immersive view
  6. Test with both Canvas uploaded media and Studio LTI embeds

Teacher App

  1. Navigate to an assignment or page with Studio embed
  2. Open SpeedGrader and view submissions with Studio content
  3. Verify immersive view launches correctly from all contexts
  4. Test with syllabus content containing Studio videos

Parent App

  1. Navigate to course details and front page
  2. Verify HTML content with Studio embeds loads correctly
  3. Verify baseUrl is properly set for navigation

All Apps

  1. Test in both dark and light modes
  2. Verify non-Studio content continues to work normally
  3. Test landscape orientation with embedded media
  4. Verify the JavaScript handler doesn't affect pages without Studio content (zero overhead)

refs: MBL-19588
affects: Student, Teacher, Parent
release note: Users can now open Studio embedded videos in immersive full-screen view for a better viewing experience

Checklist

  • Follow-up e2e test ticket created or not needed
  • Tested in dark mode
  • Tested in light mode
  • Test in landscape mode and/or tablet
  • A11y checked
  • Approve from product

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Implements support for Studio embed videos to open in immersive view with
"Open in Detail View" buttons. This provides better video viewing experience
for Studio content embedded in pages and assignments.

Changes:
- Detect Studio embed URLs (thumbnail_embed and learn_embed types)
- Detect Studio media URLs (media_attachments_iframe)
- Transform embed URLs to immersive view format with required parameters
- Add "Open in Detail View" buttons below Studio iframes
- Route immersive view URLs to InternalWebviewFragment without LTI auth
- Extract and pass video titles to immersive view

Known limitation:
- Buttons inside iframes cannot be intercepted due to WebView cross-origin
  isolation. Users must use the "Open in Detail View" button below the iframe.
- Working with web team on postMessage solution for better UX.

Test plan:
- Verify Studio embed iframes show "Open in Detail View" button
- Verify button navigates to immersive view in InternalWebviewFragment
- Verify video title displays correctly in immersive view
- Verify standard media uploads continue to work with Expand button

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Nov 21, 2025

📊 Code Coverage Report

⚠️ Student

  • PR Coverage: 43.42%
  • Master Coverage: 43.52%
  • Delta: -0.10%

⚠️ Teacher

  • PR Coverage: 25.51%
  • Master Coverage: 25.61%
  • Delta: -0.10%

✅ Pandautils

  • PR Coverage: 22.98%
  • Master Coverage: 22.97%
  • Delta: +0.01%

📈 Overall Average

  • PR Coverage: 30.64%
  • Master Coverage: 30.70%
  • Delta: -0.06%

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

Student Install Page

claude[bot]
claude bot previously requested changes Jan 12, 2026
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

PR Review - Update

I've reviewed the latest changes to this PR. Here's my assessment:

What Changed

This update includes improvements to handle Studio embed URLs in both the RouteMatcher and HtmlContentFormatter:

  1. RouteMatcher.kt: Added early detection logic for Studio embed immersive view URLs to prevent them from being caught by the generic LTI route matcher
  2. HtmlContentFormatter.kt:
    • Restructured iframe handling logic to check for Studio embeds before generic external tools
    • Added new convertStudioEmbedToImmersiveView() function for URL transformation
    • Fixed HTML entity escaping in generated buttons (security improvement)
    • Added hasStudioEmbedUrl() helper function

Issues Found

🔴 Must Fix

  • Debug logging in production code (RouteMatcher.kt:564-581): Multiple Logger.e() calls should be removed or changed to debug level
  • Null-safety concern (RouteMatcher.kt:571): Force-unwrap operator !! used after insufficient null checks
  • Missing error handling (HtmlContentFormatter.kt:219): URL decoding operations could fail and should be wrapped in try-catch

🟡 Should Improve

  • Performance (RouteMatcher.kt:564-567): Repeated toString() calls - extract to variable
  • Code complexity (HtmlContentFormatter.kt:219-276): Complex URL manipulation logic could benefit from simplification and better error handling

❓ Questions

  • Test coverage: Are there unit tests for the new hasStudioEmbedUrl() pattern matching with various encoding scenarios?

Positive Changes

✅ HTML entity escaping fix prevents potential XSS issues
✅ Improved control flow logic prevents routing conflicts
✅ Good separation of concerns between Studio embed types

Please address the must-fix issues before merging.

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

🧪 Unit Test Results

✅ 📱 Parent App

  • Tests: 309 total, 0 failed, 0 skipped
  • Duration: 34.673s
  • Success Rate: 100%

✅ 📱 Student App

  • Tests: 1225 total, 0 failed, 0 skipped
  • Duration: 0.000s
  • Success Rate: 100%

✅ 📱 Teacher App

  • Tests: 369 total, 0 failed, 0 skipped
  • Duration: 33.033s
  • Success Rate: 100%

✅ 🌅 Horizon

  • Tests: 490 total, 0 failed, 0 skipped
  • Duration: 35.583s
  • Success Rate: 100%

✅ 📦 Submodules

  • Tests: 2601 total, 0 failed, 0 skipped
  • Duration: 51.281s
  • Success Rate: 100%

📊 Summary

  • Total Tests: 4994
  • Failed: 0
  • Skipped: 0
  • Status: ✅ All tests passed!

Last updated: Fri, 16 Jan 2026 13:34:02 GMT

@tamaskozmer tamaskozmer changed the title [MBL-19552] Add Studio embed immersive view support [MBL-19588][All] Add Studio embed immersive view support Jan 16, 2026
@tamaskozmer tamaskozmer marked this pull request as ready for review January 16, 2026 12:53
@github-actions
Copy link

github-actions bot commented Jan 16, 2026

Parent Install Page

@github-actions
Copy link

Teacher Install Page

@kdeakinstructure kdeakinstructure self-requested a review January 16, 2026 19:10
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.

3 participants