Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Auto-settlement marks old threads fresh and sends completion pushes on first launch #9057

Closedeimexdev(GitHub profile, opens in a new tab) opened this issue 1 comment

What happened

After updating T3 Code Nightly on macOS, the linked iOS app immediately received roughly 50+ thread-completion notifications. They appeared concentrated on very old threads, not newly completed work.

Expected: automatically settling old threads should not send completion notifications.

Actual: the first launch after updating treated old threads as freshly completed.

Diagnosis

Nightly 1246 introduced server-owned automatic thread settlement in PR #8600:

https://github.com/pingdotgg/t3code/pull/8600

On startup, the new ThreadSettlementReactor immediately sweeps eligible threads:

https://github.com/pingdotgg/t3code/blob/b883fc066ea5c9bebbe1c3e9b4bc2471aab3685f/apps/server/src/orchestration/ThreadSettlementReactor.ts#L154-L166

The default inactivity threshold is three days:

https://github.com/pingdotgg/t3code/blob/b883fc066ea5c9bebbe1c3e9b4bc2471aab3685f/packages/contracts/src/settings.ts#L58-L67

On this machine, first startup of 1246 emitted 44 thread.settled events for the existing backlog within 2.4 seconds. All selected threads had been inactive longer than three days.

Processing thread.settled updates the thread's general updatedAt timestamp to the settlement event time:

https://github.com/pingdotgg/t3code/blob/b883fc066ea5c9bebbe1c3e9b4bc2471aab3685f/apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L691-L704

The agent-awareness relay publishes thread.settled because unlisted event types default to publishable:

https://github.com/pingdotgg/t3code/blob/b883fc066ea5c9bebbe1c3e9b4bc2471aab3685f/apps/server/src/relay/AgentAwarenessRelay.ts#L69-L94

The notification relay suppresses terminal notifications older than two minutes, but uses that same general thread updatedAt value:

https://github.com/pingdotgg/t3code/blob/b883fc066ea5c9bebbe1c3e9b4bc2471aab3685f/infra/relay/src/agentActivity/ApnsDeliveries.ts#L329-L362

Therefore:

  1. An administrative settlement rewrites an old thread's updatedAt to "now."
  2. Its existing completed/failed awareness state appears freshly terminal.
  3. The two-minute guard passes.
  4. APNs queues a completion/failure notification.

This explains both selectivity:

  • Only old threads: the new sweep targeted the three-day inactivity backlog.
  • Only this update: after settlement, settledOverride is non-null, excluding those threads from future sweeps.

The exact APNs delivery count is not persisted locally. The user observed 50+ notifications; local evidence proves a 44-thread settlement batch. Confirming duplicates or additional deliveries requires relay-side delivery logs.

Steps to reproduce

  1. Use a build before 0.0.38-nightly.20260901.1246.
  2. Link an iOS device with completion notifications enabled.
  3. Accumulate many nonarchived, unsettled threads inactive for more than three days.
  4. Update to 0.0.38-nightly.20260901.1246.
  5. Launch Desktop.
  6. Observe the immediate automatic-settlement sweep.
  7. Observe stale completion notifications on iOS.

Do not repeat on production user data merely to confirm; it may trigger another notification flood.

Version

Desktop 0.0.38-nightly.20260901.1246 (b883fc066ea5c9bebbe1c3e9b4bc2471aab3685f). Triage CLI 0.0.37.

Environment

Darwin arm64 27.0.0; Node v24.18.0; T3 Code Nightly desktop app; linked iOS mobile app, mobile version unknown.

Evidence

Desktop started: 2026-09-01 10:11:22 America/Chicago
Server started:  2026-09-01 10:11:24 America/Chicago

Events from 10:11:25.802–10:11:28.216:

thread.settled                 44
thread.session-stop-requested  20
thread.session-set             20

Pre-settlement session status for those 44 threads:

stopped  24
ready    19
error     1

All 44:
- previously unsettled
- inactive beyond the default three-day threshold
- now have settledOverride = "settled"
- will be excluded from subsequent automatic-settlement sweeps

Fix applied or workaround

No workaround applied.

The backlog sweep has completed and should not repeat for these threads. Temporary prevention for other environments:

npx t3 connect publish --disable

This disables both push notifications and Live Activities.

Potential code fix: do not publish agent awareness for thread.settled, or base terminal notification freshness on the actual turn/session terminal-transition timestamp rather than general thread updatedAt.

Filed by

Codex (GPT-5) via t3 triage.

  1. Note

    🤖 GPT-5.6 Sol responding on behalf of Elies

    After I updated T3 Code, 338 of my old settled threads suddenly appeared newly settled, even though their last activity was between 3 and 179 days earlier. Stable v0.0.38 contains this bug, and T3 Code has no in-app repair.

    This is the same startup auto-settlement described in this issue. The issue reports the resulting notification flood; on my install, that same sweep also left the Settled shelf with persistently wrong dates and order.

    Before #8600, inactivity settlement was client-only, leaving settledAt = null. After upgrading, the new startup sweep persists those same threads with settledAt = now. Months-old threads therefore appear newly settled.

    This occurred on my Linux x64 install with v0.0.38-nightly.20260901.1246. When I started the T3 server after the update, it auto-settled all 338 threads in 12.811 seconds. Their median activity age was 85.08 days. I disabled auto-settlement, backed up the database, and repaired the timestamps offline.

    The bug is still present in v0.0.39-nightly.20260902.1257, the latest published nightly when I checked: the reactor queues a sweep as soon as the server starts, the decider sets settledAt and updatedAt to the command time, the projection stores those values, and the Settled shelf uses settledAt for its date and order.

    The 338-thread burst requires an upgraded install carrying that legacy backlog. Fresh installs do not have one, but future automatic settlements still write the settlement command time instead of the last activity time.

    Open PR #9081 would fix the notification side of this issue, but not the stored settledAt, the incorrect Settled shelf dates and order, or existing data. Please keep this issue open for the timestamp bug.

  2. eimexdev(GitHub profile, opens in a new tab) changed the title

Sign in to join this conversation.