Skip to content

feat(mobile): add AI chat screens - #1206

Closed
Kitenite wants to merge 1 commit into
mainfrom
split-ai-chat/mobile
Closed

Kitenite wants to merge 1 commit into
mainfrom
split-ai-chat/mobile

Conversation

@Kitenite

@Kitenite Kitenite commented Feb 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add chat list and chat detail screens
  • Add chat route pages for Expo Router
  • Add streams client for connecting to durable-streams server
  • Add ChatInput, ChatMessage, PresenceBar components
  • Add chat entry point to HomeScreen
  • Add STREAMS_URL env variable

Context

Split from ai-chat branch. Depends on PR #1 (shared-package).

Test plan

  • Verify chat screens render on iOS/Android
  • Verify navigation from HomeScreen to chat list
  • Verify stream client connects to server

Summary by CodeRabbit

Release Notes

  • New Features
    • Real-time chat functionality with session management
    • Chat sessions list with ability to create new chats
    • Streaming message support for instant message delivery
    • User presence indicator showing active participants
    • Chat navigation and integration into home screen

- Add chat list and chat detail screens
- Add chat route pages for Expo Router
- Add streams client for connecting to durable-streams server
- Add ChatInput, ChatMessage, PresenceBar components
- Add chat entry point to HomeScreen
- Add STREAMS_URL env variable
@coderabbitai

coderabbitai Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR introduces a complete real-time chat feature for the mobile app, including a Streams API client for session management, session listing and individual chat screens with message rendering, UI components for message input and user presence, and integration with the app's navigation and authentication systems.

Changes

Cohort / File(s) Summary
Route Configuration
apps/mobile/app/(authenticated)/chat/[sessionId].tsx, apps/mobile/app/(authenticated)/chat/index.tsx
Added route wrapper files that re-export ChatScreen and ChatListScreen, establishing entry points for the session-based chat routes.
Environment & Dependencies
apps/mobile/lib/env.ts, apps/mobile/package.json
Added EXPO_PUBLIC_STREAMS_URL optional environment variable; added @superset/ai-chat workspace dependency and updated TanStack package versions.
Streams API Client
apps/mobile/lib/streams/client.ts, apps/mobile/lib/streams/index.ts
Implemented session management client with functions for listing, retrieving, creating, and upserting sessions; includes UUID generation and session info interface.
Chat Screens
apps/mobile/screens/(authenticated)/chat/ChatListScreen.tsx, apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx, apps/mobile/screens/(authenticated)/chat/[sessionId]/index.ts, apps/mobile/screens/(authenticated)/chat/index.ts
Added session list screen with creation form and navigation, and individual session screen with message streaming, auto-scroll, and connection status handling.
Chat UI Components
apps/mobile/screens/(authenticated)/chat/[sessionId]/components/ChatInput/ChatInput.tsx, apps/mobile/screens/(authenticated)/chat/[sessionId]/components/ChatMessage/ChatMessage.tsx, apps/mobile/screens/(authenticated)/chat/[sessionId]/components/PresenceBar/PresenceBar.tsx, apps/mobile/screens/(authenticated)/chat/[sessionId]/components/.../index.ts
Implemented message input with send button, message bubble rendering with timestamps, and active user presence indicator; added barrel exports for component access.
Home Navigation
apps/mobile/screens/(authenticated)/index/HomeScreen.tsx
Added Real-time Chat card to HomeScreen with navigation to the chat feature.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant ChatList as ChatListScreen
    participant Mobile as Mobile App
    participant StreamAPI as Streams API
    participant ChatScreen as ChatScreen
    participant MessageStream as Message Stream Server

    User->>ChatList: Opens chat list
    ChatList->>StreamAPI: listSessions()
    StreamAPI-->>ChatList: Returns sessions
    ChatList-->>User: Displays sessions

    User->>ChatList: Create new chat
    ChatList->>StreamAPI: createSession(title)
    StreamAPI-->>ChatList: Returns SessionInfo
    ChatList->>Mobile: Navigate to [sessionId]

    Mobile->>ChatScreen: Load with sessionId
    ChatScreen->>StreamAPI: getSession(sessionId)
    StreamAPI-->>ChatScreen: Returns session data
    
    ChatScreen->>MessageStream: Connect to /streams/{sessionId}
    MessageStream-->>ChatScreen: Stream messages

    User->>ChatScreen: Type & send message
    ChatScreen->>StreamAPI: POST /streams/{sessionId}
    StreamAPI->>MessageStream: Forwards message
    MessageStream-->>ChatScreen: Stream receives message
    ChatScreen-->>User: Message appears in list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hops through streams so swift and bright,
Messages flowing left and right,
Sessions created with a bound,
Real-time chat all around!
Presence bars and bubbles fair,
Chat magic fills the mobile air! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(mobile): add AI chat screens' clearly and concisely summarizes the primary change: adding chat screen components to the mobile app.
Description check ✅ Passed The pull request description provides a clear summary, context, and test plan, but lacks proper template structure and is missing the 'Type of Change' and 'Related Issues' sections from the repository template.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch split-ai-chat/mobile

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) ❌ Failed to create
Fly.io Electric (Fly.io) ❌ Failed to deploy
Vercel API (Vercel) ❌ Failed to deploy
Vercel Web (Vercel) ❌ Failed to deploy
Vercel Marketing (Vercel) ❌ Failed to deploy
Vercel Admin (Vercel) ❌ Failed to deploy
Vercel Docs (Vercel) ❌ Failed to deploy

Preview updates automatically with new commits

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Fix all issues with AI agents
In `@apps/mobile/lib/streams/client.ts`:
- Around line 38-118: Responses from the Streams API in listSessions,
getSession, createSession and getOrCreateSession are used without validation;
add Zod schemas (e.g., SessionInfoSchema and SessionsArraySchema) and use them
to parse/validate the parsed JSON from each fetch before returning, throwing a
clear error on validation failure; import z from "zod", call await res.json()
into a variable, run SessionInfoSchema.parse or .safeParse (for listSessions use
the array schema), and provide tolerant parsing/fallbacks for optional fields
like createdBy so malformed payloads fail fast and don’t break the UI.

