From f307923db2a09132e01925288a4a905e4b7eb8b3 Mon Sep 17 00:00:00 2001 From: vp275 Date: Wed, 11 Mar 2026 21:39:02 +0530 Subject: [PATCH] fix: scope session list to current working directory Sessions are stored in a single flat ~/.gsd/sessions/ directory, so /resume shows sessions from all projects regardless of which folder you're in. Use per-cwd subdirectories under ~/.gsd/sessions/ with the same path encoding the upstream SDK uses (--path-segments--), so /resume only lists sessions from the current working directory. --- src/cli.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 9c253fe28..59cc8ec01 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -6,6 +6,7 @@ import { createAgentSession, InteractiveMode, } from '@mariozechner/pi-coding-agent' +import { join } from 'path' import { agentDir, sessionsDir, authFilePath } from './app-paths.js' import { buildResourceLoader, initResources } from './resource-loader.js' import { loadStoredEnvKeys, runWizardIfNeeded } from './wizard.js' @@ -53,7 +54,12 @@ if (!settingsManager.getCollapseChangelog()) { settingsManager.setCollapseChangelog(true) } -const sessionManager = SessionManager.create(process.cwd(), sessionsDir) +// Per-directory session storage — same encoding as the upstream SDK so that +// /resume only shows sessions from the current working directory. +const cwd = process.cwd() +const safePath = `--${cwd.replace(/^[/\\]/, '').replace(/[/\\:]/g, '-')}--` +const projectSessionsDir = join(sessionsDir, safePath) +const sessionManager = SessionManager.create(cwd, projectSessionsDir) initResources(agentDir) const resourceLoader = buildResourceLoader(agentDir)