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
4 changes: 0 additions & 4 deletions packages/extension/src/sidebar_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export interface TreeEntry {
type: "file" | "directory";
path: string;
gitStatus?: "modified" | "added" | "deleted" | "untracked" | "ignored" | "conflict";
/** Discriminant for the environment root row (#885). */
entryKind?: "environment-root";
/** Environment slug for coloring the environment root row (#885). */
environmentSlug?: string;
}

// ── File operation types ─────────────────────────────────────────────────────
Expand Down
17 changes: 0 additions & 17 deletions packages/extension/src/sidebar_tree_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export interface TreeServiceDeps {
*/
export class SidebarTreeService {
private deps: TreeServiceDeps;
/** Map root path → resolved environment info from the last getRoots() call (#885). */
private rootEnvironments = new Map<string, { name: string; slug: string; path: string }>();

constructor(deps: TreeServiceDeps) {
this.deps = deps;
Expand All @@ -64,7 +62,6 @@ export class SidebarTreeService {
const envBySlug = new Map<string, TreeRoot>();
/** Track which slugs each research project resolves to, for boundProjectCount. */
const projectEnvSlugs: string[] = [];
this.rootEnvironments.clear();

// ── Pass 1: workspace folders ──────────────────────────────────────────
for (const folder of workspaceFolders) {
Expand Down Expand Up @@ -119,7 +116,6 @@ export class SidebarTreeService {
path: env.path,
colorIndex: envColorIndex(env.slug),
};
this.rootEnvironments.set(dir, { name: env.name, slug: env.slug, path: env.path });
projectEnvSlugs.push(env.slug);

// Auto-surface resolved environments that aren't already in the map (#895)
Expand Down Expand Up @@ -198,19 +194,6 @@ export class SidebarTreeService {
path: `${dirPath}/${entry.name}`,
}));

// If this is a project root with a bound environment, append the
// environment as the last child (#885)
const envInfo = this.rootEnvironments.get(dirPath);
if (envInfo) {
entries.push({
name: envInfo.name,
type: "directory",
path: envInfo.path,
entryKind: "environment-root",
environmentSlug: envInfo.slug,
});
}

return entries;
}
}
2 changes: 0 additions & 2 deletions packages/extension/src/sidebar_webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ interface TreeEntry {
type: "file" | "directory";
path: string;
gitStatus?: string;
entryKind?: "environment-root";
environmentSlug?: string;
}

// ── Icon theme data (embedded by the host in window.__iconTheme) ─────────────
Expand Down
41 changes: 11 additions & 30 deletions packages/extension/test/sidebar_env_tree.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Sidebar environment tree — TreeService getChildren appends env row + getRoots environment discovery.
// Part of #885 (sub-issue of #880 Research Environments) and #895 (environment accordion section).
// Sidebar environment tree — getRoots environment discovery.
// Part of #895 (environment accordion section). The nested environment virtual
// child (#885) has been removed — environments have their own section now.
import { describe, it, expect } from "vitest";
import { SidebarTreeService } from "../src/sidebar_tree_service";
import type { RawDirEntry } from "../src/sidebar_tree_service";
import { envColorIndex } from "../src/sidebar_bridge";

describe("SidebarTreeService nested environment tree (#885)", () => {
describe("SidebarTreeService getChildren — no virtual environment child (#895)", () => {
function makeService(env: { name: string; slug: string; path: string } | null = {
path: "/env/transmon-oc",
slug: "transmon-oc",
Expand All @@ -32,43 +33,23 @@ describe("SidebarTreeService nested environment tree (#885)", () => {
});
}

it("appends environment as last child of a bound project root (AC-11)", async () => {
it("getChildren returns only filesystem entries — no virtual environment child", async () => {
const service = makeService();
// Must call getRoots first to populate the environment map
service.getRoots();

const children = await service.getChildren("/proj");
expect(children.length).toBe(4); // 3 regular + 1 environment
const envEntry = children[children.length - 1];
expect(envEntry.entryKind).toBe("environment-root");
expect(envEntry.name).toBe("Transmon OC");
expect(envEntry.path).toBe("/env/transmon-oc");
expect(envEntry.environmentSlug).toBe("transmon-oc");
expect(envEntry.type).toBe("directory");
expect(children.length).toBe(3); // only the 3 real filesystem entries
expect(children.every((c) => !c.entryKind)).toBe(true);
});

it("no environment → no extra child", async () => {
const service = makeService(null);
service.getRoots();

const children = await service.getChildren("/proj");
expect(children.length).toBe(3); // just the regular children
expect(children.find((c) => c.entryKind === "environment-root")).toBeUndefined();
});

it("environment row is always last (after sorted files)", async () => {
it("children are sorted dirs-first then alphabetical", async () => {
const service = makeService();
service.getRoots();

const children = await service.getChildren("/proj");
// Regular entries should be sorted (dirs first, then files)
const regular = children.filter((c) => !c.entryKind);
expect(regular[0].name).toBe("data"); // dir
expect(regular[1].name).toBe("scripts"); // dir
expect(regular[2].name).toBe("README.md"); // file

// Environment is last
expect(children[children.length - 1].entryKind).toBe("environment-root");
expect(children[0].name).toBe("data"); // dir
expect(children[1].name).toBe("scripts"); // dir
expect(children[2].name).toBe("README.md"); // file
});
});

Expand Down
Loading