Skip to content

Fix manifest editor: repeated elements, CDATA, UWP-only SupportsMultipleInstances, image path probing - #394

Open
Chiara Mooney (chiaramooney) wants to merge 18 commits into
mainfrom
chiaramooney-manifest-editor-fixes
Open

Chiara Mooney (chiaramooney) wants to merge 18 commits into
mainfrom
chiaramooney-manifest-editor-fixes

Conversation

@chiaramooney

@chiaramooney Chiara Mooney (chiaramooney) commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Four manifest editor fixes:

  • Repeated extension elements edit the right one. Before, editing the second <Task>, <uap3:Host> or <uap:FileType> overwrote the first. Each field now carries the path to its element. Labels are numbered when names repeat (Task[1].Type, Task[2].Type), and edits land on that exact element. If the document changed and the path no longer points at an element with that name, the edit is skipped.
  • CDATA survives edits. Editing text inside <![CDATA[...]]> (package Description, extension text such as FileType) keeps the CDATA wrapper instead of rewriting it as escaped text; only a literal ]]> is split, as XML requires. The editor's edits find elements by searching the file text, so CDATA sections and comments are now hidden from that search while an edit runs. Tag-like text inside them (for example Use <Logo> here, or a commented-out <Capability>) can no longer be mistaken for a real element.
  • SupportsMultipleInstances is UWP-only. The "Add Supports Multiple Instances" button is hidden for packaged desktop apps. An existing attribute is left alone and stays editable, because shipped full-trust manifests (for example the Python Install Manager) declare it. Console apps (Subsystem="console") keep the button, because they must declare the attribute. An app counts as desktop when:
    • RuntimeBehavior is packagedClassicApp or win32App, or EntryPoint is Windows.FullTrustApplication/Windows.PartialTrustApplication; or
    • it uses the VS / WinUI 3 template token EntryPoint="$targetentrypoint$" and the project file next to the manifest is a desktop project (UseWinUI, the Windows App SDK, WindowsPackageType, or a .wapproj). A UAP or UseUwp project keeps it UWP; or
    • there is no recognizable project file, and the package declares runFullTrust without a windows.fullTrustProcess helper. UWP templates don't declare runFullTrust.
  • No more local file-existence check from the webview. checkImagePath no longer touches disk for paths outside the manifest folder and open workspace folders. Such paths show "Image is outside the package and workspace. Use Choose file to copy it into Assets." When Choose file picks an image outside the package and workspace, it is copied into Assets\ in one step, because a package can't reference files outside it.

