anthropics / anthropics/claude-code

[BUG] sshConfigs startDirectory is accepted by the schema but ignored when a session starts

Đang mở
#91,171 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area:desktop bug has repro platform:macos
Ngôn ngữ chính
Python
Star
145k
Fork
23.1k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code

### What's Wrong?

An SSH connection defined in `~/.claude/settings.json` with `startDirectory` connects correctly, but the session opens in the **remote user's home directory** instead of the directory I specified.

Because session history is keyed on the working directory, the session also starts with an **empty history**. A machine I had been working on from the CLI opens in the desktop app showing none of my conversations. The transcripts are intact on the host, just stored under the key for the other path, but it reads as data loss.

The field is schema-validated (an invalid type is rejected), so it is accepted and then discarded rather than ignored as unknown.

### What Should Happen?

The session opens in the directory given by `startDirectory`, as documented:

> Default working directory on the remote host. Supports tilde expansion (e.g. ~/projects). If not specified, defaults to the remote user home directory.

I did specify it, so the default should not apply.

### Error Messages/Logs

```shell

```

### Steps to Reproduce

1. Add an SSH connection to `~/.claude/settings.json`:

```json
{
"sshConfigs": [
{
"id": "team.project-a",
"name": "Project A",
"sshHost": "project-a",
"startDirectory": "/opt/src/project-a"
}
]
}
```

2. Restart Claude Desktop and open the Code tab.
3. Pick "Project A" from the environment dropdown. It connects.
4. Ask Claude what the working directory is, or run `pwd`.
5. It reports the remote user's home directory, not `/opt/src/project-a`.
6. On the remote host, `ls ~/.claude/projects/` shows a store keyed on the home directory rather than on the configured one, which is why the history looks empty.

### Claude Model

_No response_

### Is this a regression?

I don't know

### Last Working Version

_No response_

### Claude Code Version

2.1.56 (Claude Code); Claude Desktop 1.40609.0

### Platform

Anthropic API

### Operating System

macOS

### Terminal/Shell

Terminal.app (macOS)

### Additional Information

**Why this matters beyond one setting**

For anyone managing a fleet of remote development machines, every connection needs a manual folder step before it is usable, per machine and per developer. The published `startDirectory` is the only mechanism for that, so there is currently no way to hand someone a ready-to-use connection.

**Possibly useful**

Connections supplied by at least one built-in integration do open at a working directory, so the session model appears to carry one already; it looks like the settings path simply does not pass the value through.

The documented workaround, `claude ssh [dir]`, does not currently run either. Filed separately.

**Searched first:** #83561 also involves `sshConfigs` but is a different problem (the SSH environment never appearing in third-party API mode). I found no existing report of `startDirectory` being ignored.

Desktop app version: 1.40609.0. Also reproduced on 1.37937.3.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

The report identifies ~/.claude/settings.json and the sshConfigs.startDirectory setting, but no implementation file or test. Start by tracing how this value reaches SSH session startup; verify completion by reproducing the connection and confirming that the session opens in the configured remote directory and uses the corresponding history.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.