anthropics / anthropics/claude-code
[FEATURE] Bound background Bash tasks: optional deadline + surface output staleness in the Background tasks panel
- 主要語言
- Python
- 星號
- 145k
- 分支
- 23.1k
- PR 合併指標
- PR 指標待擷取
描述
## What happened
In a Claude Desktop (Code tab) session I dispatched two background bash watchers while waiting on a Cloudflare Workers deploy:
1. `until [ "$(curl -sS -o /dev/null -w '%{http_code}' )" = "200" ]; do sleep 15; done` — exited correctly after ~3 minutes.
2. `until [ "$(gh api .../check-runs --jq '')" -ge 2 ]; do sleep 15; done` — the assumption behind `-ge 2` was wrong. The provider (Cloudflare Workers Builds) **updates the existing check run** instead of creating a second one for the second push, so that commit only ever had 1 check run and the condition could never become true.
Watcher 2 spun for 24 minutes, polling the GitHub API every 15s, until the user noticed the persistent `1 running task` chip and asked what it was. The deploy had finished long before, and I had already verified it through watcher 1 — the task was pure garbage by then. `TaskStop` killed it instantly once I actually looked.
**The stuck loop is my bug, not the harness's** — an agent-written wait condition that can never be satisfied. That is precisely why I think the harness should bound it.
## Why this is worth fixing
- The Background tasks panel shows elapsed time but not *output staleness*. A no-op poll loop looks identical to a long build: both are just "Bash 24m 06s".
- `Monitor` has `timeout_ms` (default 300000, max 3600000). `Bash` with `run_in_background: true` has no equivalent — the `timeout` parameter documents itself as the foreground command timeout. So the dispatch path most likely to carry an agent-written `until` loop is the one path with no deadline at all.
- The user's first reading was "this is a Claude Desktop bug, I've seen this before". A silently spinning task costs trust in the panel's state even when the app is behaving correctly.
## Ask
1. Let `Bash` with `run_in_background: true` accept a deadline (same shape as `Monitor.timeout_ms`) with a sane default, and mark the task **timed out** rather than leaving it `Running` forever.
2. In the Background tasks panel, show last-output age (e.g. `no output 12m`) so a no-op loop is visible at a glance.
3. Optional: warn at dispatch when a backgrounded command is an `until`/`while` poll loop with no deadline.
## Related
- #55893 (closed as not planned) — same failure family (polling loops that never exit), but focused on cross-session orphans and `TaskStop` not reaching prior-session IDs. This ask is narrower: a deadline plus visible staleness for tasks in the *current* session.
- #74219 — nested subagents stuck as `Running` in the same panel.
## Environment
- Claude Desktop, Code tab
- Opus 5
- macOS, darwin 25.6.0
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
No files or tests are named. Start by tracing the Bash background dispatch path, comparing it with Monitor.timeout_ms, and following how the Background tasks panel receives task state and output timestamps; also inspect TaskStop handling. Done means background tasks have a bounded, visibly timed-out state and the panel exposes output staleness, with behavior covered by the relevant tests.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- bash, github
- 領域
- backend, cli, desktop
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 活躍
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100