MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / buildVisibleRows

Function buildVisibleRows

frontend/app/treeview/treeview.tsx:109–177  ·  view source on GitHub ↗
(
    nodesById: Map<string, TreeNodeData>,
    rootIds: string[],
    expandedIds: Set<string>
)

Source from the content-addressed store, hash-verified

107}
108
109export function buildVisibleRows(
110 nodesById: Map<string, TreeNodeData>,
111 rootIds: string[],
112 expandedIds: Set<string>
113): TreeViewVisibleRow[] {
114 const rows: TreeViewVisibleRow[] = [];
115
116 const appendNode = (id: string, depth: number) => {
117 const node = nodesById.get(id);
118 if (node == null) {
119 return;
120 }
121 const childIds = node.childrenIds ?? [];
122 const hasChildren = node.isDirectory && (childIds.length > 0 || node.childrenStatus !== "loaded");
123 const isExpanded = expandedIds.has(id);
124 rows.push({
125 id,
126 parentId: node.parentId,
127 depth,
128 kind: "node",
129 label: normalizeLabel(node),
130 isDirectory: node.isDirectory,
131 isExpanded,
132 hasChildren,
133 icon: node.icon,
134 node,
135 });
136 if (!isExpanded || !node.isDirectory) {
137 return;
138 }
139 const status = node.childrenStatus ?? "unloaded";
140 if (status === "loading") {
141 rows.push({
142 id: `${id}::__loading`,
143 parentId: id,
144 depth: depth + 1,
145 kind: "loading",
146 label: "Loading…",
147 });
148 return;
149 }
150 if (status === "error") {
151 rows.push({
152 id: `${id}::__error`,
153 parentId: id,
154 depth: depth + 1,
155 kind: "error",
156 label: node.staterror ? `Error: ${node.staterror}` : "Unable to load directory",
157 });
158 return;
159 }
160
161 const sortedChildren = sortIdsByNode(nodesById, childIds);
162 sortedChildren.forEach((childId) => appendNode(childId, depth + 1));
163 if (status === "capped") {
164 const capMax = node.capInfo?.max ?? childIds.length;
165 rows.push({
166 id: `${id}::__capped`,

Callers 2

treeview.test.tsFile · 0.90
treeview.tsxFile · 0.85

Calls 2

sortIdsByNodeFunction · 0.85
appendNodeFunction · 0.85

Tested by

no test coverage detected