fix(mobile): address redesign edge cases

This commit is contained in:
theomini committed 2026-08-04 21:11:06 -07:00
1 parent 73cc66ff74
commit e9921b0231
6 files changed
+50 -7

No files matched your search

+8 -2
View File
@@ -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}
</Text>
<SymbolView name="chevron.down" size={10} tintColor="#636366" type="monochrome" />
{props.selectedEnvironmentId !== null && troubledEnvironment ? (
{selectedEnvironment ? (
<Text className="ml-2 text-xs text-[#71717a]" numberOfLines={1}>
{troubledEnvironment.label}
{selectedEnvironment.label}
</Text>
) : null}
</Pressable>
@@ -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],
@@ -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> = {}): 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);
});
@@ -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" ||
@@ -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 (
<View
accessibilityLabel={`Input needed: ${activeQuestion.question}`}
@@ -153,7 +159,21 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
/>
</View>
<View className="items-end border-t border-border px-3 py-2.5">
<View className="flex-row items-center justify-between border-t border-border px-3 py-2.5">
{questionIndex > 0 ? (
<Pressable
accessibilityLabel="Previous question"
accessibilityRole="button"
accessibilityState={{ disabled: !canGoBack }}
className={cn("min-h-11 items-center justify-center px-3", !canGoBack && "opacity-50")}
disabled={!canGoBack}
onPress={handleBack}
>
<Text className="font-t3-bold text-base text-foreground-muted">Back</Text>
</Pressable>
) : (
<View />
)}
<Pressable
accessibilityLabel={isLastQuestion ? "Submit answers" : "Next question"}
accessibilityRole="button"
@@ -947,7 +947,7 @@ function ThreadRouteContent(
<>
{activeInspectorRenderer ? <InspectorPaneRoleActivation /> : null}
<NativeStackScreenOptions
optionsVersion={threadHeaderStatus.nativeLabel}
optionsVersion={nativeThreadRightHeaderItems}
options={{
// Android draws its own in-flow header (AndroidScreenHeader below);
// the native stack header stays iOS-only.