Repository navigation
feat: Default the PWA manifest start_url and scope to the base path - #1086
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new helper currently copies WasmShellWebAppBasePath verbatim (without local normalization) and the unit tests miss the symmetric “scope-only” partial case, leaving the documented/spec’d behavior insufficiently guarded.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
This PR updates the WebAssembly bootstrapper so PWA manifests default start_url and scope to WasmShellWebAppBasePath when those fields are absent, improving correctness for apps hosted under sub-paths (e.g., /app/). It also adds unit tests, documentation, and a spec describing the behavior.
Changes:
- Apply PWA manifest defaults during
GeneratePWAContent()before emitting/writing the manifest. - Introduce
PwaManifestHelper.ApplyDefaultsplus MSTest coverage for default/explicit/partial cases. - Document the new defaulting behavior and update guidance for Uno.Sdk vs non-Uno.Sdk projects; add a feature spec.
Note: The PR description uses Fixes #1085; repo guidelines typically require a fully-qualified issue URL.
| File | Description |
|---|---|
| src/Uno.Wasm.Bootstrap/ShellTask.cs | Applies the new manifest defaulting step during PWA content generation. |
| src/Uno.Wasm.Bootstrap/PwaManifestHelper.cs | Adds helper to set start_url/scope defaults when missing. |
| src/Uno.Wasm.Bootstrap.UnitTests/Given_PwaManifestHelper.cs | Adds unit tests validating defaulting and preservation behavior. |
| specs/007-pwa-manifest-defaults/spec.md | Documents requirements, edge cases, and validation strategy. |
| doc/features-pwa.md | Documents default behavior and clarifies manifest build-action guidance. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
The The signing step is meant to be skipped on pull requests, but its |
A manifest without start_url or scope now gets both from WasmShellWebAppBasePath, so an application hosted under a sub-folder launches and scopes there without repeating the path in the manifest. Values present in the manifest are kept. The PWA doc no longer tells Uno.Sdk projects to set a Content build action on the manifest, which the SDK picks up by name.
ApplyDefaults adds the trailing slash itself so the manifest members are URL prefixes even when the property is written without one.
007 is taken on main by the dotnet.js fingerprint resolution spec. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ADrzrqtw3RQdHan77rypBM
741df4e to
6f9dbf2
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues were identified; only a minor specification-link nit remains.
1 open finding
🧠 Review effort: Lite
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
🤖 Addressed PR comments up to this point
|


Fixes #1085
What is the current behavior?
start_urlandscopein the PWA manifest are left to the author. The Uno templates hard-code them to/index.htmland/, which repeatsWasmShellWebAppBasePathand is wrong for an app hosted under a sub-folder.What is the new behavior?
GeneratePWAContent()appliesPwaManifestHelper.ApplyDefaultsbefore writing the manifest: whenstart_urlorscopeis absent, it is set to the normalizedWasmShellWebAppBasePath. Values present in the manifest are kept.The PWA doc gains a section on the defaults and no longer instructs Uno.Sdk projects to set a
Contentbuild action on the manifest (the SDK picks the file up by name, and setting the action conflicts with it). Spec:specs/011-pwa-manifest-defaults/spec.md.A companion change removes the hard-coded members from the template manifest: unoplatform/uno.templates#2269.
Why the base path rather than
/index.htmlThe template value
/index.htmlcaused a startup error in a real app: the installed PWA launched at a literal file path that the app's client-side router did not recognize as a route. Launching at the base path avoids that, and it is what the site serves for that URL anyway.Offline launch does not depend on the file name either. The service worker precaches every entry of
config.offline_files, whose first entry is the base path itself, so the cache holds a response under the/key (and one under/index.html). When the installed app opensstart_urloffline, the network-first fetch handler falls back tocaches.matchand finds it. No server redirect or SPA fallback is involved.The one thing to keep in mind is that the cached response for the base path must be a plain 200: a host that redirected
/to/index.htmlwould cache a redirected response, which browsers refuse to use for a navigation. IIS, Azure Static Web Apps and the shipped hosting configs serve/directly, so the base path is the right default.Validation
Given_PwaManifestHelperunit tests cover the default, explicit and partial cases; unit test project passes, 47 tests.Uno.Wasm.Tests.Fingerprintbuilt with a manifest that omits both members:/app/yields"start_url": "/app/", "scope": "/app/";/yields/;./yields./. With a manifest that defines them, the values are unchanged.