Skip to content

Decompose App.tsx phase 2 step 3: extract useConnectionLifecycle #2154

Description

@cliffhall

Step 3 of phase 2 of the App.tsx decomposition — see #2129 for the phase, #2126 for the whole effort.

This is a stacked PR. Its branch is cut from step 2's and its PR targets that branch, not v2/main. Do not land it before step 2.

Scope — useConnectionLifecycle(session, oauth, stores), ~700 lines

  • latencyMs, connectStartRef, connectErrorMessage, recordConnectError
  • clearOAuthResumeOnExplicitDisconnect, finalizeExplicitDisconnect, resetSessionScopedUiState
  • the connection effects
  • setupClientForServer (~215 lines, the heaviest single function in the file)
  • the ~250-line effect that drives it
  • onToggleConnection
  • onDisconnect, its effect, onReauthenticateFromBanner

Supplies the onReconnect callback step 2 injects.

Constraints carried from #2129

  • resetSessionScopedUiState reaches into most of phase 1's UI state to clear it on disconnect. Give it a narrow reset() surface from each phase 1 hook rather than handing it every setter — otherwise this hook depends on everything and nothing was decoupled.
  • No behavior change.

Done when

  • useConnectionLifecycle is its own hook
  • ≥90% on all four coverage dimensions
  • npm run ci green, all three web smokes included

Metadata

Metadata

Assignees

Labels

choreMaintenance: deps, build tooling, CI, cleanup — no user-facing behavior changev2Issues and PRs for v2

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions