diff --git a/apps/mobile/src/components/ui/ListRowLayout.tsx b/apps/mobile/src/components/ui/ListRowLayout.tsx index 8e39884faf224..a401c88f83f4a 100644 --- a/apps/mobile/src/components/ui/ListRowLayout.tsx +++ b/apps/mobile/src/components/ui/ListRowLayout.tsx @@ -14,12 +14,15 @@ export interface ListRowContentProps { readonly detail?: string; /** Rich secondary content under the description, such as scores with emphasized values. */ readonly meta?: ReactNode; + /** Room for a leading mark wider than the default glyph slot, such as a Tot's face. */ + readonly leadingSize?: number; readonly disabled?: boolean; } export function ListRowLayout({ icon, leading, + leadingSize = 24, label, description, detail, @@ -49,7 +52,12 @@ export function ListRowLayout({ /> ) : leading ? ( - {leading} + + {leading} + ) : null} { feedTouchStartRef.current = { @@ -1452,6 +1455,7 @@ function ThreadDetailBody( toolCallVisibility={toolCallVisibility} environmentId={props.environmentId} threadId={props.selectedThread.id} + tot={tot} detailRef={props.selectedThreadDetailRef} workspaceRoot={props.threadCwd} feed={props.selectedThreadFeed} diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx index dbba77dc34c43..5fd37d7548d7f 100644 --- a/apps/mobile/src/features/threads/ThreadFeed.tsx +++ b/apps/mobile/src/features/threads/ThreadFeed.tsx @@ -51,7 +51,7 @@ import * as Haptics from "expo-haptics"; import { KeyboardAwareLegendList } from "@legendapp/list/keyboard"; import { useViewabilityAmount, type LegendListRef } from "@legendapp/list/react-native"; import { scopeThreadRef } from "@t3tools/client-runtime/environment"; -import { TOT_FACE_STATE_LABELS } from "@t3tools/client-runtime/tots"; +import { TOT_FACE_STATE_LABELS, type EnvironmentTot } from "@t3tools/client-runtime/tots"; import type { HandoffEndpoints } from "@t3tools/client-runtime/handoff"; import { IDLE_COMPACTING_LABELS, @@ -327,7 +327,7 @@ import { ZoomableImagePressable } from "./ZoomableImagePressable"; import { openSettings } from "../settings/settings-navigation"; import { useSelectWorkspaceDetail } from "../layout/workspace/useSelectWorkspaceDetail"; import { useMessageTimeFormatter } from "./useMessageTimeFormatter"; -import { useAnimateTotAvatars, useThreadTot, useTotFace } from "../../state/tots"; +import { useAnimateTotAvatars, useTotFace } from "../../state/tots"; import { totThemeColor, useTotThemeTokens } from "../tots/useTotThemeTokens"; import { TotLiveFace } from "../tots/TotLiveFace"; import { TOT_THREAD_HEADER_HEIGHT, TotThreadHeader } from "../tots/TotThreadHeader"; @@ -368,6 +368,8 @@ export interface ThreadFeedProps { readonly onEditPendingMessage: ((message: QueuedThreadMessage) => void) | null; readonly environmentId: EnvironmentId; readonly threadId: ThreadId; + /** The Tot whose thread this is, resolved from the thread shell as the list resolves it. */ + readonly tot: EnvironmentTot | null; /** Null while the thread's creation is queued: reading detail then caches a not-found as deleted. */ readonly detailRef: ScopedThreadRef | null; readonly threadTitle: string; @@ -3062,8 +3064,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { const gt = useGT(); const m = useMessages(); const formatMessageTime = useMessageTimeFormatter(); - const { listRef, onIsAtEndChange, onHeaderMaterialVisibilityChange } = props; - const tot = useThreadTot({ environmentId: props.environmentId, id: props.threadId }); + const { listRef, onIsAtEndChange, onHeaderMaterialVisibilityChange, tot } = props; const totTheme = useTotThemeTokens(props.environmentId, props.threadId); const totFace = useTotFace(tot); const animateTot = useAnimateTotAvatars(); diff --git a/apps/mobile/src/features/tots/TotCard.tsx b/apps/mobile/src/features/tots/TotCard.tsx new file mode 100644 index 0000000000000..c60f5cb14e02a --- /dev/null +++ b/apps/mobile/src/features/tots/TotCard.tsx @@ -0,0 +1,91 @@ +import { TOT_FACE_STATE_LABELS, type EnvironmentTot } from "@t3tools/client-runtime/tots"; +import type { TotFaceState } from "@t3tools/contracts"; +import { Platform, Pressable, View } from "react-native"; +import { useResolveClassNames } from "uniwind"; + +import { AppText } from "../../components/ui/AppText"; +import { SymbolView } from "../../components/ui/AppSymbol"; +import { RowPressable } from "../../components/ui/RowPressable"; +import { TOT_STATE_PRESENTATION } from "./totStatePresentation"; +import { TotLiveFace } from "./TotLiveFace"; +import { TotStatePill } from "./TotStatePill"; +import { TotStillFace } from "./TotStillFace"; + +/** Big enough that its eyes read at arm's length, on a phone and on a Fold. */ +const FACE_SIZE = 64; +export const TOT_CARD_MIN_HEIGHT = 172; + +/** + * One Tot in the Tots tab: its face, its name, what it is doing. The whole card opens the Tot; + * the small slider in the corner is the secondary trip to its editor. + */ +export function TotCard(props: { + readonly entry: EnvironmentTot; + readonly state: TotFaceState; + readonly machine: string | null; + readonly width: number; + readonly animate: boolean; + readonly onOpen: () => void; + readonly onEdit: () => void; +}) { + const { tot } = props.entry; + const accent = tot.avatar.color; + const presentation = TOT_STATE_PRESENTATION[props.state]; + const rippleStyle = useResolveClassNames("bg-subtle-strong"); + // A moving face costs a WebView, so only a Tot that is actually doing something gets one. + const live = props.animate && (props.state === "working" || props.state === "needs-you"); + return ( + part !== null) + .join(", ")} + accessibilityHint={tot.threadId === null ? "Opens its editor" : "Opens its conversation"} + onPress={props.onOpen} + android_ripple={{ color: rippleStyle.backgroundColor }} + unstable_pressDelay={Platform.OS === "android" ? 50 : undefined} + className={`rounded-3xl border bg-grouped-card ${presentation.cardClassName}`} + style={{ width: props.width, minHeight: TOT_CARD_MIN_HEIGHT }} + > + + + {live ? ( + + ) : ( + + )} + + + {tot.name} + + + {props.machine === null ? null : ( + + {props.machine} + + )} + + + + + + ); +} diff --git a/apps/mobile/src/features/tots/TotLiveFace.tsx b/apps/mobile/src/features/tots/TotLiveFace.tsx index cd9015a928638..8d5036f1947d4 100644 --- a/apps/mobile/src/features/tots/TotLiveFace.tsx +++ b/apps/mobile/src/features/tots/TotLiveFace.tsx @@ -1,7 +1,7 @@ import totFaceScript from "@t3tools/mobile-totface-stream"; import { TOT_FACE_ACTION, type TotAvatar, type TotFaceState } from "@t3tools/contracts"; import { useEffect, useRef, useState } from "react"; -import { View } from "react-native"; +import { StyleSheet, View } from "react-native"; import { WebView } from "react-native-webview"; import { TotStillFace } from "./TotStillFace"; @@ -36,6 +36,8 @@ export function TotLiveFace(props: { const [source] = useState(() => ({ html: faceDocument(faceMessage(props.avatar, props.state, props.size)), })); + // The WebView paints nothing until its document loads, which read as a missing face. + const [painted, setPainted] = useState(false); const message = faceMessage(props.avatar, props.state, props.size); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- sends the new face to the WebView @@ -48,6 +50,12 @@ export function TotLiveFace(props: { } return ( + {/* The still pose stands in until the WebView has something to show. */} + {painted ? null : ( + + + + )} ref={webView} source={source} @@ -55,7 +63,13 @@ export function TotLiveFace(props: { scrollEnabled={false} bounces={false} setSupportMultipleWindows={false} - style={{ width: props.size, height: props.size, backgroundColor: "transparent" }} + onLoadEnd={() => setPainted(true)} + style={{ + width: props.size, + height: props.size, + backgroundColor: "transparent", + opacity: painted ? 1 : 0, + }} containerStyle={{ backgroundColor: "transparent" }} onShouldStartLoadWithRequest={(request) => request.url === "about:blank"} /> diff --git a/apps/mobile/src/features/tots/TotStatePill.tsx b/apps/mobile/src/features/tots/TotStatePill.tsx new file mode 100644 index 0000000000000..bb079d387e9cd --- /dev/null +++ b/apps/mobile/src/features/tots/TotStatePill.tsx @@ -0,0 +1,34 @@ +import { TOT_FACE_STATE_LABELS } from "@t3tools/client-runtime/tots"; +import type { TotFaceState } from "@t3tools/contracts"; +import { View } from "react-native"; + +import { AppText } from "../../components/ui/AppText"; +import { cn } from "../../lib/cn"; +import { TOT_STATE_PRESENTATION } from "./totStatePresentation"; + +/** What a Tot is doing, in the same shape on its card and above its conversation. */ +export function TotStatePill(props: { + readonly state: TotFaceState; + /** The Tot's own colour, used for the state it is in most. */ + readonly accent: string; + readonly size?: "card" | "band"; +}) { + const presentation = TOT_STATE_PRESENTATION[props.state]; + return ( + + + {TOT_FACE_STATE_LABELS[props.state]} + + + ); +} diff --git a/apps/mobile/src/features/tots/TotThreadHeader.tsx b/apps/mobile/src/features/tots/TotThreadHeader.tsx index 0911f072b9937..8b74ed49cea7a 100644 --- a/apps/mobile/src/features/tots/TotThreadHeader.tsx +++ b/apps/mobile/src/features/tots/TotThreadHeader.tsx @@ -1,18 +1,23 @@ import { TOT_FACE_STATE_LABELS, type EnvironmentTot } from "@t3tools/client-runtime/tots"; import type { TotThemeTokens } from "@t3tools/shared/totThemeTokens"; -import { View } from "react-native"; +import { Platform, View } from "react-native"; import { AppText } from "../../components/ui/AppText"; +import { cn } from "../../lib/cn"; import { useTotFace } from "../../state/tots"; import { TotLiveFace } from "./TotLiveFace"; +import { TotStatePill } from "./TotStatePill"; -const FACE_SIZE = 36; -const FACE_RING = 1.5; +const FACE_RING = 6; /** How tall the pinned identity band is, so the feed can clear it. */ -export const TOT_THREAD_HEADER_HEIGHT = 52; +export const TOT_THREAD_HEADER_HEIGHT = 64; +const FACE_SIZE = 42; -/** The Tot you are talking to: its face, name and what it is doing, above its thread. */ +/** + * The Tot you are talking to: its face, its name, what it is doing. It sits under the navigation + * bar on the Tot's own wash, so the thread header keeps the title and this keeps the identity. + */ export function TotThreadHeader(props: { readonly entry: EnvironmentTot; readonly animate: boolean; @@ -23,47 +28,63 @@ export function TotThreadHeader(props: { const state = useTotFace(props.entry); const label = TOT_FACE_STATE_LABELS[state]; const tokens = props.tokens; + const accent = tot.avatar.color; const bandBackground = tokens["--tot-bg"]; - const bandBorder = tokens["--tot-border"]; const textColor = tokens["--tot-text"]; - const mutedColor = tokens["--tot-muted"]; return ( + {/* The feed scrolls under this band, so a theme's translucent --tot-bg and the accent wash + both sit over the opaque canvas colour instead of replacing it. */} + {bandBackground === undefined ? null : ( + + )} - + pointerEvents="none" + className="absolute inset-0" + style={{ backgroundColor: `${accent}14` }} + /> + + + + + + + {tot.name} + + + + + - - {tot.name} - - - - {label} - ); } diff --git a/apps/mobile/src/features/tots/TotsTabScreen.tsx b/apps/mobile/src/features/tots/TotsTabScreen.tsx index 991be03fa2e84..92bbe35c09760 100644 --- a/apps/mobile/src/features/tots/TotsTabScreen.tsx +++ b/apps/mobile/src/features/tots/TotsTabScreen.tsx @@ -1,21 +1,15 @@ -import { - TOT_FACE_STATE_LABELS as STATE_LABELS, - type EnvironmentTot, -} from "@t3tools/client-runtime/tots"; +import type { EnvironmentTot } from "@t3tools/client-runtime/tots"; import { useAtomValue } from "@effect/atom-react"; import { HOME_TOT_ID, type ServerSettings } from "@t3tools/contracts"; import { Atom } from "effect/reactivity"; import { useNavigation } from "@react-navigation/native"; import { useState } from "react"; -import { Platform, View } from "react-native"; +import { Pressable, Platform, View } from "react-native"; import { useResolveClassNames } from "uniwind"; import { AppText } from "../../components/ui/AppText"; -import { IconButton } from "../../components/ui/IconButton"; -import { ListActionRow } from "../../components/ui/ListActionRow"; -import { ListRowLayout } from "../../components/ui/ListRowLayout"; -import { ListSection } from "../../components/ui/ListSection"; -import { RowPressable } from "../../components/ui/RowPressable"; +import { EmptyState } from "../../components/ui/EmptyState"; +import { SymbolView } from "../../components/ui/AppSymbol"; import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView"; import { serverEnvironment } from "../../state/server"; import { @@ -29,23 +23,30 @@ import { useWorkspaceSettledContentWidth } from "../layout/workspace-content-wid import { useWorkspaceListBottomInset } from "../layout/workspace/workspace-list-insets"; import { useSelectWorkspaceDetail } from "../layout/workspace/useSelectWorkspaceDetail"; import { SettingsScreen } from "../settings/components/SettingsScreen"; -import { TotLiveFace } from "./TotLiveFace"; -import { TOT_ROW_FACE_SIZE, TotStillFace } from "./TotStillFace"; +import { TOT_CARD_MIN_HEIGHT, TotCard } from "./TotCard"; +import { + TOT_GRID_GAP, + TOT_GRID_MAX_WIDTH, + totCardWidth, + totGridColumns, + totGridRows, +} from "./totGrid"; const NO_SETTINGS_ATOM = Atom.make(null).pipe( Atom.withLabel("mobile-tots-no-host"), ); -// The unfolded Fold and tablets: hero beside the list, as wide as a desktop settings column. -const WIDE_LAYOUT_MIN_WIDTH = 600; - /** Opens the Tot's thread, or its editor while it is off, like the desktop sidebar row. */ -function TotListRow(props: { readonly entry: EnvironmentTot; readonly machine: string | null }) { +function TotGridCard(props: { + readonly entry: EnvironmentTot; + readonly machine: string | null; + readonly width: number; +}) { const { environmentId, tot } = props.entry; const state = useTotFace(props.entry); + const animate = useAnimateTotAvatars(); const navigation = useNavigation(); const selectDetail = useSelectWorkspaceDetail(); - const rippleStyle = useResolveClassNames("bg-subtle-strong"); const edit = () => navigation.navigate("TotEditor", { environmentId, totId: tot.id }); const open = () => { if (tot.threadId === null) { @@ -54,42 +55,42 @@ function TotListRow(props: { readonly entry: EnvironmentTot; readonly machine: s } selectDetail({ name: "Thread", params: { environmentId, threadId: tot.threadId } }); }; - const description = - props.machine === null ? STATE_LABELS[state] : `${STATE_LABELS[state]} ยท ${props.machine}`; return ( - - } - label={tot.name} - description={description} - accessory={ - - } - /> - + ); } -function TotHero(props: { readonly entry: EnvironmentTot }) { - const state = useTotFace(props.entry); - const animate = useAnimateTotAvatars(); +/** The grid's last cell: the same card shape, so making a Tot reads as one more face. */ +function NewTotCard(props: { readonly width: number; readonly onPress: () => void }) { + const rippleStyle = useResolveClassNames("bg-subtle-strong"); return ( - - - {props.entry.tot.name} - {STATE_LABELS[state]} - + + + + + New Tot + ); } @@ -98,7 +99,7 @@ function machineLabel(hosts: ReadonlyArray, entry: EnvironmentTot): str return hosts.find((host) => host.environmentId === entry.environmentId)?.label ?? null; } -/** The Tots tab: every Tot on every machine, then a way to make one. */ +/** The Tots tab: every Tot on every machine as a face, then a way to make one. */ export function TotsTabScreen() { const [measuredWidth, setMeasuredWidth] = useState(0); const bottomInset = useWorkspaceListBottomInset({ automaticBottomInset: true }); @@ -118,35 +119,27 @@ export function TotsTabScreen() { : (hostSettings?.tots.find((tot) => tot.id === HOME_TOT_ID) ?? null); const rows: ReadonlyArray = offHome === null || host === null ? tots : [{ environmentId: host, tot: offHome }, ...tots]; - const hero = tots.find((entry) => entry.tot.threadId !== null); - const wide = width >= WIDE_LAYOUT_MIN_WIDTH; - const list = ( - - - {rows.map((entry) => ( - - ))} - {host === null ? null : ( - navigation.navigate("TotEditor", { environmentId: host })} - /> - )} - - {hostSettings === null || hostSettings.linkedEnvironmentsEnabled ? null : ( - - Turn on Linked environments in Labs, on each machine, so Tots can reach your other - machines. - - )} - - ); + // The page's own settled width, not the scroll content's: Android caps that content at 720dp, and + // a card row wide enough to fill the cap would keep a fold-narrowed page at the wide layout. + const available = Math.max(0, Math.min(width - 40, TOT_GRID_MAX_WIDTH)); + const columns = totGridColumns(available); + const cardWidth = totCardWidth(available, columns); + const newTot = + host === null ? undefined : () => navigation.navigate("TotEditor", { environmentId: host }); + const cells = [ + ...rows.map((entry) => ( + + )), + ...(newTot === undefined + ? [] + : []), + ]; return ( @@ -154,25 +147,38 @@ export function TotsTabScreen() { contentInsetAdjustmentBehavior="automatic" showsVerticalScrollIndicator={false} className="flex-1" - contentContainerClassName="px-5 pt-4" + contentContainerClassName="px-5 pt-5" contentContainerStyle={{ paddingBottom: bottomInset }} onLayout={(event) => setMeasuredWidth(event.nativeEvent.layout.width)} > - {wide ? ( - - {hero === undefined ? null : ( - - - - )} - {list} - + {rows.length === 0 ? ( + ) : ( - - {hero === undefined ? null : } - {list} + + {totGridRows(cells, columns).map((row) => ( + + {row} + + ))} )} + {rows.length === 0 ? null : ( + + A Tot is an agent you talk to in one thread. It starts, watches and answers the threads + in its scope for you. + + )} + {hostSettings === null || hostSettings.linkedEnvironmentsEnabled ? null : ( + + Turn on Linked environments in Labs, on each machine, so Tots can reach your other + machines. + + )} ); diff --git a/apps/mobile/src/features/tots/totGrid.test.ts b/apps/mobile/src/features/tots/totGrid.test.ts new file mode 100644 index 0000000000000..295c85ca1e406 --- /dev/null +++ b/apps/mobile/src/features/tots/totGrid.test.ts @@ -0,0 +1,56 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { TOT_GRID_GAP, totCardWidth, totGridColumns, totGridRows } from "./totGrid"; + +describe("totGridColumns", () => { + it("keeps two faces across a phone", () => { + // A 344dp Fold outer window, less the page's padding. + expect(totGridColumns(304)).toBe(2); + }); + + it("spends the unfolded Fold's width on a third face", () => { + // A 673dp Fold inner window, less the page's padding. + expect(totGridColumns(558)).toBe(3); + }); + + it("gives a tablet four", () => { + expect(totGridColumns(680)).toBe(4); + expect(totGridColumns(1200)).toBe(4); + }); + + it("never drops below two, even before the grid has measured itself", () => { + expect(totGridColumns(0)).toBe(2); + expect(totGridColumns(120)).toBe(2); + }); +}); + +describe("totCardWidth", () => { + it.each([ + [304, 2], + [558, 3], + [680, 4], + ])("fills a %idp row of %i cards without spilling", (available, columns) => { + const width = totCardWidth(available, columns); + const used = width * columns + TOT_GRID_GAP * (columns - 1); + expect(used).toBeLessThanOrEqual(available); + expect(used).toBeGreaterThan(available - columns); + }); + + it("hands a single column the whole row", () => { + expect(totCardWidth(304, 1)).toBe(304); + }); +}); + +describe("totGridRows", () => { + it("draws the last row short instead of stretching it", () => { + expect(totGridRows(["a", "b", "c", "d", "e"], 4)).toEqual([["a", "b", "c", "d"], ["e"]]); + expect(totGridRows(["a", "b", "c"], 2)).toEqual([["a", "b"], ["c"]]); + }); + + it("keeps every card in a full row", () => { + expect(totGridRows([1, 2, 3, 4], 2)).toEqual([ + [1, 2], + [3, 4], + ]); + }); +}); diff --git a/apps/mobile/src/features/tots/totGrid.ts b/apps/mobile/src/features/tots/totGrid.ts new file mode 100644 index 0000000000000..2cef81f56f5d8 --- /dev/null +++ b/apps/mobile/src/features/tots/totGrid.ts @@ -0,0 +1,37 @@ +/** The narrowest a Tot card may get before the grid drops a column. */ +const CARD_MIN_WIDTH = 152; +const CARD_GAP = 12; +const MAX_COLUMNS = 4; +/** Android's scroll content caps at 720dp; without the page padding that is all a row may use. */ +export const TOT_GRID_MAX_WIDTH = 680; + +/** + * How many face cards fit side by side. Two on a phone, three unfolded on a Fold, four on a + * tablet: the extra width becomes more Tots in view instead of a stretched phone column. + */ +export function totGridColumns(availableWidth: number): number { + if (availableWidth <= 0) return 2; + const fitting = Math.floor((availableWidth + CARD_GAP) / (CARD_MIN_WIDTH + CARD_GAP)); + return Math.min(MAX_COLUMNS, Math.max(2, fitting)); +} + +/** One card's width, whole dp so four of them and their gaps never spill past the row. */ +export function totCardWidth(availableWidth: number, columns: number): number { + if (columns <= 1 || availableWidth <= 0) return Math.max(0, availableWidth); + return Math.max(0, Math.floor((availableWidth - CARD_GAP * (columns - 1)) / columns)); +} + +/** + * Cards in rows the grid draws itself. Wrapping a flex row at an exact fit rounds the last card + * onto a line of its own on a tablet, so each row is laid out instead. + */ +export function totGridRows(items: ReadonlyArray, columns: number): ReadonlyArray { + const perRow = Math.max(1, columns); + const rows: T[][] = []; + for (let index = 0; index < items.length; index += perRow) { + rows.push(items.slice(index, index + perRow)); + } + return rows; +} + +export { CARD_GAP as TOT_GRID_GAP }; diff --git a/apps/mobile/src/features/tots/totStatePresentation.test.ts b/apps/mobile/src/features/tots/totStatePresentation.test.ts new file mode 100644 index 0000000000000..c2425aeab114f --- /dev/null +++ b/apps/mobile/src/features/tots/totStatePresentation.test.ts @@ -0,0 +1,25 @@ +import { TOT_FACE_STATE_LABELS } from "@t3tools/client-runtime/tots"; +import type { TotFaceState } from "@t3tools/contracts"; +import { describe, expect, it } from "vite-plus/test"; + +import { TOT_STATE_PRESENTATION } from "./totStatePresentation"; + +describe("TOT_STATE_PRESENTATION", () => { + it("dresses every state a face can hold", () => { + for (const state of Object.keys(TOT_FACE_STATE_LABELS) as TotFaceState[]) { + expect(TOT_STATE_PRESENTATION[state].pillClassName).not.toBe(""); + } + }); + + it("marks only the states that are asking for him", () => { + const urgent = (Object.keys(TOT_STATE_PRESENTATION) as TotFaceState[]).filter( + (state) => TOT_STATE_PRESENTATION[state].urgent, + ); + expect(urgent).toEqual(["needs-you", "failure"]); + }); + + it("paints the working state in the Tot's own colour", () => { + expect(TOT_STATE_PRESENTATION.working.accentText).toBe(true); + expect(TOT_STATE_PRESENTATION.idle.accentText).toBe(false); + }); +}); diff --git a/apps/mobile/src/features/tots/totStatePresentation.ts b/apps/mobile/src/features/tots/totStatePresentation.ts new file mode 100644 index 0000000000000..b7b9c1e780208 --- /dev/null +++ b/apps/mobile/src/features/tots/totStatePresentation.ts @@ -0,0 +1,58 @@ +import type { TotFaceState } from "@t3tools/contracts"; + +export interface TotStatePresentation { + /** A Tot at a glance: "Needs you" has to read from arm's length. */ + readonly textClassName: string; + readonly pillClassName: string; + /** Uses the Tot's own accent for the words, for the state it spends the most time in. */ + readonly accentText: boolean; + readonly urgent: boolean; + /** The card's border, so an urgent Tot is not just a coloured word. */ + readonly cardClassName: string; +} + +/** One look for a Tot's state across its card and its thread band. */ +export const TOT_STATE_PRESENTATION: Record = { + idle: { + textClassName: "text-foreground-muted", + pillClassName: "bg-subtle", + accentText: false, + urgent: false, + cardClassName: "border-separator", + }, + working: { + textClassName: "", + pillClassName: "bg-subtle", + accentText: true, + urgent: false, + cardClassName: "border-separator", + }, + "needs-you": { + textClassName: "text-warning-foreground", + pillClassName: "border border-warning-border bg-warning", + accentText: false, + urgent: true, + cardClassName: "border-warning-border", + }, + success: { + textClassName: "text-adaptive-emerald-700-300", + pillClassName: "bg-subtle", + accentText: false, + urgent: false, + cardClassName: "border-separator", + }, + failure: { + textClassName: "text-danger-foreground", + pillClassName: "border border-danger-border bg-danger", + accentText: false, + urgent: true, + cardClassName: "border-danger-border", + }, + sleep: { + textClassName: "text-foreground-tertiary", + pillClassName: "bg-subtle", + accentText: false, + urgent: false, + cardClassName: "border-separator", + }, +}; diff --git a/apps/mobile/src/lib/filePreview.test.ts b/apps/mobile/src/lib/filePreview.test.ts index cb96ac55a041f..ec920adba07c0 100644 --- a/apps/mobile/src/lib/filePreview.test.ts +++ b/apps/mobile/src/lib/filePreview.test.ts @@ -465,6 +465,7 @@ describe("ThreadInlineFilePreview playback", () => { createElement(ThreadFeed, { environmentId, threadId, + tot: null, detailRef: null, threadTitle: "preview", workspaceRoot: "/repo", @@ -1457,6 +1458,7 @@ describe("ThreadFeed previews", () => { createElement(ThreadFeed, { environmentId, threadId, + tot: null, detailRef: null, threadTitle: "preview", workspaceRoot: "/repo",