-
+
{!props.collapsed &&
sections.map((section) => {
const tasks = props.tasks.filter((task) => task.kind === section.kind);
diff --git a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx b/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
index 91f7fe206d825..fc7d0f49ff029 100644
--- a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
+++ b/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
@@ -1,5 +1,5 @@
-import { useGT } from "gt-react";
-import { SearchIcon, SquarePenIcon, XIcon } from "lucide-react";
+import { useGT, useMessages } from "gt-react";
+import { EllipsisIcon, SearchIcon, SquarePenIcon, XIcon } from "lucide-react";
import {
type ComponentProps,
type KeyboardEvent as ReactKeyboardEvent,
@@ -11,6 +11,12 @@ import {
import { cn } from "~/lib/utils";
import { Button } from "../ui/button";
import { SidebarInput, SidebarMenuButton } from "../ui/sidebar";
+import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
+import {
+ collapseSidebarSectionsLabel,
+ expandSidebarSectionsLabel,
+ setAllSidebarSectionsExpanded,
+} from "./sidebarSectionExpansion";
import { SharedTooltipTrigger } from "../ui/shared-tooltip";
export interface SidebarThreadHeaderProps {
@@ -49,6 +55,7 @@ export function SidebarThreadHeader({
onClearSearch,
}: SidebarThreadHeaderProps) {
const gt = useGT();
+ const messages = useMessages();
const resultsVisible = isSearching && searchResultCount > 0;
// Shrinking results can remove the active option; never leave aria-activedescendant pointing at it.
const activeResultExists = resultsVisible && activeSearchResultIndex < searchResultCount;
@@ -98,6 +105,21 @@ export function SidebarThreadHeader({
{hasProjects ? projectScope : null}
+ {hasProjects ? (
+
+ ) : null}
({
+ allExpanded,
+ overrides: {},
+});
+const initial = allSections(null);
+const legacySchema = Schema.Array(Schema.String);
+const emptyKeys: readonly string[] = [];
+
+export const collapseSidebarSectionsLabel = msg("Collapse all agent and task sections");
+export const expandSidebarSectionsLabel = msg("Expand all agent and task sections");
+
+export function setAllSidebarSectionsExpanded(expanded: boolean) {
+ writeLocalStorageValue(key, allSections(expanded), initial, schema);
+}
+
+export function useSidebarSectionExpansion() {
+ const [state, setState] = useLocalStorage(key, initial, schema);
+ const [collapsedRoles] = useLocalStorage(
+ "t3code:sidebar:role-sections-collapsed",
+ emptyKeys,
+ legacySchema,
+ );
+ const [expandedTasks] = useLocalStorage(
+ "t3code:sidebar:task-sections-expanded",
+ emptyKeys,
+ legacySchema,
+ );
+
+ function defaultExpanded(id: string) {
+ if (id.startsWith("tasks:")) return expandedTasks.includes(id.slice("tasks:".length));
+ return !collapsedRoles.includes(id);
+ }
+
+ function isExpanded(current: SectionExpansion, id: string) {
+ return current.overrides[id] ?? current.allExpanded ?? defaultExpanded(id);
+ }
+
+ function toggleSection(id: string, all: boolean) {
+ setState((current) => {
+ const expanded = !isExpanded(current, id);
+ return all
+ ? allSections(expanded)
+ : { ...current, overrides: { ...current.overrides, [id]: expanded } };
+ });
+ }
+
+ return { sectionExpanded: (id: string) => isExpanded(state, id), toggleSection };
+}
diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json
index 99bd1a15a5e2d..ee7aaad07aea9 100644
--- a/apps/web/src/i18n/translations/de.json
+++ b/apps/web/src/i18n/translations/de.json
@@ -13085,5 +13085,9 @@
"b7df38b7d8792d78": "Leitfaden öffnen",
"9e91e9a77b664e4e": "Review-Leitfaden konnte nicht gestartet werden",
"ee71ac7e8e9b000c": "Ultrafast-Modus an",
- "e649c08fbd9a1a30": "Fast-Modus an"
+ "e649c08fbd9a1a30": "Fast-Modus an",
+ "99d122b4ef1f6aa4": "Agenten",
+ "55556e217edef043": "Sidebar-Optionen",
+ "c3d3392960181c62": "Alle Agenten- und Aufgabenbereiche einklappen",
+ "dbac868688de3988": "Alle Agenten- und Aufgabenbereiche ausklappen"
}
diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json
index b5f26da1032e3..c27006997224e 100644
--- a/apps/web/src/i18n/translations/en.json
+++ b/apps/web/src/i18n/translations/en.json
@@ -13094,5 +13094,9 @@
"b7df38b7d8792d78": "Open guide",
"9e91e9a77b664e4e": "Could not start a review guide",
"ee71ac7e8e9b000c": "Ultrafast mode on",
- "e649c08fbd9a1a30": "Fast mode on"
+ "e649c08fbd9a1a30": "Fast mode on",
+ "99d122b4ef1f6aa4": "Agents",
+ "55556e217edef043": "Sidebar options",
+ "c3d3392960181c62": "Collapse all agent and task sections",
+ "dbac868688de3988": "Expand all agent and task sections"
}
diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json
index b741518ccbf76..e2d95affffa41 100644
--- a/apps/web/src/i18n/translations/es.json
+++ b/apps/web/src/i18n/translations/es.json
@@ -13080,5 +13080,9 @@
"b7df38b7d8792d78": "Abrir guía",
"9e91e9a77b664e4e": "No se pudo iniciar una guía de revisión",
"ee71ac7e8e9b000c": "Modo Ultrafast activado",
- "e649c08fbd9a1a30": "Modo rápido activado"
+ "e649c08fbd9a1a30": "Modo rápido activado",
+ "99d122b4ef1f6aa4": "Agentes",
+ "55556e217edef043": "Opciones de la barra lateral",
+ "c3d3392960181c62": "Contraer todas las secciones de agentes y tareas",
+ "dbac868688de3988": "Expandir todas las secciones de agentes y tareas"
}
diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json
index de03939589878..a0bc1dc406586 100644
--- a/apps/web/src/i18n/translations/fr.json
+++ b/apps/web/src/i18n/translations/fr.json
@@ -13085,5 +13085,9 @@
"b7df38b7d8792d78": "Ouvrir le guide",
"9e91e9a77b664e4e": "Impossible de démarrer un guide de revue",
"ee71ac7e8e9b000c": "Mode Ultrafast activé",
- "e649c08fbd9a1a30": "Mode Fast activé"
+ "e649c08fbd9a1a30": "Mode Fast activé",
+ "99d122b4ef1f6aa4": "Agents",
+ "55556e217edef043": "Options de la barre latérale",
+ "c3d3392960181c62": "Réduire toutes les sections d’agents et de tâches",
+ "dbac868688de3988": "Développer toutes les sections d’agents et de tâches"
}
diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json
index e8d1700f2dd4c..e80ecf97c75b2 100644
--- a/apps/web/src/i18n/translations/ja.json
+++ b/apps/web/src/i18n/translations/ja.json
@@ -13021,5 +13021,9 @@
"b7df38b7d8792d78": "ガイドを開く",
"9e91e9a77b664e4e": "レビューガイドを開始できませんでした",
"ee71ac7e8e9b000c": "超高速モード オン",
- "e649c08fbd9a1a30": "高速モード オン"
+ "e649c08fbd9a1a30": "高速モード オン",
+ "99d122b4ef1f6aa4": "エージェント",
+ "55556e217edef043": "サイドバーのオプション",
+ "c3d3392960181c62": "すべてのエージェントとタスクのセクションを折りたたむ",
+ "dbac868688de3988": "すべてのエージェントとタスクのセクションを展開する"
}
diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json
index c4ed9a5462c52..573b2fb841125 100644
--- a/apps/web/src/i18n/translations/ko.json
+++ b/apps/web/src/i18n/translations/ko.json
@@ -13018,5 +13018,9 @@
"b7df38b7d8792d78": "가이드 열기",
"9e91e9a77b664e4e": "검토 가이드를 시작할 수 없습니다",
"ee71ac7e8e9b000c": "초고속 모드 켜짐",
- "e649c08fbd9a1a30": "고속 모드 켜짐"
+ "e649c08fbd9a1a30": "고속 모드 켜짐",
+ "99d122b4ef1f6aa4": "에이전트",
+ "55556e217edef043": "사이드바 옵션",
+ "c3d3392960181c62": "모든 에이전트 및 작업 섹션 접기",
+ "dbac868688de3988": "모든 에이전트 및 작업 섹션 펼치기"
}
diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json
index ac50f963f4ee5..3fdaa7b78a569 100644
--- a/apps/web/src/i18n/translations/pt-BR.json
+++ b/apps/web/src/i18n/translations/pt-BR.json
@@ -13085,5 +13085,9 @@
"b7df38b7d8792d78": "Abrir guia",
"9e91e9a77b664e4e": "Não foi possível iniciar um guia de revisão",
"ee71ac7e8e9b000c": "Modo Ultrafast ativado",
- "e649c08fbd9a1a30": "Modo Fast ativado"
+ "e649c08fbd9a1a30": "Modo Fast ativado",
+ "99d122b4ef1f6aa4": "Agentes",
+ "55556e217edef043": "Opções da barra lateral",
+ "c3d3392960181c62": "Recolher todas as seções de agentes e tarefas",
+ "dbac868688de3988": "Expandir todas as seções de agentes e tarefas"
}
diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json
index 0b55b34e4f297..036acdb05a06c 100644
--- a/apps/web/src/i18n/translations/ru.json
+++ b/apps/web/src/i18n/translations/ru.json
@@ -13085,5 +13085,9 @@
"b7df38b7d8792d78": "Открыть гид",
"9e91e9a77b664e4e": "Не удалось запустить гид по ревью",
"ee71ac7e8e9b000c": "Сверхбыстрый режим включён",
- "e649c08fbd9a1a30": "Быстрый режим включён"
+ "e649c08fbd9a1a30": "Быстрый режим включён",
+ "99d122b4ef1f6aa4": "Агенты",
+ "55556e217edef043": "Настройки боковой панели",
+ "c3d3392960181c62": "Свернуть все разделы агентов и задач",
+ "dbac868688de3988": "Развернуть все разделы агентов и задач"
}
diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json
index 86a93ee99f507..f3e74fc6ec625 100644
--- a/apps/web/src/i18n/translations/sv.json
+++ b/apps/web/src/i18n/translations/sv.json
@@ -13092,5 +13092,9 @@
"b7df38b7d8792d78": "Öppna guiden",
"9e91e9a77b664e4e": "Kunde inte starta en granskningsguide",
"ee71ac7e8e9b000c": "Ultrasnabbt läge på",
- "e649c08fbd9a1a30": "Snabbläge på"
+ "e649c08fbd9a1a30": "Snabbläge på",
+ "99d122b4ef1f6aa4": "Agenter",
+ "55556e217edef043": "Alternativ för sidofältet",
+ "c3d3392960181c62": "Fäll ihop alla agent- och uppgiftsavsnitt",
+ "dbac868688de3988": "Fäll ut alla agent- och uppgiftsavsnitt"
}
diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json
index bb810e960209c..48605deb098ae 100644
--- a/apps/web/src/i18n/translations/zh.json
+++ b/apps/web/src/i18n/translations/zh.json
@@ -13099,5 +13099,9 @@
"b7df38b7d8792d78": "打开导览",
"9e91e9a77b664e4e": "无法开始生成审查导览",
"ee71ac7e8e9b000c": "极速模式已开启",
- "e649c08fbd9a1a30": "快速模式已开启"
+ "e649c08fbd9a1a30": "快速模式已开启",
+ "99d122b4ef1f6aa4": "智能体",
+ "55556e217edef043": "侧边栏选项",
+ "c3d3392960181c62": "折叠所有智能体和任务分区",
+ "dbac868688de3988": "展开所有智能体和任务分区"
}
diff --git a/packages/client-runtime/src/state/sidebarFamilies.test.ts b/packages/client-runtime/src/state/sidebarFamilies.test.ts
index bc56f06161eb7..612ba5b434173 100644
--- a/packages/client-runtime/src/state/sidebarFamilies.test.ts
+++ b/packages/client-runtime/src/state/sidebarFamilies.test.ts
@@ -6,6 +6,7 @@ import {
countSidebarAgentStates,
groupSidebarThreadsByProject,
sidebarFamilyRows,
+ sidebarOrphanAgents,
indexSidebarChildren,
} from "./sidebarFamilies.ts";
@@ -67,20 +68,22 @@ it("keeps each orchestrator's role sections and each worker's native children to
"env:first",
[
["env:first", undefined, 0],
- ["role:env:first:implementation", "env:first", 1],
- ["env:new-impl", "role:env:first:implementation", 2],
- ["env:/root/native", "env:new-impl", 3],
- ["env:old-impl", "role:env:first:implementation", 2],
- ["role:env:first:review", "env:first", 1],
- ["env:review", "role:env:first:review", 2],
+ ["agents:env:first", "env:first", 1],
+ ["role:env:first:implementation", "agents:env:first", 2],
+ ["env:new-impl", "role:env:first:implementation", 3],
+ ["env:/root/native", "env:new-impl", 4],
+ ["env:old-impl", "role:env:first:implementation", 3],
+ ["role:env:first:review", "agents:env:first", 2],
+ ["env:review", "role:env:first:review", 3],
],
],
[
"env:second",
[
["env:second", undefined, 0],
- ["role:env:second:implementation", "env:second", 1],
- ["env:other-impl", "role:env:second:implementation", 2],
+ ["agents:env:second", "env:second", 1],
+ ["role:env:second:implementation", "agents:env:second", 2],
+ ["env:other-impl", "role:env:second:implementation", 3],
],
],
["env:owner", [["env:owner", undefined, 0]]],
@@ -88,10 +91,21 @@ it("keeps each orchestrator's role sections and each worker's native children to
expect(rows(new Map(expanded).set("env:first", false))[0]?.[1]).toEqual([
["env:first", undefined, 0],
]);
- expect(rows(expanded, "role:env:first:implementation")[1]).toEqual(rows()[1]);
+ expect(rows(expanded, "role:env:first:implementation")[0]?.[1]).toEqual([
+ ["env:first", undefined, 0],
+ ["agents:env:first", "env:first", 1],
+ ["role:env:first:implementation", "agents:env:first", 2],
+ ["role:env:first:review", "agents:env:first", 2],
+ ["env:review", "role:env:first:review", 3],
+ ]);
+ expect(rows(expanded, "agents:env:first")[0]?.[1]).toEqual([
+ ["env:first", undefined, 0],
+ ["agents:env:first", "env:first", 1],
+ ]);
+ expect(rows(expanded, "agents:env:first")[1]).toEqual(rows()[1]);
});
-it("can group linked agents when the parent's environment is absent", () => {
+it("puts agents with missing or archived parents under the project Agents row", () => {
const linked = {
...thread("linked", { role: "review" }),
delegatedFrom: {
@@ -100,8 +114,29 @@ it("can group linked agents when the parent's environment is absent", () => {
title: "Parent",
},
};
- expect(indexSidebarChildren([linked]).get("remote:parent")).toEqual([linked]);
- expect(indexSidebarChildren([linked], new Set()).size).toBe(0);
+ const owner = thread("owner");
+ const archived = thread("archived", { archived: true });
+ const orphan = thread("orphan", { parent: "archived", role: "implementation" });
+ const attached = thread("attached", { parent: "owner", role: "implementation" });
+ const threads = [owner, archived, orphan, linked, attached];
+ const children = indexSidebarChildren(threads);
+ const orphans = sidebarOrphanAgents(threads, children);
+ expect(orphans).toEqual([orphan, linked]);
+
+ const project = "folder:app";
+ const projectAgents = new Map([[project, orphans]]);
+ const keys = (expanded: boolean) =>
+ sidebarFamilyRows([], children, new Map(), null, () => expanded, projectAgents)
+ .get(project)
+ ?.map(({ key, parentKey }) => [key, parentKey]);
+ expect(keys(true)).toEqual([
+ ["agents:folder:app", project],
+ ["role:folder:app:implementation", "agents:folder:app"],
+ ["env:orphan", "role:folder:app:implementation"],
+ ["role:folder:app:review", "agents:folder:app"],
+ ["env:linked", "role:folder:app:review"],
+ ]);
+ expect(keys(false)).toEqual([["agents:folder:app", project]]);
});
describe("countSidebarAgentStates", () => {
diff --git a/packages/client-runtime/src/state/sidebarFamilies.ts b/packages/client-runtime/src/state/sidebarFamilies.ts
index 3dcc98be8aba9..6fa05ca6126c0 100644
--- a/packages/client-runtime/src/state/sidebarFamilies.ts
+++ b/packages/client-runtime/src/state/sidebarFamilies.ts
@@ -40,6 +40,35 @@ export function indexSidebarChildren(
return children;
}
+function sidebarThreadKey(thread: EnvironmentThreadShell) {
+ return scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
+}
+
+export function sidebarOrphanAgents(
+ threads: readonly EnvironmentThreadShell[],
+ childrenByParent: ReadonlyMap,
+) {
+ const activeKeys = new Set(
+ threads.filter((thread) => thread.archivedAt === null).map(sidebarThreadKey),
+ );
+ const attached = new Set();
+ for (const [parent, children] of childrenByParent) {
+ if (activeKeys.has(parent)) {
+ for (const child of children) attached.add(sidebarThreadKey(child));
+ }
+ }
+ return threads.filter(
+ (thread) =>
+ thread.archivedAt === null &&
+ !thread.lineage.sideChat &&
+ !thread.lineage.workflowStep &&
+ (thread.lineage.relationshipToParent === "subagent" ||
+ thread.delegatedFrom != null ||
+ thread.delegatedRole !== undefined) &&
+ !attached.has(sidebarThreadKey(thread)),
+ );
+}
+
export interface SidebarFamilyRow {
kind: "thread";
thread: EnvironmentThreadShell;
@@ -55,7 +84,8 @@ export function sidebarFamilyRows(
childrenByParent: ReadonlyMap,
expansion: ReadonlyMap,
routeKey: string | null,
- roleExpanded: (key: string) => boolean,
+ sectionExpanded: (key: string) => boolean,
+ projectAgents?: ReadonlyMap,
) {
type FamilyNode = {
row: SidebarFamilyRow;
@@ -64,18 +94,16 @@ export function sidebarFamilyRows(
hasRoute: boolean;
};
- function build(thread: EnvironmentThreadShell, parentKey?: string): FamilyNode {
- const key = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
- const children: FamilyNode[] = (childrenByParent.get(key) ?? []).map((child) =>
- build(child, key),
- );
+ function build(thread: EnvironmentThreadShell): FamilyNode {
+ const key = sidebarThreadKey(thread);
+ const children = (childrenByParent.get(key) ?? []).map((child) => build(child));
const hasLiveChildren = children.some((child) => child.live);
const hasChildRoute = children.some((child) => child.hasRoute);
const row: SidebarFamilyRow = {
kind: "thread",
thread,
key,
- parentKey,
+ parentKey: undefined,
depth: 0,
descendantCount: children.reduce((count, child) => count + 1 + child.row.descendantCount, 0),
expanded: expansion.get(key) ?? (hasLiveChildren || hasChildRoute),
@@ -97,40 +125,66 @@ export function sidebarFamilyRows(
function flatten(
node: FamilyNode,
depth = 0,
- parentKey = node.row.parentKey,
+ parentKey?: string,
+ agent = false,
): SidebarFamilyItem[] {
const { row, children } = node;
const result: SidebarFamilyItem[] = [{ ...row, depth, parentKey }];
if (!row.expanded) return result;
- if (row.thread.lineage.parentThreadId !== null || row.thread.delegatedFrom != null) {
- return result.concat(children.flatMap((child) => flatten(child, depth + 1)));
+ if (agent) {
+ return result.concat(children.flatMap((child) => flatten(child, depth + 1, row.key, true)));
}
- for (const section of sidebarRoleSections(row.key, children)) {
- const expanded = roleExpanded(section.key);
+ return result.concat(flattenAgents(row.key, children, depth + 1));
+ }
+
+ function flattenAgents(parentKey: string, children: FamilyNode[], depth: number) {
+ if (children.length === 0) return [];
+ const key = `agents:${parentKey}`;
+ const expanded = sectionExpanded(key);
+ const result: SidebarFamilyItem[] = [
+ {
+ kind: "agents",
+ key,
+ parentKey,
+ depth,
+ threads: children.map((child) => child.row.thread),
+ expanded,
+ },
+ ];
+ for (const section of sidebarRoleSections(parentKey, children)) {
+ if (!expanded && !section.children.some((child) => child.hasRoute)) continue;
+ const roleExpanded = sectionExpanded(section.key);
result.push({
kind: "role",
key: section.key,
- parentKey: row.key,
+ parentKey: key,
depth: depth + 1,
role: section.role,
threads: section.children.map((child) => child.row.thread),
- expanded,
+ expanded: roleExpanded,
});
for (const child of section.children) {
- if (expanded || child.hasRoute) {
- result.push(...flatten(child, depth + 2, section.key));
+ if ((expanded && roleExpanded) || child.hasRoute) {
+ result.push(...flatten(child, depth + 2, section.key, true));
}
}
}
return result;
}
- return new Map(
+ const rows = new Map(
roots.map((thread) => {
const node = build(thread);
- return [node.row.key, flatten(node)] as const;
+ const isAgent = thread.lineage.parentThreadId !== null || thread.delegatedFrom != null;
+ return [node.row.key, flatten(node, 0, undefined, isAgent)] as const;
}),
);
+ if (projectAgents) {
+ for (const [key, threads] of projectAgents) {
+ rows.set(key, flattenAgents(key, threads.map(build), 0));
+ }
+ }
+ return rows;
}
const SIDEBAR_AGENT_ROLES = [
@@ -151,15 +205,13 @@ function sidebarAgentRole(thread: Pick)
export type SidebarFamilyItem =
| SidebarFamilyRow
- | {
- kind: "role";
+ | ({
key: string;
parentKey: string;
depth: number;
- role: SidebarAgentRole;
threads: readonly EnvironmentThreadShell[];
expanded: boolean;
- };
+ } & ({ kind: "agents" } | { kind: "role"; role: SidebarAgentRole }));
function sidebarRoleSections(
parentKey: string,
@@ -236,24 +288,32 @@ export function sidebarAgentState(
}
}
-/** "2 working · 1 waiting on you · 1 failed", leaving out zeros; `short` says "waiting". */
export function formatSidebarAgentStates(
counts: Readonly>,
resolve: MFunctionType = mFallback,
short = false,
-): string {
- const parts = [
- counts.working > 0 ? resolve(msg("{count} working", { count: counts.working })) : null,
+) {
+ const working =
+ counts.working > 0
+ ? { count: counts.working, label: resolve(msg("{count} working", { count: counts.working })) }
+ : null;
+ const details = [
counts.attention > 0
? short
? resolve(msg("{count} waiting", { count: counts.attention }))
: resolve(msg("{count} waiting on you", { count: counts.attention }))
: null,
counts.failed > 0 ? resolve(msg("{count} failed", { count: counts.failed })) : null,
- ];
- return parts.filter((part) => part !== null).join(" · ");
+ ]
+ .filter((part) => part !== null)
+ .join(" · ");
+ return { working, details, text: [working?.label, details].filter(Boolean).join(" · ") };
}
+export const sidebarAgentsSectionLabel = msg("Agents", {
+ $context: "sidebar section for agent threads",
+});
+
/**
* Boring sidebar folders. Folders follow `groups` order and threads keep their
* input order. A project with no threads gets a folder only when `keepEmpty` says so.