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
6 changes: 6 additions & 0 deletions .claude/docs/V1.2.1_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,9 @@ Then pushed `v1.2.1` to `origin` at the maintainer's request. **No merge and no

**Measured**: `npm test` 1,138/1,138; ESLint warnings unchanged at 154. In Chromium + A-Frame 1.7.1 (scratch page, not committed): before, two added screens both at (0, 2.30, -10.20); after, (0, 2.40, -10.40) and (5.05, 2.40, -10.40); with the table in front of the user the screen goes above the chart volume (y 5.35); a followed screen stops at another screen. Not done: text sizes for VR legibility need a headset (manual guide); the evolution overlay keeps its fixed position (now an obstacle, not moved).

### XR bug-fix epic #72 — S10 reliable project evolution (#82) [confirmed by unit tests + harnesses] (2026-11-25, branch `claude/project-thread-kvvyg6-evolution`)

**What changed**: EVO-5, frames load by their own immutable `dataN.json` URL. The `data.json` bridge is gone, `applyFrameToBridge` became `resolveFrame` (validation only), and apply-frame errors go to the requester only. LIFECYCLE-4, a half-built pipeline is torn down (`failEvolutionPipeline`) and component waits went from 1200 to 4000 ms. EVO-14, progress carries `completed` and the bar is monotonic. EVO-8 (partial), revision analyses run `silent`, snapshots are released after each analysis, and the payload cache is an LRU of 128. EVO-11, one `revision-N` on disk, Clear removes `evolution/`, and revision numbers never reuse a folder. EVO-15, Play at the end restarts, a same-revision replay keeps `frameIndex`, and `setSpeed` does not re-arm under a seek. EVO-13, manual picks are sorted chronologically online and more than `maxFrames` is refused on both ends. EVO-18, the remote HEAD alias is filtered by full ref. EVO-1 was already covered by S6 (plus `applySharedState` now ends `generating`).

**Measured**: `npm test` 1,139/1,139; ESLint 154 (unchanged); filesOver500 unchanged (`resolveEvolutionFrame`/`evolutionDirectoryOf` moved to `projectEvolutionArtifacts.ts`). Harnesses xr-mode, project-evolution (now asserts each frame loads `data<i>.json` and that no bridge file exists) and xr pass. **Not done**: live evolution still materializes snapshots with one `git show` per file and runs the directory analysis per revision; reusing the export's blob pipeline (`GitTimelineBlobAnalyzer` + worker pool) needs a payload-parity check first and is left as follow-up.

9 changes: 9 additions & 0 deletions apps/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
- Two screens turned toward you at an angle could still pass through each other while you dragged or followed them. The collision check now compares the whole panel, not a few points on it.
- Added screens now use the scene's screen settings (sizes, distance in front of you, collision) instead of built-in defaults, and their idle label shows the screen's name ("vscreen 2") instead of an internal id.
- Dependency graph cards now have a close button (**X**, at the top-right corner of a pinned card). The stack stays at most two rows high and grows sideways, so six pinned cards no longer climb through the ceiling.
- **Project evolution is more reliable.**
- Two people moving through the movie at the same time no longer get errors that stop playback for the whole room, or a frame shown under another frame's title. Each frame is now loaded from its own file instead of being copied over a shared one, and a frame that cannot be shown is reported only to the person who asked for it.
- A movie whose first frame could not be built (a component slow to load on a headset, for example) no longer makes the mode impossible to open again until a new movie is generated. The half-built frame is removed and rebuilt, and slow components get 4 s instead of 1.2 s.
- The progress bar now counts finished revisions, so it only moves forward and reaches the end. Before, it jumped back and forth between parallel analyses.
- Generating a movie no longer opens one VS Code notification per revision, and each revision's temporary copy of the project is deleted as soon as it is analyzed instead of staying on disk (up to about 100 MB each) until VS Code closed.
- Only the current movie is kept on disk. Before, every movie generated stayed, **Clear movie** removed only the newest one, and a later export could ship an older movie that had been replaced and cleared.
- **Play** on the last frame starts the movie over instead of stopping at once, and reconnecting to the room keeps the frame you were on instead of jumping back to frame 1.
- Manual movies always play from oldest to newest, as exported movies already did, whatever order the commits were picked in. A 25th pick is refused with a message instead of being dropped without notice.
- The commit picker no longer lists the remote's default-branch alias as a branch named "origin".
- A source file of the XR chart-mapping runtime contained a raw control character typed into a string. Behaviour was correct, but the file was invisible to code search and review tools. It now uses the equivalent escape sequence; the runtime value is identical.

