fix(client-runtime): a slow host no longer shows settings as read-only #25526
main fromrefs/pull/25526/head·merged by juliusmarminge View on GitHubA slow session response should not leave permission-gated Settings read-only. The client retries only session timeouts with increasing deadlines, then returns the final timeout; other failures keep their existing behavior.
Capture interactions also exercise existing provider toggles, which can reset the provider-status probe; the resulting status differences are disclosed below.
Original description by @yordis
Problem#
When a host takes longer than 6 seconds to answer the session request (busy machine, slow relay or tunnel), the request times out and the client treats the missing session as missing grants. Settings and other permission-gated controls then show as read-only even though the user has full access, and they stay that way until the session atom revalidates.
Change#
fetchEnvironmentSessionState now treats a session timeout as "no answer yet" rather than a failure. It retries with a doubled timeout each time, and if the 60 second attempt also times out, the timeout error surfaces so a dead host is not waited on forever. Every other error, including a rejected credential, still fails immediately as before. The error type is pinned to RemoteEnvironmentRequestError so the exported web session atoms keep a type TypeScript can name.
Scope and approval#
This is a small, focused fix for an obvious bug in an existing path: a timeout tells us nothing about grants, so it should not be reported as if the user lacked them. It changes only the session fetch in packages/client-runtime and adds no settings or UI.
Verification#
- Added
waits longer for session permissions each time the environment is too slow to answerinenvironmentHttpAuth.test.ts. It fails onmain(the request is never retried, so the test times out) and passes with this change. - Added
gives up on session permissions once the longest wait also times out, covering the bounded retries. vp test run src/state/environmentHttpAuth.test.ts src/state/commandPermissions.test.tsinpackages/client-runtime: 48 passed.vp run typecheckinpackages/client-runtimeandapps/web: no errors.vp linton the changed files: clean.
Takeover#
Credit to @yordis for the report and original fix; their commit remains in this branch. The two regression tests now fail by assertion on main. A request with increasing timeouts replaces the counter/logarithmic retry count, and main is merged without rebasing. Default attempts are 6, 12, 24, 48 and 60 seconds. Credential rejection, renewal, grants and server authorization retain their existing behavior.
Evidence#
Fixture matrix · Runtime fixture clarification · Capture index · Final proof audit
Chromium 156 on Linux, DPR 1, no device emulation, 1440×900 or 390×844; light/dark and reduced motion. Two real isolated environments; only the secondary session endpoint is delayed. Cold loads have no cached grants; warm rows use genuine cached grants and explicit runtime revalidation after 31 seconds.
R1: cold, 8-second answers. R2: warm, 8-second answers. R3: cold, held requests. R4: warm, held requests. Recordings retain real time: baseline fails at 6 seconds; head retries at 6/18/42/90 seconds and finally fails at 150 seconds. Each recording and checkpoint has request/state timestamps in the capture index. R1/R2 after recordings include saving and restoring a setting.
Diff0: absolute channel delta ×8. Diff8: maximum channel delta >8/255, ×8. The table embeds the pending checkpoint; each row links its written steps and video timestamps above the paired recordings on its full evidence page; the index includes all retry/terminal frames, diffs, recordings, request ownership and executable capture scripts.
What else changed: cold controls remain disabled/loading while awaiting real grants, then become editable after a late response. Warm controls retain cached permissions during the wait, then lose them after final failure. The existing provider toggle invalidates its normal status probe; post-interaction status may show “Not found/not checked.” The recorded R3 driver continuation keeps the same live browser session and native recording; its exact continuation is documented in the index. No component, style or layout changed. Incidental age text and animations are masked identically and disclosed in the scripts.
Verification log
Credit: @yordis. Original commit retained, main merged by merge commit, takeover pushed to the original contributor branch.
- Tests: original two additions → two rewritten regression tests in existing environmentHttpAuth.test.ts (32 → 34 total). Both fail by assertion on main and pass on the head; scoped HTTP/permission suites 48/48, HTTP/supervisor 69/69.
- Regression driver / before-after log. Default schedule driver / log. Scripts are public artifacts, not committed scratch.
- Final-head check:changed log: format, lint, knip, affected typechecks and 34 changed-file tests pass.
- Code review round 1: GPT-6.1 Sol and Claude Opus 5.5 independently returned MERGE; no confirmed blocking findings. Reviewed tree equals final tree byte for byte. No regex/parser/dependency patch added.
- External merge: 024e593a63 at 22:27 UTC; both changed files exactly match the pushed head. No further branch push.
- CI: 38 successful, 0 pending, 0 failing (including post-merge cleanup contexts) on final head; CodeRabbit no actionable finding. Macroscope timing-policy note disclosed: default maximum wait is 150 seconds; existing independent command authorization deadline remains six seconds.
- Unverified: native mobile UI. Shared-runtime tests cover logic, not native rendering. No other changed surface is omitted.
- Source ownership: repaired captures retain launch/switch process records; older retained captures use checkout chronology and cleanup corroboration, with that historical qualification disclosed in the index.
- Proof audit: SUFFICIENT, all 32 scoped web rows; independent live rebuild exact zero-pixel delta. Full verification and collected friction.
- Models/harness: tests and implementation Claude Opus 5.5 via claudeAgent; reviewers GPT-6.1 Sol via Codex and Claude Opus 5.5 via claudeAgent; evidence and proof audit GPT-6.1 Sol via Codex. Lead GPT-6.1 Sol via Codex.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: dd5b540
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f2c3f343-2ab3-4fb6-a419-059b4514cd11
Commits-
Reviewing files that changed from the base of the PR and between 03ab5cd0d70a40932a37892d1e3d49ed9f584dae and 8fbfc33c1ac503048ca2983564318bc29143086a.
Files selected for processing: 2-
packages/client-runtime/src/state/environmentHttpAuth.test.tspackages/client-runtime/src/state/session.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
Walkthrough
-
Session-state fetching now retries remote authentication timeout errors with increasing timeouts, starting at the configured timeout or 6,000 ms and capped at 60,000 ms. Tests cover success after a retry and failure after the retry limit.
Changes: Session authentication retries
Priority:Layer / File(s) Summary Retry session-state timeouts
packages/client-runtime/src/state/session.ts,packages/client-runtime/src/state/environmentHttpAuth.test.tsThe loader retries remote authentication timeout errors with increasing timeouts, up to 60,000 ms. Tests verify success after a retry and failure with a timeout error after retries are exhausted. NormalEstimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- pingdotgg/t3code#24221: The issue reports session permission checks timing out and making permission-gated controls unavailable. This PR retries session timeout errors.
Possibly related PRs
- pingdotgg/t3code#18594: It adds the primary-environment session reader and its six-second authenticated request, which this PR changes to retry on timeout.
- pingdotgg/t3code#24445: It changes permission handling after session-check timeouts. This PR retries those timeouts before returning a result.
Suggested reviewers:
juliusmarminge
Merge Risk:
Minimal · up to8fbfc-
No actionable issue remains with session timeout retries; the change is mergeable after normal checks.
Pre-merge checks:
4-
Check name Status Explanation Description check The description includes all required sections. It explains the problem, the retry-based fix, the focused scope, the exemption from prior approval, and specific verification results. Title check The title clearly and concisely describes the primary user-visible fix: slow hosts no longer cause settings to appear read-only. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge added labelstakeover
juliusmarminge added labelspr:in-progress
juliusmarminge assignedjuliusmarminge
Taking over this one
juliusmarminge merged this024e593
juliusmarminge closed this
juliusmarminge removed labelspr:in-progress
Sign in to join this conversation.






































Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — This focused fix changes the default authenticated session path from a single 6-second request to multiple retries, with cumulative waiting potentially reaching roughly 150 seconds before failure. Because it changes default permission-state behavior in an authentication-related path, the runtime policy should receive human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).