Commit bd7202f
authored
Fix file tree refresh logic (#10184)
## Description
Fix local file tree blinking and reshuffling after connecting to an SSH
session.
**Root cause:** When a remote SSH session is active, the remote server
streams frequent
`FileTreeEntryUpdated { Remote }` events for every filesystem change on
the remote host.
The previous code called `rebuild_flattened_items()` on each such event,
which re-flattened
*all* roots (including local ones), causing the local file tree to
re-render on every remote
filesystem change — visible as constant blinking/reshuffling.
**Fix:** Add an optional `target_root` parameter to the core
`rebuild_flatten_items_impl`
method. When `Some`, only the specified root is re-flattened; all other
roots keep their
existing items untouched. Three thin wrappers provide the public API:
- `rebuild_flattened_items_for_root(path)` — single-root rebuild
- `rebuild_flattened_items()` — full rebuild (all roots)
- `rebuild_flattened_items_without(path)` — full rebuild excluding a
deleted path
Updated the following event handlers to use per-root rebuilds instead of
full rebuilds:
- `FileTreeEntryUpdated { Local }` — rebuilds only the affected local
root(s)
- `FileTreeEntryUpdated { Remote }` — rebuilds only the affected remote
root
- `RepositoryRemoved { Remote }` — no-op rebuild (root already removed),
avoids touching remaining roots
Skipping unchanged roots is safe because the rebuild is fully
deterministic given the same
`entry`, `expanded_folders`, and `item_states` — re-flattening an
unmodified root produces
an identical items list and selection index.
## Testing
- `cargo check -p warp --lib` passes cleanly
- Verified the three updated event handlers and the rename flow
(editing.rs) all route through `rebuild_flatten_items_impl` correctly
## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode
<!--
CHANGELOG-BUG-FIX: Fixed local file tree blinking/reshuffling when
connected to an SSH session
-->1 parent 74bdbd1 commit bd7202f
2 files changed
Lines changed: 44 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
553 | | - | |
| 552 | + | |
| 553 | + | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
559 | 561 | | |
560 | 562 | | |
561 | 563 | | |
| |||
600 | 602 | | |
601 | 603 | | |
602 | 604 | | |
603 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
604 | 610 | | |
605 | 611 | | |
606 | 612 | | |
| |||
610 | 616 | | |
611 | 617 | | |
612 | 618 | | |
613 | | - | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
614 | 623 | | |
615 | 624 | | |
616 | 625 | | |
| |||
1594 | 1603 | | |
1595 | 1604 | | |
1596 | 1605 | | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
1597 | 1614 | | |
1598 | 1615 | | |
1599 | | - | |
| 1616 | + | |
1600 | 1617 | | |
1601 | 1618 | | |
1602 | 1619 | | |
1603 | | - | |
| 1620 | + | |
1604 | 1621 | | |
1605 | 1622 | | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
1609 | | - | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
1610 | 1633 | | |
1611 | | - | |
| 1634 | + | |
1612 | 1635 | | |
1613 | 1636 | | |
1614 | 1637 | | |
| 1638 | + | |
1615 | 1639 | | |
1616 | 1640 | | |
1617 | 1641 | | |
1618 | 1642 | | |
1619 | 1643 | | |
1620 | 1644 | | |
1621 | | - | |
| 1645 | + | |
1622 | 1646 | | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
1623 | 1653 | | |
1624 | 1654 | | |
1625 | 1655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| |||
0 commit comments