Skip to content

Commit e340256

Browse files
committed
🤖 Fix E2E tests: use legacy ID format for metadata.json lookup
The migration logic in getAllWorkspaceMetadata() was trying to load metadata.json using workspace basename first (e.g., 'demo-review'), then falling back to legacy ID format (e.g., 'demo-repo-demo-review'). However: - New workspaces have metadata in config (id + name fields), not metadata.json - E2E tests and legacy workspaces use the legacy ID format (project-workspace) The first check (workspace basename) would never succeed for valid cases: - It's unnecessary for new workspaces (they skip metadata.json lookup) - It fails for E2E tests/legacy workspaces (they use legacy ID format) This caused all E2E tests to timeout waiting for workspace list items to appear, because workspaces weren't being discovered during config migration. Fix: Remove the redundant first check and go straight to legacy ID format. This makes E2E tests work while maintaining backward compatibility with existing workspaces. 🤖 Fix formatting in config.ts
1 parent 387ed0e commit e340256

File tree

1 file changed

+3
-34
lines changed

1 file changed

+3
-34
lines changed

src/config.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ export class Config {
276276
}
277277

278278
// LEGACY FORMAT: Fall back to reading metadata.json
279-
// Try workspace basename first (for new stable ID workspaces)
280-
let metadataPath = path.join(this.getSessionDir(workspaceBasename), "metadata.json");
279+
// Try legacy ID format first (project-workspace) - used by E2E tests and old workspaces
280+
const legacyId = this.generateWorkspaceId(projectPath, workspace.path);
281+
const metadataPath = path.join(this.getSessionDir(legacyId), "metadata.json");
281282
let metadataFound = false;
282283

283284
if (fs.existsSync(metadataPath)) {
@@ -304,38 +305,6 @@ export class Config {
304305
metadataFound = true;
305306
}
306307

307-
// Try legacy ID format (project-workspace)
308-
if (!metadataFound) {
309-
const legacyId = this.generateWorkspaceId(projectPath, workspace.path);
310-
metadataPath = path.join(this.getSessionDir(legacyId), "metadata.json");
311-
312-
if (fs.existsSync(metadataPath)) {
313-
const data = fs.readFileSync(metadataPath, "utf-8");
314-
let metadata = JSON.parse(data) as WorkspaceMetadata;
315-
316-
// Ensure required fields are present
317-
if (!metadata.name || !metadata.projectPath) {
318-
metadata = {
319-
...metadata,
320-
name: metadata.name ?? workspaceBasename,
321-
projectPath: metadata.projectPath ?? projectPath,
322-
projectName: metadata.projectName ?? projectName,
323-
};
324-
}
325-
326-
// Migrate to config for next load
327-
workspace.id = metadata.id;
328-
workspace.name = metadata.name;
329-
workspace.createdAt = metadata.createdAt;
330-
configModified = true;
331-
332-
workspaceMetadata.push(
333-
this.addPathsToMetadata(metadata, workspace.path, projectPath)
334-
);
335-
metadataFound = true;
336-
}
337-
}
338-
339308
// No metadata found anywhere - create basic metadata
340309
if (!metadataFound) {
341310
const legacyId = this.generateWorkspaceId(projectPath, workspace.path);

0 commit comments

Comments
 (0)