In `@apps/mobile/package.json`:
- Line 22: The package dependency "@superset/ai-chat" declared with
"workspace:*" is missing from the monorepo; either add a new package named
"@superset/ai-chat" under your workspaces (packages/* or apps/*) with a valid
package.json and export entry points, or remove the "@superset/ai-chat" entry
from the apps/mobile package.json to avoid workspace resolution failures; update
any import usage to match the created package name or adjust imports to existing
packages if you remove the dependency.

In `@apps/mobile/screens/`(authenticated)/chat/[sessionId]/ChatScreen.tsx:
- Around line 100-120: The handleSend useCallback currently captures streamsUrl
but omits it from its dependency array, risking stale closures; update the
dependency array for handleSend to include streamsUrl (in addition to
user?.userId and sessionId) so the callback updates when streamsUrl
changes—locate the useCallback for handleSend and add streamsUrl to its
dependencies.

In
`@apps/mobile/screens/`(authenticated)/chat/[sessionId]/components/ChatInput/ChatInput.tsx:
- Around line 39-50: The TextInput with multiline={true} prevents
onSubmitEditing (handleSend) from firing; update the ChatInput TextInput props
(the TextInput element using value, onChange, placeholder,
onSubmitEditing={handleSend}) to include submitBehavior="blurAndSubmit" and
returnKeyType="send" so Enter triggers send on the keyboard for multiline input;
do not use the deprecated blurOnSubmit prop.

In
`@apps/mobile/screens/`(authenticated)/chat/[sessionId]/components/ChatMessage/ChatMessage.tsx:
- Around line 25-36: The formatTime function currently assumes a Date object but
message.createdAt is an ISO string; update formatTime (and its usages) to
normalize the input (e.g., accept date: string | Date) and convert strings to a
Date before calling toLocaleTimeString so you never call toLocaleTimeString on a
string; locate the formatTime function in ChatMessage.tsx and the call passing
message.createdAt and ensure you create a Date instance when needed (handle
null/invalid values defensively).

In `@apps/mobile/screens/`(authenticated)/chat/ChatListScreen.tsx:
- Around line 29-38: Destructure the error from the useQuery call that uses
queryFn: listSessions (i.e., add error to the returned fields) and add an
onError callback to that useQuery to log the failure (e.g., console.error or
your app logger) with context; then update the ListEmptyComponent to render an
error state when that error exists (show a user-facing message and a Retry
button that calls refetch) instead of silently showing "No chats yet", ensuring
you reference the same useQuery variables (error, isLoading, refetch,
isRefetching) and the list's ListEmptyComponent to implement the retry UI.
🧹 Nitpick comments (4)
apps/mobile/package.json (1)

25-27: Align versioning strategy for TanStack packages (Lines 25-27).

These packages are tightly coupled; mixing caret ranges with a pinned exact version increases the chance of peer mismatch as ranges float forward. Consider standardizing to all caret or all exact versions, and verify peer dependency compatibility.

🔧 Option A — allow consistent ranged updates
-		"@tanstack/electric-db-collection": "0.2.30",
+		"@tanstack/electric-db-collection": "^0.2.30",
apps/mobile/screens/(authenticated)/index/HomeScreen.tsx (1)

85-98: Consider hoisting the new Chat card copy/route into constants.

This keeps the screen cleaner and makes reuse/i18n easier.

♻️ Suggested refactor
+const CHAT_ROUTE = "/(authenticated)/chat";
+const CHAT_TITLE = "Real-time Chat";
+const CHAT_DESCRIPTION =
+	"Chat with durable streams - syncs across all devices";
+const CHAT_CTA = "Open Chat";
+
...
-						<CardTitle>Real-time Chat</CardTitle>
+						<CardTitle>{CHAT_TITLE}</CardTitle>
...
-							Chat with durable streams - syncs across all devices
+							{CHAT_DESCRIPTION}
...
-						<Button onPress={() => router.push("/(authenticated)/chat")}>
-							<Text>Open Chat</Text>
+						<Button onPress={() => router.push(CHAT_ROUTE)}>
+							<Text>{CHAT_CTA}</Text>

As per coding guidelines: Extract hardcoded magic numbers, strings, and enums to named constants at module top instead of leaving them inline in logic.

apps/mobile/screens/(authenticated)/chat/ChatListScreen.tsx (1)

35-36: Extract session query key and date thresholds into module constants.
Reduces magic values and keeps queryKey usage consistent.

♻️ Suggested refactor
 import { useCallback, useState } from "react";
 import { Alert, FlatList, Pressable, RefreshControl, View } from "react-native";
 import { Button } from "@/components/ui/button";
 import { Card, CardContent } from "@/components/ui/card";
 import { Input } from "@/components/ui/input";
 import { Text } from "@/components/ui/text";
 import { useSession } from "@/lib/auth/client";
 import { env } from "@/lib/env";
 import {
 	createSession,
 	listSessions,
 	type SessionInfo,
 } from "@/lib/streams/client";

+const SESSIONS_QUERY_KEY = ["sessions"] as const;
+const ONE_DAY_MS = 24 * 60 * 60 * 1000;
+const ONE_WEEK_MS = 7 * ONE_DAY_MS;
+
 ...
 	} = useQuery({
-		queryKey: ["sessions"],
+		queryKey: SESSIONS_QUERY_KEY,
 		queryFn: listSessions,
 		enabled: !!streamsUrl,
 	});
 ...
-			queryClient.invalidateQueries({ queryKey: ["sessions"] });
+			queryClient.invalidateQueries({ queryKey: SESSIONS_QUERY_KEY });
 ...
-	if (diff < 24 * 60 * 60 * 1000) {
+	if (diff < ONE_DAY_MS) {
 		return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
 	}

 	// Less than 7 days
-	if (diff < 7 * 24 * 60 * 60 * 1000) {
+	if (diff < ONE_WEEK_MS) {
 		return date.toLocaleDateString([], { weekday: "short" });
 	}

As per coding guidelines: Extract hardcoded magic numbers, strings, and enums to named constants at module top instead of leaving them inline in logic.

Also applies to: 55-55, 202-217

apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx (1)

91-99: Clear the scroll timeout on unmount/update.
Prevents queued timeouts from firing after unmount and avoids piling up timers during rapid message streaming.

♻️ Suggested refactor
 	useEffect(() => {
-		if (messages.length > 0 || streamingMessage) {
-			setTimeout(() => {
-				flatListRef.current?.scrollToEnd({ animated: true });
-			}, 100);
-		}
-	}, [messages.length, streamingMessage?.content, streamingMessage]);
+		if (messages.length === 0 && !streamingMessage) {
+			return;
+		}
+
+		const timeout = setTimeout(() => {
+			flatListRef.current?.scrollToEnd({ animated: true });
+		}, 100);
+
+		return () => clearTimeout(timeout);
+	}, [messages.length, streamingMessage?.content, streamingMessage]);

Comment on lines +38 to +118
export async function listSessions(): Promise<SessionInfo[]> {
const url = getStreamsUrl();
const res = await fetch(`${url}/sessions`);

if (!res.ok) {
throw new Error(`Failed to list sessions: ${res.status} ${res.statusText}`);
}

return res.json();
}

export async function getSession(
sessionId: string,
): Promise<SessionInfo | null> {
const url = getStreamsUrl();
const res = await fetch(`${url}/sessions/${sessionId}`);

if (res.status === 404) {
return null;
}

if (!res.ok) {
throw new Error(`Failed to get session: ${res.status} ${res.statusText}`);
}

return res.json();
}

export async function createSession({
title,
createdBy,
}: {
title: string;
createdBy?: string;
}): Promise<SessionInfo> {
const url = getStreamsUrl();
const sessionId = generateUUID();

const res = await fetch(`${url}/sessions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sessionId, title, createdBy }),
});

if (!res.ok) {
throw new Error(
`Failed to create session: ${res.status} ${res.statusText}`,
);
}

return res.json();
}

export async function getOrCreateSession({
sessionId,
title,
createdBy,
}: {
sessionId: string;
title: string;
createdBy?: string;
}): Promise<SessionInfo> {
const existing = await getSession(sessionId);
if (existing) {
return existing;
}

const url = getStreamsUrl();
const res = await fetch(`${url}/sessions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sessionId, title, createdBy }),
});

if (!res.ok) {
throw new Error(
`Failed to create session: ${res.status} ${res.statusText}`,
);
}

return res.json();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate the file
find . -name "client.ts" -o -name "client.tsx" | grep -E "mobile|streams"

Repository: superset-sh/superset

Length of output: 201


🏁 Script executed:

# Check if the file exists and get its full structure
test -f "apps/mobile/lib/streams/client.ts" && echo "File exists" || echo "File not found"

Repository: superset-sh/superset

Length of output: 75


🏁 Script executed:

# Get the line count and content of the file
wc -l apps/mobile/lib/streams/client.ts 2>/dev/null || echo "File not accessible"

Repository: superset-sh/superset

Length of output: 101


🏁 Script executed:

# Read the file to verify the exact lines and current state
head -120 apps/mobile/lib/streams/client.ts | tail -90 2>/dev/null || cat apps/mobile/lib/streams/client.ts 2>/dev/null | head -130

Repository: superset-sh/superset

Length of output: 1930


🏁 Script executed:

# Check if zod is in dependencies
find . -name "package.json" | xargs grep -l "zod" | head -5

Repository: superset-sh/superset

Length of output: 196


🏁 Script executed:

# Read the complete file including imports and beginning
head -40 apps/mobile/lib/streams/client.ts

Repository: superset-sh/superset

Length of output: 1142


🏁 Script executed:

# Check mobile app's package.json for zod
cat apps/mobile/package.json | jq '.dependencies, .devDependencies' | grep -A 5 -B 5 "zod" || echo "Checking if zod exists in mobile..."

Repository: superset-sh/superset

Length of output: 317


🏁 Script executed:

# Check mobile app's package.json structure
head -50 apps/mobile/package.json

Repository: superset-sh/superset

Length of output: 1626


🏁 Script executed:

# Get the complete file
cat apps/mobile/lib/streams/client.ts

Repository: superset-sh/superset

Length of output: 2698


🏁 Script executed:

# Verify if there are any other files that might import/use SessionInfo or handle responses
rg "SessionInfo" apps/mobile --type ts --type tsx

Repository: superset-sh/superset

Length of output: 91


🏁 Script executed:

# Check if there are any existing validation patterns in the mobile app
rg "safeParse|zod" apps/mobile --type ts --type tsx | head -20

Repository: superset-sh/superset

Length of output: 91


🏁 Script executed:

# Check SessionInfo usage without file type restriction
rg "SessionInfo" apps/mobile

Repository: superset-sh/superset

Length of output: 874


🏁 Script executed:

# Check for zod usage without file type restriction
rg "safeParse|\.parse\(" apps/mobile | head -20

Repository: superset-sh/superset

Length of output: 123


🏁 Script executed:

# Check if there are other API clients to see if they validate responses
ls -la apps/mobile/lib/*/client.ts

Repository: superset-sh/superset

Length of output: 389


🏁 Script executed:

# Check one of the other client files to see if validation patterns exist
cat apps/mobile/lib/auth/client.ts | head -60

Repository: superset-sh/superset

Length of output: 609


🏁 Script executed:

# Check env.ts to see the Zod pattern used in the codebase
cat apps/mobile/lib/env.ts | head -40

Repository: superset-sh/superset

Length of output: 1171


🏁 Script executed:

# Verify ChatListScreen uses SessionInfo and see how it's consumed
grep -A 5 -B 5 "SessionInfo" apps/mobile/screens/\(authenticated\)/chat/ChatListScreen.tsx | head -30

Repository: superset-sh/superset

Length of output: 840


Validate Streams API responses before returning them.

The client currently trusts res.json() implicitly; malformed payloads from the API can break the UI. Add Zod schema validation to parse and validate each response, failing fast on invalid data.

Proposed fix (schema validation)
+import { z } from "zod";
 import { env } from "../env";

 export interface SessionInfo {
 	sessionId: string;
 	title: string;
 	createdAt: string;
 	createdBy?: string;
 }
+
+const sessionInfoSchema = z.object({
+	sessionId: z.string(),
+	title: z.string(),
+	createdAt: z.string(),
+	createdBy: z.string().optional(),
+});
+const sessionListSchema = z.array(sessionInfoSchema);
+
+function parseSessionInfo(data: unknown): SessionInfo {
+	const parsed = sessionInfoSchema.safeParse(data);
+	if (!parsed.success) {
+		throw new Error("Invalid session response");
+	}
+	return parsed.data;
+}

 export async function listSessions(): Promise<SessionInfo[]> {
 	const url = getStreamsUrl();
 	const res = await fetch(`${url}/sessions`);

 	if (!res.ok) {
 		throw new Error(`Failed to list sessions: ${res.status} ${res.statusText}`);
 	}

-	return res.json();
+	return sessionListSchema.parse(await res.json());
 }

 export async function getSession(
 	sessionId: string,
 ): Promise<SessionInfo | null> {
 	const url = getStreamsUrl();
 	const res = await fetch(`${url}/sessions/${sessionId}`);

 	if (res.status === 404) {
 		return null;
 	}

 	if (!res.ok) {
 		throw new Error(`Failed to get session: ${res.status} ${res.statusText}`);
 	}

-	return res.json();
+	return parseSessionInfo(await res.json());
 }

 export async function createSession({
 	title,
 	createdBy,
 }: {
 	title: string;
 	createdBy?: string;
 }): Promise<SessionInfo> {
 	const url = getStreamsUrl();
 	const sessionId = generateUUID();

 	const res = await fetch(`${url}/sessions`, {
 		method: "POST",
 		headers: { "Content-Type": "application/json" },
 		body: JSON.stringify({ sessionId, title, createdBy }),
 	});

 	if (!res.ok) {
 		throw new Error(
 			`Failed to create session: ${res.status} ${res.statusText}`,
 		);
 	}

-	return res.json();
+	return parseSessionInfo(await res.json());
 }

 export async function getOrCreateSession({
 	sessionId,
 	title,
 	createdBy,
 }: {
 	sessionId: string;
 	title: string;
 	createdBy?: string;
 }): Promise<SessionInfo> {
 	const existing = await getSession(sessionId);
 	if (existing) {
 		return existing;
 	}

 	const url = getStreamsUrl();
 	const res = await fetch(`${url}/sessions`, {
 		method: "POST",
 		headers: { "Content-Type": "application/json" },
 		body: JSON.stringify({ sessionId, title, createdBy }),
 	});

 	if (!res.ok) {
 		throw new Error(
 			`Failed to create session: ${res.status} ${res.statusText}`,
 		);
 	}

-	return res.json();
+	return parseSessionInfo(await res.json());
 }

Per coding guidelines: Validate external API data as untrusted by handling missing fields, unknown enums, and unexpected shapes with tolerant parsing and explicit fallbacks.

🤖 Prompt for AI Agents
In `@apps/mobile/lib/streams/client.ts` around lines 38 - 118, Responses from the
Streams API in listSessions, getSession, createSession and getOrCreateSession
are used without validation; add Zod schemas (e.g., SessionInfoSchema and
SessionsArraySchema) and use them to parse/validate the parsed JSON from each
fetch before returning, throwing a clear error on validation failure; import z
from "zod", call await res.json() into a variable, run SessionInfoSchema.parse
or .safeParse (for listSessions use the array schema), and provide tolerant
parsing/fallbacks for optional fields like createdBy so malformed payloads fail
fast and don’t break the UI.

Comment thread apps/mobile/package.json
"@rn-primitives/portal": "^1.3.0",
"@rn-primitives/slot": "^1.2.0",
"@rn-primitives/switch": "^1.2.0",
"@superset/ai-chat": "workspace:*",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Check root workspace config
cat -n package.json | head -40

Repository: superset-sh/superset

Length of output: 1745


🏁 Script executed:

# Find all package.json files and check for `@superset/ai-chat`
fd 'package.json$' -x grep -l '@superset/ai-chat'

Repository: superset-sh/superset

Length of output: 90


🏁 Script executed:

# Find Metro config files in the monorepo
fd -e 'js' -e 'cjs' -e 'mjs' -e 'ts' | grep -i metro

Repository: superset-sh/superset

Length of output: 91


🏁 Script executed:

# Check if ai-chat package exists in apps directory
fd -type d '@superset.*ai-chat|ai-chat' apps/

Repository: superset-sh/superset

Length of output: 234


🏁 Script executed:

# Get full root package.json to check for workspaces field
cat package.json | grep -A 20 '"workspaces"'

Repository: superset-sh/superset

Length of output: 222


🏁 Script executed:

# Read the metro config to see resolver setup
cat -n apps/mobile/metro.config.js

Repository: superset-sh/superset

Length of output: 989


🏁 Script executed:

# Search for ai-chat package definition
find . -path '*/ai-chat/package.json' -o -path '*/ai-chat/index.*' 2>/dev/null | head -5

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Check what packages exist in apps and packages directories
ls -la apps/ && echo "---" && ls -la packages/

Repository: superset-sh/superset

Length of output: 1220


🏁 Script executed:

# Search for any reference to ai-chat in the codebase
rg 'ai-chat' --type js --type json -i | head -20

Repository: superset-sh/superset

Length of output: 126


🏁 Script executed:

# Check if there's an ai-chat directory anywhere in the monorepo
find . -type d -name '*ai*chat*' 2>/dev/null

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look at the full apps/mobile/package.json to understand context
cat -n apps/mobile/package.json | head -50

Repository: superset-sh/superset

Length of output: 1976


Create the @superset/ai-chat package before declaring it as a workspace dependency.

The @superset/ai-chat package referenced in Line 22 does not exist in the monorepo. Adding "workspace:*" dependency to a non-existent package will cause installation and resolution failures.

The existing workspace configuration ("workspaces": ["packages/*", "apps/*"] in root package.json) and Metro setup (watchFolders and nodeModulesPaths in metro.config.js) are already properly configured for monorepo resolution, but they cannot help if the package itself is missing. Either create the @superset/ai-chat package in the appropriate directory (packages/ or apps/) or remove this dependency.

🤖 Prompt for AI Agents
In `@apps/mobile/package.json` at line 22, The package dependency
"@superset/ai-chat" declared with "workspace:*" is missing from the monorepo;
either add a new package named "@superset/ai-chat" under your workspaces
(packages/* or apps/*) with a valid package.json and export entry points, or
remove the "@superset/ai-chat" entry from the apps/mobile package.json to avoid
workspace resolution failures; update any import usage to match the created
package name or adjust imports to existing packages if you remove the
dependency.

Comment on lines +100 to +120
const handleSend = useCallback(
async (content: string) => {
if (!user?.userId || !streamsUrl || !sessionId) {
console.error(
"[chat] Cannot send message: missing user, URL, or sessionId",
);
return;
}
try {
await sendMessageToStream({
proxyUrl: streamsUrl,
sessionId,
userId: user.userId,
content,
});
} catch (err) {
console.error("[chat] Failed to send message:", err);
}
},
[user?.userId, sessionId],
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find apps/mobile/screens -name "ChatScreen.tsx" -type f

Repository: superset-sh/superset

Length of output: 131


🏁 Script executed:

if [ -f "apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx" ]; then
  wc -l "apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx"
fi

Repository: superset-sh/superset

Length of output: 135


🏁 Script executed:

# List the actual structure to find the correct path
fd ChatScreen.tsx apps/mobile/screens

Repository: superset-sh/superset

Length of output: 131


🏁 Script executed:

sed -n '95,130p' "apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx" | cat -n

Repository: superset-sh/superset

Length of output: 1190


🏁 Script executed:

sed -n '85,110p' "apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx" | cat -n

Repository: superset-sh/superset

Length of output: 949


🏁 Script executed:

sed -n '1,30p' "apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx" | cat -n

Repository: superset-sh/superset

Length of output: 1182


🏁 Script executed:

sed -n '30,120p' "apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx" | cat -n

Repository: superset-sh/superset

Length of output: 2756


🏁 Script executed:

cat -n "apps/mobile/screens/(authenticated)/chat/[sessionId]/ChatScreen.tsx" | sed -n '62,95p'

Repository: superset-sh/superset

Length of output: 1181


🏁 Script executed:

# Check ESLint configuration
find . -maxdepth 2 -name ".eslintrc*" -o -name "eslint.config.*" | head -5

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

ls -la | grep -E "eslint|biome"

Repository: superset-sh/superset

Length of output: 127


🏁 Script executed:

# Check if there's an eslint or biome config in the root or package.json
cat package.json | grep -A 10 '"eslint\|"lint'

Repository: superset-sh/superset

Length of output: 631


🏁 Script executed:

cat biome.jsonc

Repository: superset-sh/superset

Length of output: 545


Add streamsUrl to handleSend dependency array to prevent stale closures.

The callback captures streamsUrl (checked at line 73 and used at line 81) but omits it from dependencies, causing the React exhaustive-deps linter to flag this as an issue.

Fix
 	const handleSend = useCallback(
 		async (content: string) => {
 			if (!user?.userId || !streamsUrl || !sessionId) {
 				console.error(
 					"[chat] Cannot send message: missing user, URL, or sessionId",
 				);
 				return;
 			}
 			try {
 				await sendMessageToStream({
 					proxyUrl: streamsUrl,
 					sessionId,
 					userId: user.userId,
 					content,
 				});
 			} catch (err) {
 				console.error("[chat] Failed to send message:", err);
 			}
 		},
-		[user?.userId, sessionId],
+		[user?.userId, sessionId, streamsUrl],
 	);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleSend = useCallback(
async (content: string) => {
if (!user?.userId || !streamsUrl || !sessionId) {
console.error(
"[chat] Cannot send message: missing user, URL, or sessionId",
);
return;
}
try {
await sendMessageToStream({
proxyUrl: streamsUrl,
sessionId,
userId: user.userId,
content,
});
} catch (err) {
console.error("[chat] Failed to send message:", err);
}
},
[user?.userId, sessionId],
);
const handleSend = useCallback(
async (content: string) => {
if (!user?.userId || !streamsUrl || !sessionId) {
console.error(
"[chat] Cannot send message: missing user, URL, or sessionId",
);
return;
}
try {
await sendMessageToStream({
proxyUrl: streamsUrl,
sessionId,
userId: user.userId,
content,
});
} catch (err) {
console.error("[chat] Failed to send message:", err);
}
},
[user?.userId, sessionId, streamsUrl],
);
🤖 Prompt for AI Agents
In `@apps/mobile/screens/`(authenticated)/chat/[sessionId]/ChatScreen.tsx around
lines 100 - 120, The handleSend useCallback currently captures streamsUrl but
omits it from its dependency array, risking stale closures; update the
dependency array for handleSend to include streamsUrl (in addition to
user?.userId and sessionId) so the callback updates when streamsUrl
changes—locate the useCallback for handleSend and add streamsUrl to its
dependencies.

Comment on lines +39 to +50
<TextInput
className="flex-1 text-base text-foreground min-h-[24px] max-h-[120px]"
value={value}
onChangeText={onChange}
placeholder={placeholder}
placeholderTextColor="#9ca3af"
multiline
editable={!disabled}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
onSubmitEditing={handleSend}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find apps/mobile/screens -name "ChatInput.tsx" -type f

Repository: superset-sh/superset

Length of output: 151


🏁 Script executed:

cat -n "apps/mobile/screens/(authenticated)/chat/[sessionId]/components/ChatInput/ChatInput.tsx"

Repository: superset-sh/superset

Length of output: 2163


🌐 Web query:

React Native TextInput multiline onSubmitEditing blurOnSubmit behavior

💡 Result:

In TextInput with multiline={true}, the Return/Enter key defaults to inserting a newline, so onSubmitEditing typically won’t behave like “submit” unless you change the submit behavior. React Native’s current docs note:

  • blurOnSubmit is deprecated and submitBehavior overrides it. [1]
  • For multiline inputs, submitBehavior defaults to 'newline' (i.e., Enter inserts a newline). [2]
  • Setting multiline + blurOnSubmit={true} makes Enter blur and fire onSubmitEditing instead of inserting a newline (legacy behavior). [1]

Recommended (current) approach: submitBehavior

<TextInput
  multiline
  submitBehavior="blurAndSubmit" // Enter blurs + triggers onSubmitEditing
  onSubmitEditing={() => {/* submit */}}
