Skip to content
Merged
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
4 changes: 2 additions & 2 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8523,7 +8523,7 @@ paths:
in: query
deprecated: true
x-deprecation-date: '2026-12-01'
x-sunset: '2027-12-01'
x-sunset: '2027-12-02'
description: 'Deprecated: send the actions in a body with readBotApp (POST /api/v2/organizations/{organizationId}/bots/{botId}/apps/{appId}/read) instead. Fifty actions of 300 characters make an address longer than proxies carry. Actions of the app the Bot needs, written <app id>/<action name>, at most 50. One the app doesn''t offer is left out.'
style: form
explode: false
Expand Down Expand Up @@ -23158,7 +23158,7 @@ paths:
summary: Read the titles of a person's recordings (deprecated)
deprecated: true
x-deprecation-date: '2026-12-01'
x-sunset: '2027-12-01'
x-sunset: '2027-12-02'
description: 'Deprecated: send the ids in a body with readRecordingTitles (POST /api/v2/organizations/{organizationId}/people/{personId}/recording-titles/read) instead, so no list of ids rides in the address. Return the title of each recording named, by the id the backend gives it, so a proposal''s evidence can name the recordings it was learned from. A recording that isn''t the person''s is left out. The person themselves or an administrator may read them.'
x-openbot-singleton: true
security:
Expand Down
2 changes: 1 addition & 1 deletion api/openapi/bot-grants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ paths:
in: query
deprecated: true
x-deprecation-date: 2026-12-01
x-sunset: 2027-12-01
x-sunset: 2027-12-02
description: >-
Deprecated: send the actions in a body with readBotApp (POST
/api/v2/organizations/{organizationId}/bots/{botId}/apps/{appId}/read)
Expand Down
2 changes: 1 addition & 1 deletion api/openapi/learning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ paths:
summary: Read the titles of a person's recordings (deprecated)
deprecated: true
x-deprecation-date: 2026-12-01
x-sunset: 2027-12-01
x-sunset: 2027-12-02
description: >-
Deprecated: send the ids in a body with readRecordingTitles (POST
/api/v2/organizations/{organizationId}/people/{personId}/recording-titles/read)
Expand Down
11 changes: 11 additions & 0 deletions mobile/app/(tabs)/(account)/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
IconBell,
IconBook,
IconBrain,
IconBug,
IconBuilding,
IconChecks,
IconClock,
Expand All @@ -27,6 +28,7 @@ import {
} from "../../../src/icons";
import { unregisterPush } from "../../../src/notifications";
import { queries } from "../../../src/queries";
import { useShareDetails } from "../../../src/share-details";
import { useFocusRefresh } from "../../../src/use-focus-refresh";
import { useLoad } from "../../../src/use-load";

