Skip to content

feat: auto-download cli binary in editor window#137

Merged
hashiiiii merged 5 commits into
mainfrom
feat/editor-cli-auto-download
Jul 14, 2026
Merged

feat: auto-download cli binary in editor window#137
hashiiiii merged 5 commits into
mainfrom
feat/editor-cli-auto-download

Conversation

@hashiiiii

Copy link
Copy Markdown
Owner

Summary

The Unity Editor window now downloads the pinned prefablens CLI binary automatically when it is missing, instead of showing a "Download from GitHub Releases" button on every package-version bump. The download runs off the main thread with progress in the status line, and stale Library/PrefabLens/<old-version>/ caches are cleaned up best-effort after a successful download.

Closes #135

Motivation

Cli.Version bumps with every package update, so each upgrade dropped users back to the not-found screen for a click that adds nothing: installing the package already expressed intent, the asset is version-pinned from the project's own releases, and the README/site copy has always described the download as automatic. The old code also blocked the Unity main thread behind a modal progress bar, which auto-triggering would have made unacceptable.

Changes

  • Cli.Download() no longer touches Unity APIs (modal progress bar removed) so it can run on a worker thread; .GetAwaiter().GetResult() unwraps AggregateException for clean error messages
  • New Cli.DownloadAsync(Action<string, string> onDone) mirrors the existing RunAsync SynchronizationContext pattern; exactly one of (path, error) is non-null
  • New pure helpers Cli.ExtractTo and Cli.DeleteStaleVersions (best-effort: a locked old-version directory on Windows cannot fail a successful download), both unit-tested
  • PrefabLensWindow.Refresh() auto-starts the download once per session when Cli.Find() misses; status line shows Downloading prefablens v{Version}…; failure falls back to the manual screen with the error and a retry button sharing the same StartDownload path; DownloadThenRefresh deleted
  • Both list-reset sites also null lastStdout so the post-download re-render cannot be skipped by OnBulkDone's unchanged-output dedupe (this also fixes a pre-existing latent variant on the manual path)
  • The EditorPrefs manual override (PrefabLens.CliPath) and version pinning are unchanged; no PATH search

Testing

  • dotnet test DotNetTests~/Tests: 25/25 passed (3 new tests: real in-memory zip extraction, stale-version cleanup, missing-root no-op)
  • dotnet csharpier check . --no-msbuild-check: clean
  • TDD: the new tests failed with CS0117 before the implementation existed, then passed
  • Reviewed: per-task reviews plus a whole-branch review walked the download/refresh state machine (first open, focus during download, failure + refocus, manual retry, success, mid-session binary loss) — verdict "Ready to merge"

Note

Post-merge manual task: real-Unity GUI smoke — with a fresh Library/, open Window > PrefabLens and confirm the automatic download then the changed list; offline, confirm the error + retry screen. The dotnet harness proves compile + pure logic only.

@github-actions github-actions Bot added the editor Unity Editor integration (C#) label Jul 14, 2026
@hashiiiii
hashiiiii merged commit 9fbd4f4 into main Jul 14, 2026
12 checks passed
@hashiiiii
hashiiiii deleted the feat/editor-cli-auto-download branch July 14, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor Unity Editor integration (C#)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-download the CLI binary instead of prompting on every version bump

1 participant