/>

submitBehavior options:

  • "newline": inserts newline (default for multiline)
  • "submit": fires submit event, does not blur
  • "blurAndSubmit": fires submit event and blurs [2]

If you want newline behavior (typical textarea)

Just keep defaults (or set explicitly):

<TextInput multiline submitBehavior="newline" />

Sources: React Native TextInput docs on blurOnSubmit (deprecated) and submitBehavior. [1][2]


Update submitBehavior to enable keyboard send for multiline input.

With multiline={true}, React Native defaults to newline behavior on Enter, preventing onSubmitEditing from firing. Use submitBehavior="blurAndSubmit" (modern, non-deprecated) instead of the legacy blurOnSubmit. Also add returnKeyType="send" to display a send button on the keyboard.

🛠️ Suggested fix
 				<TextInput
 					className="flex-1 text-base text-foreground min-h-[24px] max-h-[120px]"
 					value={value}
 					onChangeText={onChange}
 					placeholder={placeholder}
 					placeholderTextColor="#9ca3af"
 					multiline
+					submitBehavior="blurAndSubmit"
+					returnKeyType="send"
 					editable={!disabled}
 					onFocus={() => setIsFocused(true)}
 					onBlur={() => setIsFocused(false)}
 					onSubmitEditing={handleSend}
 				/>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<TextInput
