Add raw message/comment types and reduce members stale time

This commit is contained in:
CREDO23 2026-01-21 17:58:17 +02:00
parent 3765d0a868
commit 73ff261194
3 changed files with 31 additions and 1 deletions

View file

@ -9,7 +9,7 @@ export const membersAtom = atomWithQuery((get) => {
return {
queryKey: cacheKeys.members.all(searchSpaceId?.toString() ?? ""),
enabled: !!searchSpaceId,
staleTime: 5 * 60 * 1000, // 5 minutes
staleTime: 3 * 1000, // 3 seconds - short staleness for live collaboration
queryFn: async () => {
if (!searchSpaceId) {
return [];

View file

@ -1,5 +1,18 @@
import { z } from "zod";
/**
* Raw comment
*/
export const rawComment = z.object({
id: z.number(),
message_id: z.number(),
parent_id: z.number().nullable(),
author_id: z.string().nullable(),
content: z.string(),
created_at: z.string(),
updated_at: z.string(),
});
export const author = z.object({
id: z.string().uuid(),
display_name: z.string().nullable(),
@ -122,6 +135,7 @@ export const getMentionsResponse = z.object({
total_count: z.number(),
});
export type RawComment = z.infer<typeof rawComment>;
export type Author = z.infer<typeof author>;
export type CommentReply = z.infer<typeof commentReply>;
export type Comment = z.infer<typeof comment>;

View file

@ -0,0 +1,16 @@
import { z } from "zod";
/**
* Raw message from database (Electric SQL sync)
*/
export const rawMessage = z.object({
id: z.number(),
thread_id: z.number(),
role: z.enum(["user", "assistant", "system"]),
content: z.unknown(),
author_id: z.string().nullable(),
created_at: z.string(),
updated_at: z.string(),
});
export type RawMessage = z.infer<typeof rawMessage>;