Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
3ed7b94
refactor(db): rename channel_badge_counts to badge_counts (general pu…
iscekic Apr 29, 2026
e8d062c
feat(db): migration to rename badge_counts and reset rows
iscekic Apr 29, 2026
20b9b3b
feat(notifications): add badge-bucket key builders
iscekic Apr 29, 2026
1bb97c6
chore(notifications): add EVENT_SERVICE binding, drop STREAM_CHAT_API…
iscekic Apr 29, 2026
d87c0fb
chore(notifications): add vitest scaffold
iscekic Apr 29, 2026
2a621db
feat(notifications): rewrite NotificationChannelDO around dispatchPush
iscekic Apr 29, 2026
26fccf5
chore(notifications): drop orphan badgeBucketForInstance helper
iscekic Apr 29, 2026
7fad879
feat(notifications): add sendPushForConversation WorkerEntrypoint RPC
iscekic Apr 29, 2026
f6e1848
chore(notifications): delete Stream webhook route
iscekic Apr 29, 2026
3c7c82e
chore(notifications): type EVENT_SERVICE RPC and enable cloudflare:te…
iscekic Apr 29, 2026
227b90e
feat(event-service): add kiloclaw event-context helpers; migrate kilo…
iscekic Apr 29, 2026
87f0fab
feat(kilo-chat): add fetchSandboxLabel helper
iscekic Apr 29, 2026
822d327
chore(kilo-chat): add NOTIFICATIONS service binding
iscekic Apr 29, 2026
372f0a0
feat(kilo-chat): publish push on message.created via NOTIFICATIONS RPC
iscekic Apr 29, 2026
52fe8a6
chore(notifications): drop orphan stream-chat dep, refresh worker typ…
iscekic Apr 29, 2026
4e95291
fix(notifications): named entrypoint export, retry-safe badge, alarm-…
iscekic Apr 29, 2026
4faf0dd
fix(notifications): close two cleanup-alarm leaks
iscekic Apr 29, 2026
8d7b9d7
refactor(event-service): compose presence contexts from kiloclaw helpers
iscekic Apr 29, 2026
893b7f1
feat(web): add kiloChat.getToken tRPC procedure
iscekic Apr 29, 2026
a35c98c
refactor(web): use kiloclaw-context helpers for event subscriptions
iscekic Apr 29, 2026
a43585d
feat(web): lift EventServiceClient to global provider
iscekic Apr 29, 2026
e98f370
feat(web): add usePresenceSubscription primitive
iscekic Apr 29, 2026
6bfbf95
refactor(web): collapse kilo-chat event subscriptions into usePresenc…
iscekic Apr 29, 2026
832e2b7
feat(web): subscribe to /presence/web while tab is visible
iscekic Apr 29, 2026
99b52d5
feat(web): subscribe to /presence/kiloclaw/{sandboxId} on instance views
iscekic Apr 29, 2026
bdb99c6
refactor(web): extract useDocumentVisible primitive
iscekic Apr 29, 2026
405b185
feat(web): subscribe to conversation presence while tab visible
iscekic Apr 29, 2026
4429bdf
style(web): reflow useDocumentVisible useState init to one line
iscekic Apr 29, 2026
eca983e
refactor(web): tighten presence hook + kilo-chat router contract
iscekic Apr 29, 2026
7edca1a
fix(event-service): refcount subscribe/unsubscribe by context
iscekic Apr 29, 2026
67e0fe3
chore(mobile): add EXPO_PUBLIC_KILO_CHAT_URL and EXPO_PUBLIC_EVENT_SE…
iscekic Apr 29, 2026
7b2d7fa
chore(mobile): add kilo-chat workspace deps
iscekic Apr 29, 2026
0735765
feat(mobile): add kilo-chat token getter with caching
iscekic Apr 29, 2026
4294250
feat(mobile): add useCurrentUserId from JWT sub
iscekic Apr 29, 2026
4081c29
feat(mobile): add KiloChatProvider
iscekic Apr 29, 2026
57448bd
feat(mobile): add useKiloChatClient and useEventServiceClient hooks
iscekic Apr 29, 2026
257f381
fix(mobile): fix lint errors in kilo-chat token getter
iscekic Apr 29, 2026
5844aaf
fix(mobile): fix lint errors in useCurrentUserId hook
iscekic Apr 29, 2026
825d1ac
fix(mobile): fix lint errors in useKiloChatClient hook
iscekic Apr 29, 2026
fe060dd
feat(mobile): mount KiloChatProvider in (app) layout
iscekic Apr 29, 2026
029c69a
fix(kilo-chat): assert non-null in base64urlEncode loop
iscekic Apr 29, 2026
f1eb38c
fix(mobile): share kilo-chat token cache + handle fetch errors
iscekic Apr 29, 2026
ecf29a1
fix(mobile): tie kilo-chat token cache to auth token, decode kiloUserId
iscekic Apr 30, 2026
d73befb
fix(mobile): read auth token at call time, not at hook render
iscekic Apr 30, 2026
b89c4d9
feat(mobile): add usePresenceSubscription primitive
iscekic Apr 30, 2026
87a74ed
feat(mobile): subscribe to /presence/app while app is active
iscekic Apr 30, 2026
7e20f1c
feat(mobile): add useInstancePresence hook
iscekic Apr 30, 2026
6d4e6c2
feat(mobile): add useConversationPresence hook
iscekic Apr 30, 2026
4898f43
fix(mobile): fix lint errors in presence hooks
iscekic Apr 30, 2026
1a6b241
feat(mobile): add useEventSubscription primitive
iscekic Apr 30, 2026
f0563e8
feat(mobile): add useInstanceEventSubscription
iscekic Apr 30, 2026
b939c3f
fix(mobile): apply curly/switch-case-braces lint rules to event hooks
iscekic Apr 30, 2026
d40b216
feat(kilo-chat-hooks): create shared package; extract useConversations
iscekic Apr 30, 2026
c829254
feat(kilo-chat-hooks): extract useMessages — base query + optimistic …
iscekic Apr 30, 2026
aa560af
feat(kilo-chat-hooks): useMessages adds edit/delete/react mutations
iscekic Apr 30, 2026
1dd065a
feat(kilo-chat-hooks): extract useMessageCacheUpdater into shared pac…
iscekic Apr 30, 2026
ad591d9
feat(mobile): wire shared kilo-chat-hooks + platform adapters
iscekic Apr 30, 2026
66713ba
fix(kilo-chat-hooks): centralize query keys; tighten event-subscripti…
iscekic Apr 30, 2026
ffeb4b6
fix(mobile): subscribe to conversation.* events on instance context
iscekic Apr 30, 2026
c259c95
chore(mobile): add @shopify/flash-list dependency
iscekic Apr 30, 2026
41bb565
chore(mobile): add EXPO_PUBLIC_KILO_CHAT_URL and EXPO_PUBLIC_EVENT_SE…
iscekic Apr 30, 2026
5fd8c69
feat(mobile): add EmptyConversationList
iscekic Apr 30, 2026
a4c1b99
feat(mobile): add ConversationHeader
iscekic Apr 30, 2026
e3b7d04
feat(mobile): add TypingIndicator placeholder
iscekic Apr 30, 2026
0f910d6
feat(mobile): add MessageInput
iscekic Apr 30, 2026
682e87b
feat(mobile): add MessageBubble
iscekic Apr 30, 2026
a0f8c84
feat(mobile): add MessageList
iscekic Apr 30, 2026
497613a
feat(mobile): add ConversationScreen
iscekic Apr 30, 2026
0d78ce7
feat(mobile): add ConversationListScreen
iscekic Apr 30, 2026
1bf1b34
fix(mobile): address review feedback on kilo-chat components
iscekic Apr 30, 2026
fe52d37
Merge remote-tracking branch 'origin/feat/kilo-chat-migration-pr1' in…
iscekic Apr 30, 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: 2 additions & 0 deletions apps/mobile/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ CLOUD_AGENT_WS_URL=wss://cloud-agent-next.kilosessions.ai
SESSION_INGEST_WS_URL=wss://ingest.kilosessions.ai
APPSFLYER_DEV_KEY=jnoVs6KzXanpbKrqXckPu9
APPSFLYER_APP_ID=6761193135
EXPO_PUBLIC_KILO_CHAT_URL=https://kilo-chat.kilosessions.ai
EXPO_PUBLIC_EVENT_SERVICE_URL=wss://event-service.kilosessions.ai
1 change: 1 addition & 0 deletions apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@rn-primitives/portal": "^1.3.0",
"@rn-primitives/slot": "^1.2.0",
"@sentry/react-native": "~7.11.0",
"@shopify/flash-list": "2.0.2",
"@tailwindcss/postcss": "^4.2.2",
"@tanstack/react-query": "catalog:",
"@trpc/client": "catalog:",
Expand Down
15 changes: 15 additions & 0 deletions apps/mobile/src/components/kilo-chat/conversation-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ScreenHeader } from '@/components/screen-header';
import { Text } from '@/components/ui/text';

type Props = { title: string; subtitle?: string };

export function ConversationHeader({ title, subtitle }: Props) {
return (
<ScreenHeader
title={title}
headerRight={
subtitle ? <Text className="text-sm text-muted-foreground">{subtitle}</Text> : undefined
}
/>
);
}
126 changes: 126 additions & 0 deletions apps/mobile/src/components/kilo-chat/conversation-list-screen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { FlashList } from '@shopify/flash-list';
import { type Href, useRouter } from 'expo-router';
import { Pressable, View } from 'react-native';
import Animated, { FadeIn } from 'react-native-reanimated';

import { ScreenHeader } from '@/components/screen-header';
import { Skeleton } from '@/components/ui/skeleton';
import { Text } from '@/components/ui/text';
import { timeAgo } from '@/lib/utils';

import { EmptyConversationList } from './empty-conversation-list';
import { useKiloChatClient } from './hooks/use-kilo-chat-client';
import { useConversations, useCreateConversation } from './hooks/use-conversations';
import { useInstanceEventSubscription } from './hooks/use-instance-event-subscription';
import { useInstancePresence } from './hooks/use-instance-presence';

type Props = {
sandboxId: string;
sandboxLabel: string;
};

type ConversationItem = {
conversationId: string;
title: string | null;
lastActivityAt: number | null;
lastReadAt: number | null;
joinedAt: number;
};

