Skip to content

Expose the working directory in target snapshots - #882

Merged
Nikola Metulev (nmetulev) merged 9 commits into
mainfrom
nmetulev-snapshot-work-root
Sep 21, 2026
Merged

Nikola Metulev (nmetulev) merged 9 commits into
mainfrom
nmetulev-snapshot-work-root

Conversation

@nmetulev

@nmetulev Nikola Metulev (nmetulev) commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #879.

  • Expose snapshot workRoot (text: Work root) separately from capabilities.managedRoot, using GuestPaths.Resolve and the existing transfer WorkScope. Missing guest/root metadata stays omitted; snapshot remains read-only.
  • With explicit user approval, fix related push JSON/text reporting to use the prepared guest's actual root instead of hardcoded C:\WinApp\work. Resolve before copying, so missing-root metadata fails before writes. Copy destinations, accepted relative paths, and target lifecycle are unchanged.
  • Make preconnection advice target-neutral and update the guide, usage reference, and shipped Sandbox skill. Single-file examples use the returned path's parent for --cwd.

Validation

  • Snapshot JSON/text tests failed before implementation. A real command/guest-service in-memory probe reproduced the nondefault-root push-response mismatch. Four reporting regressions failed before the correction and pass afterward; directory-to-. and default-root output are covered too.
  • 162 targeted non-UI tests pass on 28306ce829ff950c1b692bcb096f44989fdb75f9: snapshot/capture-command fakes, shared guest paths, parser/path acceptance, path safety, source/link handling, and guest file services.
  • Current-head scripts\build-cli.ps1 -SkipTests passed both NativeAOT architectures, npm format/lint/compile/package, four NuGet packages, both MSIX packages and generated docs. scripts\validate-llm-docs.ps1 passed including plugin conformance. Generated schema/manifests unchanged. Earlier iterations also passed npm run build and -OnlyDocs.
  • Full local suites deliberately skipped with -SkipTests to avoid uncoordinated live UI. Repository CI subsequently passed: CLI 6,632 passed / 0 failed / 35 skipped, UIAutomation 875 passed / 0 failed / 2 skipped, analyzer 65 passed, plus the separate UI E2E/coordination job and all 14 sample jobs.
  • Initial snapshot commit 298df24bad11308be8e0523c6f58e69c69ec0394 passed a coordinated live default-root snapshot/path check: workRoot=C:\WinApp\work matched an installed-transport unique upload's destination/content; exact guest/host probes cleaned, epoch/readiness unchanged. No UI/lifecycle/guest-CLI change. This does not claim live coverage of the later formatter correction.
  • The current candidate push was not live-run against the shared Sandbox because normal preparation fallback could repair the guest on attachment failure. Direct candidate-command/GuestFileService in-memory tests validate its formatter; an installed-only upload would not test the new code.
  • Live snapshot used the existing process-scoped WINAPP_TARGET_STATE_ROOT selector for the installed package's physical ownership store. The unconfigured developer build correctly reported its obsolete unpackaged record as stale. No state/credentials copied or modified; installed transfer environment unchanged. Installed CLI version was not explicitly recorded.
  • First live candidate SHA256: 301423ADFB580FF189307B6E31FCE50BA099F0AB9788BA350A2C6DAAF0CBC271. Current built ARM64 SHA256: F975D2D433A6B39943029BEE86CBF0FAC98E00C40E846DB43770829D152DDE38.

CI retry disclosure

build-and-package attempt 1 failed in the existing QueryOptions_RealApp_DelayedRootAndReadCommands replacement-provider wait (exit 1; 17.482s). That test and its UI implementation are unchanged; it passed on the exact base commit in 11.674s. The failure artifacts omit child stdout, so a timeout/provider-timing explanation is consistent with the evidence but not proven.

One approved failed-job rerun on the unchanged head succeeded: Build and Package attempt 2. The same test passed in 11.635s. First-failure, baseline and rerun TRX evidence was preserved. No assertions were weakened, no unrelated code changed, and no further retries were needed.

Ready for human review

Verified head: 28306ce829ff950c1b692bcb096f44989fdb75f9; based on current main 09a401bc9877625a1e7b2b915fea09833bafbb05.

Required build/package and all relevant build, sample, UI E2E, docs and language-analysis checks are successful. The aggregate CodeQL check is neutral; underlying analyses succeeded. Copilot's latest-head review recommends approval, reviewed 10/10 files and generated no new comments. All 11 review threads are resolved: actionable findings fixed, fixed-relative-literal test reports explained. Human approval is still required. No merge requested.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread src/winapp-CLI/WinApp.Cli.Tests/TargetCaptureCommandTests.cs Fixed
Comment thread src/winapp-CLI/WinApp.Cli.Tests/TargetCaptureCommandTests.cs Fixed
Comment thread src/winapp-CLI/WinApp.Cli.Tests/TargetCaptureCommandTests.cs Fixed
Comment thread src/winapp-CLI/WinApp.Cli/Commands/TargetSnapshotCommand.cs Fixed
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Transfer output still reports a hard-coded root that can conflict with the new snapshot value.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Exposes the target’s transfer working directory in snapshots without changing transfer behavior.

