Add `/chat list` (#1361)
This commit is contained in:
parent
37034045ae
commit
104f23da90
|
@ -171,6 +171,23 @@ export const useSlashCommandProcessor = (
|
||||||
[addMessage],
|
[addMessage],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const savedChatTags = async function () {
|
||||||
|
const geminiDir = config?.getProjectTempDir();
|
||||||
|
if (!geminiDir) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const files = await fs.readdir(geminiDir);
|
||||||
|
return files
|
||||||
|
.filter(
|
||||||
|
(file) => file.startsWith('checkpoint-') && file.endsWith('.json'),
|
||||||
|
)
|
||||||
|
.map((file) => file.replace('checkpoint-', '').replace('.json', ''));
|
||||||
|
} catch (_err) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const slashCommands: SlashCommand[] = useMemo(() => {
|
const slashCommands: SlashCommand[] = useMemo(() => {
|
||||||
const commands: SlashCommand[] = [
|
const commands: SlashCommand[] = [
|
||||||
{
|
{
|
||||||
|
@ -653,7 +670,7 @@ Add any other context about the problem here.
|
||||||
{
|
{
|
||||||
name: 'chat',
|
name: 'chat',
|
||||||
description:
|
description:
|
||||||
'Manage conversation history. Usage: /chat <save|resume> [tag]',
|
'Manage conversation history. Usage: /chat <list|save|resume> [tag]',
|
||||||
action: async (_mainCommand, subCommand, args) => {
|
action: async (_mainCommand, subCommand, args) => {
|
||||||
const tag = (args || '').trim();
|
const tag = (args || '').trim();
|
||||||
const logger = new Logger(config?.getSessionId() || '');
|
const logger = new Logger(config?.getSessionId() || '');
|
||||||
|
@ -737,36 +754,26 @@ Add any other context about the problem here.
|
||||||
refreshStatic();
|
refreshStatic();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case 'list':
|
||||||
|
addMessage({
|
||||||
|
type: MessageType.INFO,
|
||||||
|
content:
|
||||||
|
'list of saved conversations: ' +
|
||||||
|
(await savedChatTags()).join(', '),
|
||||||
|
timestamp: new Date(),
|
||||||
|
});
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
addMessage({
|
addMessage({
|
||||||
type: MessageType.ERROR,
|
type: MessageType.ERROR,
|
||||||
content: `Unknown /chat command: ${subCommand}. Available: save, resume`,
|
content: `Unknown /chat command: ${subCommand}. Available: list, save, resume`,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
completion: async () => {
|
completion: async () =>
|
||||||
const geminiDir = config?.getProjectTempDir();
|
(await savedChatTags()).map((tag) => 'resume ' + tag),
|
||||||
if (!geminiDir) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const files = await fs.readdir(geminiDir);
|
|
||||||
return files
|
|
||||||
.filter(
|
|
||||||
(file) =>
|
|
||||||
file.startsWith('checkpoint-') && file.endsWith('.json'),
|
|
||||||
)
|
|
||||||
.map(
|
|
||||||
(file) =>
|
|
||||||
'resume ' +
|
|
||||||
file.replace('checkpoint-', '').replace('.json', ''),
|
|
||||||
);
|
|
||||||
} catch (_err) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'quit',
|
name: 'quit',
|
||||||
|
|
Loading…
Reference in New Issue