mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 15:19:16 +00:00
285fcd55a94de9034ace3d921e204505fab8def0
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1b08e5ee88 |
[codex] Fix SFTP editor saved state (#887)
* Fix SFTP editor saved state * Restore window input focus after SFTP editor * Harden SFTP editor save flows |
||
|
|
08f00ed143 |
fix(editor): address Codex review feedback on PR #808 (#809)
* fix(editor): address Codex review feedback on PR #808 Three issues raised on the merged editor-tab-form PR: P1 — Host-picker switch ignored onDisconnect cancellation SftpPaneDialogs' onSelectLocal / onSelectHost awaited onDisconnect() and unconditionally called onConnect() regardless of the dirty-editor prompt outcome. A user who hit Cancel on the "unsaved changes" dialog would still end up switched to the new host, stranding the editor tabs on a now-stale connection. Change onDisconnect to return Promise<boolean> (true when the disconnect actually ran, false on prompt cancel) and gate onConnect on it. Propagate the new signature through SftpPaneCallbacks, the pane-actions hook result, and both left/right implementations. P2 — setIsQuitting leaked across canceled quits electron/main.cjs called windowManager.setIsQuitting(true) at the top of before-quit, before the dirty-editor check returned. If the renderer reported hasDirty=true and the quit was canceled, isQuitting stayed true, changing later window-close behavior (close-to-tray paths gated on !isQuitting would stop firing). Move the setIsQuitting call into a commitQuit() helper that only runs once we've decided to actually proceed — on hasDirty=true we leave state untouched. P2 — SftpSidePanel unmount only cleaned active-pane connections The cleanup effect inspected only leftPane / rightPane (the active tab per side), missing editor tabs tied to inactive tabs in the same side panel. On unmount those tabs would survive with a dead save bridge. Iterate leftTabs.tabs and rightTabs.tabs and collect every connection id before calling forceCloseBySessions. npm test — 212/212 pass, tsc error count unchanged from main, lint clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * perf(editor): stabilize bridge registration effect and memoize filename dedup Two perf concerns from a focused leak/perf audit of PR #808: 1. Bridge writer effect re-ran on every SFTP state change. SftpView / SftpSidePanel registered their bridge writer in an effect with `[sftp]` deps. The `sftp` object identity changes on every SFTP state update — transfer progress, directory listing, pane updates, tab switches — so the effect would unregister+reregister constantly during routine SFTP use. Not a leak (React runs cleanup before each re-effect), just high-frequency churn on the hot path. Route through sftpRef and run the effect once; writeTextFileByConnection is a methodsRef-backed dispatcher that stays valid across sftp re-renders. 2. O(n²) filename disambiguation scan in TopTabs render. Each editor tab ran `editorTabs.filter(same fileName)` inside the per-tab render branch. Negligible at ~20 tabs but trivially fixable: build a fileName→count map in a useMemo keyed on editorTabs and look up in O(1). Separately noted but NOT fixed here (needs a store refactor and deserves its own PR): App.tsx subscribing to useEditorTabs() means every keystroke in an editor tab re-renders the App root. Would need a useEditorTabIds() selector that only notifies on add/remove. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
b9e9a0d59c |
feat(editor): promote SFTP text editor into top-level tabs (#631) (#808)
* chore: ignore local .worktrees/ directory Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): editorTabStore scaffold with single-tab ops Implements the EditorTabStore class singleton (matching activeTabStore pattern) with updateContent, markSaved, setWordWrap, setSavingState, close, and subscribe. Includes useSyncExternalStore hooks and 6 passing unit tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): editorTabStore promoteFromModal with per-session path dedup * feat(editor): confirmCloseBySession for session teardown Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(sftp): writeTextFileByConnection for pane-agnostic saves Adds a new `writeTextFileByConnection(connectionId, expectedHostId, filePath, content, filenameEncoding?)` method to `useSftpExternalOperations` that looks up the SFTP pane by connection ID (with a hostId safety check) instead of the left/right-side coupling used by `writeTextFile`. Threads the existing `getPaneByConnectionId` callback through the call site and re-exports the new method via `SftpStateApi`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(editor): editorSftpBridge singleton for out-of-React saves Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(editor): extract TextEditorPane from TextEditorModal Lift Monaco editor body + toolbar + theme sync + paste fallback into a pure TextEditorPane component. Adds sftp.editor.maximize i18n key to en.ts and zh-CN.ts locale files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(editor): drop unused getLanguageId import in TextEditorPane Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(editor): TextEditorModal delegates to TextEditorPane Replace the monolithic modal (560 lines including full Monaco setup) with a thin Dialog shell (~150 lines) that owns content/saving/saveError/ languageId state, save orchestration, and dirty-check on close, then delegates all editor chrome to <TextEditorPane chrome="modal" />. Exports TextEditorModalSnapshot for the optional onPromoteToTab callback so callers can later wire tab promotion (Task 12) without breaking the existing interface — the new prop is optional and existing callers (SftpOverlays.tsx) are source-compatible with zero changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): include fileName and wordWrap in TextEditorModalSnapshot Task 12 will populate the promoted tab with these fields, so the snapshot must carry them from the modal at maximize time. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): UnsavedChangesDialog three-button confirm * fix(editor): resolve UnsavedChangesDialog re-entrance and unmount leaks - Re-entrance: if prompt() is called while a prior prompt is still pending, cancel the prior one so its caller doesn't hang forever. - Unmount: resolve any in-flight prompt as "cancel" in the effect cleanup so awaiters don't leak when the provider unmounts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): TextEditorTabView tab-form shell Add TextEditorTabView component that binds an editorTabStore entry to TextEditorPane, with CSS display:none toggling for inactive tabs so the Monaco instance persists across tab switches. Also adds setLanguage public method to EditorTabStore (lands Task 15's intent early — Task 15 can be a no-op). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): read live store state in TextEditorTabView handlers React state snapshot lags the store by a microtask. Closing over `tab` meant a keystroke between Monaco's onChange and a Ctrl+S would write stale content and mark a stale baseline. Read via editorTabStore.getTab at call time instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): dispatch editor:* tab ids in App and activeTabStore - Add EDITOR_PREFIX, isEditorTabId, toEditorTabId, fromEditorTabId helpers - Add useIsEditorTabActive hook to activeTabStore - Update useIsTerminalLayerVisible to exclude editor tabs - Import useEditorTabs and TextEditorTabView into App.tsx - Append editor tab ids (editor:<id>) to allTabs in hotkey handler - Mount TextEditorTabView per editorTab with CSS visibility toggling - Add editorTabs to executeHotkeyAction useCallback dependency array Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(editor): render editor tabs in TopTabs with icon/dirty/tooltip - Add `fromEditorTabId`, `isEditorTabId` imports to TopTabs.tsx - Add `FileCode`, `FileText` icons; use FileCode for code-like extensions - Extend `TopTabsProps` with `editorTabs`, `onRequestCloseEditorTab`, `hostById` - Build `editorTabMap` for O(1) lookup; add `editor` branch in `orderedTabItems` - Render editor tab chrome matching terminal tab style: file icon, dirty dot (●), filename with disambiguation suffix for duplicate filenames, close button - In App.tsx: add stub `handleRequestCloseEditorTab`, `orderedTabsWithEditors`, pass new props to `<TopTabs>` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(editor): hoist editor-tab code-extension regex and use onSelectTab - Move CODE_EXTENSIONS_RE to module scope so it isn't recompiled per render. - Call onSelectTab(tabId) for consistency with other tab types, instead of reaching into activeTabStore directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): maximize modal to tab and dirty-confirm tab close Wire onPromoteToTab from TextEditorModal through SftpOverlays and useSftpViewFileOps so clicking the maximize button snapshots editor state into editorTabStore and activates the new editor tab. Replace the stub handleRequestCloseEditorTab in App.tsx with a real dirty-confirm flow using UnsavedChangesProvider render-prop: clean tabs close immediately, dirty tabs prompt save/discard/cancel, and save routes through editorSftpBridge with markSaved on success. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(editor): register SFTP bridge and gate session close on dirty editor tabs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): make onDisconnect async so host-picker waits for dirty check The session-close dirty gate added in Task 13 made onDisconnect async, but the host-picker in SftpPaneDialogs still called it synchronously before kicking off onConnect — a fire-and-forget that raced past the dirty prompt and let unsaved editor tabs slip through. Propagate the Promise return type through SftpPaneCallbacks / SftpPaneDialogs / useSftpViewPaneActionsResult and await it at the host-picker call sites. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): block app quit while editor tabs are dirty Add a before-quit IPC guard that asks the renderer whether any editor tab has unsaved changes. If dirty tabs exist, preventDefault() blocks the quit and a warning toast is shown. The app quits normally once editors are clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): add 5s timeout fallback to quit-guard IPC check If the renderer crashes or throws before reporting back, the quitGuard would stay busy forever and the app could not be quit. Fall back to force-quit after 5 s if no reply arrives. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): quit-guard uses quitConfirmed flag to prevent re-entry loop The prior flow reset quitGuardChannelBusy before calling app.quit(), which on macOS re-fires before-quit and re-entered the dirty check with the flag cleared — creating an infinite IPC loop. Introduce a separate quitConfirmed flag that commits to quitting before app.quit() fires, so the re-entry takes the fast path. Also extract QUIT_GUARD_TIMEOUT_MS and clarify that a concurrent quit while a check is in flight is swallowed (preventDefault) rather than letting the second event through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): use absolute inset-0 for tab panel and add sr-only DialogTitle Two bugs surfaced during the first dev-server smoke test: 1. Editor tab content was blank because TextEditorTabView used only className="h-full", while its sibling panels (VaultView, SftpView, TerminalLayerMount, LogView) all fill their flex-1 parent via `absolute inset-0`. In normal flow the editor tab collapsed to zero height. Match the sibling convention. 2. Radix printed an accessibility warning because the Task 7 refactor pulled the DialogTitle out of DialogContent and into the Pane header (now a plain span). Add a visually hidden DialogTitle that mirrors the filename, so screen readers have a title without showing it twice. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): raise tab panel z-index to 20 so it sits above TerminalLayer TerminalLayer's root is visibility:hidden when the active tab is an editor tab, but its inner panels set `absolute inset-0 z-10` on their own and those still paint. Without an explicit z on the editor tab panel, TerminalLayer's inner bg-background div was covering the Monaco content, producing a blank screen. Also add bg-background to the wrapper so the editor tab paints an opaque surface (matches the pattern VaultViewContainer / TerminalLayer follow). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): show host label and remote path next to filename in tab header The editor tab form previously only showed the bare filename in its header, which is ambiguous when the same filename is open against multiple hosts. Add an optional subtitle prop on TextEditorPane and populate it from the tab form with `<hostLabel>:<remotePath>` rendered in muted text beside the filename. The modal keeps its existing filename-only header. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): bridge supports multiple useSftpState instances useSftpState is instantiated in both the top-level SftpView and the terminal's SftpSidePanel, each owning its own pane registry. The editor bridge previously stored only one writer, so maximizing a file opened from the terminal side panel registered nothing (bridge was owned by SftpView which may never have mounted) and save failed with "bridge not registered". Change the bridge to track a Set of writers and dispatch by trying each until one owns the connectionId (signalled by its specific "connection no longer available" error). Add registerEditorSftpWriterScoped that returns an unregister fn so each instance's cleanup removes only its own entry. Register in both SftpView and SftpSidePanel. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): Cmd+W closes editor tab + terminal close forces tab close Two behaviors added after user feedback from dev-server smoke-test: 1. Cmd/Ctrl+W (the closeTab hotkey) previously did nothing on editor tabs because executeHotkeyAction had no branch for editor:* ids. Add one that reaches into the UnsavedChangesProvider render-prop's close flow via a ref, routing through the existing dirty-confirm path. 2. Closing a terminal tab unmounts its SftpSidePanel which destroys the useSftpState instance that owned the connection. Any editor tab promoted from that panel would then be stuck — bridge gone, save channel dead. On SftpSidePanel unmount, gather the connection ids it owned and call a new editorTabStore.forceCloseBySessions to drop matching editor tabs. Dirty state is dropped because the user closed the terminal knowing the file was open — there is no save channel left anyway. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): Cmd/Ctrl+W works when focus is inside Monaco Monaco's internal key-event dispatcher swallows keydown before the capture-phase handler on the Pane's root div can see it, so the global hotkey dispatcher never got the chance to close the editor tab when the editor had focus. Register a Monaco editor command for the close-tab keybinding and route it through a handleCloseRef — mirrors the same pattern used for Cmd/Ctrl+S. Also drop the modal-only guard in the capture-phase handler so the outer-chrome path works in tab mode too. TextEditorTabView now receives an onRequestClose(tabId) prop that App.tsx wires via the render-prop-exposed handleRequestCloseEditorTabRef, same mechanism as the hotkey-dispatcher path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): fall back to Vaults when forceCloseBySessions removes the active tab Closing a terminal tab triggers SftpSidePanel unmount which force-closes its editor tabs. If the editor tab being removed happened to be the active tab (user maximized → then closed the owning terminal from another path), the app ended up on a stale activeTabId with no selected tab and blank content. Inside forceCloseBySessions, if the active tab was one of the removed editor ids, redirect to 'vault'. Picking a more sophisticated neighbor would need the full orderedTabs list which isn't reachable from this layer; Vaults is always valid. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
986fdda008 | fix sftp selection clearing across panes and tabs | ||
|
|
e3b882bdf9 |
feat(sftp): add tree view explorer for SFTP pane (#547)
* feat(sftp): add onListDirectory to SftpPaneCallbacks interface Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * feat(sftp): implement onListDirectory in left and right callbacks * feat(sftp): add tree view i18n keys * feat(sftp): add list/tree view mode toggle to toolbar * feat(sftp): add viewMode state and tree view conditional rendering to SftpPaneView * feat(sftp): implement SftpPaneTreeView with lazy loading and context menu Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(sftp): resolve lint errors in tree view implementation Rename inner `t` and `ts` variables in onListDirectory callbacks to `toSize`/`toTs`/`ms` to avoid shadowing the outer `t` translation param. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(sftp): resolve post-merge lint errors - Remove duplicate sftp.context.copyPath i18n key (upstream added it too) - Remove unused AlertCircle import from SftpPaneFileList (upstream removed usage) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * perf(sftp): optimize SftpPaneTreeView render pipeline Split useMemo into two stages so selection changes no longer rebuild the full node descriptor array. Extract stable selection-aware callbacks (drag, copy, delete) via refs so TreeNode React.memo can reliably bail out. Remove unused props (onNavigateTo, draggedFiles), move NodeDescriptor type to module scope, and fix selectedFiles undefined bug in context menu. * feat(sftp): add path-aware rename and delete for tree view Wire renameFileAtPath and deleteFilesAtPath through the full callback stack so tree view context menu actions operate on full paths instead of basenames. Update useSftpPaneDialogs to accept entryPath in openRenameDialog and resolve parent dir in handleDelete, keeping list view behaviour unchanged. * fix: harden SFTP tree view actions and selection * fix: support tree selection shortcuts and nested create targets * fix: keep SFTP tree view sorting in sync * Improve SFTP tree view interactions and refresh behavior * Optimize SFTP tree refresh and pane state usage * Reduce remaining SFTP tree performance overhead * Fix nested SFTP drop target routing * Restore keyboard access to parent tree entry * Revert "Display approved AI commands in terminal sessions before their output. (#546)" This reverts commit |
||
|
|
a4abcab019 | Merge feature/gb18030 into main | ||
|
|
ca91483d01 | Merge upstream/main | ||
|
|
dfcdcda189 |
Refactors module imports and updates hook deps
Adjusts relative import paths across the application to reflect recent changes in the project's directory structure. This primarily affects SFTP state management and modal components. Updates React hook dependency arrays for `useCallback` and `useEffect` to ensure proper memoization and re-execution, addressing `react-hooks/exhaustive-deps` linting rules. Improves type safety for translation function parameters by changing `Record<string, any>` to `Record<string, unknown>`. Adds the `ls` command to the allowed commands for the Claude AI assistant in local settings. |
||
|
|
951d1307cd |
Refactors SFTP features for improved modularity and readability
Decomposes the core SFTP state management hook and related UI components into smaller, domain-specific custom hooks and specialized sub-components. This refactoring aims to: - Break down the monolithic `useSftpState` hook into focused hooks like `useSftpConnections`, `useSftpTransfers`, and `useSftpPaneActions`. - Extract complex logic and rendering from `SFTPModal` and `SftpView` into dedicated presentational components and custom hooks. - Centralize SFTP-related types and utility functions into new `sftp/types.ts` and `sftp/utils.ts` modules. The changes enhance code organization, maintainability, and testability across the SFTP functionality. |