Repository navigation
refactor(gateway): simplify presence and profile request paths - #159130
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 4:10 PM ET / 20:10 UTC. ClawSweeper reviewWhat this changesThe branch simplifies Gateway typing cleanup, viewer presence comparisons, account-connect error handling, and avatar response caching, while removing a test mock of the production ETag formatter. Merge readiness✅ Ready for maintainer review Keep this coherent cleanup open. Current main retains the redundant paths, and review of the introduced changes and their callers found no actionable regression. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway handles WebSocket presence and account requests and authenticated HTTP avatar requests. These paths produce live session indicators, account responses, and profile images for the Control UI. flowchart LR
A[Viewer and typing requests] --> B[Presence and typing state]
B --> C[Control UI indicators]
D[Account requests] --> E[Authorization and replies]
E --> F[Account results]
G[Avatar HTTP requests] --> H[Avatar selection and cache headers]
H --> C
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -42, Tests -7. Total -49 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep these simplifications with their existing Gateway owners while preserving live account authorization and the distinct avatar success and miss cache policies. Do we have a high-confidence way to reproduce the issue? Not applicable: the PR addresses redundant control flow rather than a reported behavior defect; its body reports comparative base and candidate tests. Is this the best way to solve the issue? Yes: the consolidation stays within the existing Gateway owners and preserves the traced authorization, presence publication, and HTTP cache contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c0e6951d6f02. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
The performance campaign left small amounts of redundant control flow and copied test behavior in Gateway presence, account identity requests, and profile avatar responses.
User Impact
No user-visible behavior changes. Presence publication, typing pacing, authorization, avatar freshness, HTTP caching, and error responses retain their existing contracts.
Why This Change Was Made
Remove timer-presence guards because Node defines
clearTimeout(undefined)as a no-op; compare absent viewer declarations as the empty sets they already represent; inline an error callback left behind by the account-request async conversion; and let the avatar response helper own the identical cache policy previously repeated at three callers. Condense two repeated Gravatar comments while preserving their disclosure and timeout rationale.The avatar HTTP suite no longer mocks the ETag formatter with a copy of its implementation. Its unchanged literal ETag assertions now exercise the production formatter. No tests or assertions were removed.
This is a small, honest consolidation. Pairing metadata allowlists and commit receipts, publication windows, typing authority checks, reconnect/roster jitter, and the distinct identity/avatar cache lifecycles stay intact. Larger apparent consolidations either crossed different contracts or touched files owned by open PRs; none of those files is changed here.
Evidence
Production: +25 / -67, net -42 LOC. Tests and test support: +0 / -7, net -7 LOC.
All 151 tests across 8 files pass on both the original base and the candidate using one Blacksmith Testbox,
tbx_01m3fhp7nt1c6pdrdbyz2rv88a(run). Candidate source bytes were verified before execution.--maxWorkers=1These are cold verification costs, including compiled-worker preparation, not a speedup claim. The changed test file adds no cases, assertions, timers, or test-only production seams. Hosted PR CI timing is pending.
node scripts/check-changed.mjs -- <the five changed paths>passed on the same Testbox in 1,302.05 s, including production typecheck, all 25 test typecheck groups, changed-file lint, dead-export checks, and contract guards. Formatting andgit diff --checkpassed. Deslop and test-audit are complete; independent Codex pre-commit and branch autoreviews are clean through P2. The committed tree exactly matches the validated candidate. The Testbox is stopped and its temporary source mirror removed.The initial comparison setup failed before running tests: a borrowed root dependency link omitted a plugin-owned dependency, and a later Testbox sync replaced the carrier Git metadata supporting that temporary worktree. The completed comparison used a fresh, fully installed baseline and ran both revisions in one invocation. No product-code change was needed for either setup failure.