feat(core, cli): Add auth type to history checkpoint. (#13023)

This commit is contained in:
joshualitt
2025-11-13 15:13:39 -08:00
committed by GitHub
parent d304216300
commit 48e3932f65
6 changed files with 143 additions and 73 deletions
+21 -4
View File
@@ -128,11 +128,14 @@ const saveCommand: SlashCommand = {
const history = chat.getHistory();
if (history.length > 2) {
await logger.saveCheckpoint(history, tag);
const authType = config?.getContentGeneratorConfig()?.authType;
await logger.saveCheckpoint({ history, authType }, tag);
return {
type: 'message',
messageType: 'info',
content: `Conversation checkpoint saved with tag: ${decodeTagName(tag)}.`,
content: `Conversation checkpoint saved with tag: ${decodeTagName(
tag,
)}.`,
};
} else {
return {
@@ -160,9 +163,10 @@ const resumeCommand: SlashCommand = {
};
}
const { logger } = context.services;
const { logger, config } = context.services;
await logger.initialize();
const conversation = await logger.loadCheckpoint(tag);
const checkpoint = await logger.loadCheckpoint(tag);
const conversation = checkpoint.history;
if (conversation.length === 0) {
return {
@@ -172,6 +176,19 @@ const resumeCommand: SlashCommand = {
};
}
const currentAuthType = config?.getContentGeneratorConfig()?.authType;
if (
checkpoint.authType &&
currentAuthType &&
checkpoint.authType !== currentAuthType
) {
return {
type: 'message',
messageType: 'error',
content: `Cannot resume chat. It was saved with a different authentication method (${checkpoint.authType}) than the current one (${currentAuthType}).`,
};
}
const rolemap: { [key: string]: MessageType } = {
user: MessageType.USER,
model: MessageType.GEMINI,