className="flex-1 text-base text-foreground min-h-[24px] max-h-[120px]"
value={value}
onChangeText={onChange}
placeholder={placeholder}
placeholderTextColor="#9ca3af"
multiline
editable={!disabled}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
onSubmitEditing={handleSend}
/>
<TextInput
className="flex-1 text-base text-foreground min-h-[24px] max-h-[120px]"
value={value}
onChangeText={onChange}
placeholder={placeholder}
placeholderTextColor="#9ca3af"
multiline
submitBehavior="blurAndSubmit"
returnKeyType="send"
editable={!disabled}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
onSubmitEditing={handleSend}
/>
🤖 Prompt for AI Agents
In
`@apps/mobile/screens/`(authenticated)/chat/[sessionId]/components/ChatInput/ChatInput.tsx
around lines 39 - 50, The TextInput with multiline={true} prevents
onSubmitEditing (handleSend) from firing; update the ChatInput TextInput props
(the TextInput element using value, onChange, placeholder,
onSubmitEditing={handleSend}) to include submitBehavior="blurAndSubmit" and
returnKeyType="send" so Enter triggers send on the keyboard for multiline input;
do not use the deprecated blurOnSubmit prop.

Comment on lines +25 to +36
<Text className={textColor}>{message.content}</Text>
<Text className={`text-xs ${textColor} opacity-50 mt-1`}>
{formatTime(message.createdAt)}
</Text>
</View>
</View>
);
}

