From e9921b0231742471cb66ef51e36f333f5674a0be Mon Sep 17 00:00:00 2001 From: theomini Date: Tue, 4 Aug 2026 21:11:06 -0700 Subject: [PATCH] fix(mobile): address redesign edge cases --- apps/mobile/src/features/home/HomeHeader.tsx | 10 +++++++-- .../src/features/home/HomeRouteScreen.tsx | 9 +++++--- .../home/WorkspaceConnectionStatus.test.ts | 7 ++++++ .../home/workspace-connection-status.ts | 7 ++++++ .../features/threads/PendingUserInputCard.tsx | 22 ++++++++++++++++++- .../features/threads/ThreadRouteScreen.tsx | 2 +- 6 files changed, 50 insertions(+), 7 deletions(-) diff --git a/apps/mobile/src/features/home/HomeHeader.tsx b/apps/mobile/src/features/home/HomeHeader.tsx index cb7d604b20..a13a3f5cb2 100644 --- a/apps/mobile/src/features/home/HomeHeader.tsx +++ b/apps/mobile/src/features/home/HomeHeader.tsx @@ -197,6 +197,12 @@ export function HomeHeader(props: { ) ?? props.environments.find((environment) => environment.connectionState !== "connected") ?? props.environments[0]; + const selectedEnvironment = + props.selectedEnvironmentId === null + ? null + : (props.environments.find( + (environment) => environment.environmentId === props.selectedEnvironmentId, + ) ?? null); const selectedProjectLabel = props.projects.find((project) => project.key === props.selectedProjectKey)?.label ?? "All projects"; @@ -314,9 +320,9 @@ export function HomeHeader(props: { {selectedProjectLabel} - {props.selectedEnvironmentId !== null && troubledEnvironment ? ( + {selectedEnvironment ? ( - {troubledEnvironment.label} + {selectedEnvironment.label} ) : null} diff --git a/apps/mobile/src/features/home/HomeRouteScreen.tsx b/apps/mobile/src/features/home/HomeRouteScreen.tsx index c39729ef52..7ae9f29a6e 100644 --- a/apps/mobile/src/features/home/HomeRouteScreen.tsx +++ b/apps/mobile/src/features/home/HomeRouteScreen.tsx @@ -20,6 +20,7 @@ import { HomeScreen } from "./HomeScreen"; import { HomeHeader } from "./HomeHeader"; import { useHomeListOptions } from "./home-list-options"; import { buildHomeProjectScopes } from "./homeThreadList"; +import { resolveHomeEnvironmentConnectionPhase } from "./workspace-connection-status"; import { usePendingTaskListActions } from "./usePendingTaskListActions"; import { useThreadListActions } from "./useThreadListActions"; @@ -61,12 +62,14 @@ export function HomeRouteScreen() { Object.values(savedConnectionsById).map((connection) => ({ environmentId: connection.environmentId, label: connection.environmentLabel, - connectionState: - connectionStateByEnvironmentId.get(connection.environmentId) ?? "available", + connectionState: resolveHomeEnvironmentConnectionPhase( + connectionStateByEnvironmentId.get(connection.environmentId), + catalogState.isLoadingConnections, + ), })), Order.mapInput(Order.String, (environment: { readonly label: string }) => environment.label), ); - }, [savedConnectionsById, workspaceEnvironments]); + }, [catalogState.isLoadingConnections, savedConnectionsById, workspaceEnvironments]); const availableEnvironmentIds = useMemo( () => new Set(environments.map((environment) => environment.environmentId)), [environments], diff --git a/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts b/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts index 7a6a18d2f3..a0e3bc7146 100644 --- a/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts +++ b/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vite-plus/test"; import type { WorkspaceState } from "../../state/workspaceModel"; import { + resolveHomeEnvironmentConnectionPhase, shouldShowWorkspaceConnectionStatus, workspaceConnectionHeaderPresentation, workspaceConnectionStatusLabel, @@ -26,6 +27,12 @@ function workspaceState(overrides: Partial = {}): WorkspaceState } describe("workspace connection status", () => { + it("treats uncatalogued saved environments as connecting during startup", () => { + expect(resolveHomeEnvironmentConnectionPhase(undefined, true)).toBe("connecting"); + expect(resolveHomeEnvironmentConnectionPhase(undefined, false)).toBe("available"); + expect(resolveHomeEnvironmentConnectionPhase("connected", true)).toBe("connected"); + }); + it("stays hidden while a ready environment is connected", () => { expect(shouldShowWorkspaceConnectionStatus(workspaceState())).toBe(false); }); diff --git a/apps/mobile/src/features/home/workspace-connection-status.ts b/apps/mobile/src/features/home/workspace-connection-status.ts index 5f8f730b6a..e38f110f52 100644 --- a/apps/mobile/src/features/home/workspace-connection-status.ts +++ b/apps/mobile/src/features/home/workspace-connection-status.ts @@ -2,6 +2,13 @@ import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connect import type { WorkspaceState } from "../../state/workspaceModel"; +export function resolveHomeEnvironmentConnectionPhase( + connectionState: EnvironmentConnectionPhase | undefined, + isLoadingConnections: boolean, +): EnvironmentConnectionPhase { + return connectionState ?? (isLoadingConnections ? "connecting" : "available"); +} + export function shouldShowWorkspaceConnectionStatus(state: WorkspaceState): boolean { return ( state.networkStatus === "offline" || diff --git a/apps/mobile/src/features/threads/PendingUserInputCard.tsx b/apps/mobile/src/features/threads/PendingUserInputCard.tsx index 2c344e3645..4dec80fcb2 100644 --- a/apps/mobile/src/features/threads/PendingUserInputCard.tsx +++ b/apps/mobile/src/features/threads/PendingUserInputCard.tsx @@ -47,6 +47,7 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) { const draft = activeQuestion ? props.drafts[activeQuestion.id] : undefined; const isResponding = props.respondingUserInputId === props.pendingUserInput.requestId; const isLastQuestion = questionIndex >= props.pendingUserInput.questions.length - 1; + const canGoBack = questionIndex > 0 && !isResponding; const canAdvance = hasDraftAnswer(draft); if (!activeQuestion) { @@ -68,6 +69,11 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) { } }; + const handleBack = () => { + if (!canGoBack) return; + setQuestionIndex((current) => Math.max(0, current - 1)); + }; + return ( - + + {questionIndex > 0 ? ( + + Back + + ) : ( + + )} {activeInspectorRenderer ? : null}