anthropics / anthropics/claude-code

[BUG] Remote Control: web and mobile derive the environment label from different payload fields, producing indistinguishable duplicates for subdirectory environments

オープン
#93,012 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:claude-code-web bug has repro platform:linux
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

## Summary

Running `claude remote-control` in a tracked subdirectory of a git repo registers an environment whose label collides with the environment for that repo's root. The claude.ai/code environment picker shows two entries with the identical name and identical subtitle (machine name); the Claude mobile app shows the same two environments correctly and distinctly.

The two surfaces appear to label the environment from different fields of the same registration payload.

## Cause

`POST /v1/environments/bridge` carries no name field at all. From `--debug-file` for a server started in `/subproject` (paths and names generalized):

```
[bridge:init] bridgeId= dir=/home/user/projects/monorepo/subproject branch=dev gitRepoUrl=https://github.com//monorepo machine=
[bridge:api] POST /v1/environments/bridge -> 200 environment_id=env_…
[bridge:api] >>> {"machine_name":"",
"machine_id":"",
"directory":"/home/user/projects/monorepo/subproject",
"branch":"dev",
"git_repo_url":"https://github.com//monorepo",
"max_sessions":32,
"metadata":{"worker_type":"claude_code"}}
```

Web labels the environment from `git_repo_url`; mobile labels it from `directory`. When the server's cwd is the repo root those two agree, so the inconsistency is invisible. It only surfaces for a subdirectory environment, where the same payload yields two different names depending on which client you open.

Observed across four concurrent environments — the three whose cwd is a repo root label identically on both surfaces; only the subdirectory one diverges:

| server cwd | `directory` basename | `git_repo_url` basename | web shows | mobile shows |
|---|---|---|---|---|
| `projects/alpha` | alpha | alpha | alpha | alpha |
| `projects/beta` | beta | beta | beta | beta |
| `projects/monorepo` | monorepo | monorepo | monorepo | monorepo |
| `projects/monorepo/subproject` | **subproject** | **monorepo** | **monorepo** ❌ | subproject ✅ |

Both entries are live and healthy (3/32 and 1/32 sessions), so this is not a stale-registration artifact — it is two distinct working environments that the web UI renders under one name.

## Reproduction

1. In any git repo, run `claude remote-control` at the repo root.
2. In a second terminal, run `claude remote-control` in a tracked subdirectory of that same repo.
3. Open claude.ai/code and expand the Remote Control environment picker: the repo name appears twice, with no field distinguishing them.
4. Open the same picker in the Claude mobile app: the two entries are named for their directories and are distinguishable.

## Expected

Consistent labelling across surfaces, and ideally some way to set it. Today there is none:

- `--name` sets the **session** title, per the [documented precedence](https://code.claude.com/docs/en/remote-control) (`--name` → `/rename` → last meaningful message → `myhost-graceful-unicorn`). It is not part of the environment registration payload and has no effect on the picker's environment label. All four servers above pass distinct `--name` values.
- `/rename` renames a session within an environment, not the environment.
- Restarting re-mints the environment id but recomputes the same derived label.

Any of these would resolve it:

- Have web fall back to (or disambiguate with) `directory` when `git_repo_url` is not unique for the machine.
- Show `directory` or `branch` as the picker subtitle alongside `machine_name`.
- Accept an explicit environment name — e.g. `--environment-name`, or a settings key resolved per-directory.

## Related

- #77372 — stale environments cannot be deleted. Same visible symptom (indistinguishable picker entries) but a different cause; both entries here are live.
- #88939 — configurable peer-registration session name. Adjacent motivation, different subsystem (cross-session messaging, not the environment registration).

## Version

Claude Code v2.1.266

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start by reproducing with `claude remote-control` at a repo root and then in a tracked subdirectory, using `--debug-file` to inspect the `POST /v1/environments/bridge` payload. Trace how web and mobile choose labels from `git_repo_url`, `directory`, `branch`, and `machine_name`. Done means duplicate repo-root and subdirectory environments are distinguishable and labelled consistently across the picker surfaces.

索引モデルが issue の本文から書いたものです。

評価

領域
api, cli, frontend, mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

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

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