mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 15:19:16 +00:00
* fix: resolve SFTP tab connection key race condition in workspace mode When rapidly switching focus between workspace panes, the single pendingConnectionKeyRef could be overwritten before the tracking effect mapped it to the created tab. This left tabs unmapped in tabConnectionKeyMapRef, causing duplicate tabs on subsequent switches. Replace the two-step async mechanism (pendingConnectionKeyRef + deferred tracking effect) with a synchronous onTabCreated callback on connect(). The callback fires immediately after the tab ID is determined, before any async SSH work begins, eliminating the race window entirely. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: scope SFTP transfers to active connection and prevent stale session lookups Two fixes for workspace focus-switching issues: 1. Transfer queue now filters by the active connection's host, so switching focus between workspace panes only shows transfers relevant to the currently displayed SFTP tab. 2. Move sftpSessionsRef.delete() before the async closeSftp() call to close the race window where concurrent code could look up a stale sftpId that the backend has already removed, causing "SFTP session not found" errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: allow SFTP focus switching during file transfers Active transfers should not block workspace focus-following. Transfers run on their own sftpId independent of the active tab, and forceNewTab preserves old connections, so switching focus is safe. Only interactive operations (text editor, permissions dialog, file opener, file watches) still block host switching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: refresh correct SFTP tab after transfer completes during focus switch When a transfer completes while focus has switched to a different host, refresh was targeting the currently active pane instead of the pane that initiated the transfer. Add optional tabId parameter to navigateTo() and refresh() so callers can target a specific tab. Capture the tab ID at transfer start and use it for the post-transfer refresh, ensuring the correct tab's file list is updated regardless of which tab is currently focused. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: auto-reconnect SFTP when session is lost during navigation When navigateTo() detected a missing or expired SFTP session, it cleared the connection to null, showing the empty "Select a host" state. Now it delegates to handleSessionError(), which triggers the existing reconnection mechanism — keeping files visible while reconnecting in the background. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * perf: eliminate redundant stat calls before file transfers Before this change, each file transfer performed 3-4 stat calls over the network before the progress bar started moving: 1. startTransfer: stat to get file size (~100ms) 2. processTransfer: stat again if size was 0 (~100ms) 3. Conflict check: stat source file for mtime (~100ms) 4. Backend: stat again if totalBytes missing (~100ms) Now: - Use the source pane's cached file list for size and mtime (zero network cost) instead of stat calls in startTransfer - Store sourceLastModified on TransferTask so the conflict check can use it directly instead of a redundant source stat - Backend already skips stat when totalBytes is provided This saves ~200-300ms of network round-trips per file before the progress bar starts moving. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * perf: show immediate progress feedback during transfer setup The progress bar previously stayed at 0% for ~500ms-1s while the backend acquired an isolated SFTP channel and waited for the first data chunk. Users perceived this as the transfer being "sluggish". Now start simulated progress immediately for all single-file transfers (not just non-streaming ones). When the first real progress update arrives from the backend, the simulation is stopped and real progress takes over seamlessly. This gives instant visual feedback that the transfer is in progress. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: show accurate transfer progress instead of simulated values The progress system had fundamental issues: 1. Simulated progress ran for ALL transfers including streaming ones, creating fake progress that could reach 95% while real progress was at 60%. The Math.max ratchet prevented regression, so users saw inflated numbers. 2. Speed and remaining time were based on simulated data during the setup phase, giving misleading estimates. Changes: - Only use simulated progress for non-streaming transfers (no real progress callback available). Streaming transfers get real data. - Remove the double ratchet (Math.max) from onProgress — the backend already enforces monotonic progress, so the frontend should trust the reported values directly. - Show an indeterminate "preparing..." state during the setup phase (channel acquisition, conflict check) instead of fake progress. This honestly communicates that the transfer is starting. - Hide speed and remaining time during the indeterminate phase since no real data is available yet. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: remove dead progress simulation and non-streaming transfer code startStreamTransfer is always available in Electron, so: - Remove the non-streaming fallback path in transferFile() that read entire files into memory with no progress reporting - Remove startProgressSimulation / stopProgressSimulation and all related refs (progressIntervalsRef, useSimulatedProgress, hasStreamingTransfer) - Remove the cleanup effect for progress intervals All transfers now use the streaming path with real backend-reported progress. The indeterminate "preparing..." state covers the setup phase until the first real progress arrives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * perf: reduce SFTP transfer concurrency from 64 to 4 64 parallel SFTP read/write requests overwhelmed servers, causing the first chunk response to be delayed by 46+ seconds. Reducing to 4 concurrent requests provides a responsive first progress update (~1-2s) while still offering significant speedup over sequential streaming. Also adds timing logs to the transfer pipeline (processTransfer, transferFile, downloadFile, uploadFile) to aid future diagnostics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address review findings from PR #443 Critical fixes: - Fix refresh/navigateTo type signatures to include the tabId option parameter — previously it was silently ignored, making tab-targeted refresh non-functional - Fix handleSessionError/reconnection in navigateTo for background tabs: when called with explicit tabId, update that specific tab instead of the active tab (which could be a different host) - Fix uploadExternalFiles to capture and pass tabId for post-upload refresh (was missing, only uploadExternalEntries was fixed) Medium fixes: - Restore Math.max monotonic ratchet on single-file onProgress to guard against any non-monotonic backend values - Add stat fallback in processTransfer to populate sourceLastModified when file is not in the pane's visible file list (filtered/search) - Adjust TRANSFER_CONCURRENCY from 4 to 8 as a better throughput/ responsiveness balance Cleanup: - Remove all debug timing logs (console.log with Transfer/downloadFile/ uploadFile prefixes) from both frontend and backend Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: prevent background tab navigation from rolling back active tab Two P1 fixes from automated review: 1. navSeqRef race: navigateTo uses a per-side sequence counter, so a background tab refresh would bump it and cause the active tab's concurrent navigation to think it was superseded, restoring previousPath instead of applying the fetched files. Now when navSeqRef is superseded but tabNavSeqRef still matches, the fetched result is applied (it's valid for this tab — only a different tab bumped the counter). 2. Auto-follow tear down: needsNewTab only checked hostId, so same host with different session-time overrides (port/protocol) would reuse the tab and close the old SFTP session, aborting any in-flight transfer. Now needsNewTab is true whenever the current connection is alive, always preserving it with forceNewTab. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>