function formatTime(date: Date): string {
return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the ChatMessage component file
cat -n "apps/mobile/screens/(authenticated)/chat/[sessionId]/components/ChatMessage/ChatMessage.tsx"

Repository: superset-sh/superset

Length of output: 1429


🏁 Script executed:

# Also check if the file exists and explore the directory structure
fd -t f "ChatMessage" apps/mobile/screens/

Repository: superset-sh/superset

Length of output: 155


🏁 Script executed:

# Search for message type definitions in the codebase
rg -t ts -t tsx "MessageRow|message.*createdAt" --max-count 20

Repository: superset-sh/superset

Length of output: 91


🏁 Script executed:

# Search for MessageRow type definition
rg -t ts "type MessageRow|interface MessageRow"

Repository: superset-sh/superset

Length of output: 207


🏁 Script executed:

# Check if `@superset/ai-chat` is a local package
fd -t d "ai-chat" packages/

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look for the stream file in ai-chat package
fd -t f "stream" packages/ai-chat/

Repository: superset-sh/superset

Length of output: 168


🏁 Script executed:

# Find all packages directories
ls -la packages/ | head -20

Repository: superset-sh/superset

Length of output: 665


🏁 Script executed:

# Search for ai-chat package
find . -name "ai-chat" -type d 2>/dev/null | head -10

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Search for stream.ts or stream.tsx files
fd -t f "stream\.(ts|tsx)"

Repository: superset-sh/superset

Length of output: 187


🏁 Script executed:

# Look for MessageRow definition
rg "type MessageRow\s*=" -A 5

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Check if `@superset/ai-chat` is defined in tsconfig or package.json
rg "@superset/ai-chat" -g "tsconfig.json" -g "package.json" -A 2 -B 2

Repository: superset-sh/superset

Length of output: 366


🏁 Script executed:

# Look for where MessageRow is exported/defined
rg "export.*MessageRow|export type MessageRow" -A 3

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Check packages/shared directory
ls -la packages/shared/

Repository: superset-sh/superset

Length of output: 352


🏁 Script executed:

# Search for ai-chat related files anywhere
fd "ai-chat"

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look for ai-chat in packages/shared/src
find packages/shared/src -name "*ai-chat*" -o -name "*stream*"

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# List the structure of packages/shared/src
ls -la packages/shared/src/

Repository: superset-sh/superset

Length of output: 416


🏁 Script executed:

# Search for MessageRow in all files
rg "MessageRow" --type-list | head -20

Repository: superset-sh/superset

Length of output: 453


🏁 Script executed:

# Try searching without type filter
rg "MessageRow" -B 2 -A 5

Repository: superset-sh/superset

Length of output: 4288


🏁 Script executed:

# Check git ls-files for ai-chat related files
git ls-files | grep -i "ai-chat"

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look for the `@superset/ai-chat` package definition
find . -path "*/node_modules" -prune -o -name "package.json" -exec grep -l "ai-chat" {} \;

Repository: superset-sh/superset

Length of output: 90


🏁 Script executed:

# Check packages directory more thoroughly
find packages -type f -name "*.json" | xargs grep -l "ai-chat" 2>/dev/null

Repository: superset-sh/superset

Length of output: 48


🏁 Script executed:

# Look for a stream.ts file anywhere in the repo
find . -path "*/node_modules" -prune -o -name "stream.ts" -type f -print

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Check the mobile app's tsconfig for path mappings
cat apps/mobile/tsconfig.json

Repository: superset-sh/superset

Length of output: 300


🏁 Script executed:

# Check if ai-chat is in the root packages directory list
ls -la packages/

Repository: superset-sh/superset

Length of output: 665


🏁 Script executed:

# Search in the entire repo for the text "type MessageRow" or interface definition
rg "interface MessageRow|type MessageRow" --no-heading

Repository: superset-sh/superset

Length of output: 207


🏁 Script executed:

# Look at how messages are used in ChatScreen to understand the type
cat -n apps/mobile/screens/\(authenticated\)/chat/\[sessionId\]/ChatScreen.tsx | head -60

Repository: superset-sh/superset

Length of output: 1982


🏁 Script executed:

# Check the root package.json for workspaces definition
cat package.json | grep -A 20 "workspaces"

Repository: superset-sh/superset

Length of output: 503


🏁 Script executed:

# Look for ai-chat in the entire repo without node_modules
find . -name "ai-chat" -not -path "*/node_modules/*"

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Check if ai-chat is defined as a package in pnpm-workspace.yaml or similar
ls -la | grep -E "pnpm|yarn|package-lock"

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look for any TypeScript definition files for MessageRow
rg "MessageRow" -B 5 -A 10 | head -100

Repository: superset-sh/superset

Length of output: 6861


🏁 Script executed:

# Search for useChatSession hook to understand message structure
rg "useChatSession" -B 3 -A 15

Repository: superset-sh/superset

Length of output: 3500


🏁 Script executed:

# Look for how messages are returned/deserialized in the chat functionality
rg "messages" apps/mobile/screens/\(authenticated\)/chat/\[sessionId\]/ChatScreen.tsx -A 2 -B 2

Repository: superset-sh/superset

Length of output: 775


🏁 Script executed:

# Check if there's an ai-chat package in the monorepo by looking at all package.json files
find . -name "package.json" -not -path "*/node_modules/*" -exec grep -l '"name".*ai-chat' {} \;

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Try to understand the structure - look for where `@superset/ai-chat` might be imported from
rg "@superset/ai-chat" -B 2 -A 2

Repository: superset-sh/superset

Length of output: 1604


🏁 Script executed:

# List all directories in packages to see if ai-chat exists
ls -la packages/

Repository: superset-sh/superset

Length of output: 665


🏁 Script executed:

# Search for any reference to ai-chat package definition
find . -name "package.json" -not -path "*/node_modules/*" | xargs grep -l '"name".*"@superset/ai-chat"'

Repository: superset-sh/superset

Length of output: 48


🏁 Script executed:

# Check if there's an ai-chat directory anywhere
find . -type d -name "*ai*" -not -path "*/node_modules/*"

Repository: superset-sh/superset

Length of output: 530


🏁 Script executed:

# Look at the full ChatScreen file to understand message handling better
cat -n apps/mobile/screens/\(authenticated\)/chat/\[sessionId\]/ChatScreen.tsx | tail -80

Repository: superset-sh/superset

Length of output: 2603


🏁 Script executed:

# Check if `@superset/ai-chat` might be an external package
cat apps/mobile/package.json | grep -A 50 "dependencies"

Repository: superset-sh/superset

Length of output: 1785


🏁 Script executed:

# Look for a workspaces file or similar
find . -name "pnpm-workspace.yaml" -o -name "yarn-workspaces.json"

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Check root turbo.json or similar to see workspace config
cat turbo.json 2>/dev/null || echo "No turbo.json"

Repository: superset-sh/superset

Length of output: 77


🏁 Script executed:

# Try to find the ai-chat package by looking in git
git ls-files | grep -i ai-chat | head -20

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Search all TypeScript files for MessageRow type definition
rg "export.*MessageRow|export type MessageRow|export interface MessageRow" -A 5

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Check if there's a hidden ai-chat folder
find . -type d -name "*ai*chat*" -not -path "*/node_modules/*"

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look in apps directory for ai-chat
ls -la apps/

Repository: superset-sh/superset

Length of output: 614


🏁 Script executed:

# Try searching in all package.json files
grep -r '"@superset/ai-chat"' --include="*.json"

Repository: superset-sh/superset

Length of output: 126


🏁 Script executed:

# Check git status to see if there are untracked files
git status --short | grep -i ai-chat

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look for any .d.ts files that might define MessageRow
find . -name "*.d.ts" -not -path "*/node_modules/*" | xargs grep -l "MessageRow" 2>/dev/null

Repository: superset-sh/superset

Length of output: 48


🏁 Script executed:

# Check the mobile apps' tsconfig to understand path resolution
cat apps/mobile/tsconfig.json

Repository: superset-sh/superset

Length of output: 300


🏁 Script executed:

# Look at the sendMessageToStream function more closely to see what the message structure should be
cat -n apps/mobile/screens/\(authenticated\)/chat/\[sessionId\]/ChatScreen.tsx | sed -n '37,50p'

Repository: superset-sh/superset

Length of output: 379


🏁 Script executed:

# Search for where ai-chat package might be defined - check if it's perhaps not in packages/
find . -name "package.json" -not -path "*/node_modules/*" -exec grep -l '"name": "@superset/ai-chat"' {} \;

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look for any index files or exports in the packages directory
find packages -name "index.ts" -o -name "index.tsx" -o -name "stream.ts" -o -name "stream.tsx" 2>/dev/null | head -20

Repository: superset-sh/superset

Length of output: 996


🏁 Script executed:

# Check if ai-chat might be external by looking at the lockfile
head -100 pnpm-lock.yaml | grep -i "ai-chat"

Repository: superset-sh/superset

Length of output: 137


🏁 Script executed:

# Now let's verify the actual behavior - check what toLocaleTimeString does with a string
node -e "
const str = new Date().toISOString();
try {
  const result = str.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
  console.log('String result:', result);
} catch(e) {
  console.log('String error:', e.message);
}
const date = new Date(str);
try {
  const result = date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
  console.log('Date result:', result);
} catch(e) {
  console.log('Date error:', e.message);
}
"

Repository: superset-sh/superset

Length of output: 140


🏁 Script executed:

# This is critical - the review is about type safety. Let's check the actual error behavior
# and look for the MessageRow source more systematically
git log --oneline --all -- "*ai-chat*" 2>/dev/null | head -10

Repository: superset-sh/superset

Length of output: 46


🏁 Script executed:

# Look for any built/dist directories that might contain ai-chat
find . -type d \( -name dist -o -name build -o -name lib \) -not -path "*/node_modules/*" | head -20

Repository: superset-sh/superset

Length of output: 377


🏁 Script executed:

# Search exhaustively for MessageRow in entire repo excluding node_modules
rg "MessageRow" --type-list

Repository: superset-sh/superset

Length of output: 453


🏁 Script executed:

# Since ai-chat is workspace:*, let's check if it needs to be created or if there's a setup step
cat package.json | grep -A 20 scripts

Repository: superset-sh/superset

Length of output: 1476


🏁 Script executed:

# Check if MessageRow might be defined locally in mobile app
find apps/mobile -name "*.ts" -o -name "*.tsx" | xargs grep -l "interface MessageRow\|type MessageRow" 2>/dev/null

Repository: superset-sh/superset

Length of output: 131


🏁 Script executed:

# Check the mobile lib directory
ls -la apps/mobile/lib/

Repository: superset-sh/superset

Length of output: 630


🏁 Script executed:

# Look in the entire mobile app directory for any chat-related types
find apps/mobile -name "*.ts" -o -name "*.tsx" | xargs grep "createdAt" 2>/dev/null | head -20

Repository: superset-sh/superset

Length of output: 452


🏁 Script executed:

# Since the package doesn't exist, let's check if there's a types file or declaration
find apps/mobile -name "*.d.ts" | head -20

Repository: superset-sh/superset

Length of output: 123


Add date type normalization before formatting.

The message.createdAt is serialized as an ISO string (see apps/mobile/lib/streams/client.ts where createdAt: string and ChatScreen.tsx line 45 where createdAt: new Date().toISOString()), but formatTime() expects a Date object. Passing a string directly to toLocaleTimeString() will throw a TypeError at runtime.

Suggested fix
-				<Text className={`text-xs ${textColor} opacity-50 mt-1`}>
-					{formatTime(message.createdAt)}
-				</Text>
+				<Text className={`text-xs ${textColor} opacity-50 mt-1`}>
+					{formatTime(
+						message.createdAt instanceof Date
+							? message.createdAt
+							: new Date(message.createdAt)
+					)}
+				</Text>
🤖 Prompt for AI Agents
In
`@apps/mobile/screens/`(authenticated)/chat/[sessionId]/components/ChatMessage/ChatMessage.tsx
around lines 25 - 36, The formatTime function currently assumes a Date object
but message.createdAt is an ISO string; update formatTime (and its usages) to
normalize the input (e.g., accept date: string | Date) and convert strings to a
Date before calling toLocaleTimeString so you never call toLocaleTimeString on a
string; locate the formatTime function in ChatMessage.tsx and the call passing
message.createdAt and ensure you create a Date instance when needed (handle
null/invalid values defensively).

Comment on lines +29 to +38
const {
data: sessions = [],
isLoading,
refetch,
isRefetching,
} = useQuery({
queryKey: ["sessions"],
queryFn: listSessions,
enabled: !!streamsUrl,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "ChatListScreen.tsx" | head -5

Repository: superset-sh/superset

Length of output: 125


🏁 Script executed:

cat -n apps/mobile/screens/authenticated/chat/ChatListScreen.tsx | head -100

Repository: superset-sh/superset

Length of output: 153


🏁 Script executed:

cat -n "apps/mobile/screens/(authenticated)/chat/ChatListScreen.tsx" | head -100

Repository: superset-sh/superset

Length of output: 3722


🏁 Script executed:

cat -n "apps/mobile/screens/(authenticated)/chat/ChatListScreen.tsx" | sed -n '100,220p'

Repository: superset-sh/superset

Length of output: 3861


Handle useQuery errors explicitly instead of silencing them as empty state.

The listSessions query at lines 29–38 doesn't destructure the error state or log failures, so when the query fails, sessions falls back to [] and the UI shows "No chats yet" instead of indicating the actual problem. This violates the coding guideline to never swallow errors silently.

Extract the error property, add an onError callback with context logging, and display an error UI with a retry button in the ListEmptyComponent (lines 179–193) when error exists.

Proposed fix
const {
    data: sessions = [],
    isLoading,
+   error,
    refetch,
    isRefetching,
} = useQuery({
    queryKey: ["sessions"],
    queryFn: listSessions,
    enabled: !!streamsUrl,
+   onError: (err) => {
+       console.error("[chat-list] Failed to load sessions:", err);
+   },
});

...

ListEmptyComponent={
    <View className="flex-1 items-center justify-center py-20">
-       {isLoading ? (
+       {isLoading ? (
            <Text className="text-muted-foreground">Loading chats...</Text>
+       ) : error ? (
+           <View className="items-center">
+               <Text className="text-destructive">
+                   Failed to load chats
+               </Text>
+               <Button className="mt-4" onPress={() => refetch()}>
+                   <Text>Retry</Text>
+               </Button>
+           </View>
        ) : (
            <View className="items-center">
                <MessageSquare size={48} color="#9ca3af" />
                <Text className="text-muted-foreground mt-4">
                    No chats yet
                </Text>
                <Button className="mt-4" onPress={() => setShowNewChat(true)}>
                    <Text>Start a Chat</Text>
                </Button>
            </View>
        )}
    </View>
}
🤖 Prompt for AI Agents
In `@apps/mobile/screens/`(authenticated)/chat/ChatListScreen.tsx around lines 29
- 38, Destructure the error from the useQuery call that uses queryFn:
listSessions (i.e., add error to the returned fields) and add an onError
callback to that useQuery to log the failure (e.g., console.error or your app
logger) with context; then update the ListEmptyComponent to render an error
state when that error exists (show a user-facing message and a Retry button that
calls refetch) instead of silently showing "No chats yet", ensuring you
reference the same useQuery variables (error, isLoading, refetch, isRefetching)
and the list's ListEmptyComponent to implement the retry UI.

@Kitenite

Copy link
Copy Markdown
Member Author

Closing — stale and conflicting, depends on closed PR.

@Kitenite Kitenite closed this Feb 17, 2026
@Kitenite
Kitenite deleted the split-ai-chat/mobile branch February 19, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant