Chat refactoring

This commit is contained in:
2026-02-21 15:05:56 +00:00
parent fda5ea147a
commit af803236c8
25 changed files with 732 additions and 713 deletions
@@ -1,31 +0,0 @@
import { useChatSessions } from '@/state/useChatSessions';
export type SlashCommandResult = { handled: true; feedback: string } | { handled: false };
type UseSlashCommandsParams = {
sessionId: string | null;
};
export const useSlashCommands = ({ sessionId }: UseSlashCommandsParams) => {
const { renameSession } = useChatSessions();
const execute = async (input: string): Promise<SlashCommandResult> => {
const trimmed = input.trim();
if (!trimmed.startsWith('/')) return { handled: false };
const spaceIndex = trimmed.indexOf(' ');
const command = spaceIndex === -1 ? trimmed.slice(1) : trimmed.slice(1, spaceIndex);
const args = spaceIndex === -1 ? '' : trimmed.slice(spaceIndex + 1).trim();
switch (command) {
case 'rename':
if (!sessionId || !args) return { handled: false };
await renameSession(sessionId, args);
return { handled: true, feedback: `Session renamed to "${args}"` };
default:
return { handled: false };
}
};
return { execute };
};