Skip to content

feat: Default the PWA manifest start_url and scope to the base path - #1086

Merged
MartinZikmund merged 3 commits into
unoplatform:mainfrom
mikernet:dev/mikernet/pwa-manifest-defaults
Oct 8, 2026
Merged

MartinZikmund merged 3 commits into
unoplatform:mainfrom
mikernet:dev/mikernet/pwa-manifest-defaults

Conversation

@mikernet

@mikernet mikernet commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1085

What is the current behavior?

start_url and scope in the PWA manifest are left to the author. The Uno templates hard-code them to /index.html and /, which repeats WasmShellWebAppBasePath and is wrong for an app hosted under a sub-folder.

What is the new behavior?

GeneratePWAContent() applies PwaManifestHelper.ApplyDefaults before writing the manifest: when start_url or scope is absent, it is set to the normalized WasmShellWebAppBasePath. 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 Content build 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.html

The template value /index.html caused 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 opens start_url offline, the network-first fetch handler falls back to caches.match and 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.html would 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_PwaManifestHelper unit tests cover the default, explicit and partial cases; unit test project passes, 47 tests.
  • Uno.Wasm.Tests.Fingerprint built 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 Medium severity · 1 Low severity

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.ApplyDefaults plus 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.

Copilot AI review requested due to automatic review settings September 21, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation is small, directly matches the linked issue/spec requirements, and is covered by targeted unit tests.

Review effort: Lite
Findings: None

Resolved since last review (2)

@mikernet

mikernet commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

The Packages Windows failure here is not related to this change. The only failing task is Authenticode Sign Packages: the sign tool rejects an empty Azure tenant id for every package because PR builds don't receive the signing secrets. Every other job (Linux, Windows and macOS tests, docs checks, and the package build itself) passes.

The signing step is meant to be skipped on pull requests, but its condition in build/ci/stage-build-packages.yml is indented under the task's parameters, so the pipeline ignores it. #1080 moves that line to the task level and is the only one of my open PRs with a green Packages Windows job. Once #1080 is in, a re-run against master will clear this.

mikernet and others added 3 commits October 8, 2026 10:20
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.
@MartinZikmund
MartinZikmund force-pushed the dev/mikernet/pwa-manifest-defaults branch from 741df4e to 6f9dbf2 Compare October 8, 2026 08:21
Copilot AI lite review requested due to automatic review settings October 8, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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.

Comment thread specs/011-pwa-manifest-defaults/spec.md Resolved
@MartinZikmund

Copy link
Copy Markdown
Member

🤖 Addressed PR comments up to this point

@MartinZikmund
MartinZikmund merged commit 267c34d into unoplatform:main Oct 8, 2026
15 checks passed
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.

Default the PWA manifest start_url and scope from WasmShellWebAppBasePath

3 participants