Skip to content

Commit e7a2697

Browse files
aksOpsclaude
andcommitted
fix: file-tree returns full depth for treemap drill-down
The /api/file-tree endpoint was capping depth at maxDepth (10), causing directories deeper than 10 levels to have empty children. The frontend treemap couldn't drill into them and directory node counts were wrong. Fix: when no depth param is passed, return the full tree (null depth = unlimited). The treemap needs the complete hierarchy for drill-down and correct proportional sizing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7570eb4 commit e7a2697

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/io/github/randomcodespace/iq/api/GraphController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ public Map<String, Object> getFileTree(
207207
@RequestParam(required = false) Integer depth,
208208
@RequestParam(required = false) Integer maxFiles) {
209209
requireQueryService();
210-
int cappedDepth = (depth != null) ? Math.min(depth, config.getMaxDepth()) : config.getMaxDepth();
211-
// Default unlimited for treemap; pass maxFiles to limit if needed
210+
// depth=null means unlimited (full tree for treemap). Otherwise cap at maxDepth.
211+
Integer cappedDepth = (depth != null) ? Math.min(depth, config.getMaxDepth()) : null;
212+
// Default unlimited for treemap
212213
int limit = (maxFiles != null) ? maxFiles : Integer.MAX_VALUE;
213214
return queryService.getFileTree(cappedDepth, limit);
214215
}

src/test/java/io/github/randomcodespace/iq/api/GraphControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ void getFileTreeShouldReturnHierarchicalTree() throws Exception {
567567
Map.of("name", "src", "type", "directory", "nodeCount", 10L, "children", List.of()),
568568
Map.of("name", "pom.xml", "type", "file", "nodeCount", 1L, "children", List.of())));
569569
treeResult.put("total_files", 3L);
570-
when(queryService.getFileTree(anyInt(), anyInt())).thenReturn(treeResult);
570+
when(queryService.getFileTree(any(), anyInt())).thenReturn(treeResult);
571571

572572
mockMvc.perform(get("/api/file-tree"))
573573
.andExpect(status().isOk())

0 commit comments

Comments
 (0)