fix(app): always open small tree branches, even with a crowded centre

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 03:36:16 +01:00
1 parent 0005a8e7a4
commit 3b0d4a5f81
2 files changed
+17 -3

No files matched your search

+6 -3
View File
@@ -198,8 +198,9 @@ Iterable<TreeItem> _shown(TreeItem t) sync* {
}
/// Opens levels breadth-first while the canvas stays readable (about `budget` items), so a
/// small graph shows whole and a large one its top levels.
void expandInitial(TreeItem root, {int budget = 150}) {
/// small graph shows whole and a large one its top levels. Small branches (up to `small`
/// children) always open: a crowded centre must not leave them folded.
void expandInitial(TreeItem root, {int budget = 150, int small = 12}) {
root.expanded = true;
var shown = 1 + root.children.length;
var level = root.children;
@@ -207,7 +208,9 @@ void expandInitial(TreeItem root, {int budget = 150}) {
final next = <TreeItem>[];
for (final t in level) {
if (t.children.isEmpty) continue;
if (shown + t.children.length > budget) continue;
if (t.children.length > small && shown + t.children.length > budget) {
continue;
}
t.expanded = true;
shown += t.children.length;
next.addAll(t.children);
+11
View File
@@ -398,6 +398,17 @@ void main() {
expect(hub.expanded, isFalse);
});
test('small branches open even when the centre is crowded', () {
final root = TreeItem('Graph');
for (var i = 0; i < 300; i++) {
root.children.add(TreeItem('Note $i', global: i));
}
final ns = TreeItem('Anthropic')..children.add(TreeItem('Claude'));
root.children.add(ns);
expandInitial(root);
expect(ns.expanded, isTrue);
});
testWidgets('branches expand and collapse in the canvas', (tester) async {
await pumpGraph(tester, _HubBackend(bigHub()));
await mode(tester, 'Tree');