## [1.2.0] - 2026-07-30
Expand Down
23 changes: 18 additions & 5 deletions apps/vscode-extension/docs/features/PROJECT_EVOLUTION_XR.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,32 @@ The XR panel exposes a compact player:
between modes;
- page through available Git sources with previous/next arrows;
- mark range starts in green and range ends in red;
- show manual picks with their selection order;
- show manual picks with their selection order (the movie itself always plays
oldest first, and a manual movie holds at most 24 frames: a 25th pick is
refused with a message);
- play and pause;
- previous and next frame;
- speed presets;
- clear the generated movie for everyone in the shared XR room;
- current frame label, frame count and progress status.

Each frame replaces the active chart datasource and asks the analysis table to
renormalize. Playback waits for the chart/table to settle, then holds briefly
Each frame points the chart datasource at that frame's own file,
`/evolution/revision-N/data<i>.json`, and asks the analysis table to
renormalize. The files are written once and never changed, so participants
seeking at the same time cannot overwrite each other's frame (until 1.2.1 every
frame was copied over a shared `data.json`, which raced). Playback waits for the chart/table to settle, then holds briefly
before advancing, so the movie reads as a sequence of stable scenes instead of a
rapid data swap. While playback is active, a small overlay above the table shows
the current revision, date and frame number. When playback reaches the last
frame, the final chart remains visible and the panel reports completion until
the user generates another movie or presses `Clear movie`. The Field Mapping panel remains
the user generates another movie or presses `Clear movie`; Play on the last
frame starts the movie over. The Field Mapping panel remains
available, so users can change the chart and dimensions while reviewing the
evolution.

`Clear movie` removes the generated `/evolution/` JSON files, clears the shared
Only the current movie is kept on disk: a new movie removes the older
`revision-N` folders, so an export always ships the movie the room was looking
at. `Clear movie` removes the whole `/evolution/` folder, clears the shared
Project Evolution entity, hides the movie chart, and resets every connected
client to the empty Project Evolution panel. It does not delete the normal
analysis `data.json`.
Expand All @@ -69,6 +77,11 @@ button reads `Cancel`:
- **Leaving the mode** changes nothing on the server: the generation goes on
for the room and its movie appears when it is ready.

The progress bar counts revisions finished (analyzed or discarded) out of the
total, so it only moves forward and reaches the end. Revisions are analyzed
without a VS Code notification each, and each revision's snapshot is deleted as
soon as it is analyzed.

A second Generate while one runs is answered `busy` to that participant only.
A participant who opens the panel mid-generation sees the room's job (the
references reply carries its state). A revision whose analysis times out is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import { ComparisonSource, GitAnalysisExclusionCode } from './historicalComparis
*/
export const REVISION_ANALYSIS_TIMEOUT_MS = 5 * 60 * 1000;

/**
* Analyzed revisions kept per session (least recently used dropped first).
* Enough for a 96-frame movie; before, every regeneration over a different
* range added to a cache nothing ever trimmed (EVO-8).
*/
export const MAX_CACHED_REVISIONS = 128;

/** One analyzed revision as both Git services cache it. */
export interface CachedPayload {
payload: Record<string, unknown>[];
Expand Down Expand Up @@ -107,9 +114,37 @@ export class GitAnalysisSessionContext {
const cacheKey = buildAnalyzerCacheKey(this.policy.cacheVersion, source.commitSha, session);
const cached = this.cache.get(cacheKey);
if (cached) {
this.remember(cacheKey, cached);
return cached;
}

try {
return await this.analyzeRevision(source, session, cacheKey);
} finally {
// The snapshot is only the analyzer's input: once its payload is
// cached it is dead weight (up to 100 MB per revision, EVO-8).
await this.gitService.releaseSnapshot(source).catch(() => undefined);
}
}

/** Keeps `key` as the most recently used entry and trims the oldest ones. */
private remember(key: string, value: CachedPayload): void {
this.cache.delete(key);
this.cache.set(key, value);
while (this.cache.size > MAX_CACHED_REVISIONS) {
const oldest = this.cache.keys().next().value;
if (oldest === undefined) {
break;
}
this.cache.delete(oldest);
}
}

private async analyzeRevision(
source: Extract<ComparisonSource, { kind: 'gitRef' }>,
session: UnifiedAnalysisSession,
cacheKey: string,
): Promise<CachedPayload> {
const materialized = await this.gitService.materialize(source);
if (!materialized.targetPath) {
if (this.policy.missingTarget === 'throw') {
Expand All @@ -124,7 +159,7 @@ export class GitAnalysisSessionContext {
missingTarget: true,
warnings: materialized.warnings,
};
this.cache.set(cacheKey, missing);
this.remember(cacheKey, missing);
return missing;
}

Expand All @@ -149,7 +184,7 @@ export class GitAnalysisSessionContext {
missingTarget: false,
warnings: materialized.warnings,
};
this.cache.set(cacheKey, result);
this.remember(cacheKey, result);
return result;
}

Expand All @@ -168,7 +203,10 @@ export class GitAnalysisSessionContext {
try {
analysisResult = await runWithLaunchSignal(
watchdog.signal,
() => new ExecutePython(this.extensionContext).executeAnalysis(revisionSession),
// Silent: one VS Code notification per revision (up to 24,
// four at a time) was noise; the room's progress bar is the
// report (EVO-8).
() => new ExecutePython(this.extensionContext).executeAnalysis(revisionSession, { silent: true }),
);
} catch (error) {
if (jobSignal?.aborted) {
Expand Down
35 changes: 33 additions & 2 deletions apps/vscode-extension/src/core/history/gitRepositoryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,26 @@ export class GitRepositoryService {
if (!Array.isArray(sourceIds) || sourceIds.length === 0) {
return [];
}
return Promise.all(sourceIds.map((sourceId) => this.resolveSource(sourceId)));
const resolved = await Promise.all(sourceIds.map((sourceId) => this.resolveSource(sourceId)));
// Oldest first, like the offline export (EVO-13): a movie plays in
// history order whatever order the commits were picked in. Dated refs
// by committer time, then undated ones in pick order, and the working
// copy (the present) last.
const group = (source: ComparisonSource): number => {
if (source.kind === 'workingCopy') {
return 2;
}
return typeof source.timestamp === 'number' ? 0 : 1;
};
const time = (source: ComparisonSource): number => (
source.kind === 'gitRef' && typeof source.timestamp === 'number' ? source.timestamp : 0
);
return resolved
.map((source, index) => ({ source, index }))
.sort((a, b) => group(a.source) - group(b.source)
|| time(a.source) - time(b.source)
|| a.index - b.index)
.map((entry) => entry.source);
}

public async materialize(source: ComparisonSource): Promise<MaterializedGitTarget> {
Expand All @@ -233,6 +252,16 @@ export class GitRepositoryService {
: this.materializeFile(repositoryRoot, source.commitSha, targetRelativePath, destinationPath);
}

/** Deletes one revision's snapshot once its analysis is done (EVO-8). */
public async releaseSnapshot(source: ComparisonSource): Promise<void> {
if (source.kind !== 'gitRef' || !this.isCommitSha(source.commitSha)) {
return;
}
const sourceDirectory = path.join(this.snapshotRoot, this.safeSnapshotName(source.commitSha));
this.assertInside(this.snapshotRoot, sourceDirectory);
await fs.promises.rm(sourceDirectory, { recursive: true, force: true });
}

public async dispose(): Promise<void> {
await fs.promises.rm(this.snapshotRoot, { recursive: true, force: true });
}
Expand Down Expand Up @@ -430,7 +459,9 @@ export class GitRepositoryService {
const sources: ComparisonSource[] = [];
for (const line of splitGitLines(stdout)) {
const [fullRef, commitSha, shortName, committerDate, committerUnix] = line.split('\0');
if (!fullRef || !this.isCommitSha(commitSha) || !shortName || shortName.endsWith('/HEAD')) {
// `%(refname:short)` of refs/remotes/origin/HEAD is just "origin",
// so the alias is recognised by its full ref (EVO-18).
if (!fullRef || !this.isCommitSha(commitSha) || !shortName || fullRef.endsWith('/HEAD')) {
continue;
}
if (headName && fullRef === `refs/heads/${headName}`) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ export interface ProjectEvolutionResult {
frames: ProjectEvolutionFrame[];
generatedAt: string;
manifestUrl: string;
bridgeUrl: string;
/**
* Gone since 1.2.1: frames are loaded by their own immutable `url`
* (EVO-5). Kept optional so a movie exported by 1.2.0 still parses.
*/
bridgeUrl?: string;
excludedSources: GitAnalysisExclusion[];
}

Expand All @@ -172,6 +176,12 @@ export interface ProjectEvolutionProgress {
revision?: number;
frameIndex?: number;
frameCount?: number;
/**
* Revisions finished so far (analyzed or discarded) out of `frameCount`.
* Only ever grows and reaches `frameCount`, unlike `frameIndex`, which
* names whichever of the parallel workers spoke last (EVO-14).
*/
completed?: number;
/** The job this progress belongs to. */
jobId?: string;
}
Expand Down
79 changes: 66 additions & 13 deletions apps/vscode-extension/src/core/history/projectEvolutionArtifacts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* The files of one generated project-evolution movie: `dataN.json` per frame,
* the `data.json` bridge the scene reads, and the manifest.
* The files of one generated project-evolution movie: `dataN.json` per frame
* and the manifest. Every file is written once and never changed: the scene
* loads each frame by its own URL (EVO-5), so there is no shared bridge file
* for concurrent players to race on.
*
* Pure helpers split out of ProjectEvolutionService: the service owns WHEN a
* revision becomes current (only once these files are written and the job is
Expand All @@ -21,7 +23,7 @@ export interface EvolutionFrameInput {
source: ComparisonSource;
}

/** Phase 4: a fresh revision folder with dataN.json per frame, the data.json bridge and the manifest. */
/** Phase 4: a fresh revision folder with dataN.json per frame and the manifest. */
export async function writeEvolutionRevision(
revision: number,
revisionDirectory: string,
Expand Down Expand Up @@ -57,13 +59,8 @@ export async function writeEvolutionRevision(
frames,
generatedAt: new Date().toISOString(),
manifestUrl: `/evolution/revision-${revision}/manifest.json`,
bridgeUrl: `/evolution/revision-${revision}/data.json`,
excludedSources,
};
await copyFileAtomically(
path.join(revisionDirectory, 'data1.json'),
path.join(revisionDirectory, 'data.json'),
);
await fs.promises.writeFile(
path.join(revisionDirectory, 'manifest.json'),
JSON.stringify(result, null, 2),
Expand All @@ -79,11 +76,67 @@ export function extractSourceDate(source: ComparisonSource): string | undefined
return match ? match[1] : undefined;
}

/** Copy through a temp file + rename, so a reader never sees half a file. */
export async function copyFileAtomically(sourcePath: string, destinationPath: string): Promise<void> {
const tempPath = `${destinationPath}.${process.pid}.${Date.now()}.tmp`;
await fs.promises.copyFile(sourcePath, tempPath);
await fs.promises.rename(tempPath, destinationPath);
/** `<staticRoot>/evolution`, refusing anything that would escape the static root. */
export function evolutionDirectoryOf(staticRootPath: string): string {
const staticRoot = path.resolve(staticRootPath);
const evolutionDirectory = path.resolve(staticRoot, 'evolution');
if (!evolutionDirectory.startsWith(staticRoot + path.sep)) {
throw new Error('project-evolution-outside-static-root');
}
return evolutionDirectory;
}

/**
* Validates a frame of the current movie and returns its own URL. No file is
* copied (EVO-5): each frame is an immutable `dataN.json`, so players seeking
* at once can no longer race on a shared bridge file.
*/
export function resolveEvolutionFrame(
revision: number,
frameIndex: number,
currentRevision: number,
frameCount: number,
): { revision: number; frameIndex: number; frameUrl: string } {
const safeRevision = Math.floor(Number(revision));
const safeFrameIndex = Math.floor(Number(frameIndex));
if (!Number.isFinite(safeRevision) || safeRevision < 1 || safeRevision !== currentRevision) {
throw new Error('project-evolution-invalid-revision');
}
if (!Number.isFinite(safeFrameIndex) || safeFrameIndex < 0 || safeFrameIndex >= frameCount) {
throw new Error('project-evolution-invalid-frame');
}
return {
revision: safeRevision,
frameIndex: safeFrameIndex,
frameUrl: `/evolution/revision-${safeRevision}/data${safeFrameIndex + 1}.json`,
};
}

/** The revision numbers of the `revision-N` folders under `evolutionDirectory`. */
export async function listEvolutionRevisions(evolutionDirectory: string): Promise<number[]> {
let names: string[];
try {
names = await fs.promises.readdir(evolutionDirectory);
} catch {
return [];
}
return names
.map((name) => /^revision-(\d+)$/.exec(name))
.filter((match): match is RegExpExecArray => !!match)
.map((match) => Number(match[1]))
.filter((value) => Number.isSafeInteger(value) && value > 0);
}

/**
* Removes every `revision-N` folder but `keep` (EVO-11): one movie on disk,
* so an export can only ship the movie the room is looking at.
*/
export async function removeOtherEvolutionRevisions(evolutionDirectory: string, keep: number): Promise<void> {
for (const revision of await listEvolutionRevisions(evolutionDirectory)) {
if (revision !== keep) {
await fs.promises.rm(path.join(evolutionDirectory, `revision-${revision}`), { recursive: true, force: true });
}
}
}

/** How a frame's revision is named in progress messages. */
Expand Down
Loading
Loading