Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(server,web,mobile): a host that drops because it froze now says why #22213

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/22213/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Stacked on #22212.

When a host is CPU-starved, its server freezes until the client's 15s ping timeout drops it. While the host is frozen, the client cannot tell a frozen server from a dropped network. Only the server knows it froze, and it can only say so after it recovers. So nothing told the user why leftbook kept dropping. (The cause was load 219 on 18 cores from 8 parallel headless Chrome benchmark runs.)

Now the host says so when the client reconnects:

leftbook froze for 12s Its CPU is overloaded (load 219 on 18 cores).

  • Server: EventLoopMonitor keeps its latest stall of 5s or more, with the 1-minute load average and core count. When a client loads config, the monitor first takes a sample, so a stall that ended right before the reconnect is included. The stall goes in the config snapshot as optional lastEventLoopStall, and only for 5 minutes after detection. The server uses its own clock for this, so clients need no clock.
  • Clients: hostFreezeNotice in client-runtime writes the text. If the load is not above the core count, it says "T3 Code on leftbook was too busy to answer." Web and desktop show a warning toast once per stall. Mobile has no toasts, so it shows the same line in the environment's connection row. The config cache never stores the stall, so a restart cannot replay it.

Proof: in a script with the real Node sampler, a 3s block was logged but not reported, and a 7s block was reported as { durationMs: 6025, loadAverage: 3.2, cpuCount: 18 }. The histogram undercounts by up to its 1s resolution, as the file already documents. I did not exercise the toast or the mobile row in a real client.

Reviewed with sol-loop: 1 round with GPT-6.1 Sol. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

    1. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This PR adds a new cross-platform host-freeze notification capability, including server-side stall retention, config propagation, web toasts, and mobile connection messaging. The additive schema and tests reduce risk, but the production runtime coordination and new user-facing behavior merit human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    2. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—5.0 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.9 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: 4e8b005 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    3. @@ -21,3 +26,17 @@
      2126 const STALL_THRESHOLD_MS = 2000;
      2227 const SAMPLE_INTERVAL = "30 seconds";
      2328 const STALL_LOG_MAX_BYTES = 256 * 1024;
      29+// Long enough that users felt it. Shorter stalls stay in the log only.
      30+const NOTICEABLE_STALL_MS = 5000;
      31+// Clients show what they get, so an old stall must not explain a new drop.
      32+const NOTICEABLE_STALL_MAX_AGE_MS = 5 * 60_000;
      33+
      34+export class EventLoopMonitor extends Context.Reference<{
      35+ /**
      36+ * The latest stall of 5 s or more, if seen in the last 5 minutes. It samples
      37+ * first, so a stall that ended just before a client reconnected is included.
      38+ */
      39+ readonly latestNoticeableStall: Effect.Effect<ServerEventLoopStall | undefined>;
      40+}>("t3/observability/EventLoopMonitor", {
      41+ defaultValue: () => ({ latestNoticeableStall: Effect.succeed(undefined) }),
      42+}) {}
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Use a Context.Service tag with the interface inline instead of a Context.Reference with a no-op default. The default makes ws.loadServerConfig silently report no stall if the monitor layer is omitted, rather than exposing the missing service dependency. Provide the real layer at the application boundary (and an explicit no-op test layer where needed).

      Posted via Macroscope — Effect Service Conventions

Sign in to join this conversation.