mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-16 06:39:01 +02:00
- Refactor store to persist raw user intent (chatWidth/chatHeight/isExpanded) with no clamp logic - Add ResizeObserver-based resize hook for dynamic container tracking - Add drag-to-resize handles (left, top, corner) with pointer capture - Expand/Restore button uses visual state (isAtMax) not internal flag - Open/close animation (scale + opacity from bottom-right) - Resize animation on button click, instant on drag (isDragging gate) - Move ChatWindow inside content area (absolute, not fixed) - Add input draft persistence, remove agent prop from message list Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
export { createChatStore, CHAT_MIN_W, CHAT_MIN_H, CHAT_DEFAULT_W, CHAT_DEFAULT_H } from "./store";
|
|
export type { ChatStoreOptions, ChatState, ChatTimelineItem } from "./store";
|
|
|
|
import type { createChatStore as CreateChatStoreFn } from "./store";
|
|
|
|
type ChatStoreInstance = ReturnType<typeof CreateChatStoreFn>;
|
|
|
|
/** Module-level singleton — set once at app boot via `registerChatStore()`. */
|
|
let _store: ChatStoreInstance | null = null;
|
|
|
|
/**
|
|
* Register the chat store instance created by the app.
|
|
* Must be called at boot before any component renders.
|
|
*/
|
|
export function registerChatStore(store: ChatStoreInstance) {
|
|
_store = store;
|
|
}
|
|
|
|
/**
|
|
* Singleton accessor — a Zustand hook backed by the registered instance.
|
|
* Supports `useChatStore(selector)` and `useChatStore.getState()`.
|
|
*/
|
|
export const useChatStore: ChatStoreInstance = new Proxy(
|
|
(() => {}) as unknown as ChatStoreInstance,
|
|
{
|
|
apply(_target, _thisArg, args) {
|
|
if (!_store)
|
|
throw new Error(
|
|
"Chat store not initialised — call registerChatStore() first",
|
|
);
|
|
return (_store as unknown as (...a: unknown[]) => unknown)(...args);
|
|
},
|
|
get(_target, prop) {
|
|
if (!_store) return undefined;
|
|
return Reflect.get(_store, prop);
|
|
},
|
|
},
|
|
);
|