Update the implementation details of the external bus for the apps#3049
Update the implementation details of the external bus for the apps#3049
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 24 minutes and 52 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds Android WebView V2 messaging (JSON Changes
Sequence Diagram(s)sequenceDiagram
participant FE as Frontend (Web)
participant WV as WebView (injected bridge)
participant App as Native App
rect rgba(200,220,255,0.5)
FE->>WV: check WebViewFeature.WEB_MESSAGE_LISTENER
alt V2 supported
FE->>WV: postMessage(JSON.stringify({type,payload}))
WV->>App: deliver message object
App-->>WV: response (if expected)
WV-->>FE: deliver response
else V2 not supported
FE->>App: call `window.externalApp.*` (V1) or `window.webkit.messageHandlers.*` (iOS)
App-->>FE: callback/response (if expected)
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/frontend/external-authentication.md`:
- Around line 22-40: Docs show inconsistent iOS postMessage formats; update the
iOS examples in external-authentication.md so they match the string parameter
style used in external-bus.md by JSON-stringifying the message before calling
window.webkit.messageHandlers.getExternalAuth.postMessage(...) (and likewise for
revokeExternalAuth or any other window.webkit.messageHandlers.* usages), i.e.,
pass a single string via JSON.stringify({ callback: "...", force: true, type:
"..." }) to align with the externalBus signature.
In `@docs/frontend/external-bus.md`:
- Around line 444-448: The "Messages from app to frontend" section currently
uses h3 for the section title and then jumps to h5 for each message heading,
violating markdown heading order; update every message heading in that section
(all instances between the "Messages from app to frontend" heading and the end
of that block, roughly lines 448-569) by changing the h5 markers (`#####`) to h4
markers (`####`) so headings flow h3 → h4 consistently.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 51958ac0-c7fc-4596-b9a1-a38bbaedea9d
📒 Files selected for processing (2)
docs/frontend/external-authentication.mddocs/frontend/external-bus.md
There was a problem hiding this comment.
Pull request overview
Updates the frontend developer documentation for embedded apps by clarifying Android WebView integration (V2 vs V1) and expanding/organizing the external-bus message catalog.
Changes:
- Document Android V2 vs V1 setup for the external bus, including WebViewFeature-based behavior.
- Reorganize and substantially expand the “Supported messages” section for external bus (direction-based grouping + additional commands/payloads).
- Update external authentication docs to describe/use the Android V2
postMessageapproach with a V1 fallback.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| docs/frontend/external-bus.md | Adds Android V2/V1 guidance and reorganizes/extends the external-bus message reference. |
| docs/frontend/external-authentication.md | Updates Android integration docs to include V2 (externalAppV2) messaging with V1 fallback and iOS examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jpelgrom
left a comment
There was a problem hiding this comment.
The reasoning behind some of my earlier comments is: the mobile_app integration and frontend support for native apps is supposed to be for any native app, the official Home Assistant companion apps are just one of the users.
(Out of scope for this PR, but I feel like it would be nice to have a flowchart for the Improv Wi-Fi and bar code scanner flows.)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
docs/frontend/external-bus.md (1)
454-467:⚠️ Potential issue | 🟡 MinorDocument the
navigatepayload parameters.The
pathandoptions.replaceparameters lack descriptions. Users need to know:
- Is
pathrelative to the frontend root or absolute?- What does the
replaceoption do (e.g., does it replace the current history entry)?📝 Suggested documentation additions
```ts { path: string; options?: { replace: boolean; }; }
+-
path: The path to navigate to (e.g., "/lovelace/0" or "/config/dashboard")
+-options.replace: If true, replaces the current history entry instead of adding a new one</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@docs/frontend/external-bus.mdaround lines 454 - 467, The documentation for
thenavigatepayload is missing parameter descriptions; update thenavigate
payload block to documentpathandoptions.replaceby stating thatpathis
the URL path to navigate to (examples like "/lovelace/0" or "/config/dashboard"
and whether it should be treated as absolute from the frontend root) and that
options.replaceis a boolean which, when true, replaces the current browser
history entry instead of pushing a new one; keep the existing type signature for
navigateand add those two concise bullet descriptions next topathand
options.replace.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Inline comments:
In@docs/frontend/external-bus.md:
- Line 17: Replace the empty fenced code block with a concrete V2 message
example (or remove it if unnecessary): add a fenced block with a language tag
(e.g., ```json) and a representative V2 message showing fields like version
(e.g., "v2"), id/messageId, type/event, timestamp, and payload/body to
illustrate the V2 message format; ensure the example matches the repo's V2
schema naming (referenced as "V2 message format") and is realistic enough for
documentation readers.
Duplicate comments:
In@docs/frontend/external-bus.md:
- Around line 454-467: The documentation for the
navigatepayload is missing
parameter descriptions; update thenavigatepayload block to documentpath
andoptions.replaceby stating thatpathis the URL path to navigate to
(examples like "/lovelace/0" or "/config/dashboard" and whether it should be
treated as absolute from the frontend root) and thatoptions.replaceis a
boolean which, when true, replaces the current browser history entry instead of
pushing a new one; keep the existing type signature fornavigateand add those
two concise bullet descriptions next topathandoptions.replace.</details> <details> <summary>🪄 Autofix (Beta)</summary> Fix all unresolved CodeRabbit comments on this PR: - [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended) - [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Organization UI **Review profile**: CHILL **Plan**: Pro **Run ID**: `86bad38b-dbc7-4e27-9e95-46ef7ea7bfe6` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 09d07540d4b216ae6470a05763e0c8ced793271b and 2c399bfd52b733300811865ec81de815e64988df. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `docs/frontend/external-authentication.md` * `docs/frontend/external-bus.md` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * docs/frontend/external-authentication.md </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
|
|
||
| **V2 (recommended)**: Uses [`WebViewFeature.WEB_MESSAGE_LISTENER`][web-message-listener] for secure origin validation. The frontend sends messages using the injected V2 object: | ||
|
|
||
| ``` |
There was a problem hiding this comment.
Fix incomplete code block.
The code block is empty and has no language identifier. This appears to be an error. Based on the context, this should likely demonstrate the V2 message format or be removed if not needed.
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)
[warning] 17-17: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/frontend/external-bus.md` at line 17, Replace the empty fenced code
block with a concrete V2 message example (or remove it if unnecessary): add a
fenced block with a language tag (e.g., ```json) and a representative V2 message
showing fields like version (e.g., "v2"), id/messageId, type/event, timestamp,
and payload/body to illustrate the V2 message format; ensure the example matches
the repo's V2 schema naming (referenced as "V2 message format") and is realistic
enough for documentation readers.
Proposed change
Update the documentation regarding the external bus messages and how to set it up properly.
Type of change
Checklist
Additional information
Summary by CodeRabbit