fix(agent): fold large unchanged subtrees in the full-screen fallback

VA
1h ago
+1306-63
  • When an action changes most of the screen, the presenter sends the whole tree again, repeating subtrees the model already holds.
  • The fallback now folds a subtree of 10 or more nodes to its root line with the node count and the revision it was last seen at, when every node in it reads as before with the same node ids.
  • The first screen still goes out whole, observe is untouched, and a truncated listing never folds.
  • A subtree holding the focused node stays listed, and a subtree that lost a node stays listed.

Folded line, from the new test:

 #n2 navigation "Sidebar" (12 nodes inside, unchanged since revision b1)

Issue

Fixes #1788

Verified

Ran it locally: yes

  • packages/e2e unit tests for the presenter, the full unit suite, and the MCP run_code integration suite with E2E_CHROMIUM_SANDBOX=0
  • The two new folding tests fail on main (no folding) and pass here
mainthis branch
562 chars, 24 lines: the 12-node sidebar repeats in full427 chars, 14 lines: the sidebar folds to one line, a 24.0% cut on this 23-node fixture