@adminide-stack/yantra-mobile 12.0.28-alpha.84 → 12.0.28-alpha.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -376,13 +376,10 @@ function useChatMutations() {
376
376
  let assistantPost;
377
377
  try {
378
378
  const assistantResult = await sendMessagesMutation({
379
- variables: __spreadProps(__spreadValues({
379
+ variables: {
380
380
  channelId: input.sessionId,
381
381
  type: RoomType.Aiassistant,
382
- content: sanitizedAssistantContent
383
- }, userPostId ? {
384
- postId: userPostId
385
- } : {}), {
382
+ content: sanitizedAssistantContent,
386
383
  extraProps: __spreadValues(__spreadValues(__spreadValues({
387
384
  type: PostTypeEnum.Aiassistant,
388
385
  role: "assistant",
@@ -393,12 +390,12 @@ function useChatMutations() {
393
390
  finishReason: (_h = input.assistantMessage.finishReason) != null ? _h : null,
394
391
  isActive: true,
395
392
  status: "complete"
396
- }, userPostId ? {
393
+ }, assistantMessageWithoutContent), userPostId ? {
397
394
  parentId: userPostId
398
- } : {}), assistantMessageWithoutContent), input.mode ? {
395
+ } : {}), input.mode ? {
399
396
  mode: input.mode
400
397
  } : {})
401
- })
398
+ }
402
399
  });
403
400
  assistantPost = (_i = assistantResult.data) == null ? void 0 : _i.sendMessage;
404
401
  } catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"useChatApi.js","sources":["../../src/hooks/useChatApi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AiAgentMessageRole, PostTypeEnum, RoomType, SortEnum } from 'common';\nimport {\n GetChannelsByUserWithLastMessageDocument,\n useAddChannelMutation,\n useGetChannelsByUserWithLastMessageQuery,\n useMessagesQuery,\n useSendMessagesMutation,\n} from 'common/graphql';\nimport type {\n IAccountCreateChatSessionInput,\n IAccountSaveChatMessagesInput as IAccountSaveChatMessagesInputBase,\n} from 'common/server';\nimport { useCallback, useMemo } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\n\nconst MESSAGES_PAGE_LIMIT = 100;\n\n/** Same variables as web Inbox / AIAgent: list AI assistant channels for the current user. */\nexport const AI_ASSISTANT_CHANNELS_QUERY_VARS = {\n criteria: { type: RoomType.Aiassistant },\n limit: 100,\n skip: 0,\n sort: { key: 'updatedAt', value: SortEnum.Desc },\n};\n\nexport const HISTORY_PAGE_SIZE = 20;\n\n/**\n * Variables for the channels-based chat history list (`ChatHistoryLanding`).\n *\n * IMPORTANT: pass the user's org `slug` (e.g. `tarun-upadhyay-qraw`) so the\n * `channelsByUser` resolver's `$in: [criteria.orgName, orgId]` includes\n * channels stored under the slug. When `criteria.orgName` is omitted, the\n * `$in` collapses to just `[orgId]` and channels saved with the slug as\n * `orgName` (the mobile create path) never match. That's the cause of the\n * silently-empty history screen.\n *\n * Kept as a builder (not a constant) because the slug varies per user and\n * because Apollo treats different `variables` as different cached entries —\n * if the create mutation refetches a no-orgName variant, the orgName-variant\n * the screen watches stays stale.\n */\nexport function getHistoryChannelsQueryVariables(orgName?: string | null, options?: { skip?: number; limit?: number }) {\n const trimmedOrg = typeof orgName === 'string' && orgName.trim().length > 0 ? orgName.trim() : undefined;\n return {\n criteria: {\n type: RoomType.Aiassistant,\n ...(trimmedOrg ? { orgName: trimmedOrg } : {}),\n },\n limit: options?.limit ?? HISTORY_PAGE_SIZE,\n skip: options?.skip ?? 0,\n sort: { key: 'updatedAt' as const, value: SortEnum.Desc },\n };\n}\n\n/** @deprecated Use {@link getHistoryChannelsQueryVariables} so `orgName` is included. */\nexport const HISTORY_QUERY_BASE = getHistoryChannelsQueryVariables();\n\n/**\n * Variables for the chat-history feed on the mobile `ChatHistory` screen.\n *\n * First page uses `HISTORY_PAGE_SIZE` (20) posts; \"Load older\" paginates by post\n * `skip` in increments of 20. Rows are still one per channel (collapsed from posts).\n *\n * This query intentionally hits `messages` (not `channelsByUser`) — the same\n * pattern the web sidebar uses (`useNewChatPageHistorySessions`). Reasons:\n * 1. `channelsByUser` is server-side gated by an injected `orgName` /\n * `members` filter that can mismatch when channels were stored with an\n * org slug while the resolver injects the org id. The `messages`\n * resolver filters Post directly by `editedBy: accountId`, so the\n * user's own AI-assistant posts always show up.\n * 2. The user-authored post IS the conversation's natural title — no need\n * to walk `lastMessage.propsConfiguration.contents.parent` to recover\n * the original prompt.\n *\n * - `type: AIASSISTANT` scopes to AI chat (not direct/service rooms).\n * - `props.role: 'user'` selects only the user's turns. The assistant reply\n * is ignored here; it would override the title with the agent's words.\n * - `editedBy: accountUserId` scopes to the current user's own posts,\n * independent of channel membership / org name.\n */\nexport function getChatHistoryMessagesQueryVariables(\n accountUserId: string,\n options?: { skip?: number; limit?: number },\n) {\n return {\n limit: options?.limit ?? HISTORY_PAGE_SIZE,\n skip: options?.skip ?? 0,\n sort: { key: 'updatedAt' as const, value: SortEnum.Desc },\n type: PostTypeEnum.Aiassistant,\n editedBy: accountUserId,\n props: { role: 'user' },\n };\n}\n\nexport type ChatHistoryMode = 'chat' | 'deep-search';\n\nexport interface ChatHistorySession {\n /** Channel id — used to navigate to the Chat screen. */\n channelId: string;\n /** User's most recent prompt in this channel (used as the row title). */\n title: string;\n /** Second line: latest post `message` field (same as Manus subtitle). */\n preview: string;\n /** Conversation mode (chat / deep-search), inferred from channel display name / title. */\n mode: ChatHistoryMode;\n /** Most-recent activity timestamp (sort key + bucket key for Today/Yesterday/…). */\n updatedAt: Date;\n createdAt: Date;\n /**\n * True when no concrete prompt was recoverable (no parent, no user turn, no\n * meaningful channel.title). UI renders the title in a quieter style.\n */\n isPlaceholder: boolean;\n}\n\n/**\n * Collapse a list of user-authored AI assistant posts (newest first) into one\n * row per channel. First post per `channel.id` wins the title, which — because\n * the query is sorted by `updatedAt DESC` — is the user's latest prompt in\n * that channel. Posts whose `channel.id` is missing (unexpected, but possible\n * if the resolver omits the relation) are skipped.\n */\nexport function chatHistorySessionsFromMessages(\n data: { messages?: { data?: unknown[] | null } | null } | null | undefined,\n): ChatHistorySession[] {\n const rows = data?.messages?.data;\n if (!rows?.length) return [];\n\n const seen = new Set<string>();\n const sessions: ChatHistorySession[] = [];\n\n for (const post of rows as any[]) {\n const channelId = post?.channel?.id ? String(post.channel.id) : '';\n if (channelId && !seen.has(channelId)) {\n seen.add(channelId);\n\n const rawTitle = String(post?.message ?? '')\n .replace(/\\s+/g, ' ')\n .trim();\n const updatedAt = post?.updatedAt ? new Date(post.updatedAt) : new Date();\n const createdAt = post?.createdAt ? new Date(post.createdAt) : updatedAt;\n const title = rawTitle || 'New chat';\n\n sessions.push({\n channelId,\n title,\n preview: '',\n mode: 'chat',\n updatedAt,\n createdAt,\n isPlaceholder: !rawTitle,\n });\n }\n }\n\n return sessions;\n}\n\n/**\n * Mobile parity hook for the web sidebar's `useNewChatPageHistorySessions`.\n *\n * Returns one row per channel where the user has authored at least one AI assistant\n * post, with the title taken from that user's latest prompt. Skipped when\n * `accountUserId` isn't known yet (we don't want to fire a query without it).\n */\nexport function useChatHistorySessionsFromMessages(\n accountUserId: string | null | undefined,\n options?: { skip?: boolean },\n) {\n const skip = options?.skip || !accountUserId;\n const { data, loading, error, refetch } = useMessagesQuery({\n variables: accountUserId ? getChatHistoryMessagesQueryVariables(accountUserId) : undefined,\n skip,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n context: { cacheKey: 'new-chat-history-messages' },\n });\n\n const sessions = useMemo(() => chatHistorySessionsFromMessages(data), [data]);\n const sourcePostCount = data?.messages?.data?.length ?? 0;\n\n return { sessions, loading, error, refetch, sourcePostCount };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Channels-based chat history (parent + lastMessage) */\n/* -------------------------------------------------------------------------- */\n\ninterface ChannelLastMessageLike {\n message?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n props?: { role?: string | null } | null;\n propsConfiguration?: {\n contents?: {\n role?: string | null;\n parent?: {\n message?: string | null;\n props?: { role?: string | null } | null;\n } | null;\n } | null;\n content?: { role?: string | null } | null;\n } | null;\n}\n\ninterface ChannelLike {\n id?: string | null;\n type?: string | null;\n displayName?: string | null;\n title?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n lastMessage?: ChannelLastMessageLike | null;\n}\n\nfunction getLastMessageRole(lastMessage: ChannelLastMessageLike | null | undefined): string {\n return String(\n lastMessage?.propsConfiguration?.contents?.role ??\n lastMessage?.propsConfiguration?.content?.role ??\n lastMessage?.props?.role ??\n '',\n ).toUpperCase();\n}\n\nfunction getParentUserPrompt(lastMessage: ChannelLastMessageLike | null | undefined): string {\n const parent = lastMessage?.propsConfiguration?.contents?.parent;\n if (!parent) return '';\n return String(parent?.message ?? '').trim();\n}\n\nfunction detectMode(channel: ChannelLike): ChatHistoryMode {\n const display = String(channel?.displayName ?? '').toLowerCase();\n const title = String(channel?.title ?? '').toLowerCase();\n if (display.startsWith('deep-search') || title.startsWith('deep search') || title.startsWith('deep-search')) {\n return 'deep-search';\n }\n return 'chat';\n}\n\n/**\n * Drop the internal slug we use as `channel.title` for server-side mode detection\n * (`chat-channel-<uuid>` / `deep-search-<uuid>`) so it doesn't leak into the row\n * label. The server sometimes also reformats this slug into `displayName` as\n * title-cased text with spaces (e.g. `\"Deep Search b64be4f7 9fe6 …\"`) — those\n * are equally machine-generated and must NOT be shown to the user.\n *\n * Pattern accepts:\n * • `deep-search-<uuid>` / `chat-channel-<uuid>` (raw, mode signal)\n * • `Deep Search <uuid>` / `Chat Channel <uuid>` (display-cased, server-reformatted)\n * • UUID may use hyphens, spaces, or be partially truncated as long as the\n * trailing chunk is hex.\n */\nfunction cleanChannelTitle(rawTitle: string | null | undefined): string {\n const t = String(rawTitle ?? '').trim();\n if (!t) return '';\n if (/^(chat[\\s-]channel|deep[\\s-]search)[\\s-][0-9a-f][0-9a-f\\s-]{7,}\\.?$/i.test(t)) return '';\n return t;\n}\n\n/**\n * Map one channel into a session row (Manus-style two-line list):\n *\n * **Title (line 1):** `lastMessage.propsConfiguration.contents.parent.message`\n * when present (the user turn the thread is anchored on). Otherwise fall back\n * to the last post body if that post is still a user message, then a\n * machine-slug-stripped channel title, then a machine-slug-stripped\n * `displayName`, then `\"Thinking…\"`. Machine slugs (`deep-search-<uuid>`,\n * `chat-channel-<uuid>`, and their server-reformatted display variants)\n * are filtered via `cleanChannelTitle`, so they never reach the row.\n *\n * **Preview (line 2):** `lastMessage.message` as returned by the API (trimmed,\n * whitespace collapsed). Agent errors that start with `⚠` stay visible in the\n * subtitle, matching the reference UI.\n *\n * If preview text equals the title after trim, the second line is omitted\n * (single-line channel, no duplicate).\n */\nexport function buildSessionFromChannel(channel: ChannelLike): ChatHistorySession | null {\n const channelId = String(channel?.id ?? '');\n if (!channelId) return null;\n\n const lastMessage = channel?.lastMessage ?? null;\n const lastMessageRole = getLastMessageRole(lastMessage);\n const parentUserPrompt = getParentUserPrompt(lastMessage);\n const parentTrimmed = parentUserPrompt.trim();\n\n const userTurn = lastMessageRole === 'USER' && lastMessage?.message ? String(lastMessage.message).trim() : '';\n const cleanedChannelTitle = cleanChannelTitle(channel?.title);\n /**\n * Apply the same machine-slug cleaner to `displayName`. The server\n * sometimes derives displayName from the title (`\"deep-search-<uuid>\"`\n * → `\"Deep Search <uuid>\"`), so without this the slug bypasses\n * `cleanedChannelTitle` and lands directly in the row label.\n */\n const cleanedDisplayName = cleanChannelTitle(channel?.displayName);\n\n let resolvedTitle = parentTrimmed || userTurn || cleanedChannelTitle || cleanedDisplayName;\n const isPlaceholder = !resolvedTitle;\n /**\n * When every signal fails — typical when a send just landed and the\n * server hasn't yet persisted the message that would populate\n * `propsConfiguration.contents.parent.message` — show `\"Thinking…\"`\n * instead of an empty label or the raw machine slug. The row's mode\n * tile still signals chat vs deep-search, so the user has enough\n * context to recognize the entry without leaking implementation noise.\n */\n if (isPlaceholder) resolvedTitle = 'Thinking…';\n\n const rawPreview = String(lastMessage?.message ?? '')\n .replace(/\\s+/g, ' ')\n .trim();\n let preview = rawPreview;\n if (preview && preview === parentTrimmed) preview = '';\n\n const sortAt = (() => {\n const candidates = [channel?.updatedAt, lastMessage?.updatedAt, lastMessage?.createdAt, channel?.createdAt];\n for (const candidate of candidates) {\n if (candidate) {\n const t = new Date(candidate).getTime();\n if (Number.isFinite(t) && t > 0) return t;\n }\n }\n return Date.now();\n })();\n\n const createdAtRaw = channel?.createdAt ? new Date(channel.createdAt).getTime() : sortAt;\n\n return {\n channelId,\n title: resolvedTitle,\n preview,\n mode: detectMode(channel),\n updatedAt: new Date(sortAt),\n createdAt: new Date(Number.isFinite(createdAtRaw) ? createdAtRaw : sortAt),\n isPlaceholder,\n };\n}\n\n/** Collapse a `channelsByUser` response into session rows for the history list. */\nexport function chatHistorySessionsFromChannels(\n data: { channelsByUser?: (ChannelLike | null)[] | null } | null | undefined,\n): ChatHistorySession[] {\n const channels = (data?.channelsByUser ?? []) as (ChannelLike | null)[];\n return channels\n .filter((c): c is ChannelLike => Boolean(c?.id) && (!c?.type || c.type === RoomType.Aiassistant))\n .map((c) => buildSessionFromChannel(c))\n .filter((row): row is ChatHistorySession => row !== null)\n .sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());\n}\n\n/**\n * Chat history feed driven by `channelsByUser`. Each row: parent prompt as title,\n * `lastMessage.message` as subtitle (Manus-style), when the API provides them.\n *\n * Caller MUST pass `orgName` (the org slug). Without it, the resolver only\n * matches channels whose `orgName` field equals the user's `orgId`, which is\n * never the case for mobile-created channels (those store the slug). The hook\n * suspends the query (`skip: true`) until `orgName` is known, so we never\n * fire a guaranteed-empty request.\n *\n * Pagination is by channel count (one channel = one row in this query),\n * unlike the messages-based path which paginates by raw post rows.\n */\nexport function useChatHistorySessionsFromChannels(orgName: string | null | undefined, options?: { skip?: boolean }) {\n const skip = options?.skip || !orgName;\n const variables = useMemo(() => getHistoryChannelsQueryVariables(orgName), [orgName]);\n\n const { data, loading, error, refetch } = useGetChannelsByUserWithLastMessageQuery({\n variables,\n skip,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n context: { cacheKey: 'chat-history-channels-list' },\n });\n\n const sessions = useMemo(() => chatHistorySessionsFromChannels(data), [data]);\n const sourceChannelCount = data?.channelsByUser?.length ?? 0;\n /**\n * `sessionsLoaded` means \"we have data we can show\", regardless of whether a\n * background revalidation is still in flight. Same contract as `messagesLoaded`\n * in `useChatMessages` — lets the screen show the cached list (or empty state)\n * immediately on revisit instead of flashing a loader for the network round-trip.\n */\n const sessionsLoaded = data !== undefined;\n\n return { sessions, loading, sessionsLoaded, error, refetch, sourceChannelCount };\n}\n\nfunction stripModelCostHeader(content: string): string {\n const normalized = content.replace(/\\r\\n/g, '\\n');\n return normalized.replace(\n /^\\s*(?:[^\\w\\n]+\\s*)?[a-z0-9][a-z0-9._-]*\\s*\\(\\s*\\$[\\d.]+\\s*\\/\\s*MTok\\s+in\\s*\\)\\s*\\n+/i,\n '',\n );\n}\n\nfunction sanitizeAssistantContentByRole(role: unknown, content: string): string {\n return role === 'assistant' ? stripModelCostHeader(content) : content;\n}\n\nfunction omitContent<T extends Record<string, any>>(value: T | null | undefined): Omit<T, 'content'> {\n const clone = { ...(value ?? {}) } as Record<string, any>;\n delete clone.content;\n return clone as Omit<T, 'content'>;\n}\n\nexport interface ChatSessionUI {\n id: string;\n title: string;\n createdAt: Date;\n updatedAt: Date;\n messageCount?: number;\n}\n\nexport function useChatSessions(options?: { includeArchived?: boolean; skip?: boolean }) {\n const { data, loading, error, refetch } = useGetChannelsByUserWithLastMessageQuery({\n variables: AI_ASSISTANT_CHANNELS_QUERY_VARS,\n skip: options?.skip,\n fetchPolicy: 'cache-and-network',\n });\n\n const sessions: ChatSessionUI[] = useMemo(() => {\n const channels = data?.channelsByUser ?? [];\n return channels\n .filter((c): c is NonNullable<typeof c> => Boolean(c?.id))\n .map((channel) => ({\n id: channel.id,\n title: channel.title || channel.displayName || 'New Chat',\n createdAt: new Date(channel.createdAt ?? Date.now()),\n updatedAt: new Date(channel.updatedAt ?? Date.now()),\n messageCount: undefined,\n }));\n }, [data]);\n\n return { sessions, loading, error, refetch };\n}\n\nexport interface ChatMessageUI {\n id: string;\n sessionId: string;\n role: 'user' | 'assistant' | 'system';\n content: string;\n attachments?: Array<{ id: string; name: string; type: string; mimeType?: string; size?: number; url?: string }>;\n tokenCount?: number;\n model?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\ninterface MinimalFile {\n id?: string | null;\n name?: string | null;\n mimeType?: string | null;\n size?: number | null;\n url?: string | null;\n}\n\ninterface MinimalPost {\n id?: string | null;\n message?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n channel?: { id?: string | null } | null;\n files?: { data?: MinimalFile[] | null } | null;\n props?: { role?: string | null; tokenCount?: number | null; model?: string | null } | null;\n propsConfiguration?: {\n contents?: { role?: string | null } | null;\n content?: { role?: string | null } | null;\n } | null;\n}\n\nfunction mapPostToChatMessageUI(post: MinimalPost, fallbackChannelId: string): ChatMessageUI {\n const props = (post.props ?? {}) as Record<string, any>;\n const contents = post.propsConfiguration?.contents ?? {};\n const roleRaw = props.role ?? contents.role ?? post.propsConfiguration?.content?.role;\n let role: ChatMessageUI['role'] = 'assistant';\n if (roleRaw === 'user' || roleRaw === AiAgentMessageRole.User) role = 'user';\n else if (roleRaw === 'assistant' || roleRaw === AiAgentMessageRole.Assistant) role = 'assistant';\n else if (roleRaw === 'system') role = 'system';\n\n const rawContent = post?.message ?? '';\n const content = sanitizeAssistantContentByRole(role, rawContent);\n\n return {\n id: post?.id ?? uuidv4(),\n sessionId: post?.channel?.id ?? fallbackChannelId,\n role,\n content,\n attachments: (post?.files?.data ?? []).map((file) => ({\n id: file.id ?? uuidv4(),\n name: file.name ?? 'file',\n type: typeof file.mimeType === 'string' && file.mimeType.startsWith('image/') ? 'screenshot' : 'file',\n mimeType: file.mimeType ?? undefined,\n size: file.size ?? undefined,\n url: file.url ?? undefined,\n })),\n tokenCount: props.tokenCount ?? undefined,\n model: props.model ?? undefined,\n createdAt: post?.createdAt ? new Date(post.createdAt) : new Date(),\n updatedAt: post?.updatedAt ? new Date(post.updatedAt) : new Date(),\n };\n}\n\nexport function useChatMessages(sessionId: string | null, options?: { skip?: boolean }) {\n const { data, loading, error, refetch } = useMessagesQuery({\n variables: {\n channelId: sessionId ?? undefined,\n parentId: null,\n limit: MESSAGES_PAGE_LIMIT,\n skip: 0,\n },\n skip: !sessionId || options?.skip,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n /**\n * Cache key is per-channel so switching sessions doesn't read another channel's response.\n * Keeping this as a constant ('messages-list') used to cause cross-session bleed in the\n * custom Apollo link before reaching the normalized cache.\n */\n context: { cacheKey: sessionId ? `messages-list:${sessionId}` : 'messages-list' },\n });\n\n /**\n * `messagesLoaded` means \"we have data we can show\", regardless of whether a\n * background revalidation is in flight. With `cache-and-network`, Apollo\n * fills `data` from cache synchronously while `loading` is still true for\n * the network round-trip — gating hydration on `!loading` made every chat\n * revisit show a loader for the network latency even though the messages\n * were already cached. The chat stream re-hydrates whenever `data` changes,\n * so the fresh network response still swaps in silently afterward.\n */\n const messagesLoaded = data !== undefined;\n\n const messages: ChatMessageUI[] = useMemo(() => {\n if (!sessionId) return [];\n const rows = data?.messages?.data ?? [];\n return rows\n .map((post) => mapPostToChatMessageUI(post as MinimalPost, sessionId))\n .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());\n }, [data, sessionId]);\n\n return { messages, loading, messagesLoaded, error, refetch };\n}\n\nexport type IAccountSaveChatMessagesInput = IAccountSaveChatMessagesInputBase & {\n mode?: 'plan' | 'build';\n createdBy?: string;\n};\n\n/** Backend/gateway may have already inserted the post (E11000 duplicate `_id`). */\nfunction isDuplicatePostError(error: unknown): boolean {\n const parts: string[] = [];\n if (error && typeof error === 'object' && 'graphQLErrors' in error) {\n const gqlErrors = (error as { graphQLErrors?: Array<{ message?: string }> }).graphQLErrors ?? [];\n parts.push(...gqlErrors.map((e) => e?.message ?? ''));\n }\n if (error instanceof Error) {\n parts.push(error.message);\n } else if (error != null) {\n parts.push(String(error));\n }\n const msg = parts.join(' ');\n return /E11000|duplicate key/i.test(msg);\n}\n\nexport function useChatMutations() {\n const [addChannelMutation, { loading: createChannelLoading }] = useAddChannelMutation();\n const [sendMessagesMutation, { loading: sendMessagesLoading }] = useSendMessagesMutation();\n\n const createChannel = useCallback(\n async (input?: IAccountCreateChatSessionInput): Promise<ChatSessionUI> => {\n const {\n orgName: orgNameArg,\n projectId: projectIdArg,\n ...inputForSettings\n } = (input ?? {}) as IAccountCreateChatSessionInput & {\n orgName?: string | null;\n projectId?: string | null;\n };\n const orgName =\n typeof orgNameArg === 'string' && orgNameArg.trim().length > 0 ? orgNameArg.trim() : undefined;\n const projectId =\n typeof projectIdArg === 'string' && projectIdArg.trim().length > 0 ? projectIdArg.trim() : undefined;\n\n const settings = {\n title: input?.title ?? 'New Chat',\n description: input?.systemPrompt ?? null,\n isShared: false,\n sharedSlug: null,\n isArchived: false,\n isPinned: false,\n model: input?.model ?? null,\n systemPrompt: input?.systemPrompt ?? null,\n ...inputForSettings,\n };\n\n const { data } = await addChannelMutation({\n variables: {\n channelId: input?.id ?? null,\n name: input?.title ?? 'New Chat',\n description: input?.systemPrompt ?? null,\n type: RoomType.Aiassistant,\n settings,\n ...(orgName ? { orgName } : {}),\n ...(projectId ? { projectId } : {}),\n },\n /**\n * Refetch every cache slot the rest of the app is watching for\n * channel lists. Apollo keys cached results by `variables`, so each\n * shape we emit here must match a watched query exactly.\n *\n * Variants:\n * 1. Legacy limit:100 list (web parity, no `criteria.orgName`).\n * 2. Mobile history-screen variant WITH `criteria.orgName` so the\n * resolver's `$in: [slug, orgId]` matches mobile-created channels.\n * 3. Same variant WITHOUT orgName, in case the screen mounted before\n * org settings resolved.\n */\n refetchQueries: [\n { query: GetChannelsByUserWithLastMessageDocument, variables: AI_ASSISTANT_CHANNELS_QUERY_VARS },\n ...(orgName\n ? [\n {\n query: GetChannelsByUserWithLastMessageDocument,\n variables: getHistoryChannelsQueryVariables(orgName),\n },\n ]\n : []),\n { query: GetChannelsByUserWithLastMessageDocument, variables: HISTORY_QUERY_BASE },\n ],\n awaitRefetchQueries: true,\n });\n\n if (!data?.createChannel?.id) {\n throw new Error('Failed to create channel');\n }\n\n const channel = data.createChannel;\n const title = channel.title ?? input?.title ?? 'New Chat';\n const now = new Date();\n\n return {\n id: channel.id,\n title,\n createdAt: now,\n updatedAt: now,\n };\n },\n [addChannelMutation],\n );\n\n const saveMessages = useCallback(\n async (\n input: IAccountSaveChatMessagesInput,\n ): Promise<{\n userMessage: ChatMessageUI;\n assistantMessage: ChatMessageUI;\n session: ChatSessionUI;\n }> => {\n const sanitizedAssistantContent = stripModelCostHeader(input.assistantMessage.content ?? '');\n const assistantMessageWithoutContent = omitContent((input.assistantMessage as any) ?? {});\n\n let userPost: MinimalPost | null | undefined;\n try {\n const userResult = await sendMessagesMutation({\n variables: {\n channelId: input.sessionId,\n type: RoomType.Aiassistant,\n content: input.userMessage.content ?? '',\n ...(input.createdBy ? { createdBy: input.createdBy } : {}),\n extraProps: {\n type: PostTypeEnum.Aiassistant,\n role: 'user',\n attachments: input.userMessage.attachments ?? [],\n isActive: true,\n status: 'complete',\n ...(input.userMessage as any),\n ...(input.mode ? { mode: input.mode } : {}),\n },\n } as any,\n });\n userPost = userResult.data?.sendMessage as MinimalPost | undefined;\n } catch (err) {\n if (!isDuplicatePostError(err)) {\n throw err;\n }\n console.warn('[saveMessages] user post already persisted (skipping duplicate insert)');\n }\n\n /**\n * Link the assistant reply to its prompting user message via `postId` (the parentId\n * on the schema). Without this, channel.lastMessage.propsConfiguration.contents.parent\n * stays null, the chat history can't recover the original prompt, and rows fall back\n * to the assistant reply as a label.\n */\n const userPostId = userPost?.id ?? null;\n\n let assistantPost: MinimalPost | null | undefined;\n try {\n const assistantResult = await sendMessagesMutation({\n variables: {\n channelId: input.sessionId,\n type: RoomType.Aiassistant,\n content: sanitizedAssistantContent,\n ...(userPostId ? { postId: userPostId } : {}),\n extraProps: {\n type: PostTypeEnum.Aiassistant,\n role: 'assistant',\n attachments: input.assistantMessage.attachments ?? [],\n tokenCount: input.assistantMessage.tokenCount,\n latencyMs: input.assistantMessage.latencyMs,\n model: input.assistantMessage.model,\n finishReason: (input.assistantMessage as any).finishReason ?? null,\n isActive: true,\n status: 'complete',\n ...(userPostId ? { parentId: userPostId } : {}),\n ...assistantMessageWithoutContent,\n ...(input.mode ? { mode: input.mode } : {}),\n },\n } as any,\n });\n assistantPost = assistantResult.data?.sendMessage as MinimalPost | undefined;\n } catch (err) {\n if (!isDuplicatePostError(err)) {\n throw err;\n }\n console.warn('[saveMessages] assistant post already persisted (skipping duplicate insert)');\n }\n\n if (!userPost && !assistantPost) {\n throw new Error('Failed to send messages');\n }\n\n const now = new Date();\n const fallbackUser: ChatMessageUI = {\n id: userPostId ?? uuidv4(),\n sessionId: input.sessionId,\n role: 'user',\n content: input.userMessage.content ?? '',\n createdAt: now,\n updatedAt: now,\n };\n const fallbackAssistant: ChatMessageUI = {\n id: uuidv4(),\n sessionId: input.sessionId,\n role: 'assistant',\n content: sanitizedAssistantContent,\n createdAt: now,\n updatedAt: now,\n tokenCount: input.assistantMessage.tokenCount,\n model: input.assistantMessage.model,\n };\n return {\n userMessage: userPost ? mapPostToChatMessageUI(userPost, input.sessionId) : fallbackUser,\n assistantMessage: assistantPost\n ? mapPostToChatMessageUI(assistantPost, input.sessionId)\n : fallbackAssistant,\n session: {\n id: input.sessionId,\n title: 'Chat',\n createdAt: now,\n updatedAt: now,\n },\n };\n },\n [sendMessagesMutation],\n );\n\n return {\n createChannel,\n createSession: createChannel,\n saveMessages,\n loading: { create: createChannelLoading, saveMessages: sendMessagesLoading },\n };\n}\n"],"names":["uuidv4","_a","_b","_c","_d","_e"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,mBAAsB,GAAA,GAAA;AAGrB,MAAM,gCAAmC,GAAA;AAAA,EAC9C,QAAU,EAAA;AAAA,IACR,MAAM,QAAS,CAAA;AAAA,GACjB;AAAA,EACA,KAAO,EAAA,GAAA;AAAA,EACP,IAAM,EAAA,CAAA;AAAA,EACN,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A,MACtC,SAAW,EAAA,GAAA;AAAA,MACX,SAAW,EAAA;AAAA,KACb;AACA,IAAA,MAAM,iBAAmC,GAAA;AAAA,MACvC,IAAIA,EAAO,EAAA;AAAA,MACX,WAAW,KAAM,CAAA,SAAA;AAAA,MACjB,IAAM,EAAA,WAAA;AAAA,MACN,OAAS,EAAA,yBAAA;AAAA,MACT,SAAW,EAAA,GAAA;AAAA,MACX,SAAW,EAAA,GAAA;AAAA,MACX,UAAA,EAAY,MAAM,gBAAiB,CAAA,UAAA;AAAA,MACnC,KAAA,EAAO,MAAM,gBAAiB,CAAA;AAAA,KAChC;AACA,IAAO,OAAA;AAAA,MACL,aAAa,QAAW,GAAA,sBAAA,CAAuB,QAAU,EAAA,KAAA,CAAM,SAAS,CAAI,GAAA,YAAA;AAAA,MAC5E,kBAAkB,aAAgB,GAAA,sBAAA,CAAuB,aAAe,EAAA,KAAA,CAAM,SAAS,CAAI,GAAA,iBAAA;AAAA,MAC3F,OAAS,EAAA;AAAA,QACP,IAAI,KAAM,CAAA,SAAA;AAAA,QACV,KAAO,EAAA,MAAA;AAAA,QACP,SAAW,EAAA,GAAA;AAAA,QACX,SAAW,EAAA;AAAA;AACb,KACF;AAAA,GACF,EAAG,CAAC,oBAAoB,CAAC,CAAA;AACzB,EAAO,OAAA;AAAA,IACL,aAAA;AAAA,IACA,aAAe,EAAA,aAAA;AAAA,IACf,YAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA,oBAAA;AAAA,MACR,YAAc,EAAA;AAAA;AAChB,GACF;AACF"}
1
+ {"version":3,"file":"useChatApi.js","sources":["../../src/hooks/useChatApi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AiAgentMessageRole, PostTypeEnum, RoomType, SortEnum } from 'common';\nimport {\n GetChannelsByUserWithLastMessageDocument,\n useAddChannelMutation,\n useGetChannelsByUserWithLastMessageQuery,\n useMessagesQuery,\n useSendMessagesMutation,\n} from 'common/graphql';\nimport type {\n IAccountCreateChatSessionInput,\n IAccountSaveChatMessagesInput as IAccountSaveChatMessagesInputBase,\n} from 'common/server';\nimport { useCallback, useMemo } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\n\nconst MESSAGES_PAGE_LIMIT = 100;\n\n/** Same variables as web Inbox / AIAgent: list AI assistant channels for the current user. */\nexport const AI_ASSISTANT_CHANNELS_QUERY_VARS = {\n criteria: { type: RoomType.Aiassistant },\n limit: 100,\n skip: 0,\n sort: { key: 'updatedAt', value: SortEnum.Desc },\n};\n\nexport const HISTORY_PAGE_SIZE = 20;\n\n/**\n * Variables for the channels-based chat history list (`ChatHistoryLanding`).\n *\n * IMPORTANT: pass the user's org `slug` (e.g. `tarun-upadhyay-qraw`) so the\n * `channelsByUser` resolver's `$in: [criteria.orgName, orgId]` includes\n * channels stored under the slug. When `criteria.orgName` is omitted, the\n * `$in` collapses to just `[orgId]` and channels saved with the slug as\n * `orgName` (the mobile create path) never match. That's the cause of the\n * silently-empty history screen.\n *\n * Kept as a builder (not a constant) because the slug varies per user and\n * because Apollo treats different `variables` as different cached entries —\n * if the create mutation refetches a no-orgName variant, the orgName-variant\n * the screen watches stays stale.\n */\nexport function getHistoryChannelsQueryVariables(orgName?: string | null, options?: { skip?: number; limit?: number }) {\n const trimmedOrg = typeof orgName === 'string' && orgName.trim().length > 0 ? orgName.trim() : undefined;\n return {\n criteria: {\n type: RoomType.Aiassistant,\n ...(trimmedOrg ? { orgName: trimmedOrg } : {}),\n },\n limit: options?.limit ?? HISTORY_PAGE_SIZE,\n skip: options?.skip ?? 0,\n sort: { key: 'updatedAt' as const, value: SortEnum.Desc },\n };\n}\n\n/** @deprecated Use {@link getHistoryChannelsQueryVariables} so `orgName` is included. */\nexport const HISTORY_QUERY_BASE = getHistoryChannelsQueryVariables();\n\n/**\n * Variables for the chat-history feed on the mobile `ChatHistory` screen.\n *\n * First page uses `HISTORY_PAGE_SIZE` (20) posts; \"Load older\" paginates by post\n * `skip` in increments of 20. Rows are still one per channel (collapsed from posts).\n *\n * This query intentionally hits `messages` (not `channelsByUser`) — the same\n * pattern the web sidebar uses (`useNewChatPageHistorySessions`). Reasons:\n * 1. `channelsByUser` is server-side gated by an injected `orgName` /\n * `members` filter that can mismatch when channels were stored with an\n * org slug while the resolver injects the org id. The `messages`\n * resolver filters Post directly by `editedBy: accountId`, so the\n * user's own AI-assistant posts always show up.\n * 2. The user-authored post IS the conversation's natural title — no need\n * to walk `lastMessage.propsConfiguration.contents.parent` to recover\n * the original prompt.\n *\n * - `type: AIASSISTANT` scopes to AI chat (not direct/service rooms).\n * - `props.role: 'user'` selects only the user's turns. The assistant reply\n * is ignored here; it would override the title with the agent's words.\n * - `editedBy: accountUserId` scopes to the current user's own posts,\n * independent of channel membership / org name.\n */\nexport function getChatHistoryMessagesQueryVariables(\n accountUserId: string,\n options?: { skip?: number; limit?: number },\n) {\n return {\n limit: options?.limit ?? HISTORY_PAGE_SIZE,\n skip: options?.skip ?? 0,\n sort: { key: 'updatedAt' as const, value: SortEnum.Desc },\n type: PostTypeEnum.Aiassistant,\n editedBy: accountUserId,\n props: { role: 'user' },\n };\n}\n\nexport type ChatHistoryMode = 'chat' | 'deep-search';\n\nexport interface ChatHistorySession {\n /** Channel id — used to navigate to the Chat screen. */\n channelId: string;\n /** User's most recent prompt in this channel (used as the row title). */\n title: string;\n /** Second line: latest post `message` field (same as Manus subtitle). */\n preview: string;\n /** Conversation mode (chat / deep-search), inferred from channel display name / title. */\n mode: ChatHistoryMode;\n /** Most-recent activity timestamp (sort key + bucket key for Today/Yesterday/…). */\n updatedAt: Date;\n createdAt: Date;\n /**\n * True when no concrete prompt was recoverable (no parent, no user turn, no\n * meaningful channel.title). UI renders the title in a quieter style.\n */\n isPlaceholder: boolean;\n}\n\n/**\n * Collapse a list of user-authored AI assistant posts (newest first) into one\n * row per channel. First post per `channel.id` wins the title, which — because\n * the query is sorted by `updatedAt DESC` — is the user's latest prompt in\n * that channel. Posts whose `channel.id` is missing (unexpected, but possible\n * if the resolver omits the relation) are skipped.\n */\nexport function chatHistorySessionsFromMessages(\n data: { messages?: { data?: unknown[] | null } | null } | null | undefined,\n): ChatHistorySession[] {\n const rows = data?.messages?.data;\n if (!rows?.length) return [];\n\n const seen = new Set<string>();\n const sessions: ChatHistorySession[] = [];\n\n for (const post of rows as any[]) {\n const channelId = post?.channel?.id ? String(post.channel.id) : '';\n if (channelId && !seen.has(channelId)) {\n seen.add(channelId);\n\n const rawTitle = String(post?.message ?? '')\n .replace(/\\s+/g, ' ')\n .trim();\n const updatedAt = post?.updatedAt ? new Date(post.updatedAt) : new Date();\n const createdAt = post?.createdAt ? new Date(post.createdAt) : updatedAt;\n const title = rawTitle || 'New chat';\n\n sessions.push({\n channelId,\n title,\n preview: '',\n mode: 'chat',\n updatedAt,\n createdAt,\n isPlaceholder: !rawTitle,\n });\n }\n }\n\n return sessions;\n}\n\n/**\n * Mobile parity hook for the web sidebar's `useNewChatPageHistorySessions`.\n *\n * Returns one row per channel where the user has authored at least one AI assistant\n * post, with the title taken from that user's latest prompt. Skipped when\n * `accountUserId` isn't known yet (we don't want to fire a query without it).\n */\nexport function useChatHistorySessionsFromMessages(\n accountUserId: string | null | undefined,\n options?: { skip?: boolean },\n) {\n const skip = options?.skip || !accountUserId;\n const { data, loading, error, refetch } = useMessagesQuery({\n variables: accountUserId ? getChatHistoryMessagesQueryVariables(accountUserId) : undefined,\n skip,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n context: { cacheKey: 'new-chat-history-messages' },\n });\n\n const sessions = useMemo(() => chatHistorySessionsFromMessages(data), [data]);\n const sourcePostCount = data?.messages?.data?.length ?? 0;\n\n return { sessions, loading, error, refetch, sourcePostCount };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Channels-based chat history (parent + lastMessage) */\n/* -------------------------------------------------------------------------- */\n\ninterface ChannelLastMessageLike {\n message?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n props?: { role?: string | null } | null;\n propsConfiguration?: {\n contents?: {\n role?: string | null;\n parent?: {\n message?: string | null;\n props?: { role?: string | null } | null;\n } | null;\n } | null;\n content?: { role?: string | null } | null;\n } | null;\n}\n\ninterface ChannelLike {\n id?: string | null;\n type?: string | null;\n displayName?: string | null;\n title?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n lastMessage?: ChannelLastMessageLike | null;\n}\n\nfunction getLastMessageRole(lastMessage: ChannelLastMessageLike | null | undefined): string {\n return String(\n lastMessage?.propsConfiguration?.contents?.role ??\n lastMessage?.propsConfiguration?.content?.role ??\n lastMessage?.props?.role ??\n '',\n ).toUpperCase();\n}\n\nfunction getParentUserPrompt(lastMessage: ChannelLastMessageLike | null | undefined): string {\n const parent = lastMessage?.propsConfiguration?.contents?.parent;\n if (!parent) return '';\n return String(parent?.message ?? '').trim();\n}\n\nfunction detectMode(channel: ChannelLike): ChatHistoryMode {\n const display = String(channel?.displayName ?? '').toLowerCase();\n const title = String(channel?.title ?? '').toLowerCase();\n if (display.startsWith('deep-search') || title.startsWith('deep search') || title.startsWith('deep-search')) {\n return 'deep-search';\n }\n return 'chat';\n}\n\n/**\n * Drop the internal slug we use as `channel.title` for server-side mode detection\n * (`chat-channel-<uuid>` / `deep-search-<uuid>`) so it doesn't leak into the row\n * label. The server sometimes also reformats this slug into `displayName` as\n * title-cased text with spaces (e.g. `\"Deep Search b64be4f7 9fe6 …\"`) — those\n * are equally machine-generated and must NOT be shown to the user.\n *\n * Pattern accepts:\n * • `deep-search-<uuid>` / `chat-channel-<uuid>` (raw, mode signal)\n * • `Deep Search <uuid>` / `Chat Channel <uuid>` (display-cased, server-reformatted)\n * • UUID may use hyphens, spaces, or be partially truncated as long as the\n * trailing chunk is hex.\n */\nfunction cleanChannelTitle(rawTitle: string | null | undefined): string {\n const t = String(rawTitle ?? '').trim();\n if (!t) return '';\n if (/^(chat[\\s-]channel|deep[\\s-]search)[\\s-][0-9a-f][0-9a-f\\s-]{7,}\\.?$/i.test(t)) return '';\n return t;\n}\n\n/**\n * Map one channel into a session row (Manus-style two-line list):\n *\n * **Title (line 1):** `lastMessage.propsConfiguration.contents.parent.message`\n * when present (the user turn the thread is anchored on). Otherwise fall back\n * to the last post body if that post is still a user message, then a\n * machine-slug-stripped channel title, then a machine-slug-stripped\n * `displayName`, then `\"Thinking…\"`. Machine slugs (`deep-search-<uuid>`,\n * `chat-channel-<uuid>`, and their server-reformatted display variants)\n * are filtered via `cleanChannelTitle`, so they never reach the row.\n *\n * **Preview (line 2):** `lastMessage.message` as returned by the API (trimmed,\n * whitespace collapsed). Agent errors that start with `⚠` stay visible in the\n * subtitle, matching the reference UI.\n *\n * If preview text equals the title after trim, the second line is omitted\n * (single-line channel, no duplicate).\n */\nexport function buildSessionFromChannel(channel: ChannelLike): ChatHistorySession | null {\n const channelId = String(channel?.id ?? '');\n if (!channelId) return null;\n\n const lastMessage = channel?.lastMessage ?? null;\n const lastMessageRole = getLastMessageRole(lastMessage);\n const parentUserPrompt = getParentUserPrompt(lastMessage);\n const parentTrimmed = parentUserPrompt.trim();\n\n const userTurn = lastMessageRole === 'USER' && lastMessage?.message ? String(lastMessage.message).trim() : '';\n const cleanedChannelTitle = cleanChannelTitle(channel?.title);\n /**\n * Apply the same machine-slug cleaner to `displayName`. The server\n * sometimes derives displayName from the title (`\"deep-search-<uuid>\"`\n * → `\"Deep Search <uuid>\"`), so without this the slug bypasses\n * `cleanedChannelTitle` and lands directly in the row label.\n */\n const cleanedDisplayName = cleanChannelTitle(channel?.displayName);\n\n let resolvedTitle = parentTrimmed || userTurn || cleanedChannelTitle || cleanedDisplayName;\n const isPlaceholder = !resolvedTitle;\n /**\n * When every signal fails — typical when a send just landed and the\n * server hasn't yet persisted the message that would populate\n * `propsConfiguration.contents.parent.message` — show `\"Thinking…\"`\n * instead of an empty label or the raw machine slug. The row's mode\n * tile still signals chat vs deep-search, so the user has enough\n * context to recognize the entry without leaking implementation noise.\n */\n if (isPlaceholder) resolvedTitle = 'Thinking…';\n\n const rawPreview = String(lastMessage?.message ?? '')\n .replace(/\\s+/g, ' ')\n .trim();\n let preview = rawPreview;\n if (preview && preview === parentTrimmed) preview = '';\n\n const sortAt = (() => {\n const candidates = [channel?.updatedAt, lastMessage?.updatedAt, lastMessage?.createdAt, channel?.createdAt];\n for (const candidate of candidates) {\n if (candidate) {\n const t = new Date(candidate).getTime();\n if (Number.isFinite(t) && t > 0) return t;\n }\n }\n return Date.now();\n })();\n\n const createdAtRaw = channel?.createdAt ? new Date(channel.createdAt).getTime() : sortAt;\n\n return {\n channelId,\n title: resolvedTitle,\n preview,\n mode: detectMode(channel),\n updatedAt: new Date(sortAt),\n createdAt: new Date(Number.isFinite(createdAtRaw) ? createdAtRaw : sortAt),\n isPlaceholder,\n };\n}\n\n/** Collapse a `channelsByUser` response into session rows for the history list. */\nexport function chatHistorySessionsFromChannels(\n data: { channelsByUser?: (ChannelLike | null)[] | null } | null | undefined,\n): ChatHistorySession[] {\n const channels = (data?.channelsByUser ?? []) as (ChannelLike | null)[];\n return channels\n .filter((c): c is ChannelLike => Boolean(c?.id) && (!c?.type || c.type === RoomType.Aiassistant))\n .map((c) => buildSessionFromChannel(c))\n .filter((row): row is ChatHistorySession => row !== null)\n .sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());\n}\n\n/**\n * Chat history feed driven by `channelsByUser`. Each row: parent prompt as title,\n * `lastMessage.message` as subtitle (Manus-style), when the API provides them.\n *\n * Caller MUST pass `orgName` (the org slug). Without it, the resolver only\n * matches channels whose `orgName` field equals the user's `orgId`, which is\n * never the case for mobile-created channels (those store the slug). The hook\n * suspends the query (`skip: true`) until `orgName` is known, so we never\n * fire a guaranteed-empty request.\n *\n * Pagination is by channel count (one channel = one row in this query),\n * unlike the messages-based path which paginates by raw post rows.\n */\nexport function useChatHistorySessionsFromChannels(orgName: string | null | undefined, options?: { skip?: boolean }) {\n const skip = options?.skip || !orgName;\n const variables = useMemo(() => getHistoryChannelsQueryVariables(orgName), [orgName]);\n\n const { data, loading, error, refetch } = useGetChannelsByUserWithLastMessageQuery({\n variables,\n skip,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n context: { cacheKey: 'chat-history-channels-list' },\n });\n\n const sessions = useMemo(() => chatHistorySessionsFromChannels(data), [data]);\n const sourceChannelCount = data?.channelsByUser?.length ?? 0;\n /**\n * `sessionsLoaded` means \"we have data we can show\", regardless of whether a\n * background revalidation is still in flight. Same contract as `messagesLoaded`\n * in `useChatMessages` — lets the screen show the cached list (or empty state)\n * immediately on revisit instead of flashing a loader for the network round-trip.\n */\n const sessionsLoaded = data !== undefined;\n\n return { sessions, loading, sessionsLoaded, error, refetch, sourceChannelCount };\n}\n\nfunction stripModelCostHeader(content: string): string {\n const normalized = content.replace(/\\r\\n/g, '\\n');\n return normalized.replace(\n /^\\s*(?:[^\\w\\n]+\\s*)?[a-z0-9][a-z0-9._-]*\\s*\\(\\s*\\$[\\d.]+\\s*\\/\\s*MTok\\s+in\\s*\\)\\s*\\n+/i,\n '',\n );\n}\n\nfunction sanitizeAssistantContentByRole(role: unknown, content: string): string {\n return role === 'assistant' ? stripModelCostHeader(content) : content;\n}\n\nfunction omitContent<T extends Record<string, any>>(value: T | null | undefined): Omit<T, 'content'> {\n const clone = { ...(value ?? {}) } as Record<string, any>;\n delete clone.content;\n return clone as Omit<T, 'content'>;\n}\n\nexport interface ChatSessionUI {\n id: string;\n title: string;\n createdAt: Date;\n updatedAt: Date;\n messageCount?: number;\n}\n\nexport function useChatSessions(options?: { includeArchived?: boolean; skip?: boolean }) {\n const { data, loading, error, refetch } = useGetChannelsByUserWithLastMessageQuery({\n variables: AI_ASSISTANT_CHANNELS_QUERY_VARS,\n skip: options?.skip,\n fetchPolicy: 'cache-and-network',\n });\n\n const sessions: ChatSessionUI[] = useMemo(() => {\n const channels = data?.channelsByUser ?? [];\n return channels\n .filter((c): c is NonNullable<typeof c> => Boolean(c?.id))\n .map((channel) => ({\n id: channel.id,\n title: channel.title || channel.displayName || 'New Chat',\n createdAt: new Date(channel.createdAt ?? Date.now()),\n updatedAt: new Date(channel.updatedAt ?? Date.now()),\n messageCount: undefined,\n }));\n }, [data]);\n\n return { sessions, loading, error, refetch };\n}\n\nexport interface ChatMessageUI {\n id: string;\n sessionId: string;\n role: 'user' | 'assistant' | 'system';\n content: string;\n attachments?: Array<{ id: string; name: string; type: string; mimeType?: string; size?: number; url?: string }>;\n tokenCount?: number;\n model?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\ninterface MinimalFile {\n id?: string | null;\n name?: string | null;\n mimeType?: string | null;\n size?: number | null;\n url?: string | null;\n}\n\ninterface MinimalPost {\n id?: string | null;\n message?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n channel?: { id?: string | null } | null;\n files?: { data?: MinimalFile[] | null } | null;\n props?: { role?: string | null; tokenCount?: number | null; model?: string | null } | null;\n propsConfiguration?: {\n contents?: { role?: string | null } | null;\n content?: { role?: string | null } | null;\n } | null;\n}\n\nfunction mapPostToChatMessageUI(post: MinimalPost, fallbackChannelId: string): ChatMessageUI {\n const props = (post.props ?? {}) as Record<string, any>;\n const contents = post.propsConfiguration?.contents ?? {};\n const roleRaw = props.role ?? contents.role ?? post.propsConfiguration?.content?.role;\n let role: ChatMessageUI['role'] = 'assistant';\n if (roleRaw === 'user' || roleRaw === AiAgentMessageRole.User) role = 'user';\n else if (roleRaw === 'assistant' || roleRaw === AiAgentMessageRole.Assistant) role = 'assistant';\n else if (roleRaw === 'system') role = 'system';\n\n const rawContent = post?.message ?? '';\n const content = sanitizeAssistantContentByRole(role, rawContent);\n\n return {\n id: post?.id ?? uuidv4(),\n sessionId: post?.channel?.id ?? fallbackChannelId,\n role,\n content,\n attachments: (post?.files?.data ?? []).map((file) => ({\n id: file.id ?? uuidv4(),\n name: file.name ?? 'file',\n type: typeof file.mimeType === 'string' && file.mimeType.startsWith('image/') ? 'screenshot' : 'file',\n mimeType: file.mimeType ?? undefined,\n size: file.size ?? undefined,\n url: file.url ?? undefined,\n })),\n tokenCount: props.tokenCount ?? undefined,\n model: props.model ?? undefined,\n createdAt: post?.createdAt ? new Date(post.createdAt) : new Date(),\n updatedAt: post?.updatedAt ? new Date(post.updatedAt) : new Date(),\n };\n}\n\nexport function useChatMessages(sessionId: string | null, options?: { skip?: boolean }) {\n const { data, loading, error, refetch } = useMessagesQuery({\n variables: {\n channelId: sessionId ?? undefined,\n parentId: null,\n limit: MESSAGES_PAGE_LIMIT,\n skip: 0,\n },\n skip: !sessionId || options?.skip,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n /**\n * Cache key is per-channel so switching sessions doesn't read another channel's response.\n * Keeping this as a constant ('messages-list') used to cause cross-session bleed in the\n * custom Apollo link before reaching the normalized cache.\n */\n context: { cacheKey: sessionId ? `messages-list:${sessionId}` : 'messages-list' },\n });\n\n /**\n * `messagesLoaded` means \"we have data we can show\", regardless of whether a\n * background revalidation is in flight. With `cache-and-network`, Apollo\n * fills `data` from cache synchronously while `loading` is still true for\n * the network round-trip — gating hydration on `!loading` made every chat\n * revisit show a loader for the network latency even though the messages\n * were already cached. The chat stream re-hydrates whenever `data` changes,\n * so the fresh network response still swaps in silently afterward.\n */\n const messagesLoaded = data !== undefined;\n\n const messages: ChatMessageUI[] = useMemo(() => {\n if (!sessionId) return [];\n const rows = data?.messages?.data ?? [];\n return rows\n .map((post) => mapPostToChatMessageUI(post as MinimalPost, sessionId))\n .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());\n }, [data, sessionId]);\n\n return { messages, loading, messagesLoaded, error, refetch };\n}\n\nexport type IAccountSaveChatMessagesInput = IAccountSaveChatMessagesInputBase & {\n mode?: 'plan' | 'build';\n createdBy?: string;\n};\n\n/** Backend/gateway may have already inserted the post (E11000 duplicate `_id`). */\nfunction isDuplicatePostError(error: unknown): boolean {\n const parts: string[] = [];\n if (error && typeof error === 'object' && 'graphQLErrors' in error) {\n const gqlErrors = (error as { graphQLErrors?: Array<{ message?: string }> }).graphQLErrors ?? [];\n parts.push(...gqlErrors.map((e) => e?.message ?? ''));\n }\n if (error instanceof Error) {\n parts.push(error.message);\n } else if (error != null) {\n parts.push(String(error));\n }\n const msg = parts.join(' ');\n return /E11000|duplicate key/i.test(msg);\n}\n\nexport function useChatMutations() {\n const [addChannelMutation, { loading: createChannelLoading }] = useAddChannelMutation();\n const [sendMessagesMutation, { loading: sendMessagesLoading }] = useSendMessagesMutation();\n\n const createChannel = useCallback(\n async (input?: IAccountCreateChatSessionInput): Promise<ChatSessionUI> => {\n const {\n orgName: orgNameArg,\n projectId: projectIdArg,\n ...inputForSettings\n } = (input ?? {}) as IAccountCreateChatSessionInput & {\n orgName?: string | null;\n projectId?: string | null;\n };\n const orgName =\n typeof orgNameArg === 'string' && orgNameArg.trim().length > 0 ? orgNameArg.trim() : undefined;\n const projectId =\n typeof projectIdArg === 'string' && projectIdArg.trim().length > 0 ? projectIdArg.trim() : undefined;\n\n const settings = {\n title: input?.title ?? 'New Chat',\n description: input?.systemPrompt ?? null,\n isShared: false,\n sharedSlug: null,\n isArchived: false,\n isPinned: false,\n model: input?.model ?? null,\n systemPrompt: input?.systemPrompt ?? null,\n ...inputForSettings,\n };\n\n const { data } = await addChannelMutation({\n variables: {\n channelId: input?.id ?? null,\n name: input?.title ?? 'New Chat',\n description: input?.systemPrompt ?? null,\n type: RoomType.Aiassistant,\n settings,\n ...(orgName ? { orgName } : {}),\n ...(projectId ? { projectId } : {}),\n },\n /**\n * Refetch every cache slot the rest of the app is watching for\n * channel lists. Apollo keys cached results by `variables`, so each\n * shape we emit here must match a watched query exactly.\n *\n * Variants:\n * 1. Legacy limit:100 list (web parity, no `criteria.orgName`).\n * 2. Mobile history-screen variant WITH `criteria.orgName` so the\n * resolver's `$in: [slug, orgId]` matches mobile-created channels.\n * 3. Same variant WITHOUT orgName, in case the screen mounted before\n * org settings resolved.\n */\n refetchQueries: [\n { query: GetChannelsByUserWithLastMessageDocument, variables: AI_ASSISTANT_CHANNELS_QUERY_VARS },\n ...(orgName\n ? [\n {\n query: GetChannelsByUserWithLastMessageDocument,\n variables: getHistoryChannelsQueryVariables(orgName),\n },\n ]\n : []),\n { query: GetChannelsByUserWithLastMessageDocument, variables: HISTORY_QUERY_BASE },\n ],\n awaitRefetchQueries: true,\n });\n\n if (!data?.createChannel?.id) {\n throw new Error('Failed to create channel');\n }\n\n const channel = data.createChannel;\n const title = channel.title ?? input?.title ?? 'New Chat';\n const now = new Date();\n\n return {\n id: channel.id,\n title,\n createdAt: now,\n updatedAt: now,\n };\n },\n [addChannelMutation],\n );\n\n const saveMessages = useCallback(\n async (\n input: IAccountSaveChatMessagesInput,\n ): Promise<{\n userMessage: ChatMessageUI;\n assistantMessage: ChatMessageUI;\n session: ChatSessionUI;\n }> => {\n const sanitizedAssistantContent = stripModelCostHeader(input.assistantMessage.content ?? '');\n const assistantMessageWithoutContent = omitContent((input.assistantMessage as any) ?? {});\n\n let userPost: MinimalPost | null | undefined;\n try {\n const userResult = await sendMessagesMutation({\n variables: {\n channelId: input.sessionId,\n type: RoomType.Aiassistant,\n content: input.userMessage.content ?? '',\n ...(input.createdBy ? { createdBy: input.createdBy } : {}),\n extraProps: {\n type: PostTypeEnum.Aiassistant,\n role: 'user',\n attachments: input.userMessage.attachments ?? [],\n isActive: true,\n status: 'complete',\n ...(input.userMessage as any),\n ...(input.mode ? { mode: input.mode } : {}),\n },\n } as any,\n });\n userPost = userResult.data?.sendMessage as MinimalPost | undefined;\n } catch (err) {\n if (!isDuplicatePostError(err)) {\n throw err;\n }\n console.warn('[saveMessages] user post already persisted (skipping duplicate insert)');\n }\n\n /**\n * Keep the prompting user post id in metadata. `sendMessage.postId` is the id of\n * the post being created, so reusing the user post id for the assistant reply would\n * collide and leave only the user message persisted.\n */\n const userPostId = userPost?.id ?? null;\n\n let assistantPost: MinimalPost | null | undefined;\n try {\n const assistantResult = await sendMessagesMutation({\n variables: {\n channelId: input.sessionId,\n type: RoomType.Aiassistant,\n content: sanitizedAssistantContent,\n extraProps: {\n type: PostTypeEnum.Aiassistant,\n role: 'assistant',\n attachments: input.assistantMessage.attachments ?? [],\n tokenCount: input.assistantMessage.tokenCount,\n latencyMs: input.assistantMessage.latencyMs,\n model: input.assistantMessage.model,\n finishReason: (input.assistantMessage as any).finishReason ?? null,\n isActive: true,\n status: 'complete',\n ...assistantMessageWithoutContent,\n ...(userPostId ? { parentId: userPostId } : {}),\n ...(input.mode ? { mode: input.mode } : {}),\n },\n } as any,\n });\n assistantPost = assistantResult.data?.sendMessage as MinimalPost | undefined;\n } catch (err) {\n if (!isDuplicatePostError(err)) {\n throw err;\n }\n console.warn('[saveMessages] assistant post already persisted (skipping duplicate insert)');\n }\n\n if (!userPost && !assistantPost) {\n throw new Error('Failed to send messages');\n }\n\n const now = new Date();\n const fallbackUser: ChatMessageUI = {\n id: userPostId ?? uuidv4(),\n sessionId: input.sessionId,\n role: 'user',\n content: input.userMessage.content ?? '',\n createdAt: now,\n updatedAt: now,\n };\n const fallbackAssistant: ChatMessageUI = {\n id: uuidv4(),\n sessionId: input.sessionId,\n role: 'assistant',\n content: sanitizedAssistantContent,\n createdAt: now,\n updatedAt: now,\n tokenCount: input.assistantMessage.tokenCount,\n model: input.assistantMessage.model,\n };\n return {\n userMessage: userPost ? mapPostToChatMessageUI(userPost, input.sessionId) : fallbackUser,\n assistantMessage: assistantPost\n ? mapPostToChatMessageUI(assistantPost, input.sessionId)\n : fallbackAssistant,\n session: {\n id: input.sessionId,\n title: 'Chat',\n createdAt: now,\n updatedAt: now,\n },\n };\n },\n [sendMessagesMutation],\n );\n\n return {\n createChannel,\n createSession: createChannel,\n saveMessages,\n loading: { create: createChannelLoading, saveMessages: sendMessagesLoading },\n };\n}\n"],"names":["uuidv4","_a","_b","_c","_d","_e"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,mBAAsB,GAAA,GAAA;AAGrB,MAAM,gCAAmC,GAAA;AAAA,EAC9C,QAAU,EAAA;AAAA,IACR,MAAM,QAAS,CAAA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X,SAAW,EAAA;AAAA,KACb;AACA,IAAA,MAAM,iBAAmC,GAAA;AAAA,MACvC,IAAIA,EAAO,EAAA;AAAA,MACX,WAAW,KAAM,CAAA,SAAA;AAAA,MACjB,IAAM,EAAA,WAAA;AAAA,MACN,OAAS,EAAA,yBAAA;AAAA,MACT,SAAW,EAAA,GAAA;AAAA,MACX,SAAW,EAAA,GAAA;AAAA,MACX,UAAA,EAAY,MAAM,gBAAiB,CAAA,UAAA;AAAA,MACnC,KAAA,EAAO,MAAM,gBAAiB,CAAA;AAAA,KAChC;AACA,IAAO,OAAA;AAAA,MACL,aAAa,QAAW,GAAA,sBAAA,CAAuB,QAAU,EAAA,KAAA,CAAM,SAAS,CAAI,GAAA,YAAA;AAAA,MAC5E,kBAAkB,aAAgB,GAAA,sBAAA,CAAuB,aAAe,EAAA,KAAA,CAAM,SAAS,CAAI,GAAA,iBAAA;AAAA,MAC3F,OAAS,EAAA;AAAA,QACP,IAAI,KAAM,CAAA,SAAA;AAAA,QACV,KAAO,EAAA,MAAA;AAAA,QACP,SAAW,EAAA,GAAA;AAAA,QACX,SAAW,EAAA;AAAA;AACb,KACF;AAAA,GACF,EAAG,CAAC,oBAAoB,CAAC,CAAA;AACzB,EAAO,OAAA;AAAA,IACL,aAAA;AAAA,IACA,aAAe,EAAA,aAAA;AAAA,IACf,YAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA,oBAAA;AAAA,MACR,YAAc,EAAA;AAAA;AAChB,GACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminide-stack/yantra-mobile",
3
- "version": "12.0.28-alpha.84",
3
+ "version": "12.0.28-alpha.86",
4
4
  "description": "Sample core for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -25,7 +25,7 @@
25
25
  "uuid": "^9.0.0"
26
26
  },
27
27
  "devDependencies": {
28
- "common": "12.0.28-alpha.83"
28
+ "common": "12.0.28-alpha.86"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@admin-layout/gluestack-ui-mobile": "*",
@@ -49,5 +49,5 @@
49
49
  "typescript": {
50
50
  "definition": "lib/index.d.ts"
51
51
  },
52
- "gitHead": "612379848369584344fe805ad452541c479a9e2f"
52
+ "gitHead": "4c5b346c244fa32a61a098968b252d3ca8b6f491"
53
53
  }