Skip to content

Commit bb5748b

Browse files
fix(mobile): show connection status in the floating pill instead of a second one (pingdotgg#10440)
Co-authored-by: Claude Code <[email protected]>
1 parent e1230d6 commit bb5748b

5 files changed

Lines changed: 299 additions & 130 deletions

File tree

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
useState,
2727
type RefObject,
2828
} from "react";
29-
import { ActivityIndicator, Alert, Platform, Pressable, View, type ViewStyle } from "react-native";
29+
import { Alert, Platform, Pressable, View, type ViewStyle } from "react-native";
3030
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
3131
import {
3232
composerAttachmentUploadBlockReason,
@@ -113,7 +113,6 @@ export interface ThreadComposerProps {
113113
readonly contentMaxWidth?: number;
114114
readonly bottomInset?: number;
115115
readonly connectionState: RemoteClientConnectionState;
116-
readonly connectionError: string | null;
117116
readonly environmentLabel: string | null;
118117
readonly selectedThread: OrchestrationThreadShell;
119118
readonly hasCompactableConversation: boolean;
@@ -134,7 +133,6 @@ export interface ThreadComposerProps {
134133
readonly onUpdateModelSelection: (modelSelection: ModelSelection) => void;
135134
readonly onUpdateRuntimeMode: (runtimeMode: RuntimeMode) => void;
136135
readonly onUpdateInteractionMode: (interactionMode: ProviderInteractionMode) => void;
137-
readonly onReconnectEnvironment: () => void;
138136
readonly onExpandedChange?: (expanded: boolean) => void;
139137
/** Fires on editor focus/blur; hosts use it to vet stale keyboard state. */
140138
readonly onEditorFocusChange?: (focused: boolean) => void;
@@ -226,72 +224,6 @@ export function ComposerSurface(props: {
226224
);
227225
}
228226

229-
type ComposerStatusPillState = {
230-
readonly kind: "unavailable" | "reconnecting";
231-
readonly label: string;
232-
};
233-
234-
function composerConnectionStatus(input: {
235-
readonly connectionError: string | null;
236-
readonly connectionState: RemoteClientConnectionState;
237-
readonly environmentLabel: string | null;
238-
}): ComposerStatusPillState | null {
239-
const environmentLabel = input.environmentLabel ?? "Environment";
240-
241-
switch (input.connectionState) {
242-
case "connecting":
243-
case "reconnecting":
244-
return {
245-
kind: "reconnecting",
246-
label:
247-
input.connectionError === null
248-
? `Reconnecting to ${environmentLabel}...`
249-
: `Failed to connect. Retrying ${environmentLabel}...`,
250-
};
251-
case "offline":
252-
return { kind: "unavailable", label: "You are offline" };
253-
case "error":
254-
return {
255-
kind: "unavailable",
256-
label: input.connectionError
257-
? `Failed to connect to ${environmentLabel}: ${input.connectionError}`
258-
: `Failed to connect to ${environmentLabel}`,
259-
};
260-
case "available":
261-
return { kind: "unavailable", label: `${environmentLabel} is not connected` };
262-
case "connected":
263-
return null;
264-
}
265-
}
266-
267-
const ComposerConnectionStatusPill = memo(function ComposerConnectionStatusPill(props: {
268-
readonly onPress: () => void;
269-
readonly status: ComposerStatusPillState;
270-
}) {
271-
const isReconnecting = props.status.kind === "reconnecting";
272-
return (
273-
<View className="absolute inset-x-0 bottom-full items-center pb-2" pointerEvents="box-none">
274-
<Pressable
275-
accessibilityRole="button"
276-
onPress={props.onPress}
277-
className="max-w-full flex-row items-center gap-2 rounded-full bg-card px-3 py-2 shadow-sm active:opacity-70"
278-
>
279-
{isReconnecting ? (
280-
<ActivityIndicator size="small" colorClassName={"accent-icon-muted"} />
281-
) : (
282-
<View className="h-2 w-2 rounded-full bg-red-500" />
283-
)}
284-
<Text
285-
className="max-w-[260px] text-sm font-t3-bold leading-snug text-foreground"
286-
numberOfLines={1}
287-
>
288-
{props.status.label}
289-
</Text>
290-
</Pressable>
291-
</View>
292-
);
293-
});
294-
295227
export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposerProps) {
296228
const navigation = useNavigation();
297229
const foregroundColor = useUniwindTheme()["--color-foreground"];
@@ -337,11 +269,6 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
337269
const modelUnavailable =
338270
props.connectionState === "connected" &&
339271
isModelSelectionUnavailable(props.serverConfig, currentModelSelection);
340-
const connectionStatus = composerConnectionStatus({
341-
connectionError: props.connectionError,
342-
connectionState: props.connectionState,
343-
environmentLabel: props.environmentLabel,
344-
});
345272
const selectedProviderStatus = useMemo(() => {
346273
if (!props.serverConfig) return null;
347274
return (
@@ -640,13 +567,6 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
640567
</View>
641568
) : null}
642569

643-
{connectionStatus ? (
644-
<ComposerConnectionStatusPill
645-
status={connectionStatus}
646-
onPress={props.onReconnectEnvironment}
647-
/>
648-
) : null}
649-
650570
{modelUnavailable ? (
651571
<Pressable accessibilityRole="button" className="px-3 py-2" onPress={openSettings}>
652572
<Text className="text-xs text-foreground">Model unavailable. Open model settings.</Text>

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ import { PendingUserInputCard } from "./PendingUserInputCard";
8484
import {
8585
FLOATING_WORKING_CONTROL_COVERAGE,
8686
FloatingWorkingControl,
87-
type FloatingWorkingStatus,
8887
} from "./floating-working-control";
88+
import { connectionFloatingStatus, type FloatingWorkingStatus } from "./floating-working-status";
8989
import {
9090
derivePendingUserInputMaxHeight,
9191
ESTIMATED_KEYBOARD_HEIGHT,
@@ -331,14 +331,20 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
331331
return null;
332332
}
333333
})();
334-
// One floating pill above the composer: it reads the sync state while
335-
// messages load, then the working timer once the feed is settled.
334+
// One floating pill above the composer: it reads the connection phase while
335+
// disconnected, the sync state while messages load, then the working timer
336+
// once the feed is settled.
336337
const floatingStatus = ((): FloatingWorkingStatus | null => {
337-
if (
338-
props.connectionStateLabel !== "connected" ||
339-
props.activePendingApproval !== null ||
340-
props.activePendingUserInput !== null
341-
) {
338+
const connectionStatus = connectionFloatingStatus({
339+
connectionError: props.connectionError,
340+
connectionState: props.connectionStateLabel,
341+
environmentLabel: props.environmentLabel,
342+
onReconnect: props.onReconnectEnvironment,
343+
});
344+
if (connectionStatus !== null) {
345+
return connectionStatus;
346+
}
347+
if (props.activePendingApproval !== null || props.activePendingUserInput !== null) {
342348
return null;
343349
}
344350
if (threadSyncLabel !== null) {
@@ -964,7 +970,6 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
964970
placeholder="Ask the repo agent, or run a command…"
965971
contentMaxWidth={contentMaxWidth}
966972
connectionState={props.connectionStateLabel}
967-
connectionError={props.connectionError}
968973
environmentLabel={props.environmentLabel}
969974
selectedThread={props.selectedThread}
970975
hasCompactableConversation={hasCompactableConversation && !props.isCompacting}
@@ -981,7 +986,6 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
981986
onStopThread={props.onStopThread}
982987
onSendMessage={handleSendMessage}
983988
onShowUsageLimits={showUsageLimits}
984-
onReconnectEnvironment={props.onReconnectEnvironment}
985989
onUpdateModelSelection={props.onUpdateThreadModelSelection}
986990
onUpdateRuntimeMode={props.onUpdateThreadRuntimeMode}
987991
onUpdateInteractionMode={props.onUpdateThreadInteractionMode}

0 commit comments

Comments
 (0)