You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auto-Started Daemon Returns Incorrect Session Directories After Its Startup Directory Is Deleted #48879
I traced the incorrect thread.cwd fallback to the absolute-path conversion used when reading persisted threads.
thread_from_stored_thread calls AbsolutePathBuf::relative_to_current_dir(thread.cwd) even when thread.cwd is already absolute.
relative_to_current_dir unconditionally calls std::env::current_dir() before resolving the path. In this reproduction, the daemon process was started in directory A, then A was deleted. As a result, current_dir() fails even though the stored thread cwd is the still-existing absolute directory B.
The error handler then falls back to fallback_cwd, which is the daemon configuration cwd (A), causing thread/read to report A instead of B.
Suggested fix:
In AbsolutePathBuf::relative_to_current_dir, normalize and return already-absolute paths before calling std::env::current_dir().
Only resolve against the process current directory when the input path is relative.
Suggested Unix regression test:
Start a child test process in a temporary directory.
Remove that directory so current_dir() fails.
Assert that converting an already-absolute path still succeeds and preserves that path.
This preserves current behavior for relative paths while preventing a deleted daemon startup directory from corrupting the displayed cwd.
Note: this is source-level analysis with a proposed regression test. I could not complete local Rust test execution because the local Rust 1.95 toolchain repair failed during download.
Activity
hfycium commentedon Sep 28, 2026
I traced the incorrect
thread.cwdfallback to the absolute-path conversion used when reading persisted threads.thread_from_stored_threadcallsAbsolutePathBuf::relative_to_current_dir(thread.cwd)even whenthread.cwdis already absolute.relative_to_current_dirunconditionally callsstd::env::current_dir()before resolving the path. In this reproduction, the daemon process was started in directory A, then A was deleted. As a result,current_dir()fails even though the stored thread cwd is the still-existing absolute directory B.The error handler then falls back to
fallback_cwd, which is the daemon configuration cwd (A), causingthread/readto report A instead of B.Suggested fix:
AbsolutePathBuf::relative_to_current_dir, normalize and return already-absolute paths before callingstd::env::current_dir().Suggested Unix regression test:
current_dir()fails.This preserves current behavior for relative paths while preventing a deleted daemon startup directory from corrupting the displayed cwd.
Note: this is source-level analysis with a proposed regression test. I could not complete local Rust test execution because the local Rust 1.95 toolchain repair failed during download.