type ConversationRowProps = {
item: ConversationItem;
onPress: (id: string) => void;
};

function ConversationRow({ item, onPress }: ConversationRowProps) {
const hasUnread =
item.lastActivityAt !== null &&
(item.lastReadAt === null || item.lastReadAt < item.lastActivityAt);

return (
<Pressable
className="flex-row items-center gap-3 px-4 py-3 active:opacity-80"
onPress={() => {
onPress(item.conversationId);
}}
>
<View className="flex-1">
<Text className="text-base font-medium text-foreground" numberOfLines={1}>
{item.title ?? 'Untitled conversation'}
</Text>
{item.lastActivityAt !== null ? (
<Text className="mt-0.5 text-sm text-muted-foreground">
{timeAgo(new Date(item.lastActivityAt))}
</Text>
) : null}
</View>
{hasUnread ? (
<View className="h-2.5 w-2.5 rounded-full bg-primary" accessibilityLabel="Unread" />
) : (
// Reserve space so rows stay the same width whether the dot is shown or not
<View className="h-2.5 w-2.5" />
)}
</Pressable>
);
}

export function ConversationListScreen({ sandboxId, sandboxLabel }: Props) {
const router = useRouter();
const client = useKiloChatClient();
const listQuery = useConversations(client, sandboxId);
const createConversation = useCreateConversation(client);

const conversations = listQuery.data?.conversations ?? [];
const isFetchingNextPage = listQuery.isFetchingNextPage;
const fetchNextPage = listQuery.fetchNextPage;

useInstanceEventSubscription(sandboxId);
useInstancePresence(sandboxId);

function handleRowPress(conversationId: string) {
// Route lands in PR 5d (Task 47)
router.push(`/(app)/chat/${sandboxId}/${conversationId}` as Href);
}

function handleCreateAndNavigate() {
createConversation.mutate(
{ sandboxId },
{
onSuccess: result => {
// Route lands in PR 5d (Task 47)
router.push(`/(app)/chat/${sandboxId}/${result.conversationId}` as Href);
},
}
);
}

return (
<View className="flex-1">
<ScreenHeader title={sandboxLabel} />
<Animated.View entering={FadeIn.duration(200)} className="flex-1">
<FlashList
data={conversations}
keyExtractor={c => c.conversationId}
renderItem={({ item }) => <ConversationRow item={item} onPress={handleRowPress} />}
ListEmptyComponent={
<EmptyConversationList
onStart={handleCreateAndNavigate}
isStarting={createConversation.isPending}
/>
}
ListFooterComponent={
isFetchingNextPage ? (
<View className="px-4 py-3">
<Skeleton className="h-12 w-full rounded-md" />
</View>
) : null
}
onEndReached={() => {
void fetchNextPage();
}}
onEndReachedThreshold={0.5}
/>
</Animated.View>
</View>
);
}
72 changes: 72 additions & 0 deletions apps/mobile/src/components/kilo-chat/conversation-screen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import * as Crypto from 'expo-crypto';
import { useCallback } from 'react';
import { KeyboardAvoidingView, Platform, View } from 'react-native';
import { useFocusEffect } from 'expo-router';

