Skip to content

Decompose App.tsx phase 2 step 1: extract useSessionRef #2157

Closed

Description

@cliffhall

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

The prerequisite, landed first and alone. It is the seam every later step is extracted onto, so it is the base of the stack: steps 2–5 (#2153, #2154, #2155, #2156) are each cut from the previous step's branch, and step 2's PR targets this one's.

Scope — useSessionRef

App.tsx mirrors six values into refs so callbacks can read current values without being re-created: activeServerNameRef, activeServerIdRef, serversRef, inspectorClientRef, pendingStepUpRef and pendingReauthRef, plus their three sync effects. Collapse them into one useSessionRef({ … }) returning a single stable ref.

What this is not: not a store, not reactive, not context, nothing renders off it. It is exactly the pattern already in the file, written once instead of six times. It works as a seam because a hook taking sessionRef takes a stable dependency, so extracting one cluster does not force the others into its argument list.

These are the latest-ref pattern and are not what AGENTS.md's "never sync state from a prop in an effect" rule forbids — that rule is about setState in an effect, and a ref write produces no render at all.

Done when

  • useSessionRef landed; the six ad-hoc refs and their sync effects are gone
  • ≥90% on all four coverage dimensions (100%, no v8 ignore needed)
  • No behavior change
  • npm run ci green, all three web smokes included

Implemented in #2152.

Activity

  1. added this to the v2.5.0 milestone on Aug 27, 2026
  2. added
    v2
    chore
    on Aug 27, 2026
  3. self-assigned this
    on Aug 27, 2026
  4. added
    refactor
    on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

chorerefactorv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions