Skip to content

Conversation

@ogrodnek
Copy link
Owner

@ogrodnek ogrodnek commented Jan 26, 2026

Make it easier to to customize the bundled Phoenix LiveView's LiveSocket options via a global window.LiveViewConfig object, following the existing window.Hooks pattern.

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.64%. Comparing base (e5047cb) to head (94520f7).

Files with missing lines Patch % Lines
pyview/template/root_template.py 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
- Coverage   78.65%   78.64%   -0.02%     
==========================================
  Files          92       92              
  Lines        7674     7675       +1     
  Branches      528      528              
==========================================
  Hits         6036     6036              
- Misses       1541     1542       +1     
  Partials       97       97              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 862d9846f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a configurable window.LiveViewConfig hook for customizing the Phoenix LiveView JavaScript client from PyView, exposes a head_content slot in the root template to inject such configuration, and documents the JS interop patterns.

Changes:

  • Extend defaultRootTemplate / _defaultRootTemplate to accept head_content markup and render it into the <head> before the bundled app.js script.
  • Update the JS entrypoint and bundled asset to read window.LiveViewConfig and merge user-provided hooks, params, uploaders, and dom options into the LiveSocket configuration.
  • Add a “JavaScript Interop” documentation page that explains hooks, LiveSocket configuration via LiveViewConfig, and an attribute-syncing pattern for phx-update="ignore".

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
uv.lock Bumps pyview-web from 0.8.1 to 0.8.2 to reflect the new configuration capability.
pyview/template/root_template.py Adds a head_content parameter and threads it into the HTML <head>, enabling injection of JS configuration like LiveViewConfig.
pyview/static/assets/app.js Updates the compiled asset to pull window.LiveViewConfig and merge its options into LiveSocket, matching the source JS changes.
pyview/assets/js/app.js Reads window.LiveViewConfig and merges its hooks, params, uploaders, and dom into the LiveSocket options.
docs/features/js-interop.md Introduces documentation on hooks and window.LiveViewConfig, including examples using head_content in defaultRootTemplate.
Comments suppressed due to low confidence (1)

pyview/template/root_template.py:25

  • Adding the new head_content parameter between the existing css and content_wrapper parameters changes the positional argument order of this public function and will break any external callers that were using positional arguments. To avoid an accidental breaking change, consider either appending the new parameter at the end of the signature with a default, or making head_content (and perhaps the rest) keyword-only so existing positional usages stay valid while still enabling the new behavior.
def defaultRootTemplate(
    css: Optional[Markup] = None,
    head_content: Optional[Markup] = None,
    content_wrapper: Optional[ContentWrapper] = None,
    title: Optional[str] = None,
    title_suffix: Optional[str] = " | LiveView",
) -> RootTemplate:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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