Related fixes found along the way:

  • The webview regex that routes extension-field validation errors to their inputs used \d inside a template literal, which emits a plain d, so extension-field errors were never shown in the form. They now appear, and errors for repeated elements land on the correct input.
  • Because those errors are now visible, FileTypeAssociation.Name is validated against the schema type ST_FTAName instead of a stricter regex that rejected valid names like my-files.
  • Setting a package property (for example Description) to the value it already has no longer inserts a second copy of the element.
  • Extension field edits find the element's real tag boundaries (a > inside an attribute value no longer confuses them) and match the exact attribute name, so editing Name can't change DisplayName, a namespace declaration, or text inside another attribute's value.
  • Removing the badge or splash screen image removes only that element (found as a child of the app's VisualElements), so a comment or other element on the same line is kept and the manifest stays valid.

Usage Example

<Extension Category="windows.backgroundTasks" EntryPoint="Tasks.Bg">
  <BackgroundTasks>
    <Task Type="timer" />
    <Task Type="systemEvent" />
  </BackgroundTasks>
</Extension>

The editor shows Task[1].Type and Task[2].Type. Editing the second changes only <Task Type="systemEvent" /> (covered by unit tests).

Related Issue

Fixes #128
Fixes #151
Fixes #152
Fixes #263
Fixes #167
Fixes #289

Type of Change

  • 🐛 Bug fix
  • 🧪 Test update

Checklist

  • New tests added for new functionality (if applicable)
  • Tested locally on Windows (if applicable)

Screenshots / Demo

Not captured yet. The webview behavior is covered by Playwright specs (webview-state.spec.ts, applications-tab.spec.ts, project-app-kind.spec.ts).

Additional Notes

Validation (local, Windows):

  • npm run compile-tsc: passed
  • npm run lint: 0 errors (10 warnings, all already present)
  • npm run test:unit: passed (1735 + 31 node tests, 40 mocha)
  • npm run test:e2e (full suite, real VS Code) on f7d3c6b: 277 passed, 3 skipped, 3 flaky, 0 failed. The flaky tests are can remove Square 310x310 Logo visual asset (also flaky on unmodified main) and two properties-tab timing tests.
  • On the final head: applications-tab, webview-state and project-app-kind passed (81 passed, 1 flaky: the 310x310 test). Earlier (d8512da), the editor specs (webview-state, properties-tab, applications-tab, identity-tab, dependencies-tab, capabilities-tab, resources-tab, parse-error, project-app-kind): 165 passed, 2 flaky (same tests).
  • New live spec project-app-kind.spec.ts fails when the project-file wiring is removed, so it guards that path.
  • Not exercised: the native Choose file dialog itself, which Playwright can't drive. The copy-or-relative decision is unit tested (relativeImagePathOrCopy).

Behavior change (#167): typing an absolute path to an image outside the workspace no longer gives a one-click "Copy to Assets" link. Use Choose file, which now copies outside images into Assets\ directly. Files inside the workspace but outside the package still get the one-click link.

Project detection (#263) reads only project files in the manifest's own folder (up to 1 MB each), once when the editor opens. A manifest whose project lives elsewhere falls back to the runFullTrust check.

AI Description

This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments.

… image path probing

- Target repeated extension child elements by element path and label them (Task[2].Type) (#128, #151, #289)
- Preserve CDATA sections when editing text content (#152)
- Only offer SupportsMultipleInstances for UWP apps; warn when set on desktop apps (#263)
- Never inspect webview-supplied image paths outside the package/workspace; copy them only via a native picker (#167)
- Fix extension-field validation routing regex that emitted 'd' instead of '\d'

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney Chiara Mooney (chiaramooney) added agent-preparing Agent work in progress (feedback, validation, or CI) manifest-editor labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

VSIX Build

Artifact Baseline Current Delta
VS Code Extension (VSIX) 72.55 MB 72.55 MB 📈 +2.7 KB (+0.00%)

Updated 2026-12-01 23:18:17 UTC · commit 39a165e · workflow run

…py, schema-based FTA name check

- applyFieldChange inserts only when the element is missing, so writing the current value no longer duplicates it
- Browse copies images from outside the package/workspace into Assets; drop the second picker link
- Validate FileTypeAssociation.Name against ST_FTAName instead of a stricter regex
- Split '</' inside CDATA so later edits find the real closing tag
- Test that repeated-element errors route to the matching input

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ances (#263)

Template manifests use EntryPoint="$targetentrypoint$" with no RuntimeBehavior. The editor now reads
the project file next to the manifest (UseWinUI / Windows App SDK / .wapproj vs UAP / UseUwp) and
falls back to the runFullTrust capability (without a windows.fullTrustProcess helper) when no
project file is recognized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WP detection

- Extract relativeImagePathOrCopy so the Browse copy-vs-relative decision is unit tested
- Live VS Code spec: a UWP project beside a template manifest keeps Supports Multiple Instances

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney
Chiara Mooney (chiaramooney) marked this pull request as ready for review November 25, 2026 17:54
@chiaramooney Chiara Mooney (chiaramooney) added ready-for-review Agent work and checks complete; awaiting human review agent-preparing Agent work in progress (feedback, validation, or CI) and removed agent-preparing Agent work in progress (feedback, validation, or CI) ready-for-review Agent work and checks complete; awaiting human review labels Nov 25, 2026
… inside it

Preserving CDATA (#152) let the editor write raw text such as '<Logo>' into the document,
which later regex-based edits (for example the Logo field) matched instead of the real
element, corrupting the manifest. Split every '<' that is not followed by whitespace, plus
']]>', across CDATA sections.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney Chiara Mooney (chiaramooney) added ready-for-review Agent work and checks complete; awaiting human review and removed agent-preparing Agent work in progress (feedback, validation, or CI) labels Nov 30, 2026
…DATA text

Edits locate elements by text search, so tag-like text inside CDATA or comments could be
matched instead of the real element. The provider and the save path now swap CDATA sections
and comments for placeholders while edits run and restore them afterwards. CDATA the editor
writes stays clean (only ']]>' is split, as XML requires), and hand-written CDATA containing
the element's own closing tag no longer breaks the next edit.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…aceholders

- Save flush hides CDATA and comments before each change, so CDATA written by an earlier
  change in the same save can't be matched by a later one
- One placeholder per line keeps line-based removals from reaching past multi-line comments
- Processing instructions are skipped so a '<!--' inside one isn't read as a comment
- Placeholders carry a per-edit nonce and restore only their own

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The hiding scan is quadratic on unclosed '<?', '<!--' or '<![CDATA['. Unparseable text is never
edited, so skip the scan for it and keep each webview message linear on crafted manifests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney Chiara Mooney (chiaramooney) added agent-preparing Agent work in progress (feedback, validation, or CI) ready-for-review Agent work and checks complete; awaiting human review and removed ready-for-review Agent work and checks complete; awaiting human review agent-preparing Agent work in progress (feedback, validation, or CI) labels Nov 30, 2026
A DOCTYPE entity value can hold unclosed '<!--', '<?' or '<![CDATA[' openers and still parse,
which made the alternation regex quadratic on every webview message. Scan left to right with
indexOf and remember terminators already known to be missing. Output is unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The child-element scanner ended a tag at the first '>', so a '>' inside an attribute value
miscounted children and silently dropped element-path edits (main edited by first name match).
Find tag ends while skipping quoted values, skip processing instructions in the nested scan,
and with an element path replace text and attributes using the target's real tag bounds.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The attribute regex had no name boundary, so 'Name' could match inside 'DisplayName' or inside
another attribute's quoted value. Walk the opening tag's attributes sequentially and match the
exact (optionally prefixed) name.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…g attributes

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney Chiara Mooney (chiaramooney) added agent-preparing Agent work in progress (feedback, validation, or CI) ready-for-review Agent work and checks complete; awaiting human review and removed ready-for-review Agent work and checks complete; awaiting human review labels Nov 30, 2026
@chiaramooney Chiara Mooney (chiaramooney) removed the agent-preparing Agent work in progress (feedback, validation, or CI) label Dec 1, 2026
…line

Badge and splash-screen removal deleted everything to the end of the line, which cut a
multi-line comment starting on that line and could leave the manifest unparseable. Remove the
element (self-closing or open/close) with its surrounding spaces, and the whole line only when
nothing else is on it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…rations

- Remove the LockScreen/SplashScreen that is a direct child of the app's VisualElements, using the
  element scanner, so look-alike names in extension metadata or a processing instruction inside
  the element can't be matched
- Attribute matching skips only 'xmlns' and 'xmlns:*', so custom attributes like 'xmlnsMode' save

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney Chiara Mooney (chiaramooney) added agent-preparing Agent work in progress (feedback, validation, or CI) ready-for-review Agent work and checks complete; awaiting human review and removed ready-for-review Agent work and checks complete; awaiting human review agent-preparing Agent work in progress (feedback, validation, or CI) labels Dec 1, 2026
Console apps must declare SupportsMultipleInstances (Application schema remarks), including
full-trust desktop console apps such as the Python Install Manager. Don't warn about it or hide
the Add button when the application declares Subsystem="console" in any namespace.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
#263 only asks the editor to stop offering the attribute for non-UWP apps. Shipped full-trust
manifests (for example the Python Install Manager) declare it on windowed apps, so telling
users to remove it was overreach. The Add button stays hidden for non-console desktop apps.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney Chiara Mooney (chiaramooney) added agent-preparing Agent work in progress (feedback, validation, or CI) ready-for-review Agent work and checks complete; awaiting human review and removed ready-for-review Agent work and checks complete; awaiting human review agent-preparing Agent work in progress (feedback, validation, or CI) labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment