Skip to content

[Bug]: Stalled-turn sweep interrupts Claude turns after macOS sleep (counts sleep time as silence) #40762

Open

Description

@hardyn

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. A Claude turn is running (waiting on the API stream after a tool result).
  2. The MacBook goes to Clamshell Sleep on battery. caffeinate and the app's own NoIdleSleep assertion do not prevent it.
  3. During a short DarkWake (5–10 s) the server sweep runs ClaudeAdapterV2.failStalledTurn -> ClaudeAdapterV2.interruptTurn and sends query.interrupt.

Expected behavior

  • Stall detection uses monotonic time that excludes system sleep (or resets the stall timer on wake), and gives the stream a grace period after wake before declaring it stalled.
  • If a turn is ended this way, label it as a stall/sleep timeout, not as a user interrupt, and offer to resume.

Actual behavior

The SDK records "[Request interrupted by user]", the run ends as failed ("Claude sent nothing for 10 minutes"), and the next user message gets "No response requested.".

Impact

Major degradation or frequent failure

Version or commit

T3 Code desktop 0.1.11

Environment

macOS, Claude Agent provider

Logs or stack traces

Evidence (one night, UTC):

  • Last provider event 22:34:45, laptop asleep, DarkWake at 22:55:45, failStalledTurn + interruptTurn at 22:55:45.871, outgoing query.interrupt at 22:55:46.234.
  • The same pattern hit two more threads at 00:15:01 and 00:44:34, each exactly at a DarkWake.
  • The machine was never fully awake between 22:24 and 08:38, so the 10-minute silence was almost entirely sleep time.

Workaround

Long waits run on an always-on machine instead of the laptop.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions