|
30 | 30 | # On Windows, prefer USERPROFILE explicitly. Python's expanduser already does |
31 | 31 | # this internally, but being explicit guards against odd HOME settings (e.g. |
32 | 32 | # OneDrive-redirected Documents) and matches the R-side discovery_dir(). |
33 | | -if sys.platform == "win32": |
34 | | - SESSIONS_DIR = os.path.join( |
35 | | - os.environ.get("USERPROFILE") or os.path.expanduser("~"), |
36 | | - ".claude_r_sessions", |
37 | | - ) |
38 | | -else: |
39 | | - SESSIONS_DIR = os.path.expanduser("~/.claude_r_sessions") |
| 33 | +def _home_dir() -> str: |
| 34 | + """Home directory, resolved the same way the R side resolves it. |
| 35 | +
|
| 36 | + Every path shared with R must go through this. R uses path.expand("~"), |
| 37 | + which on Windows follows USERPROFILE, so a HOME pointing at OneDrive would |
| 38 | + otherwise put the two halves in different folders.""" |
| 39 | + if sys.platform == "win32": |
| 40 | + return os.environ.get("USERPROFILE") or os.path.expanduser("~") |
| 41 | + return os.path.expanduser("~") |
| 42 | + |
| 43 | + |
| 44 | +SESSIONS_DIR = os.path.join(_home_dir(), ".claude_r_sessions") |
40 | 45 | _agent_id: Optional[str] = None # Set in main() |
41 | 46 | _agent_id_source: str = "unset" # Where the identity came from (for the intro) |
42 | 47 | _target_session: Optional[str] = None # Set by connect_session tool |
@@ -329,7 +334,7 @@ def _coord_dir() -> str: |
329 | 334 | get_r_addin_url() # latch a session if not bound yet |
330 | 335 | session = _target_session or "default" |
331 | 336 | safe = re.sub(r"[^a-zA-Z0-9_-]", "_", session) |
332 | | - d = os.path.join(os.path.expanduser("~"), ".clauder_coord", safe) |
| 337 | + d = os.path.join(_home_dir(), ".clauder_coord", safe) |
333 | 338 | os.makedirs(d, mode=0o700, exist_ok=True) |
334 | 339 | return d |
335 | 340 |
|
|
0 commit comments