refactor(components): extract useDraftLifecycle hook#61
Merged
Conversation
Consolidate the six orchestration useEffects that remained in the DraftTab shell (workspace-catalog refresh on mount, similar-response suggestion debounce, savedDraftId->loadAlternatives, Cmd-1/2/3 panel-density keyboard listener, initialDraft replay, loadTemplates on mount) into a dedicated hook. Shell drops from 1451 to 1393 LOC and gains seven renderHook tests exercising each effect plus the keyboard shortcut's editable-target + conversation-mode guards.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Consolidates the six orchestration `useEffect`s in `DraftTab.tsx` into one `useDraftLifecycle` hook:
Also moves `isEditableTarget` — the helper used only by the keyboard listener — into the hook.
Shell reduction: 1451 → 1393 LOC (-58 on this PR).
Why
These effects are all orchestration glue that runs on mount or on dependency changes to drive downstream state. None of them own local state the shell still uses — they're pure side-effect producers. Collapsing them behind one hook call removes six `useEffect` blocks + their dep arrays + their inline comment banners + the `isEditableTarget` helper function from the shell.
How
Testing
Risk / Notes
Wave 5 status after this PR