refactor(frontend): extract useRecoveryRestore from App.vue - #317
Merged
Conversation
Sixth (largest) slice of milestone 5-a. App.vue owned the entire
recovery flow: the ref backing <RecoveryDialog>, both dialog callbacks,
and the ~170-line executeRestore fan-out that spawns per-pane along one
of four branches (remote re-bind / SSH reconnect / ad-hoc SSH
placeholder / local fork with pin migration). None of it referenced
App.vue lifecycle — every dependency was either a Ref, a callable, or a
lib helper — so it was doing all its work as a passenger inside the
mega-SFC.
New composables/useRecoveryRestore.ts takes:
{ tabs, localList, localHostID, pendingLocalIds, pins,
hasLocalPty, newId, gotoTab, startNewTab, predictCellDims }
and returns { recoveryDialogState, onRecoveryRestore, onRecoveryDiscard }.
The executeRestore body moves verbatim (same seed-then-await ordering,
same pins.ready()/flushNow() bracketing, same per-branch behavior). Boot
still populates `recoveryDialogState.value = { open: true, snapshot }`
directly — the load-and-decide step stays inline because it belongs to
the larger try/catch bootStage chain.
App.vue side:
- Drop the recoveryDialogState ref + onRecoveryRestore + onRecoveryDiscard
+ executeRestore (~200 lines).
- Drop classifySSHRestore / newSshSessionByID / discardRecoverySnapshot /
synthSessionInfoFromSnapshot / buildRestoreSessionReq / RecoveryTabSnapshot
imports (all consumed inside the composable).
- Add composable import + single destructuring call (arg lambdas defer
the newId / gotoTab / startNewTab references so hoisting order stays
clean).
- Keep RecoverySnapshot (boot still declares `let recoverySnap:
RecoverySnapshot`), listShells (used by an unrelated site).
Net: App.vue -201 / +18; new composable +262. `npm test` 1631 pass;
`npm run build` green. App.vue now 1766 lines (was 1949).
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.
Summary
Sixth (largest) slice of milestone 5-a. App.vue owned the entire recovery flow: the ref backing ``, both dialog callbacks, and the ~170-line `executeRestore` fan-out that spawns per-pane along one of four branches (remote re-bind / SSH reconnect / ad-hoc SSH placeholder / local fork with pin migration). None of it referenced App.vue lifecycle — every dependency was either a Ref, a callable, or a lib helper — so it was doing all its work as a passenger inside the mega-SFC.
New `composables/useRecoveryRestore.ts` takes:
```ts
{ tabs, localList, localHostID, pendingLocalIds, pins,
hasLocalPty, newId, gotoTab, startNewTab, predictCellDims }
```
and returns `{ recoveryDialogState, onRecoveryRestore, onRecoveryDiscard }`. The `executeRestore` body moves verbatim (same seed-then-await ordering, same `pins.ready()`/`flushNow()` bracketing, same per-branch behavior). Boot still populates `recoveryDialogState.value = { open: true, snapshot }` directly — the load-and-decide step stays inline because it belongs to the larger try/catch `bootStage` chain.
App.vue side:
Net: App.vue -201 / +18; new composable +262. App.vue now 1766 lines (was 1949).
Test plan