Move a session to another working directory
`POST /sessions/{id}/cwd`, behind a field in the session settings dialog. A
working directory is settled when the process is spawned -- the CLI is
launched with it as its cwd and there is no control request that changes one
-- so this records the new one and ends the process that is in the old one.
It does not start a replacement, and the field says so in a line beside it:
a session with no process starts on the next message or on Start, which is
this app's rule for that everywhere else, and "usually restarts" is a worse
control than "always stops".
The path is checked against the session's own machine and refused if it is
not there. The spawn path corrects instead of refusing, because it is
resuming a directory the *machine* recorded and that can be gone through
nobody's fault; a path somebody has just typed is different, and a mistyped
one accepted here would surface much later as a session that would not
start, with nothing pointing at the typo. The refusal names the machine and
the path, and is drawn under the field it is about.
Nothing of Claude Code's own is moved, and that is measured rather than
assumed: on CLI 2.1.237, `claude --resume <id>` finds a session from any
working directory -- an id that does not exist answers "No conversation
found with session ID", and a real one resumed from an unrelated directory
did not. So the conversation continues in the new place with nothing
relocated. Doing otherwise would mean reproducing a rule this app cannot
see the whole of; PLAN.md records what that rule is, for whoever tries.
Found while checking it: `SessionInfo.cwd` came from the snapshot a session
launched with, so a moved session went on reporting its *old* directory for
as long as its process lived -- a dialog showing a directory the next launch
would not use, with nothing saying so. It is read from the config where the
row is built now, the same way `setup_name` already was, and for the reason
already written above `setup_name`: only the manager holds the config, and
both of these change under a running session.
Checked end to end on the emulator against a session whose process really
does take a cwd: /proc said /tmp/cwd-a before and /tmp/cwd-b after, the
dialog showed the new path immediately rather than after a restart, and a
directory that is not there and a relative path were both refused with the
session left exactly as it was.
This commit is contained in:
1 parent
6236f0d5bd
commit
deb908034c
6 files changed
+305
-11
No files matched your search
@@ -247,6 +247,42 @@ turn. Claude's dialect: a `user` message on stdin mid-stream; pi's: `steer`.
|
||||
- Images in: base64 image content blocks in the stream-json user message.
|
||||
- Working directory, host, and model are spawn-screen fields.
|
||||
|
||||
### Moving a session to another directory (decided 2026-08-31)
|
||||
|
||||
`POST /sessions/{id}/cwd {cwd}`, behind a field in the session settings
|
||||
dialog. The directory is settled when the process is spawned -- the CLI is
|
||||
launched with it as its cwd and there is no control request that changes one
|
||||
-- so this records the new one and **ends** the process that is in the old
|
||||
one. It does not start a replacement: a session with no process starts on
|
||||
the next thing said to it or on Start, which is this app's rule for that
|
||||
everywhere else, and "usually restarts" would be a worse control than
|
||||
"always stops" (starting one here would have to wait for the recorded status
|
||||
to catch up with a process already gone).
|
||||
|
||||
The path is checked against the session's own machine and **refused** if it
|
||||
is not there, rather than corrected. The spawn path corrects instead,
|
||||
because it is resuming a directory the *machine* recorded and that can be
|
||||
gone through nobody's fault; a path somebody has just typed is different,
|
||||
and a mistyped one accepted here would surface much later as a session that
|
||||
would not start, with nothing pointing at the typo.
|
||||
|
||||
**Nothing of Claude Code's own is moved**, and that is a measurement rather
|
||||
than an omission. Checked against CLI 2.1.237 on 2026-08-31: `claude
|
||||
--resume <id>` finds a session from any working directory — an id that does
|
||||
not exist answers "No conversation found with session ID", and a real one
|
||||
resumed from an unrelated directory did not. So the conversation continues
|
||||
in the new place with nothing relocated, and the session file stays under
|
||||
the project directory the CLI made for it, which is where the CLI itself
|
||||
looks. Relocating it would mean reproducing a rule this app cannot see the
|
||||
whole of: the CLI's project directory is the path with every non-alphanumeric
|
||||
character replaced by `-`, truncated at 200 characters with a hash of its own
|
||||
appended, and an override can replace the name entirely.
|
||||
|
||||
While fixing this: `SessionInfo.cwd` came from the snapshot a session
|
||||
launched with, so a moved session reported its *old* directory for as long
|
||||
as the process lived. It is read from the config where the row is built now,
|
||||
the same way `setup_name` already was and for the same reason.
|
||||
|
||||
### A message from another agent, on a live session (measured 2026-08-31)
|
||||
|
||||
Peer messages were only ever produced by the *import* path, reading them out
|
||||
|
||||
Reference in new issue
Block a user