* fix(app): restore archived agents from History History navigation lost the explicit archived-agent intent during tab reconciliation, and workspace recovery stopped after restoring the workspace. Preserve the selected tab and recover its provider session as one action while serializing provider resume with timeline hydration. * fix(app): preserve archived agent recovery invariants * fix(server): preserve timeline hydration call shape * fix(app): retain agent tabs through lookup * fix(server): upgrade in-flight timeline broadcast
123 lines
3.8 KiB
TypeScript
123 lines
3.8 KiB
TypeScript
import { useCallback, useMemo, useState } from "react";
|
|
import { View, Text } from "react-native";
|
|
import { useTranslation } from "react-i18next";
|
|
import { StyleSheet } from "react-native-unistyles";
|
|
import Animated from "react-native-reanimated";
|
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
import { FOOTER_HEIGHT, MAX_CONTENT_WIDTH } from "@/constants/layout";
|
|
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
|
import { useKeyboardShiftStyle } from "@/hooks/use-keyboard-shift-style";
|
|
import { Button } from "@/components/ui/button";
|
|
import type { Theme } from "@/styles/theme";
|
|
import { toErrorMessage } from "@/utils/error-messages";
|
|
|
|
interface ArchivedAgentCalloutProps {
|
|
serverId: string;
|
|
agentId: string;
|
|
}
|
|
|
|
export function ArchivedAgentCallout({ serverId, agentId }: ArchivedAgentCalloutProps) {
|
|
const { t } = useTranslation();
|
|
const insets = useSafeAreaInsets();
|
|
const client = useHostRuntimeClient(serverId);
|
|
const isConnected = useHostRuntimeIsConnected(serverId);
|
|
const [isUnarchiving, setIsUnarchiving] = useState(false);
|
|
const [unarchiveError, setUnarchiveError] = useState<string | null>(null);
|
|
|
|
const { style: keyboardAnimatedStyle } = useKeyboardShiftStyle({ mode: "translate" });
|
|
|
|
const containerStyle = useMemo(
|
|
() => [styles.container, { paddingBottom: insets.bottom }, keyboardAnimatedStyle],
|
|
[insets.bottom, keyboardAnimatedStyle],
|
|
);
|
|
|
|
const handleUnarchive = useCallback(async () => {
|
|
if (!client || !isConnected || isUnarchiving) return;
|
|
setIsUnarchiving(true);
|
|
setUnarchiveError(null);
|
|
try {
|
|
await client.refreshAgent(agentId);
|
|
} catch (error) {
|
|
setUnarchiveError(toErrorMessage(error));
|
|
setIsUnarchiving(false);
|
|
}
|
|
}, [client, isConnected, isUnarchiving, agentId]);
|
|
|
|
return (
|
|
<Animated.View style={containerStyle}>
|
|
<View style={styles.inputAreaContainer}>
|
|
<View style={styles.inputAreaContent}>
|
|
<View style={styles.calloutStack}>
|
|
<View style={styles.callout}>
|
|
<Text style={styles.calloutText}>{t("agentPanel.archived.callout")}</Text>
|
|
<Button
|
|
size="sm"
|
|
variant="secondary"
|
|
onPress={handleUnarchive}
|
|
disabled={!isConnected || isUnarchiving}
|
|
>
|
|
{t("agentPanel.archived.unarchive")}
|
|
</Button>
|
|
</View>
|
|
{unarchiveError ? (
|
|
<Text style={styles.errorText} testID="agent-unarchive-error">
|
|
{unarchiveError}
|
|
</Text>
|
|
) : null}
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</Animated.View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create((theme: Theme) => ({
|
|
container: {
|
|
flexDirection: "column",
|
|
position: "relative",
|
|
},
|
|
inputAreaContainer: {
|
|
position: "relative",
|
|
minHeight: FOOTER_HEIGHT,
|
|
marginHorizontal: "auto",
|
|
alignItems: "center",
|
|
width: "100%",
|
|
overflow: "visible",
|
|
padding: theme.spacing[4],
|
|
},
|
|
inputAreaContent: {
|
|
width: "100%",
|
|
maxWidth: MAX_CONTENT_WIDTH,
|
|
},
|
|
callout: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
gap: theme.spacing[3],
|
|
backgroundColor: theme.colors.surface1,
|
|
borderWidth: theme.borderWidth[1],
|
|
borderColor: theme.colors.borderAccent,
|
|
borderRadius: theme.borderRadius["2xl"],
|
|
paddingVertical: {
|
|
xs: theme.spacing[3],
|
|
md: theme.spacing[4],
|
|
},
|
|
paddingHorizontal: {
|
|
xs: theme.spacing[4],
|
|
md: theme.spacing[6],
|
|
},
|
|
},
|
|
calloutStack: {
|
|
gap: theme.spacing[2],
|
|
},
|
|
calloutText: {
|
|
color: theme.colors.foregroundMuted,
|
|
fontSize: theme.fontSize.base,
|
|
},
|
|
errorText: {
|
|
color: theme.colors.statusDanger,
|
|
fontSize: theme.fontSize.sm,
|
|
textAlign: "center",
|
|
},
|
|
})) as unknown as Record<string, object>;
|