Commit 0b51a33
committed
Fix: silence get_file_at FE/BE drift warning during async listing refresh
The 'frontend/backend index mismatch!' log_error in get_file_at was added as
diagnostic to catch genuine drift, but it fires legitimately during the brief
window between a directory-diff event arriving and the FE's cached
`totalCount` being updated by the subsequent `getTotalCount` IPC. The user
saw it in their move logs (cursor settled on index 29 in a listing that had
already shrunk to 29 entries) — visually nothing was broken (FE handles
`null` from getFileAt gracefully), but the log was noisy and triggered the
opt-in error reporter.
Two-pronged fix:
- **Backend** (`get_file_at`): demote the out-of-bounds path from
`crate::log_error!` (auto-reportable) to `log::debug!`. The breadcrumb is
still in the file log when investigating cursor/selection bugs, but it no
longer surfaces as an error to the user or in error reports. Updated the
comment to explain the legitimate drift case.
- **Frontend** (`buildMcpFileList` in FilePane.svelte): the loop iterating
over the visible range to sync MCP context state used to skip null
entries silently and continue. That meant for a backendStart=0,
visibleRangeEnd=30 against a listing that had shrunk to 29, we'd make 30
IPC calls — only the last one out of bounds, but every iteration still
paid the round-trip. Changed `if (entry) {push}` to `if (!entry) break`:
null means the BE listing has fewer entries than our cached `totalCount`
(a directory-diff is mid-flight), so stop iterating instead of paying for
futile lookups.
Tests: 1606 Rust, 1739 Svelte, clippy/svelte-check/eslint all green.1 parent 72d3d7e commit 0b51a33
2 files changed
Lines changed: 21 additions & 14 deletions
File tree
- apps/desktop
- src-tauri/src/file_system/listing
- src/lib/file-explorer/pane
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
250 | 254 | | |
251 | 255 | | |
252 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
777 | 780 | | |
778 | 781 | | |
779 | 782 | | |
| |||
0 commit comments