Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

feat(mobile): resolve bot inbox incidents (#38)

Leo7b55ec174842
diff --git a/apps/mobile/src/features/settings/SettingsProviderHealthRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsProviderHealthRouteScreen.tsx
index 1dc65297d..e25cb6464 100644
--- a/apps/mobile/src/features/settings/SettingsProviderHealthRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsProviderHealthRouteScreen.tsx
@@ -1,16 +1,17 @@
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { useAtomValue } from "@effect/atom-react";
-import type { EnvironmentId, SubscriptionAuthStatuses } from "@t3tools/contracts";
+import type { BotInboxItem, EnvironmentId } from "@t3tools/contracts";
import { Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { AppText as Text } from "../../components/AppText";
import { NativeStackScreenOptions } from "../../native/StackHeader";
+import { botInboxEnvironment } from "../../state/botInbox";
import { useEnvironmentQuery } from "../../state/query";
import { serverEnvironment } from "../../state/server";
import { useAtomCommand } from "../../state/use-atom-command";
-import { settingsInboxView } from "./botInbox.logic";
+import { canResolveInboxItem, settingsInboxView } from "./botInbox.logic";
import { SettingsSection } from "./components/SettingsSection";
export type SettingsProviderHealthParams = {
@@ -27,7 +28,14 @@ function Field(props: { readonly label: string; readonly value: string }) {
);
}
-function BotInbox({ items }: { readonly items: SubscriptionAuthStatuses["inbox"] }) {
+function BotInbox({
+ environmentId,
+ items,
+}: {
+ readonly environmentId: EnvironmentId;
+ readonly items: ReadonlyArray<BotInboxItem>;
+}) {
+ const resolveIncident = useAtomCommand(botInboxEnvironment.resolve);
return (
<SettingsSection title="Error inbox" card>
{items.length === 0 ? (
@@ -42,6 +50,17 @@ function BotInbox({ items }: { readonly items: SubscriptionAuthStatuses["inbox"]
<Field label="Task or routine" value={item.taskOrRoutine} />
<Field label="Last failure" value={item.lastFailure} />
<Field label="Next action" value={item.nextAction} />
+ {canResolveInboxItem(item) ? (
+ <Pressable
+ accessibilityRole="button"
+ className="self-start rounded-[12px] bg-subtle px-3 py-2"
+ onPress={() => {
+ void resolveIncident({ environmentId, input: { id: item.id } });
+ }}
+ >
+ <Text className="text-sm font-t3-medium text-foreground">Resolve</Text>
+ </Pressable>
+ ) : null}
</View>
))
)}
@@ -102,7 +121,7 @@ export function SettingsProviderHealthRouteScreen({
const query = useEnvironmentQuery(
route.params.target === "local-execution"
? null
- : serverEnvironment.subscriptionAuth({
+ : botInboxEnvironment.list({
environmentId: route.params.environmentId,
input: {},
}),
@@ -115,7 +134,7 @@ export function SettingsProviderHealthRouteScreen({
route.params.target === "local-execution" ? (
<LocalExecution environmentId={route.params.environmentId} />
) : inboxView?.kind === "ready" ? (
- <BotInbox items={inboxView.items} />
+ <BotInbox environmentId={route.params.environmentId} items={inboxView.items} />
) : null;
return (
@@ -140,7 +159,7 @@ export function SettingsProviderHealthRouteScreen({
<Text className="py-16 text-center text-sm text-danger">{inboxView.message}</Text>
) : inboxView?.kind === "loading" ? (
<Text className="py-16 text-center text-sm text-foreground-muted">
- Loading provider health…
+ Loading bot inbox…
</Text>
) : (
section
diff --git a/apps/mobile/src/features/settings/botInbox.logic.test.ts b/apps/mobile/src/features/settings/botInbox.logic.test.ts
index 6532fc5dc..4a5ed1824 100644
--- a/apps/mobile/src/features/settings/botInbox.logic.test.ts
+++ b/apps/mobile/src/features/settings/botInbox.logic.test.ts
@@ -2,7 +2,7 @@ import { BotId } from "@t3tools/contracts";
import type { BotInboxItem } from "@t3tools/client-runtime/bot-inbox";
import { describe, expect, it } from "vite-plus/test";
-import { settingsInboxView } from "./botInbox.logic";
+import { canResolveInboxItem, settingsInboxView } from "./botInbox.logic";
function incident(overrides: Partial<BotInboxItem> = {}): BotInboxItem {
return {
@@ -27,7 +27,7 @@ describe("settingsInboxView", () => {
expect(
settingsInboxView({
error: "Environment disconnected",
- data: { inbox: [incident()] },
+ data: [incident()],
}),
).toEqual({ kind: "error", message: "Environment disconnected" });
});
@@ -39,13 +39,11 @@ describe("settingsInboxView", () => {
it("drops resolved items and sorts the newest open incident first", () => {
const view = settingsInboxView({
error: null,
- data: {
- inbox: [
- incident({ id: "older" }),
- incident({ id: "resolved", status: "resolved" }),
- incident({ id: "newer", lastSeenAt: "2026-08-30T11:00:00.000Z" }),
- ],
- },
+ data: [
+ incident({ id: "older" }),
+ incident({ id: "resolved", status: "resolved" }),
+ incident({ id: "newer", lastSeenAt: "2026-08-30T11:00:00.000Z" }),
+ ],
});
expect(view).toEqual({
@@ -61,8 +59,15 @@ describe("settingsInboxView", () => {
expect(
settingsInboxView({
error: null,
- data: { inbox: [incident({ status: "resolved" })] },
+ data: [incident({ status: "resolved" })],
}),
).toEqual({ kind: "ready", items: [] });
});
});
+
+describe("canResolveInboxItem", () => {
+ it("keeps connector incidents open until their dependency recovers", () => {
+ expect(canResolveInboxItem(incident())).toBe(false);
+ expect(canResolveInboxItem(incident({ kind: "approval-request" }))).toBe(true);
+ });
+});
diff --git a/apps/mobile/src/features/settings/botInbox.logic.ts b/apps/mobile/src/features/settings/botInbox.logic.ts
index 8beea272c..597cbd8eb 100644
--- a/apps/mobile/src/features/settings/botInbox.logic.ts
+++ b/apps/mobile/src/features/settings/botInbox.logic.ts
@@ -2,7 +2,7 @@ import { selectOpenBotInboxItems, type BotInboxItem } from "@t3tools/client-runt
export type SettingsInboxQuery = {
readonly error: string | null;
- readonly data: { readonly inbox: ReadonlyArray<BotInboxItem> } | null;
+ readonly data: ReadonlyArray<BotInboxItem> | null;
};
export type SettingsInboxView =
@@ -10,6 +10,10 @@ export type SettingsInboxView =
| { readonly kind: "loading" }
| { readonly kind: "ready"; readonly items: ReadonlyArray<BotInboxItem> };
+export function canResolveInboxItem(item: BotInboxItem): boolean {
+ return item.kind === "approval-request";
+}
+
export function settingsInboxView(query: SettingsInboxQuery): SettingsInboxView {
if (query.error !== null) {
return { kind: "error", message: query.error };
@@ -17,5 +21,5 @@ export function settingsInboxView(query: SettingsInboxQuery): SettingsInboxView
if (query.data === null) {
return { kind: "loading" };
}
- return { kind: "ready", items: selectOpenBotInboxItems(query.data.inbox) };
+ return { kind: "ready", items: selectOpenBotInboxItems(query.data) };
}
diff --git a/apps/mobile/src/state/botInbox.ts b/apps/mobile/src/state/botInbox.ts
new file mode 100644
index 000000000..e716ac5d9
--- /dev/null
+++ b/apps/mobile/src/state/botInbox.ts
@@ -0,0 +1,5 @@
+import { createBotInboxEnvironmentAtoms } from "@t3tools/client-runtime/state/bot-inbox";
+
+import { connectionAtomRuntime } from "../connection/runtime";
+
+export const botInboxEnvironment = createBotInboxEnvironmentAtoms(connectionAtomRuntime);