Files
makelore/src/pages/Chat/index.tsx

34 lines
1.2 KiB
TypeScript

import { CodingChatPanel } from './CodingChatPanel';
import { useNavigate } from 'react-router-dom';
function getNavigationDraft(state: unknown): string | undefined {
if (!state || typeof state !== 'object') return undefined;
const draft = (state as { draft?: unknown }).draft;
return typeof draft === 'string' && draft.trim() ? draft : undefined;
}
function getNavigationDraftFromHistory(): string | undefined {
if (typeof window === 'undefined') return undefined;
const historyState = window.history.state as { usr?: unknown } | unknown;
const userState = historyState && typeof historyState === 'object' && 'usr' in historyState
? (historyState as { usr?: unknown }).usr
: historyState;
return getNavigationDraft(userState);
}
export function Chat() {
const navigate = useNavigate();
const navigationDraft = getNavigationDraftFromHistory();
return (
<div data-testid="chat-operation-page" className="flex h-[calc(100%_+_3rem)] min-h-0 -m-6 overflow-hidden bg-background">
<CodingChatPanel
navigationDraft={navigationDraft}
onOpenProjectSettings={() => navigate('/project-config')}
/>
</div>
);
}
export default Chat;