Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f51cab9
feat(kilo-app): add stream-chat-react-native dependency
iscekic Mar 27, 2026
6fc58ca
feat(kilo-app): add useStreamChatCredentials hook
iscekic Mar 27, 2026
3fa5040
feat(kilo-app): add KiloClawChat component with Stream Chat integration
iscekic Mar 27, 2026
c7eb84d
feat(kilo-app): wire up chat screen with KiloClawChat component
iscekic Mar 27, 2026
a43076a
style(kilo-app): fix lint and formatting in chat files
iscekic Mar 27, 2026
666c14b
fix(kilo-app): add null guard for bot membership lookup
iscekic Mar 27, 2026
0f6f01b
revert: remove unnecessary null guard on bot membership lookup
iscekic Mar 27, 2026
21cc160
Merge branch 'main' into feature/kiloclaw-mobile-chat
iscekic Mar 27, 2026
fccb79b
chore(kilo-app): update AGENTS.md and app.config.js
iscekic Mar 27, 2026
9ef4187
fix(kilo-app): ignore netinfo peer dep in knip config
iscekic Mar 27, 2026
c841048
Merge remote-tracking branch 'origin/main' into feature/kiloclaw-mobi…
iscekic Mar 30, 2026
6dfb83b
style(kilo-app): format app.config.js
iscekic Mar 30, 2026
6c31de3
fix(kilo-app): add ascAppId for iOS App Store submission
iscekic Mar 30, 2026
13b8576
fix(kilo-app): enable noUncheckedIndexedAccess and fix type errors
iscekic Mar 30, 2026
83f8163
fix(kilo-app): fix connect/disconnect race and clear connectError on …
iscekic Mar 30, 2026
86867e3
fix(kilo-app): restore disconnectUser in cleanup to tear down WS on u…
iscekic Mar 30, 2026
0dec16c
chore(kilo-app): install stream-chat-react-native optional peer deps
iscekic Mar 30, 2026
d88d9ca
fix(kilo-app): pass empty config to react-native-share plugin
iscekic Mar 30, 2026
f90719d
chore(kilo-app): upgrade Expo SDK packages and exclude from minimumRe…
iscekic Mar 30, 2026
c87c135
fix(kilo-app): remove @stream-io/flat-list-mvcp (jcenter incompatible)
iscekic Mar 30, 2026
77ff30a
fix(kilo-app): pin lightningcss to 1.31.1 to fix CSS bundling error
iscekic Mar 30, 2026
113a244
fix: override lightningcss to 1.31.1 to fix react-native-css bundling
iscekic Mar 30, 2026
59a9963
fix(kilo-app): upgrade react-native-css to 3.0.6 to fix lightningcss …
iscekic Mar 30, 2026
237b674
fix: pin lightningcss to 1.30.1 to fix NativeWind CSS deserialization…
iscekic Mar 30, 2026
22d4cc3
chore(kilo-app): upgrade non-Expo-managed deps to latest
iscekic Mar 30, 2026
22d9d89
chore(kilo-app): upgrade @sentry/react-native from v7 to v8
iscekic Mar 30, 2026
ebc1c47
chore(kilo-app): suppress stream-chat console noise with LogBox
iscekic Mar 30, 2026
e752384
fix(kilo-app): upgrade @gorhom/bottom-sheet to fix getBoundingClientR…
iscekic Mar 30, 2026
cde24c7
revert(kilo-app): downgrade @sentry/react-native back to v7 for Expo …
iscekic Mar 30, 2026
a81a1cb
feat(kilo-app): move chat to full-screen page and fix layout
iscekic Mar 30, 2026
060e694
fix(kilo-app): fix chat input border inset and photo library crash
iscekic Mar 30, 2026
cb984ca
feat(kilo-app): add dark mode support to Stream Chat UI
iscekic Mar 30, 2026
0f7f3e0
fix(kilo-app): fix chat route name and restore LogBox suppressions
iscekic Mar 30, 2026
803c9e9
fix(kilo-app): migrate from stream-chat-react-native to stream-chat-expo
iscekic Mar 30, 2026
2bd12c3
chore(kilo-app): remove unused stream-chat peer deps and clean up kni…
iscekic Mar 30, 2026
411d8c5
chore(kilo-app): remove react-native-share, react-native-video, and s…
iscekic Mar 30, 2026
acd851f
revert(kilo-app): remove NSPhotoLibraryUsageDescription from infoPlist
iscekic Mar 30, 2026
2f51901
fix(kilo-app): use keyboardDidShow/Hide for cross-platform keyboard d…
iscekic Mar 30, 2026
29e4836
fix(kilo-app): use Stream Chat built-in KeyboardCompatibleView for ch…
iscekic Mar 31, 2026
71d333c
fix(kilo-app): apply safe area bottom inset as container padding for …
iscekic Mar 31, 2026
bbda0bf
chore(kilo-app): install stream-chat-expo peer dependencies and confi…
iscekic Mar 31, 2026
58bd21f
feat: add missing peer dep
iscekic Mar 31, 2026
3ad568c
build: remove unneeded property
iscekic Mar 31, 2026
48c7e4b
fix(kilo-app): add pnpm patch for @gorhom/bottom-sheet unstable_getBo…
iscekic Mar 31, 2026
29eecb4
fix: use expo-image as image component
iscekic Mar 31, 2026
410fc21
chore(kilo-app): remove unused useKeyboardAwareBottomInset hook
iscekic Mar 31, 2026
6b6c4c5
fix(kilo-app): fix linter error and format chat.tsx and app.config.js
iscekic Mar 31, 2026
fc08dcb
fix(kilo-app): patch stream-chat-expo video thumbnail ph:// URL error
iscekic Mar 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kilo-app/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## What This Is

