fix(cortex): update date handling in API and UI components

- Adjusted date handling in the agenda API to ensure optional parameters for start, end, and label are correctly processed.
- Enhanced chat input and action parser to support optional date labels for relative dates.
- Updated agenda components to handle date ranges and loading states more effectively.
- Improved error handling and loading indicators in the agenda block for better user experience.

This commit ensures consistency in date handling across the application, aligning with the new requirements for relative date inputs.
This commit is contained in:
colinislit
2026-01-02 09:21:37 +01:00
parent 011815072b
commit 52e07aaf80
20 changed files with 2092 additions and 65 deletions

View File

@@ -23,6 +23,7 @@ interface ChatInputProps {
export interface ChatInputHandle {
focus: () => void;
clear: () => void;
setValue: (value: string) => void;
}
export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(function ChatInput({
@@ -34,7 +35,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(function Ch
const textareaRef = useRef<HTMLTextAreaElement>(null);
const addChatMessage = useCortexStore((s) => s.addChatMessage);
// Expose focus and clear methods to parent
// Expose focus, clear, and setValue methods to parent
useImperativeHandle(ref, () => ({
focus: () => {
textareaRef.current?.focus();
@@ -45,6 +46,21 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(function Ch
textareaRef.current.style.height = 'auto';
}
},
setValue: (value: string) => {
setInputValue(value);
// Auto-resize after setting value
if (textareaRef.current) {
textareaRef.current.style.height = 'auto';
// Use setTimeout to ensure the value is set before measuring
setTimeout(() => {
if (textareaRef.current) {
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
}
}, 0);
}
// Focus the input after setting value
textareaRef.current?.focus();
},
}));
// Handle input change and auto-resize