fix(coding-agent): respect agentDir for sdk session paths closes #2457

This commit is contained in:
Mario Zechner
2026-03-20 12:12:18 +01:00
parent 653b63a870
commit 6c8ac01947
4 changed files with 71 additions and 4 deletions

View File

@@ -418,9 +418,9 @@ export function buildSessionContext(
* Compute the default session directory for a cwd.
* Encodes cwd into a safe directory name under ~/.pi/agent/sessions/.
*/
function getDefaultSessionDir(cwd: string): string {
export function getDefaultSessionDir(cwd: string, agentDir: string = getDefaultAgentDir()): string {
const safePath = `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
const sessionDir = join(getDefaultAgentDir(), "sessions", safePath);
const sessionDir = join(agentDir, "sessions", safePath);
if (!existsSync(sessionDir)) {
mkdirSync(sessionDir, { recursive: true });
}