Kilo App is an Expo (React Native) mobile application using Expo Router for file-based routing. It lives as a subpackage (`kilo-app/`) in the `cloud` monorepo. **This app targets iOS and Android only — never web.** Do not add `Platform.select({ web: ... })` patterns or web-specific code.
Kilo App is an Expo (React Native) mobile application using Expo Router for file-based routing. It lives as a subpackage (`kilo-app/`) in the `cloud` monorepo. **This app targets iOS and Android only — never web.** Do not add `Platform.select({ web: ... })` patterns or web-specific code. **We use dev builds, not Expo Go.**

## Tech Stack

Expand Down
4 changes: 3 additions & 1 deletion kilo-app/app.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('expo/config').ExpoConfig} */
const config = {
name: 'Kilo',
name: 'KiloClaw',
owner: 'kilocode',
slug: 'kilo-app',
version: '1.0.0',
Expand Down Expand Up @@ -59,6 +59,8 @@ const config = {
imageWidth: 100,
},
],
'react-native-share',
'react-native-video',
],
experiments: {
typedRoutes: true,
Expand Down
3 changes: 3 additions & 0 deletions kilo-app/eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"production": {
"android": {
"track": "internal"
},
"ios": {
"ascAppId": "6761193135"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion kilo-app/knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"expo-system-ui",
"postcss",
"eslint-plugin-sonarjs",
"@sentry/cli"
"@sentry/cli",
"@react-native-community/netinfo",
"react-native-nitro-modules"
],
"ignoreBinaries": ["oxfmt", "oxlint"],
"ignore": ["src/components/ui/**"],
Expand Down
14 changes: 14 additions & 0 deletions kilo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@
},
"dependencies": {
"@kilocode/trpc": "workspace:*",
"@react-native-camera-roll/camera-roll": "^7.10.2",
"@react-native-clipboard/clipboard": "^1.16.3",
"@react-native-community/netinfo": "11.5.2",
"@react-native-documents/picker": "^12.0.1",
"@rn-primitives/portal": "^1.3.0",
"@rn-primitives/slot": "^1.2.0",
"@sentry/react-native": "~7.11.0",
"@stream-io/flat-list-mvcp": "^0.10.3",
"@tailwindcss/postcss": "^4.2.1",
"@tanstack/react-query": "catalog:",
"@trpc/client": "catalog:",
Expand All @@ -48,14 +53,23 @@
"nativewind": "5.0.0-preview.3",
"react": "19.2.0",
"react-native": "0.83.2",
"react-native-blob-util": "^0.24.7",
"react-native-css": "3.0.5",
"react-native-gesture-handler": "~2.30.0",
"react-native-haptic-feedback": "^2.3.4",
"react-native-image-picker": "^8.2.1",
"react-native-nitro-modules": "^0.35.2",
"react-native-nitro-sound": "^0.2.12",
"react-native-reanimated": "4.2.1",
"react-native-safe-area-context": "~5.6.2",
"react-native-screens": "~4.23.0",
"react-native-share": "^12.2.6",
"react-native-svg": "15.15.3",
"react-native-video": "^6.19.1",
"react-native-worklets": "0.7.2",
"sonner-native": "^0.23.1",
"stream-chat": "^9.38.0",
"stream-chat-react-native": "^8.13.7",
"tailwind-merge": "^3.5.0",
"tailwindcss": "^4.2.1"
},
Expand Down
16 changes: 5 additions & 11 deletions kilo-app/src/app/(app)/(tabs)/(1_kiloclaw)/[instance-id]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import { useLocalSearchParams } from 'expo-router';
import { MessageSquare } from 'lucide-react-native';
import { View } from 'react-native';

import { EmptyState } from '@/components/empty-state';
import { ScreenHeader } from '@/components/screen-header';
import { KiloClawChat } from '@/components/kiloclaw/chat';
import { useKiloClawStatus } from '@/lib/hooks/use-kiloclaw';

export default function ChatScreen() {
const { 'instance-id': instanceId } = useLocalSearchParams<{ 'instance-id': string }>();
const { data: status } = useKiloClawStatus();
const isRunning = status?.status === 'running';

return (
<View className="flex-1 bg-background">
<ScreenHeader title="Chat" />
<View className="flex-1 items-center justify-center px-6">
<EmptyState
icon={MessageSquare}
title="Chat coming soon"
description={`Instance: ${instanceId}`}
/>
</View>
<KiloClawChat instanceId={instanceId} enabled={isRunning} />
</View>
);
}
268 changes: 268 additions & 0 deletions kilo-app/src/components/kiloclaw/chat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
import { useCallback, useEffect, useState } from 'react';
import { ActivityIndicator, Pressable, View } from 'react-native';
import { useQueryClient } from '@tanstack/react-query';
import { type Href, useRouter } from 'expo-router';
import { Settings } from 'lucide-react-native';
import { type Event, type Channel as StreamChannel, StreamChat } from 'stream-chat';
import {
Channel,
Chat,
MessageInput,
MessageList,
OverlayProvider,
} from 'stream-chat-react-native';

import { ScreenHeader } from '@/components/screen-header';
import { Text } from '@/components/ui/text';
import { useStreamChatCredentials } from '@/lib/hooks/use-kiloclaw';
import { useThemeColors } from '@/lib/hooks/use-theme-colors';
import { useTRPC } from '@/lib/trpc';

type KiloClawChatProps = {
instanceId: string;
enabled: boolean;
};

export function KiloClawChat({ instanceId, enabled }: Readonly<KiloClawChatProps>) {
const { data: creds, isLoading, error } = useStreamChatCredentials(enabled);

if (!enabled) {
return (
<ChatShell instanceId={instanceId}>
<ChatPlaceholder message="Chat is available when the machine is running." />
</ChatShell>
);
}

if (isLoading) {
return (
<ChatShell instanceId={instanceId}>
<View className="flex-1 items-center justify-center">
<ActivityIndicator />
</View>
</ChatShell>
);
}

if (error) {
return (
<ChatShell instanceId={instanceId}>
<ChatPlaceholder message="Failed to load chat. Please try again." />
</ChatShell>
);
}

if (!creds) {
return (
<ChatShell instanceId={instanceId}>
<ChatPlaceholder message="Chat requires an upgrade. Use 'Upgrade to Latest' on the dashboard." />
</ChatShell>
);
}

return (
<StreamChatUI
instanceId={instanceId}
apiKey={creds.apiKey}
userId={creds.userId}
channelId={creds.channelId}
/>
);
}

// ─── Internal components ────────────────────────────────────────────────────

function ChatShell({ instanceId, children }: { instanceId: string; children: React.ReactNode }) {
return (
<View className="flex-1 bg-background">
<ChatHeader instanceId={instanceId} />
{children}
</View>
);
}

function ChatHeader({ instanceId, botOnline }: { instanceId: string; botOnline?: boolean }) {
const router = useRouter();
const colors = useThemeColors();

const settingsButton = (
<Pressable
onPress={() => {
router.push(`/(app)/(tabs)/(1_kiloclaw)/${instanceId}/dashboard` as Href);
}}
hitSlop={12}
accessibilityLabel="Settings"
className="active:opacity-70"
>
<Settings size={20} color={colors.foreground} />
</Pressable>
);

return (
<ScreenHeader
title="Chat"
headerRight={
<View className="flex-row items-center gap-3">
{botOnline !== undefined && <BotStatusIndicator online={botOnline} />}
{settingsButton}
</View>
}
/>
);
}

function BotStatusIndicator({ online }: { online: boolean }) {
return (
<View className="flex-row items-center gap-1.5">
<View className={`h-2 w-2 rounded-full ${online ? 'bg-emerald-400' : 'bg-neutral-500'}`} />
<Text className="text-xs text-muted-foreground">{online ? 'Online' : 'Offline'}</Text>
</View>
);
}

function StreamChatUI({
instanceId,
apiKey,
userId,
channelId,
}: {
instanceId: string;
apiKey: string;
userId: string;
channelId: string;
}) {
const trpc = useTRPC();
const queryClient = useQueryClient();

// Stable token provider — stream-chat calls this when the current token expires.
const tokenProvider = useCallback(async () => {
const creds = await queryClient.fetchQuery(
trpc.kiloclaw.getStreamChatCredentials.queryOptions(undefined, {
staleTime: 0,
})
);
if (!creds?.userToken) {
throw new Error('Failed to fetch Stream Chat credentials');
}
return creds.userToken;
}, [queryClient, trpc]);

const [client, setClient] = useState<StreamChat | null>(null);
const [channel, setChannel] = useState<StreamChannel | null>(null);
const [connectError, setConnectError] = useState<string | null>(null);

useEffect(() => {
const chatClient = StreamChat.getInstance(apiKey);

let cancelled = false;
setConnectError(null);

const connect = async () => {
try {
// Await disconnect to prevent tokenManager.reset() from racing with the new connection
if (chatClient.userID) {
await chatClient.disconnectUser();
}
if (cancelled) {
return;
}
await chatClient.connectUser({ id: userId }, tokenProvider);
const ch = chatClient.channel('messaging', channelId);
await ch.watch({ presence: true });
// cancelled may change across awaits above
// eslint-disable-next-line typescript-eslint/no-unnecessary-condition
if (!cancelled) {
setClient(chatClient);
setChannel(ch);
}
} catch (error) {
if (!cancelled) {
setConnectError(error instanceof Error ? error.message : 'Failed to connect to chat.');
}
}
};

void connect();

return () => {
cancelled = true;
void chatClient.disconnectUser();
setClient(null);
setChannel(null);
};
}, [apiKey, userId, channelId, tokenProvider]);

// Bot presence tracking
const sandboxId = channelId.replace(/^default-/, '');
const botUserId = `bot-${sandboxId}`;
const botOnline = useBotOnlineStatus(client, channel, botUserId);

if (connectError) {
return (
<ChatShell instanceId={instanceId}>
<ChatPlaceholder message={connectError} />
</ChatShell>
);
}

if (!client || !channel) {
return (
<ChatShell instanceId={instanceId}>
<View className="flex-1 items-center justify-center">
<ActivityIndicator />
</View>
</ChatShell>
);
}

return (
<View className="flex-1 bg-background">
<ChatHeader instanceId={instanceId} botOnline={botOnline} />
<OverlayProvider>
<Chat client={client}>
<Channel channel={channel}>
<MessageList />
<MessageInput />
</Channel>
</Chat>
</OverlayProvider>
</View>
);
}

function useBotOnlineStatus(
client: StreamChat | null,
channel: StreamChannel | null,
botUserId: string
): boolean {
const [online, setOnline] = useState(false);

useEffect(() => {
const handlePresenceChange = (event: Event) => {
if (event.user?.id === botUserId) {
setOnline(Boolean(event.user.online));
}
};

if (client && channel) {
// Check initial state
const member = channel.state.members[botUserId];
setOnline(Boolean(member?.user?.online));
client.on('user.presence.changed', handlePresenceChange);
}

return () => {
client?.off('user.presence.changed', handlePresenceChange);
};
}, [client, channel, botUserId]);

return online;
}

function ChatPlaceholder({ message }: { message: string }) {
return (
<View className="flex-1 items-center justify-center px-6">
<Text className="text-sm text-muted-foreground text-center">{message}</Text>
</View>
);
}
2 changes: 1 addition & 1 deletion kilo-app/src/components/profile-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function CreditsCard() {
<Skeleton className="mt-1 h-3 w-48 rounded" />
) : (
expiringTotal > 0 &&
Boolean(earliestExpiry) && (
earliestExpiry != null && (
<Text className="mt-1 text-xs text-muted-foreground">
${expiringTotal.toFixed(2)} in bonus credits expiring{' '}
{parseTimestamp(earliestExpiry).toLocaleDateString(undefined, {
Expand Down
Loading
Loading