Expand Down Expand Up @@ -62,6 +64,7 @@ const EVERY_BOT: Part[] = [
export default function Account() {
const { data: session } = authClient.useSession();
const [busy, setBusy] = useState(false);
const shareDetails = useShareDetails();
const [error, setError] = useState("");
// The organization worked in, said on its row.
const organizations = useLoad(queries.organizations(), Boolean(session));
Expand Down Expand Up @@ -136,6 +139,14 @@ export default function Account() {
<ListHeading>Every Bot</ListHeading>
{EVERY_BOT.map(row)}
<View className="pt-7">
{/* A problem that showed no error: the app and the phone, to paste into a bug report. */}
<SettingRow
icon={IconBug}
title="Report a problem"
value="Share this app's details with your report"
chevron={false}
onPress={() => shareDetails()}
/>
<SettingRow
icon={IconLogout}
title={busy ? "Signing out…" : "Sign out"}
Expand Down
29 changes: 29 additions & 0 deletions mobile/app/conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ import {
stepLines,
} from "../src/run-steps";
import { connectAiRouteFor } from "../src/setup";
import { useShareDetails } from "../src/share-details";
import { shownMessages } from "../src/shown-messages";
import { useLoad } from "../src/use-load";
import { watchConversationLive } from "../src/watch-conversation";
Expand Down Expand Up @@ -1699,6 +1700,7 @@ const MessageLine = memo(function MessageLine({
text="This reply stopped before it finished."
/>
<ConnectAi reasons={[message.text, message.reason]} />
<FailedReplyDetails message={message} />
</View>
);
if (message.declined && message.text)
Expand Down Expand Up @@ -1828,6 +1830,33 @@ const ApprovalHere = memo(function ApprovalHere({
);
});

/**
* "Share details" under a reply that stopped: why it stopped, and the run or the message the server finds it by. A failure the run said live is drawn as `error:<run>` (../src/live-run.ts).
*/
function FailedReplyDetails({ message }: { message: ConversationMessage }) {
const share = useShareDetails();
const runId = message.id.startsWith("error:")
? message.id.slice("error:".length)
: undefined;
// A failure the run said live is its error. A failed reply the server keeps may hold the start of what the Bot
// wrote, so only its reason goes: what anybody wrote stays out of a report (../src/error-details.ts).
const why = (runId ? message.text : message.reason)?.trim();
return (
<Text
accessibilityRole="button"
onPress={() =>
share(why || "This reply stopped before it finished.", {
...(runId ? { runId } : { messageId: message.id }),
})
}
variant="caption"
className="self-start pl-[22px] font-medium text-foreground underline"
>
Share details
</Text>
);
}

/**
* "Connect your AI", under a reply that failed because no AI is connected (the server's own sentence, ../src/setup.ts),
* to the screen that connects one. Under any other failure, nothing.
Expand Down
16 changes: 16 additions & 0 deletions mobile/src/components/notice.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import type { ReactNode } from "react";
import { View } from "react-native";
import { IconAlertCircle, IconAlertTriangle, IconInfoCircle } from "../icons";
import { useShareDetails } from "../share-details";
import { cn } from "./cn";
import { Icon } from "./icon";
import { Text } from "./text";

/**
* A line that says something went wrong, or needs the person, and what to do next. `danger` is
* for what failed; `warning` for what waits on them; `info` says no color at all.
*
* What failed offers "Share details" under it (../share-details.ts): the error, the screen and the app, for a bug
* report. `details={false}` leaves it off, for a failure the person fixes themselves.
*/
export function Notice({
tone = "danger",
message,
action,
details = true,
}: {
tone?: "danger" | "warning" | "info";
message?: string;
action?: ReactNode;
details?: boolean;
}) {
const share = useShareDetails();
if (!message) return null;
return (
<View
Expand Down Expand Up @@ -51,6 +58,15 @@ export function Notice({
<View className="flex-1 gap-2">
<Text className="text-sm leading-5">{message}</Text>
{action}
{tone === "danger" && details ? (
<Text
accessibilityRole="button"
onPress={() => share(message)}
className="self-start font-medium text-foreground text-sm underline"
>
Share details
</Text>
) : null}
</View>
</View>
);
Expand Down
83 changes: 83 additions & 0 deletions mobile/src/error-details.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* What a person sends us when something in OpenBot Mobile goes wrong: what failed, where, on which release and
* build, on which phone, and against which OpenBot. Shared from "Share details" under an error (../src/components/
* notice.tsx, a failed reply in app/conversation.tsx) and from Account's "Report a problem".
*
* Only what finds the failure on the server: ids, never what anybody wrote. A screen's address keeps the ids it was
* opened with (`ID_PARAMS`) and drops the rest, which can carry a draft message or a sign-in's code. No keys or
* tokens are in reach of it. It imports nothing, so it can be tested without a phone.
*/

/** The address parameters that only name something, and are what the server finds a failure by. */
export const ID_PARAMS: Record<string, string> = {
channelId: "Conversation",
botId: "Bot",
agentId: "Bot",
routineId: "Routine",
requestId: "Approval",
appId: "App",
};

export type DetailsContext = {
/** The screen's path, as Expo Router names it. */
screen?: string;
/** The screen's address parameters; only those in `ID_PARAMS` are kept. */
params?: Record<string, unknown>;
/** The run a failed reply came from. */
runId?: string;
/** A failed reply the server keeps. */
messageId?: string;
};

export type DetailsEnvironment = {
/** The OpenBot release the app was built from (../src/release.ts). */
release?: string;
/** The store version and build. */
appVersion?: string | null;
build?: string | null;
/** The JavaScript update running, where it is not the one the build shipped with. */
updateId?: string | null;
os: string;
osVersion: string | number;
device?: string | null;
/** The OpenBot the phone is signed in to. */
server: string;
at: Date;
};

/** The report, as plain text: the error's own line first, then one fact a line. */
export function detailsText(
error: string | undefined,
context: DetailsContext,
environment: DetailsEnvironment,
): string {
const ids: string[] = [];
const named = new Set<string>();
for (const [key, label] of Object.entries(ID_PARAMS)) {
const value = context.params?.[key];
if (typeof value !== "string" || !value.trim()) continue;
const line = `${label}: ${value.trim()}`;
if (named.has(line)) continue;
named.add(line);
ids.push(line);
}
const app = [
environment.appVersion,
environment.build ? `(${environment.build})` : undefined,
]
.filter(Boolean)
.join(" ");
return [
...(error?.trim() ? [`Error: ${error.trim()}`] : []),
...(context.screen ? [`Screen: ${context.screen}`] : []),
...ids,
...(context.runId ? [`Run: ${context.runId}`] : []),
...(context.messageId ? [`Message: ${context.messageId}`] : []),
`OpenBot: ${environment.release ?? "version not known"}`,
...(app ? [`App: ${app}`] : []),
...(environment.updateId ? [`Update: ${environment.updateId}`] : []),
`Phone: ${[environment.device, `${environment.os} ${environment.osVersion}`].filter(Boolean).join(", ")}`,
`Server: ${environment.server}`,
`When: ${environment.at.toISOString()}`,
].join("\n");
}
1 change: 1 addition & 0 deletions mobile/src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export { default as IconBrandGoogle } from "@tabler/icons-react-native/IconBrand
export { default as IconBrandSlack } from "@tabler/icons-react-native/IconBrandSlack";
export { default as IconBrandTeams } from "@tabler/icons-react-native/IconBrandTeams";
export { default as IconBrandWindows } from "@tabler/icons-react-native/IconBrandWindows";
export { default as IconBug } from "@tabler/icons-react-native/IconBug";
export { default as IconBuilding } from "@tabler/icons-react-native/IconBuilding";
export { default as IconCheck } from "@tabler/icons-react-native/IconCheck";
export { default as IconChecks } from "@tabler/icons-react-native/IconChecks";
Expand Down
42 changes: 42 additions & 0 deletions mobile/src/share-details.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* "Share details": the phone's share sheet with ./error-details.ts's report in it. The sheet has Copy, and Slack or
* Mail where the phone has them, so a person can send it where we'll see it. React Native's own Share, so it needs
* no new native module and reaches installed apps in an update.
*/
import Constants from "expo-constants";
import * as Device from "expo-device";
import { useGlobalSearchParams, usePathname } from "expo-router";
import * as Updates from "expo-updates";
import { useCallback } from "react";
import { Platform, Share } from "react-native";
import { serverUrl } from "./auth";
import { type DetailsContext, detailsText } from "./error-details";
import { RELEASE } from "./release";

/** The report about `error` (or none, for a problem that showed no error), with what the phone knows now. */
export function details(error: string | undefined, context: DetailsContext) {
return detailsText(error, context, {
release: RELEASE,
appVersion: Constants.nativeAppVersion,
build: Constants.nativeBuildVersion,
updateId: Updates.isEmbeddedLaunch ? null : Updates.updateId,
os: Platform.OS,
osVersion: Platform.Version,
device: Device.modelName,
server: serverUrl,
at: new Date(),
});
}

/** Shares the report from the screen it is pressed on, with that screen's ids. */
export function useShareDetails() {
const screen = usePathname();
const params = useGlobalSearchParams();
return useCallback(
(error?: string, about: Pick<DetailsContext, "runId" | "messageId"> = {}) =>
void Share.share({
message: details(error, { screen, params, ...about }),
}).catch(() => {}),
[screen, params],
);
}
77 changes: 77 additions & 0 deletions mobile/tests/error-details.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* "Share details" sends what finds a failure on the server, and nothing anybody wrote: a screen's ids are kept, a
* draft message or a sign-in's code in its address is not.
*/
import { expect, test } from "bun:test";
import { detailsText } from "../src/error-details";

const phone = {
release: "1.2.4",
appVersion: "1.2.4",
build: "57",
updateId: "0b9e5a52-1c1f-4a07-9c4b-1a5f3b7e9d10",
os: "ios",
osVersion: "27.2.1",
device: "iPhone Duo",
server: "https://cloud.openbot.ai",
at: new Date("2026-12-01T23:51:55.000Z"),
};

test("a failed reply names its conversation, its run, the app and the phone", () => {
expect(
detailsText(
"fetch failed",
{
screen: "/conversation",
params: { channelId: "conv_1", agentId: "agent_0ac6a0a8" },
runId: "run_9",
},
phone,
),
).toBe(
[
"Error: fetch failed",
"Screen: /conversation",
"Conversation: conv_1",
"Bot: agent_0ac6a0a8",
"Run: run_9",
"OpenBot: 1.2.4",
"App: 1.2.4 (57)",
"Update: 0b9e5a52-1c1f-4a07-9c4b-1a5f3b7e9d10",
"Phone: iPhone Duo, ios 27.2.1",
"Server: https://cloud.openbot.ai",
"When: 2026-12-01T23:51:55.000Z",
].join("\n"),
);
});

test("what a person wrote, or a sign-in's code, never leaves in the address", () => {
const text = detailsText(
"Couldn't send your message.",
{
screen: "/conversation",
params: { channelId: "conv_1", draft: "my secret plan", code: "abc123" },
},
phone,
);
expect(text).toContain("Conversation: conv_1");
expect(text).not.toContain("my secret plan");
expect(text).not.toContain("abc123");
});

test("a problem that showed no error still says the app, the phone and the server", () => {
const text = detailsText(
undefined,
{},
{ ...phone, release: undefined, build: null, updateId: null, device: null },
);
expect(text).toBe(
[
"OpenBot: version not known",
"App: 1.2.4",
"Phone: ios 27.2.1",
"Server: https://cloud.openbot.ai",
"When: 2026-12-01T23:51:55.000Z",
].join("\n"),
);
});
Loading
Loading