refactor(frontend): extract useCloseSessionConfirm from App.vue - #316
Merged
Conversation
Fifth slice of milestone 5-a. App.vue held the "are you sure you want to close this session?" dialog state — pendingCloseSession(s), pendingCloseAction, four computeds (title / isAi / isRunning / isRemote), open/confirm/cancel/clear helpers, and the isRisky + shouldConfirm predicates — spread across ~80 lines interleaved with other unrelated boot state. The dialog is opened from four sites (sidebar close, tab close, pane close, multi-select close) with different follow-ups; the state itself has no dependency on anything else in App.vue except the "is this session currently open as a remote pane?" check. Move the whole state machine into composables/useCloseSessionConfirm.ts, injecting isOpenRemoteSession from the caller. The composable exposes the same identifier names the template + call sites already used (destructured out at the App.vue side), so the four call sites and the <ConfirmCloseSessionDialog> bindings stay unchanged. requestCloseSession stays in App.vue because it also references onSidebarClose from the sidebar callbacks layer. App.vue side: - Drop pendingCloseSession(s) refs + pendingCloseAction let. - Drop isCloseRiskySession, shouldConfirmCloseSession, sessionCloseTitle, the four pendingClose* computeds, clearPendingCloseSession, openCloseSessionConfirm, confirmCloseSession, cancelCloseSession. - Keep isOpenRemoteSession (used by another site too) — pass it into the composable. - Add composable import + single destructuring call. App.test.ts updated: the three source-text assertions that pinned the old inline structure now check the composable file for the predicate bodies and the App.vue side for the import + destructure + template wiring. Net: App.vue -60 / +13; new composable +121. `npm test` 1631 pass; `npm run build` green.
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
Fifth slice of milestone 5-a. App.vue held the "are you sure you want to close this session?" dialog state — `pendingCloseSession(s)`, `pendingCloseAction`, four computeds (title / isAi / isRunning / isRemote), open/confirm/cancel/clear helpers, and the `isRisky` + `shouldConfirm` predicates — spread across ~80 lines interleaved with other unrelated boot state.
The dialog is opened from four sites (sidebar close, tab close, pane close, multi-select close) with different follow-ups; the state itself has no dependency on anything else in App.vue except the "is this session currently open as a remote pane?" check. Move the whole state machine into `composables/useCloseSessionConfirm.ts`, injecting `isOpenRemoteSession` from the caller.
The composable exposes the same identifier names the template + call sites already used (destructured out at the App.vue side), so the four call sites and the `` bindings stay unchanged. `requestCloseSession` stays in App.vue because it also references `onSidebarClose` from the sidebar callbacks layer.
App.vue side:
Test update: the three source-text assertions that pinned the old inline structure now check the composable file for the predicate bodies and the App.vue side for the import + destructure + template wiring.
Net: App.vue -60 / +13; new composable +121. App.vue now 1949 lines (was 1982).
Test plan