feat(coding-agent): Add sessionDir support in settings.json (#2598)
Users can now set sessionDir in global or project settings.json instead of passing --session-dir on every invocation. CLI flag takes precedence, then settings.json, then extension hooks. Closes #2429 Co-authored-by: Sam Collins <81678+smcllns@users.noreply.github.com> Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
This commit is contained in:
@@ -439,16 +439,15 @@ async function createSessionManager(
|
||||
parsed: Args,
|
||||
cwd: string,
|
||||
extensions: LoadExtensionsResult,
|
||||
settingsManager: SettingsManager,
|
||||
): Promise<SessionManager | undefined> {
|
||||
if (parsed.noSession) {
|
||||
return SessionManager.inMemory();
|
||||
}
|
||||
|
||||
// CLI flag takes precedence, otherwise ask extensions for custom session directory
|
||||
let effectiveSessionDir = parsed.sessionDir;
|
||||
if (!effectiveSessionDir) {
|
||||
effectiveSessionDir = await callSessionDirectoryHook(extensions, cwd);
|
||||
}
|
||||
// Priority: CLI flag > settings.json > extension hook
|
||||
const effectiveSessionDir =
|
||||
parsed.sessionDir ?? settingsManager.getSessionDir() ?? (await callSessionDirectoryHook(extensions, cwd));
|
||||
|
||||
if (parsed.fork) {
|
||||
const resolved = await resolveSessionPath(parsed.fork, cwd, effectiveSessionDir);
|
||||
@@ -789,13 +788,16 @@ export async function main(args: string[]) {
|
||||
time("resolveModelScope");
|
||||
|
||||
// Create session manager based on CLI flags
|
||||
let sessionManager = await createSessionManager(parsed, cwd, extensionsResult);
|
||||
let sessionManager = await createSessionManager(parsed, cwd, extensionsResult,
|
||||
time("createSessionManager");
|
||||
|
||||
// Handle --resume: show session picker
|
||||
if (parsed.resume) {
|
||||
// Compute effective session dir for resume (same logic as createSessionManager)
|
||||
const effectiveSessionDir = parsed.sessionDir || (await callSessionDirectoryHook(extensionsResult, cwd));
|
||||
const effectiveSessionDir =
|
||||
parsed.sessionDir ??
|
||||
settingsManager.getSessionDir() ??
|
||||
(await callSessionDirectoryHook(extensionsResult, cwd));
|
||||
|
||||
const selectedPath = await selectSession(
|
||||
(onProgress) => SessionManager.list(cwd, effectiveSessionDir, onProgress),
|
||||
|
||||
Reference in New Issue
Block a user