Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 27 additions & 13 deletions apps/mobile/src/components/agents/mobile-session-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
WEB_BASE_URL,
} from '@/lib/config';
import { AUTH_TOKEN_KEY } from '@/lib/storage-keys';
import { type SendMessagePayload } from '@/lib/cloud-agent-next/types';

type CreateMobileAgentSessionManagerOptions = {
store: JotaiStore;
Expand Down Expand Up @@ -114,28 +115,41 @@ export function createMobileAgentSessionManager({
return result.token;
},
api: {
send: async payload => {
send: async input => {
await withCloudAgentDiagnostics('send', organizationId, async () => {
if (!payload.model) {
throw new Error('Model is required');
}
const input = {
cloudAgentSessionId: payload.sessionId as string,
prompt: payload.prompt,
mode: normalizeAgentMode(payload.mode),
model: payload.model,
variant: payload.variant,
const payload: SendMessagePayload = (() => {
if (input.payload.type === 'prompt') {
if (!input.payload.model) {
throw new Error('Model is required');
}
return {
type: 'prompt' as const,
prompt: input.payload.prompt,
mode: normalizeAgentMode(input.payload.mode),
model: input.payload.model,
variant: input.payload.variant,
};
}
return {
type: 'command' as const,
command: input.payload.command,
arguments: input.payload.arguments,
};
})();
const baseInput = {
cloudAgentSessionId: input.sessionId as string,
payload,
autoCommit: true,
messageId: payload.messageId,
messageId: input.messageId,
};
if (organizationId) {
await trpcClient.organizations.cloudAgentNext.sendMessage.mutate(
{ ...input, organizationId },
{ ...baseInput, organizationId },
skipBatchOptions
);
return;
}
await trpcClient.cloudAgentNext.sendMessage.mutate(input, skipBatchOptions);
await trpcClient.cloudAgentNext.sendMessage.mutate(baseInput, skipBatchOptions);
});
},
interrupt: async payload => {
Expand Down
11 changes: 7 additions & 4 deletions apps/mobile/src/components/agents/session-detail-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ export function SessionDetailContent({ sessionId }: Readonly<SessionDetailConten
}
try {
await manager.send({
prompt: text,
mode: currentMode,
model: currentModel,
variant: currentVariant || undefined,
payload: {
type: 'prompt',
prompt: text,
mode: currentMode,
model: currentModel,
variant: currentVariant || undefined,
},
});
} catch {
toast.error('Failed to send message. Please try again.');
Expand Down
9 changes: 9 additions & 0 deletions apps/storybook/src/mockData/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const mockProfiles: ProfileSummary[] = [
mcpServerCount: 2,
skillCount: 1,
agentCount: 1,
kiloCommandCount: 0,
},
{
id: 'profile-2',
Expand All @@ -149,6 +150,7 @@ export const mockProfiles: ProfileSummary[] = [
mcpServerCount: 0,
skillCount: 0,
agentCount: 0,
kiloCommandCount: 0,
},
{
id: 'profile-3',
Expand All @@ -162,6 +164,7 @@ export const mockProfiles: ProfileSummary[] = [
mcpServerCount: 1,
skillCount: 0,
agentCount: 0,
kiloCommandCount: 1,
},
{
id: 'profile-4',
Expand All @@ -175,6 +178,7 @@ export const mockProfiles: ProfileSummary[] = [
mcpServerCount: 0,
skillCount: 0,
agentCount: 0,
kiloCommandCount: 2,
},
{
id: 'profile-5',
Expand All @@ -188,6 +192,7 @@ export const mockProfiles: ProfileSummary[] = [
mcpServerCount: 0,
skillCount: 0,
agentCount: 0,
kiloCommandCount: 0,
},
];

Expand All @@ -203,6 +208,7 @@ export const mockProfileDetails: ProfileDetails = {
mcpServers: mockProfileMcpServers,
skills: mockProfileSkills,
agents: mockProfileAgents,
kiloCommands: [],
};

export const mockEmptyProfileDetails: ProfileDetails = {
Expand All @@ -217,6 +223,7 @@ export const mockEmptyProfileDetails: ProfileDetails = {
mcpServers: [],
skills: [],
agents: [],
kiloCommands: [],
};

export const mockLocalDevProfileDetails: ProfileDetails = {
Expand Down Expand Up @@ -253,6 +260,7 @@ export const mockLocalDevProfileDetails: ProfileDetails = {
mcpServers: [],
skills: [],
agents: [],
kiloCommands: [],
};

export const mockStagingProfileDetails: ProfileDetails = {
Expand Down Expand Up @@ -293,4 +301,5 @@ export const mockStagingProfileDetails: ProfileDetails = {
mcpServers: [mockProfileMcpServers[1]],
skills: [],
agents: [],
kiloCommands: [],
};
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export const ManyProfiles: Story = {
mcpServerCount: Math.floor(Math.random() * 3),
skillCount: Math.floor(Math.random() * 3),
agentCount: Math.floor(Math.random() * 2),
kiloCommandCount: 0,
}));
return <ProfileSelectorWrapper profiles={manyProfiles} />;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ export const ManyVariables: Story = {
mcpServers: [],
skills: [],
agents: [],
kiloCommands: [],
};
return <ProfileVarEditorWrapper profile={manyVarsProfile} initialTab="vars" />;
},
Expand All @@ -898,6 +899,7 @@ export const ManyCommands: Story = {
mcpServers: [],
skills: [],
agents: [],
kiloCommands: [],
};
return <ProfileVarEditorWrapper profile={manyCommandsProfile} initialTab="commands" />;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ export const ManyProfiles: Story = {
mcpServerCount: Math.floor(Math.random() * 3),
skillCount: Math.floor(Math.random() * 3),
agentCount: Math.floor(Math.random() * 2),
kiloCommandCount: 0,
}));
return <ProfilesListDialogWrapper profiles={manyProfiles} />;
},
Expand Down
Loading