mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-25 09:51:28 +00:00
* feat: add "new snippet" button in terminal ScriptsSidePanel (#641) Previously, adding a new snippet required navigating back to the main Snippets section from the Vault view. This adds a "+" button in the search header of the terminal-side ScriptsSidePanel that jumps directly into the snippet edit flow. Flow: - ScriptsSidePanel "+" → dispatches window event `netcatty:snippets:add` - App.tsx listens → switches activeTab to vault, navigates to Snippets section, and bumps a monotonic `openSnippetAddTrigger` state - VaultView forwards the trigger to SnippetsManager - SnippetsManager watches the trigger and opens its add panel when the value changes (uses a ref to ignore unrelated remounts) Closes #641 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: switch add-snippet flow to one-shot pending flag Codex review pointed out a real bug with the monotonic trigger approach: when SnippetsManager mounts for the first time with openAddTrigger already non-zero (the common "+ clicked from terminal while not on Snippets section" path), the last-seen-trigger ref is initialized to the current value and the useEffect immediately returns early, so the add panel never opens. Switch to a cleaner one-shot pending flag: - App.tsx holds pendingSnippetAdd: boolean + handlePendingSnippetAddHandled - VaultView forwards pendingSnippetAdd + onPendingSnippetAddHandled - SnippetsManager opens the add panel on every transition to pendingAdd=true, then clears the flag via onPendingAddHandled, so subsequent renders and plain remounts are no-ops Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: move useCallback above early return in ScriptsSidePanel React's rules-of-hooks require all hooks to be called unconditionally. The new handleAddSnippet useCallback was placed after the `if (!isVisible) return null;` guard, which tripped eslint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>