MCPcopy Create free account
hub / github.com/coder/mux / getGroupDescriptor

Function getGroupDescriptor

src/browser/components/ProjectSidebar/sidebarTaskGroups.ts:101–140  ·  view source on GitHub ↗
(
  workspace: FrontendWorkspaceMetadata,
  hasChildren: (workspaceId: string) => boolean
)

Source from the content-addressed store, hash-verified

99}
100
101function getGroupDescriptor(
102 workspace: FrontendWorkspaceMetadata,
103 hasChildren: (workspaceId: string) => boolean
104): GroupDescriptor | null {
105 const parentWorkspaceId = workspace.parentWorkspaceId;
106 if (!parentWorkspaceId) {
107 return null;
108 }
109 // Leaf-only rule (D4): a member that spawned its own sub-agents falls out of
110 // the group and renders as a normal subtree.
111 if (hasChildren(workspace.id)) {
112 return null;
113 }
114
115 const bestOfGroupId = workspace.bestOf?.groupId;
116 if (bestOfGroupId) {
117 if ((workspace.bestOf?.total ?? 1) < 2) {
118 return null;
119 }
120 return {
121 id: bestOfGroupId,
122 kind: getTaskGroupKindFromMetadata(workspace.bestOf),
123 parentWorkspaceId,
124 storageKey: `task:${parentWorkspaceId}:${bestOfGroupId}`,
125 };
126 }
127
128 // bestOf grouping wins when both are present (D3).
129 const workflowRunId = workspace.workflowTask?.runId;
130 if (workflowRunId) {
131 return {
132 id: workflowRunId,
133 kind: "workflow",
134 parentWorkspaceId,
135 storageKey: workflowGroupStorageKey(parentWorkspaceId, workflowRunId),
136 };
137 }
138
139 return null;
140}
141
142/**
143 * Storage key of the workflow group a workspace would belong to, ignoring the

Callers 1

computeSidebarTaskGroupsFunction · 0.85

Calls 3

hasChildrenFunction · 0.85
workflowGroupStorageKeyFunction · 0.85

Tested by

no test coverage detected