MCPcopy
hub / github.com/coder/mux / computeAgentRowRenderMeta

Function computeAgentRowRenderMeta

src/browser/utils/ui/workspaceFiltering.ts:369–489  ·  view source on GitHub ↗
(
  flattenedWorkspaces: FrontendWorkspaceMetadata[],
  depthByWorkspaceId: Record<string, number>,
  expandedParentIds: ReadonlySet<string> = new Set()
)

Source from the content-addressed store, hash-verified

367 * Build render metadata for visible rows in a flattened workspace tree.
368 */
369export function computeAgentRowRenderMeta(
370 flattenedWorkspaces: FrontendWorkspaceMetadata[],
371 depthByWorkspaceId: Record<string, number>,
372 expandedParentIds: ReadonlySet<string> = new Set()
373): Map<string, AgentRowRenderMeta> {
374 const visibleRows = filterVisibleAgentRows(flattenedWorkspaces, expandedParentIds);
375 const visibleWorkspaceIds = new Set(visibleRows.map((workspace) => workspace.id));
376
377 const visibleChildrenByParent = new Map<string, FrontendWorkspaceMetadata[]>();
378 const completedChildrenByParent = new Map<string, FrontendWorkspaceMetadata[]>();
379 const visibleWorkspaceById = new Map<string, FrontendWorkspaceMetadata>();
380
381 for (const workspace of visibleRows) {
382 visibleWorkspaceById.set(workspace.id, workspace);
383
384 const parentId = workspace.parentWorkspaceId;
385 if (!parentId) {
386 continue;
387 }
388
389 const siblings = visibleChildrenByParent.get(parentId) ?? [];
390 siblings.push(workspace);
391 visibleChildrenByParent.set(parentId, siblings);
392 }
393
394 for (const workspace of flattenedWorkspaces) {
395 if (!workspace.parentWorkspaceId || !hasCompletedAgentReport(workspace)) {
396 continue;
397 }
398
399 const completedChildren = completedChildrenByParent.get(workspace.parentWorkspaceId) ?? [];
400 completedChildren.push(workspace);
401 completedChildrenByParent.set(workspace.parentWorkspaceId, completedChildren);
402 }
403
404 const metadataByWorkspaceId = new Map<string, AgentRowRenderMeta>();
405
406 for (const workspace of visibleRows) {
407 const rowKind = workspace.parentWorkspaceId ? "subagent" : "primary";
408
409 let connectorPosition: AgentRowRenderMeta["connectorPosition"] = "single";
410 let connectorStartsAtParent = false;
411 let sharedTrunkActiveThroughRow = false;
412 let sharedTrunkActiveBelowRow = false;
413 let ancestorTrunks: AgentRowRenderMeta["ancestorTrunks"] = [];
414
415 if (workspace.parentWorkspaceId) {
416 const siblings = visibleChildrenByParent.get(workspace.parentWorkspaceId) ?? [];
417 const siblingIndex = siblings.findIndex((sibling) => sibling.id === workspace.id);
418 if (siblings.length > 1) {
419 connectorPosition = siblings[siblings.length - 1]?.id === workspace.id ? "last" : "middle";
420 }
421
422 if (siblingIndex >= 0) {
423 connectorStartsAtParent = siblingIndex === 0;
424
425 let lastRunningSiblingIndex = -1;
426 for (let index = siblings.length - 1; index >= 0; index -= 1) {

Callers 2

ProjectSidebarInnerFunction · 0.90

Calls 8

hasCompletedAgentReportFunction · 0.90
filterVisibleAgentRowsFunction · 0.85
setMethod · 0.80
addMethod · 0.80
getMethod · 0.65
pushMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected