anthropics / anthropics/claude-code

[FEATURE] Bound background Bash tasks: optional deadline + surface output staleness in the Background tasks panel

オープン
#93,387 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:bash area:tui enhancement platform:macos
主要言語
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
見積もり時間
1週間以上
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。