-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
A real React app easily has 500-2000+ components. Running get tree dumps every node at ~40 chars per line, producing 20-80k characters β a significant chunk of an AI agent's context window. This makes the tool impractical for production-sized apps without manual --depth tuning.
Proposed solution
Three complementary strategies that compose together:
1. Filter host components by default
Host components (<div>, <span>, <button>, etc.) are typically 60-80% of the tree and rarely useful for debugging.
- Add
--no-hostflag (or make it the default, with--allto include them) - Filter at the tree output level, not the internal tree structure
- Consider: host components with keys or non-trivial names (custom elements) should probably still show
2. Collapse repeated siblings
When a parent has many children with the same display name (lists, tables, grids), show a few then summarize:
ββ @c10 [fn] "TodoItem" key="1"
ββ @c11 [fn] "TodoItem" key="2"
ββ ... +48 more TodoItem
- Detect runs of siblings with the same
displayName - Show first 2-3, collapse the rest with count
- Collapsed nodes still get
@cNlabels assigned (for later reference)
3. Summary footer
Always append a summary so the agent knows what it's looking at:
127 components shown (1,843 total)
This tells the agent it's seeing a subset and can drill deeper with get tree --depth N, find, or get component @cN.
Additional considerations
--max-lines Nflag as a hard cap, with automatic depth reduction to fit- The
--depthflag already exists but requires the agent to guess the right value; smart defaults are better - These should stack: host filtering + sibling collapsing + depth limit
Files to change
src/component-tree.tsβ add host filtering option togetTree(), sibling collapsing logicsrc/formatters.tsβ implement collapsing informatTree(), add summary footersrc/daemon.tsβ pass through new flags from IPC commandssrc/cli.tsβ add--no-host/--allflags,--max-linessrc/types.tsβ extendget-treeIPC command with new optionssrc/__tests__/component-tree.test.tsβ test filtering and collapsingsrc/__tests__/formatters.test.tsβ test collapsed output
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels