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
24 changes: 24 additions & 0 deletions packages/client-runtime/src/state/threadShell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ describe("v2 thread shell lists", () => {
registry.dispose();
});

it("leaves switched-off environments out of navigation", () => {
const { registry, threads, catalogValueAtom } = makeHarness([
environmentId,
remoteEnvironmentId,
]);
const dispose = registry.mount(threads.navigationThreadShellsAtom);
const environmentsOf = () =>
new Set(registry.get(threads.navigationThreadShellsAtom).map((t) => t.environmentId));
expect(environmentsOf()).toEqual(new Set([environmentId, remoteEnvironmentId]));

const setRemoteEnabled = (enabled: boolean) => {
const catalog = registry.get(catalogValueAtom);
const entries = new Map(catalog.entries);
entries.set(remoteEnvironmentId, { ...entries.get(remoteEnvironmentId)!, enabled });
registry.set(catalogValueAtom, { ...catalog, entries });
};
setRemoteEnabled(false);
expect(environmentsOf()).toEqual(new Set([environmentId]));
setRemoteEnabled(true);
expect(environmentsOf()).toEqual(new Set([environmentId, remoteEnvironmentId]));
dispose();
registry.dispose();
});

it("shares point and list values without retaining an atom for every listed thread", () => {
const harness = makeHarness();
const snapshot = {
Expand Down
2 changes: 1 addition & 1 deletion packages/client-runtime/src/state/threadShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export function createEnvironmentThreadShellAtoms(input: {
let previousNavigationShells: ReadonlyArray<EnvironmentThreadShell> = [];
const navigationThreadShellsAtom = Atom.make((get) => {
const next: EnvironmentThreadShell[] = [];
for (const environmentId of get(input.catalogValueAtom).entries.keys()) {
for (const environmentId of enabledEnvironmentIds(get(input.catalogValueAtom))) {
for (const thread of get(environmentThreadsAtom(environmentId))) {
if (thread.archivedAt !== null || thread.lineage.relationshipToParent === "subagent")
continue;
Expand Down
Loading