1- import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection" ;
21import { formatDuration } from "@t3tools/shared/orchestrationTiming" ;
32import { GlassContainer , GlassView } from "expo-glass-effect" ;
43import { type ReactNode , useEffect , useRef , useState } from "react" ;
@@ -24,6 +23,7 @@ import { AppText as Text } from "../../components/AppText";
2423import { SymbolView } from "../../components/AppSymbol" ;
2524import { ControlPill } from "../../components/ControlPill" ;
2625import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass" ;
26+ import type { FloatingWorkingStatus } from "./floating-working-status" ;
2727
2828const CONTROL_HEIGHT = 38.5 ; // h-11 with the mobile 14px rem
2929// The collapsed composer capsule starts 6 below its overlay's top edge, so
@@ -58,63 +58,6 @@ const AnimatedGlassView = Animated.createAnimatedComponent(UniwindGlassView);
5858const CONTROL_OVERLAY_OFFSET = CONTROL_HEIGHT + CONTROL_GAP - COMPOSER_CAPSULE_INSET ;
5959export const FLOATING_WORKING_CONTROL_COVERAGE = CONTROL_OVERLAY_OFFSET + CONTROL_GAP ;
6060
61- /**
62- * What the floating pill says. Connection, syncing, and working share one
63- * element so the label swaps in place instead of one pill fading out for
64- * another. The connection variant is tappable and triggers a reconnect.
65- */
66- export type FloatingWorkingStatus =
67- | { readonly kind : "working" ; readonly startedAt : string }
68- | { readonly kind : "syncing" ; readonly label : string }
69- | { readonly kind : "compacting" }
70- | {
71- readonly kind : "connection" ;
72- readonly tone : "reconnecting" | "unavailable" ;
73- readonly label : string ;
74- readonly onPress : ( ) => void ;
75- } ;
76-
77- export function connectionFloatingStatus ( input : {
78- readonly connectionError : string | null ;
79- readonly connectionState : EnvironmentConnectionPhase ;
80- readonly environmentLabel : string | null ;
81- readonly onReconnect : ( ) => void ;
82- } ) : FloatingWorkingStatus | null {
83- const environmentLabel = input . environmentLabel ?? "Environment" ;
84- const unavailable = ( label : string ) : FloatingWorkingStatus => ( {
85- kind : "connection" ,
86- tone : "unavailable" ,
87- label,
88- onPress : input . onReconnect ,
89- } ) ;
90-
91- switch ( input . connectionState ) {
92- case "connecting" :
93- case "reconnecting" :
94- return {
95- kind : "connection" ,
96- tone : "reconnecting" ,
97- label :
98- input . connectionError === null
99- ? `Reconnecting to ${ environmentLabel } ...`
100- : `Failed to connect. Retrying ${ environmentLabel } ...` ,
101- onPress : input . onReconnect ,
102- } ;
103- case "offline" :
104- return unavailable ( "You are offline" ) ;
105- case "error" :
106- return unavailable (
107- input . connectionError
108- ? `Failed to connect to ${ environmentLabel } : ${ input . connectionError } `
109- : `Failed to connect to ${ environmentLabel } ` ,
110- ) ;
111- case "available" :
112- return unavailable ( `${ environmentLabel } is not connected` ) ;
113- case "connected" :
114- return null ;
115- }
116- }
117-
11861export function FloatingWorkingControl ( props : {
11962 readonly colorScheme : "light" | "dark" ;
12063 readonly status : FloatingWorkingStatus | null ;
0 commit comments