import { ConversationHeader } from './conversation-header';
import { MessageInput } from './message-input';
import { MessageList } from './message-list';
import { TypingIndicator } from './typing-indicator';
import { useConversationPresence } from './hooks/use-conversation-presence';
import { useKiloChatClient } from './hooks/use-kilo-chat-client';
import { useMarkRead } from './hooks/use-mark-read';
import { useMessages, useSendMessage } from './hooks/use-messages';
import { useCurrentUserId } from './hooks/use-current-user-id';

type Props = { sandboxId: string; conversationId: string; conversationTitle: string };

export function ConversationScreen({ sandboxId, conversationId, conversationTitle }: Props) {
const client = useKiloChatClient();
const currentUserId = useCurrentUserId();

const messagesQuery = useMessages(client, conversationId);
const messages = messagesQuery.data?.messages ?? [];
const hasOlder = messagesQuery.hasNextPage;
const fetchOlder = useCallback(() => {
if (messagesQuery.hasNextPage && !messagesQuery.isFetchingNextPage) {
void messagesQuery.fetchNextPage();
}
}, [messagesQuery]);

const sendMutation = useSendMessage(client, conversationId, currentUserId ?? '');
const handleSend = useCallback(
(text: string) => {
sendMutation.mutate({
conversationId,
content: [{ type: 'text', text }],
clientId: Crypto.randomUUID(),
});
},
[sendMutation, conversationId]
);

useConversationPresence(sandboxId, conversationId);

const markRead = useMarkRead();
useFocusEffect(
useCallback(() => {
markRead(sandboxId, conversationId);
// Active-conversation suppression wiring added in PR 5d (Task 50).
}, [sandboxId, conversationId, markRead])
);

return (
<View className="flex-1">
<ConversationHeader title={conversationTitle} />
<KeyboardAvoidingView
className="flex-1"
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
>
<MessageList
messages={messages}
conversationId={conversationId}
currentUserId={currentUserId}
fetchOlder={fetchOlder}
hasOlder={hasOlder}
/>
<TypingIndicator isTyping={false} />
<MessageInput onSend={handleSend} disabled={sendMutation.isPending} />
</KeyboardAvoidingView>
</View>
);
}
28 changes: 28 additions & 0 deletions apps/mobile/src/components/kilo-chat/empty-conversation-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { MessageSquarePlus } from 'lucide-react-native';
import { View } from 'react-native';

import { EmptyState } from '@/components/empty-state';
import { Button } from '@/components/ui/button';
import { Text } from '@/components/ui/text';

type Props = {
onStart: () => void;
isStarting: boolean;
};

export function EmptyConversationList({ onStart, isStarting }: Props) {
return (
<View className="flex-1 items-center justify-center px-6">
<EmptyState
icon={MessageSquarePlus}
title="No conversations yet"
description="Start your first conversation with the agent."
action={
<Button onPress={onStart} disabled={isStarting}>
<Text>{isStarting ? 'Starting…' : 'Start a conversation'}</Text>
</Button>
}
/>
</View>
);
}
Loading