fix(coding-agent): handle missing session cwd
This commit is contained in:
@@ -61,6 +61,7 @@ import { createCompactionSummaryMessage } from "../../core/messages.js";
|
||||
import { findExactModelReferenceMatch, resolveModelScope } from "../../core/model-resolver.js";
|
||||
import { DefaultPackageManager } from "../../core/package-manager.js";
|
||||
import type { ResourceDiagnostic } from "../../core/resource-loader.js";
|
||||
import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
|
||||
import { type SessionContext, SessionManager } from "../../core/session-manager.js";
|
||||
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
||||
import type { SourceInfo } from "../../core/source-info.js";
|
||||
@@ -1719,6 +1720,14 @@ export class InteractiveMode {
|
||||
return result === "Yes";
|
||||
}
|
||||
|
||||
private async promptForMissingSessionCwd(error: MissingSessionCwdError): Promise<string | undefined> {
|
||||
const confirmed = await this.showExtensionConfirm(
|
||||
"Session cwd not found",
|
||||
formatMissingSessionCwdPrompt(error.issue),
|
||||
);
|
||||
return confirmed ? error.issue.fallbackCwd : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a text input for extensions.
|
||||
*/
|
||||
@@ -3843,6 +3852,21 @@ export class InteractiveMode {
|
||||
this.renderCurrentSessionState();
|
||||
this.showStatus("Resumed session");
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof MissingSessionCwdError) {
|
||||
const selectedCwd = await this.promptForMissingSessionCwd(error);
|
||||
if (!selectedCwd) {
|
||||
this.showStatus("Resume cancelled");
|
||||
return;
|
||||
}
|
||||
const result = await this.runtimeHost.switchSession(sessionPath, selectedCwd);
|
||||
if (result.cancelled) {
|
||||
return;
|
||||
}
|
||||
await this.handleRuntimeSessionChange();
|
||||
this.renderCurrentSessionState();
|
||||
this.showStatus("Resumed session in current cwd");
|
||||
return;
|
||||
}
|
||||
await this.handleFatalRuntimeError("Failed to resume session", error);
|
||||
}
|
||||
}
|
||||
@@ -4109,6 +4133,22 @@ export class InteractiveMode {
|
||||
this.renderCurrentSessionState();
|
||||
this.showStatus(`Session imported from: ${inputPath}`);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof MissingSessionCwdError) {
|
||||
const selectedCwd = await this.promptForMissingSessionCwd(error);
|
||||
if (!selectedCwd) {
|
||||
this.showStatus("Import cancelled");
|
||||
return;
|
||||
}
|
||||
const result = await this.runtimeHost.importFromJsonl(inputPath, selectedCwd);
|
||||
if (result.cancelled) {
|
||||
this.showStatus("Import cancelled");
|
||||
return;
|
||||
}
|
||||
await this.handleRuntimeSessionChange();
|
||||
this.renderCurrentSessionState();
|
||||
this.showStatus(`Session imported from: ${inputPath}`);
|
||||
return;
|
||||
}
|
||||
await this.handleFatalRuntimeError("Failed to import session", error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user