Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/watcher-compile-scratch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"agent-bundle": patch
---

Ignore the package build's `.<output>.compile-XXXXXX` scratch directory in the `agent-bundle dev` source watcher, so a `dist/` package build no longer republishes the epoch it just produced and Workbench invocations run under the epoch that was active when they were queued. (#669)
9 changes: 5 additions & 4 deletions packages/agent-bundle/src/dev/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ const relativePath = (root: string, path: string): string | undefined => {
* Whether `source` is inside the staging directory an output root is
* assembled in: the package build (`package-build.ts`) and the artifact
* build (`build.ts`) `mkdtemp` a `.<output>.stage-XXXXXX` sibling of the
* output root and rename it into place, so those paths are build output
* too, not source. Without this, every `dist/` package build inside
* output root and rename it into place, and the package build compiles in a
* `.<output>.compile-XXXXXX` sibling first (#656), so those paths are build
* output too, not source. Without this, every `dist/` package build inside
* `agent-bundle dev` would invalidate the epoch it just produced.
*/
const isOutputStagingPath = (output: string, source: string): boolean => {
const parent = dirname(output);
const prefix = `${parent === '.' ? '' : `${parent}/`}.${basename(output)}.stage-`;
return source.startsWith(prefix);
const prefix = `${parent === '.' ? '' : `${parent}/`}.${basename(output)}.`;
return source.startsWith(`${prefix}stage-`) || source.startsWith(`${prefix}compile-`);
};

const defaultPathSignature = async (path: string): Promise<string | undefined> => {
Expand Down
4 changes: 4 additions & 0 deletions packages/agent-bundle/tests/dev-watcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ it('debounces only relevant source paths into one ordered invalidation and close
// renaming it into place; that staging tree is output, not source.
fake.emit('addDir', '/project with spaces/.dist.stage-W3rHAr');
fake.emit('add', '/project with spaces/.dist.stage-W3rHAr/bin/plugin.js');
// ... and compiles into a `.dist.compile-XXXXXX` sibling first (#656).
fake.emit('addDir', '/project with spaces/.dist.compile-Qm2xLp');
fake.emit('add', '/project with spaces/.dist.compile-Qm2xLp/bin/plugin.js');
fake.emit('unlinkDir', '/project with spaces/.dist.compile-Qm2xLp');
fake.emit('add', '/project with spaces/.distinct-source.ts');
await watcher.flush();

Expand Down
Loading