diff --git a/apps/mobile/src/features/chats/KinChatScreen.tsx b/apps/mobile/src/features/chats/KinChatScreen.tsx index 9e867aff597fc..8efee985943a9 100644 --- a/apps/mobile/src/features/chats/KinChatScreen.tsx +++ b/apps/mobile/src/features/chats/KinChatScreen.tsx @@ -138,7 +138,7 @@ import { kinAgentAvatar, kinAvatarView, type KinAvatarView, - kinLevelsAgentId, + kinOwnedLeadAgentId, kinStaleNotice, } from "@t3tools/client-runtime/kin/kinScreenState"; import { useKinHostAt } from "./state/useKinHost"; @@ -233,10 +233,8 @@ function KinLiveChat(props: { inbox?._tag === "Success" ? inbox.value.value.chats.find((chat) => chat.chatId === chatId) : undefined; - const canReadLevels = useAtomValue(kinClient.levelsRead.permissionAtom(props.environmentId)); - // The owner's own lead in their direct chat: the only one they can see and stop. - const ownedAgentId = summary === undefined ? null : kinLevelsAgentId(summary, viewer.personId); - const levelsAgentId = canReadLevels ? ownedAgentId : null; + // The owner's own lead in their direct chat: the only one they can stop. + const ownedAgentId = summary === undefined ? null : kinOwnedLeadAgentId(summary, viewer.personId); const canInterrupt = useAtomValue(kinClient.leadInterrupt.permissionAtom(props.environmentId)); const canMute = useAtomValue(kinClient.mute.permissionAtom(props.environmentId)); const runMute = useAtomCommand(kinClient.mute, "Muting this chat"); @@ -274,11 +272,6 @@ function KinLiveChat(props: { ) } agentName={summary === undefined ? null : kinDirectAgentName(summary, viewer.agentNames)} - levels={ - levelsAgentId === null - ? null - : { environmentId: props.environmentId, orgId: props.orgId, agentId: levelsAgentId } - } unread={summary?.unread ?? null} mute={ environmentId === null || chatId === null || summary === undefined || !canMute @@ -421,7 +414,6 @@ function KinChatAppBar(props: { readonly presence: KinPresence | undefined; readonly tasks: string | null; readonly onBack: () => void; - readonly actions: ComponentPropsWithRef["actions"]; readonly menus: ComponentPropsWithRef["menus"]; }) { const pill = Platform.OS === "ios"; @@ -435,13 +427,7 @@ function KinChatAppBar(props: { ); return ( <> - + {/* Always set, so going back to the default size resets the bar. */} navigation.navigate("KinLevels", levels), - }, - ] - } /> {state._tag === "ready" ? ( @@ -1026,7 +994,7 @@ function KinChatFeed(props: { viewerMemberId, reactorName, ); - // The host refuses reactions on approval, level, review and deferral cards. + // The host refuses reactions on approval and deferral cards. const reactable = canReact && message.status === "posted" && @@ -1352,7 +1320,7 @@ function KinFeedMessageActions(props: { props.viewerMemberId, props.reactorName, ); - // The host refuses reactions on approval, level, review and deferral cards. + // The host refuses reactions on approval and deferral cards. const reactable = props.canReact && message.status === "posted" && diff --git a/apps/mobile/src/features/chats/KinLevelsScreen.tsx b/apps/mobile/src/features/chats/KinLevelsScreen.tsx deleted file mode 100644 index b19609b7c495a..0000000000000 --- a/apps/mobile/src/features/chats/KinLevelsScreen.tsx +++ /dev/null @@ -1,301 +0,0 @@ -import { useAtomValue } from "@effect/atom-react"; -import { useNavigation, type StaticScreenProps } from "@react-navigation/native"; -import { - EnvironmentId, - KinAgentId, - KinChatError, - KinOrgId, - type KinLevelsGetInput, -} from "@t3tools/contracts"; -import * as Cause from "effect/Cause"; -import * as Option from "effect/Option"; -import * as Schema from "effect/Schema"; -import { AsyncResult } from "effect/reactivity"; -import { useState } from "react"; -import { Alert, View } from "react-native"; - -import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator"; -import { AppBar } from "../../components/ui/AppBar"; -import { AppText as Text } from "../../components/ui/AppText"; -import { Button } from "../../components/ui/Button"; -import { EmptyState } from "../../components/ui/EmptyState"; -import { ErrorBanner } from "../../components/ui/ErrorBanner"; -import { ScreenContent } from "../../components/ui/ScreenContent"; -import { ScreenScrollView } from "../../components/ui/ScreenScrollView"; -import { appAtomRegistry } from "../../state/atom-registry"; -import { useAtomCommand } from "../../state/use-atom-command"; -import { kinClient } from "./state/kinClient"; -import { KinApprovalCard } from "./widgets/KinApprovalCard"; -import { kinChatTitle, kinDirectory } from "@t3tools/client-runtime/kin/kinScreenState"; -import { useKinHostAt } from "./state/useKinHost"; -import { - kinLevelsFailure, - kinLevelsFailureText, - kinLevelsScreenView, - type KinLevelChange, - type KinLevelsRow, -} from "@t3tools/client-runtime/kin/kinLevelsPresentation"; - -type KinLevelsParams = { - readonly environmentId: string; - readonly orgId: string; - readonly agentId: string; -}; - -const decodeEnvironmentId = Schema.decodeUnknownOption(EnvironmentId); -const decodeOrgId = Schema.decodeUnknownOption(KinOrgId); -const decodeAgentId = Schema.decodeUnknownOption(KinAgentId); -const isKinChatError = Schema.is(KinChatError); - -/** The owner's view of one lead's levels: its own, each chat's cap, the trial and open raises. */ -export function KinLevelsScreen({ route }: StaticScreenProps) { - const navigation = useNavigation(); - const environmentId = Option.getOrNull(decodeEnvironmentId(route.params.environmentId)); - const orgId = Option.getOrNull(decodeOrgId(route.params.orgId)); - const agentId = Option.getOrNull(decodeAgentId(route.params.agentId)); - return ( - - navigation.goBack()} /> - - - {environmentId === null || orgId === null || agentId === null ? ( - - ) : ( - - )} - - - - ); -} - -function KinLevelsBody(props: { - readonly environmentId: EnvironmentId; - readonly input: KinLevelsGetInput; -}) { - const { environmentId, input } = props; - const atom = kinClient.levels({ environmentId, input }); - const result = useAtomValue(atom); - const host = useKinHostAt(environmentId); - const { agentNames } = kinDirectory(host._tag === "unpaired" ? { _tag: "none" } : host); - const inbox = useAtomValue(kinClient.inbox({ environmentId, input: {} })); - const canChange = useAtomValue(kinClient.lower.permissionAtom(environmentId)); - const lower = useAtomCommand(kinClient.lower, { reportFailure: false }); - const raise = useAtomCommand(kinClient.raise, { reportFailure: false }); - const [pending, setPending] = useState(null); - const [notice, setNotice] = useState<{ readonly text: string; readonly error: boolean } | null>( - null, - ); - - if (AsyncResult.isInitial(result)) { - return ( - - - - ); - } - if (AsyncResult.isFailure(result)) { - const cause = Cause.squash(result.cause); - if (isKinChatError(cause) && cause.reason === "not_found") { - return ( - - ); - } - if (isKinChatError(cause) && cause.reason === "not_allowed") { - return ( - - ); - } - return ( - - - -