Skip to content

Fix file tree refresh logic#10184

Merged
kevinyang372 merged 1 commit intomasterfrom
kevin/fix-file-tree-refresh-for-all
May 5, 2026
Merged

Fix file tree refresh logic#10184
kevinyang372 merged 1 commit intomasterfrom
kevin/fix-file-tree-refresh-for-all

Conversation

@kevinyang372
Copy link
Copy Markdown
Member

@kevinyang372 kevinyang372 commented May 5, 2026

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

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

@cla-bot cla-bot Bot added the cla-signed label May 5, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 5, 2026

@kevinyang372

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR narrows file tree flattened-item rebuilds to the affected root for repository metadata updates, while preserving full rebuild behavior for existing call sites that need it.

Concerns

  • No blocking correctness or security concerns found in the changed diff.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@kevinyang372 kevinyang372 merged commit bd7202f into master May 5, 2026
37 checks passed
@kevinyang372 kevinyang372 deleted the kevin/fix-file-tree-refresh-for-all branch May 5, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants