Skip to content

fix(desktop): reload Vite when workspace exports change - #4643

Merged
Astro-Han merged 2 commits into
apache:mainfrom
Astro-Han:fix/desktop-refresh-workspace-exports
Sep 3, 2026
Merged

fix(desktop): reload Vite when workspace exports change#4643
Astro-Han merged 2 commits into
apache:mainfrom
Astro-Han:fix/desktop-refresh-workspace-exports

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

When a running Desktop dev server loads an updated renderer import after a workspace adds a package export, Vite can keep resolving against the old manifest and show "./workhub-session-resolver" is not exported under the conditions [...]. The export introduced in #4439 is present in main; the stale resolver is the failing boundary.

Register the root manifest and its declared workspace manifests as Vite configuration dependencies. Vite then watches these files outside the renderer root and uses its existing server restart path to replace the native resolver cache. Ordinary file watching alone does not clear that cache.

The addition is a dev-only Vite plugin for missing invalidation metadata. Package exports remain the resolution authority; there is no separate cache or restart controller to maintain. Workspace build outputs still come from the existing build flow. This does not add library, main-process, or preload hot rebuilding.

The renderer architecture contract also pins the new plugin import, repository-root argument, and position alongside the existing entry guards. Its valid-entry fixture uses the same plugin list.

Verification

  • Regression obligation: after a workspace adds an export and an existing renderer module imports it, the same dev-server URL serves the updated module successfully. One real Vite HTTP test covers this with the workspace output already built, and is included in Desktop test:dist.
  • Confirmed RED with the exact screenshot error and HTTP 500; GREEN after the change. Removing workspace manifest registration reproduces the failure again.
  • 21 targeted tests passed: the new regression and existing dev launcher tests, after building @maka/core.
  • The CI renderer architecture command passed against base 148f8eb297c86aa3045c75e87e19cacd4967c2dc, including 71 existing architecture tests. The updated valid-entry fixture failed before the checker was updated.
  • Actual Desktop Vite configuration served application/contracts/workhub-request-intent.ts with HTTP 200 and resolved the new core export.
  • npm run format, npm run lint, focused plugin TypeScript check, Windows test inventory, and git diff --check passed.
  • Full workspace suites and an Electron window were not run; this changes development module resolution, with no visual layout change.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex investigated the resolver cache, implemented the Vite integration, and wrote and ran the regression test.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Workspace manifests live outside the renderer watch root, and ordinary file invalidation leaves Vite's native package resolver cache stale. Register those manifests as configuration dependencies so Vite owns watching and restarting. Keep package exports authoritative and retain the existing workspace build flow.

Generated-by: Codex
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 3, 2026

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved from the code-review perspective.

The Vite lifecycle and regression behavior are sound. The current required test check fails because check-renderer-architecture.mjs still pins the Vite plugin array to exactly four entries and the previous indices. This PR inserts workspacePackagesPlugin, so that checker deterministically reports “Vite must build src/renderer/index.html into dist-renderer without an input override.” Please update the checker and its canonical fixture to recognize workspacePackagesPlugin(REPO_ROOT), while keeping rendererEntryContractPlugin as the final guard. Once that contract mismatch is fixed and CI passes, this change is acceptable.

中文

从代码审查角度批准。

Vite 生命周期和回归行为本身没有问题。目前必需的 test 检查失败,是因为 check-renderer-architecture.mjs 仍把 Vite plugin 数组固定为 4 项并使用旧索引;本 PR 插入 workspacePackagesPlugin 后,checker 会稳定报出“Vite must build src/renderer/index.html into dist-renderer without an input override”。请同步更新 checker 及其 canonical fixture,明确接受 workspacePackagesPlugin(REPO_ROOT),并继续保持 rendererEntryContractPlugin 为最后一道 guard。修复该 contract 不一致且 CI 通过后,此变更即可接受。

…ract

The renderer entry guard pins Vite plugin identity, arguments, and order. Include the workspace export invalidation plugin in that contract while preserving the entry and output restrictions. Update the existing valid-entry fixture to exercise the production plugin list.

Generated-by: Codex
@Astro-Han
Astro-Han marked this pull request as ready for review September 3, 2026 10:29
@Astro-Han
Astro-Han merged commit ebcf921 into apache:main Sep 3, 2026
5 of 6 checks passed
@Astro-Han
Astro-Han deleted the fix/desktop-refresh-workspace-exports branch September 3, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants