refactor(components): extract useDraftPersistence hook#58
Merged
Conversation
Move handleSaveDraft + handleConfirmOpenDraft + handleConfirmOpenSimilarCase out of DraftTab.tsx into a dedicated hook. Hook accepts the shell's saveable state, the workspaceDraftState-derived appliers (applyLoadedDraft, loadSimilarCaseIntoWorkspace), setters for the runbook scope and saved/ autosave draft ids, and toast callbacks. Shell drops from 1893 to 1738 LOC and six new renderHook tests cover the save / update / compare branches.
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
Pulls the three draft-persistence callbacks out of `DraftTab.tsx` into a dedicated `useDraftPersistence` hook:
Shell reduction: 1893 → 1738 LOC (-155 on this PR).
Why
`handleSaveDraft` was the last remaining ~100-LOC callback in the shell. It was flagged as the biggest high-risk extraction because it reads 20+ pieces of shell state and writes 5 setters, but the two confirm-open callbacks that depend on it sit right next to it in the same concern — bundling all three keeps them co-located in one testable unit.
How
Testing
Risk / Notes
Wave 5 status after this PR