# fix\(server\): pause periodic PR discovery without foreground clients · PR \#23852 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/23852)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: fix/issue-23702

Target branch: main

Head commit: ab1418478c65754a3637796ff61657c26aae2e56

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/23852)

[Commits](https://git.cafe/pingdotgg/t3code/pull/23852/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/23852/diffs?format=markdown)

## Description

---

## Problem

A headless Linux server kept discovering branch pull requests every minute after its client disconnected, spending GitHub quota without anyone using the client. Reproduced on current main with an active branch thread: `listPullRequestsByHead` continued after the browser left and no server sockets remained.

## Change

Check the existing background activity policy before each periodic branch-discovery sweep. Discovery resumes on the next minute tick when foreground activity permits opportunistic work. Startup backfill and thread-event refreshes remain available to headless agents and scheduled tasks. The existing foreground and host/client power constraints apply; no new settings or persisted state are added.

## Scope and approval

Fixes #23702

Triaged bug via the automated issue flow: [#23702](https://git.cafe/pingdotgg/t3code/issues/23702). This change only bounds recurring branch discovery. Existing PR-summary polling is unchanged.

## Verification

- Regression test against the baseline service: **fails with 10 unwanted lookups in 10 simulated idle minutes**. Patched service: **6/6 tests pass** in `ThreadPullRequestService.test.ts`. The test also proves checkpoint-triggered discovery still runs without foreground demand.
- Focused server typecheck passes. Targeted lint has only the existing unused `layer` warning; diff check passes.
- Two independent diff reviews (Codex and Claude): **MERGE**. Proof audit: **SUFFICIENT**.
- Real Linux dev server, isolated copied state and a local git fixture with a GitHub remote. Browser paired, then disconnected. The patched server remained alive and produced **zero branch-discovery spans during 21:10:11–21:14:42 UTC**, covering multiple minute ticks. A foreground activity RPC then resumed synchronization on the next tick, with a successful GitHub branch lookup.

| Proof | Before | After |
| --- | --- | --- |
| Deterministic service test | [10 extra lookups; exit 1](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/31baa061e8805094/issue-23702-red-test.txt) | [6 tests pass; exit 0](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/6195fc9c24c8e2eb/issue-23702-green-test.txt) |
| Real server | [Recurring idle branch requests](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/8c69149e095c00ab/issue-23702-before.txt) | [No recurring branch discovery](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/6509964e2365d829/issue-23702-after-runtime.txt) |

[Foreground positive control](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/2aac934c38b79eee/issue-23702-positive-control.txt) · [Proof matrix](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/50cc10d333b1516f/issue-23702-proof-matrix.md)

Server-only change: visual matrix empty, screenshots and pixel diffs not applicable. Dev-watcher restarts are disclosed and excluded from the 271-second stable observation. Existing PR-summary requests continued during that interval; this evidence does not claim all idle GitHub traffic stops or attribute shared-account quota changes to this server. The original 450-thread/90-clone scale and quota-exhaustion state were not recreated. No platform-specific code changed; desktop/mobile shells and remote transports were not separately exercised.

Evidence captured at implementation head `29ce300674`; the final merge from main changes only unrelated mobile dependencies. The audited server files are identical.

Models and harness: Codex gpt-6.1-sol and Claude claude-opus-5-5 through T3 Code.

