-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Recover content on WebView refresh via pull model #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
Claude finished @dcalhoun's task in 1m 53s —— View job Code Review Complete ✅This PR implements a solid pull-based content recovery mechanism. The implementation is well-structured across all three platforms with comprehensive test coverage. Below is my detailed review. Overall AssessmentStrengths:
Architecture: The pull model is the right approach here. Having the web layer request content rather than push it eliminates timing issues and makes the recovery mechanism more reliable. Detailed Findings1. Code Quality
|
android/Gutenberg/src/main/java/org/wordpress/gutenberg/GutenbergView.kt
Show resolved
Hide resolved
Expose function for retrieving the latest content from the native host. This is useful for ensuring the content is updated after WebView refresh or re-initialization.
Enable the editor to request the latest content from the host.
Enable the editor to request the latest content from the host.
Ensure the editor always uses the latest content. This particularly important for subsequent initialization events--e.g., WebView refresh.
When crossing actor boundaries, Swift requires type to conform to `Sendable`, which `Any?` cannot. Constructing the dictionary outside of the `MainActor` run avoids this incompatibility.
Improve visibility of critical errors.
Mitigate crashes from unexpected characters.
There isn't an explicit preference, but a result of arbitrary code ordering.
55471c3 to
e8dd9ff
Compare
Note the draft post fallback.
| // Since we don't use the auto-save functionality, draft posts need to have an ID. | ||
| // We assign a temporary ID of -1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It remains true we need a -1 fallback ID for draft posts, but this appears unrelated to auto-save. We now use the AutosaveMonitor in the GutenbergKit project.
For posterity, this comment was first added in 444de49.
What?
Adds a pull-based content recovery mechanism that allows the web editor to request the latest content from the native host during initialization.
Why?
Ref CMM-1123.
When the WebView reinitializes (due to OS memory pressure or page refresh), the editor previously loaded stale content from
window.GBKit.postwhich was injected at original load time. The host apps have fresher content from autosave events (~1s intervals), but this wasn't being used on WebView recovery.Related WordPress app PRs:
How?
Implements a pull model where the web editor always requests content from the native host during initialization:
src/utils/bridge.js): AddedrequestLatestContent()function that calls the appropriate native bridge methodEditorViewController.swift): ImplementsWKScriptMessageHandlerWithReplyto respond to content requests via a new delegate methodeditorRequestsLatestContentGutenbergView.kt): AddsLatestContentProviderinterface and@JavascriptInterfacemethod that returns JSON contentsrc/utils/editor.jsx):getPost()now requests content from native host first, falling back towindow.GBKit.postonly when bridge is unavailableTesting Instructions
chrome://inspectAccessibility Testing Instructions
No UI changes - this is a data recovery mechanism that happens during initialization.
Screenshots or screencast
N/A - No visual changes
🤖 Generated with Claude Code