Changes:

  • Adds JSON workRoot and text Work root output.
  • Omits the field when unavailable.
  • Adds regression tests and updates Sandbox guidance.
File summaries
File Description
src/winapp-CLI/WinApp.Cli/Commands/TargetSnapshotCommand.cs Resolves and displays the work root.
src/winapp-CLI/WinApp.Cli.Tests/TargetCaptureCommandTests.cs Tests output, non-default roots, and omission behavior.
docs/sandbox-execution.md Documents snapshot and transfer-path semantics.
Review details

Suppressed comments (1)

docs/sandbox-execution.md:292

  • What is wrong: The new target-specific contract is not applied consistently across the shipped instructions. This guide's --cwd C:\WinApp\work\Setup example, docs/usage.md:1595, and plugins/winapp/skills/winapp-sandbox/SKILL.md:118,126 still assume the default root.

Show me: If a snapshot reports workRoot = D:\Managed\work, those examples direct users or agents to C:\WinApp\work instead.

Why it matters: Follow-up commands can look in the wrong directory after a successful transfer.

Smallest fix: Update the hand-authored examples and references to derive --cwd from the snapshot's workRoot, retaining C:\WinApp\work only as the normal default.

For `push` and `pull`, **target paths are relative to the `workRoot` reported by
[`target snapshot`](#inspecting-the-sandbox)**. Absolute,
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/winapp-CLI/WinApp.Cli.Tests/TargetCaptureCommandTests.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The scoped implementation reuses authoritative path resolution and has focused regression coverage.

Review details

Suppressed comments (1)

docs/sandbox-execution.md:292

  • What is wrong: The new guidance treats the snapshot's workRoot as authoritative, but the example immediately above still uses --cwd C:\WinApp\work\Setup. The command reference and shipped Sandbox skill also still describe C:\WinApp\work as fixed (docs/usage.md:1595 and plugins/winapp/skills/winapp-sandbox/SKILL.md:118,126).

Show me: If the guest reports workRoot = D:\Managed\work, following these instructions runs the copied script from C:\WinApp\work\Setup instead of D:\Managed\work\Setup.

Why it matters: Users and agents can select a nonexistent working directory despite the snapshot exposing the correct base.

Smallest fix: Update the example and linked hand-authored guidance to derive --cwd from the reported workRoot; keep C:\WinApp\work only as the default example.

For `push` and `pull`, **target paths are relative to the `workRoot` reported by
[`target snapshot`](#inspecting-the-sandbox)**. Absolute,
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation uses authoritative guest path resolution with focused regression coverage and updated documentation.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 57.03 MB 57.03 MB 📈 +1.0 KB (+0.00%)
CLI (x64) 57.07 MB 57.07 MB 📈 +1.5 KB (+0.00%)
MSIX (ARM64) 23.72 MB 23.72 MB 📉 -0.6 KB (-0.00%)
MSIX (x64) 25.16 MB 25.16 MB 📈 +0.9 KB (+0.00%)
NPM Package 49.44 MB 49.44 MB 📈 +1.9 KB (+0.00%)
NuGet Package 49.55 MB 49.55 MB 📈 +1.6 KB (+0.00%)

Test Results

✅ 7611 passed, 37 skipped out of 7648 tests in 1311.1s (+13 tests, +118.9s vs. baseline)

Test Coverage

✅ 85.8% line coverage, 79.9% branch coverage · ✅ no change vs. baseline

CLI Startup Time

62ms median (x64, winapp --version) · ✅ -10ms vs. baseline

Try This Build

Installs the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing.

& ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 882
Switching between builds often?

Put the tool on your PATH once:

& ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPath

Then this build is just:

winapp-pr 882

Run winapp-pr with no arguments to pick from a list of open PRs.


Updated 2026-09-19 22:37:10 UTC · commit 1959e71 · workflow run

@nmetulev
Nikola Metulev (nmetulev) marked this pull request as ready for review September 18, 2026 22:20

@zateutsch Zach Teutsch (zateutsch) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review fully clean. Approving.

@nmetulev
Nikola Metulev (nmetulev) merged commit 125396f into main Sep 21, 2026
3 checks passed
@nmetulev
Nikola Metulev (nmetulev) deleted the nmetulev-snapshot-work-root branch September 21, 2026 20:12
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.

[Bug]: Target snapshot does not expose the working directory used by relative file transfers

3 participants