fix: address v2 stack review findings

This commit is contained in:
ajnart committed 2026-08-20 13:08:54 +02:00
1 parent 53b518960c
commit 263702210a
48 files changed
+1235 -530

No files matched your search

+174 -157
View File
@@ -16,9 +16,9 @@ import {
CopyButton,
Fieldset,
Group,
Modal,
Paper,
PasswordInput,
Popover,
Progress,
Select,
SimpleGrid,
@@ -160,6 +160,9 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
const sounds = useOnboardingSounds();
const [activeSection, setActiveSection] = useState<StudioSection>("essentials");
const [incompleteIntegrationConfirmationOpened, setIncompleteIntegrationConfirmationOpened] = useState(false);
const [confirmedIncompleteIntegrationSignature, setConfirmedIncompleteIntegrationSignature] = useState<string | null>(
null,
);
const [selectedLocale, setSelectedLocale] = useState(currentLocale);
const [serverOrigin, setServerOrigin] = useState(environment.serverOrigin);
const [urlMode, setUrlMode] = useState<UrlTemplateMode>("hostPort");
@@ -184,6 +187,7 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
const [isApplying, setIsApplying] = useState(false);
const [applyProgress, setApplyProgress] = useState(0);
const [applyMessage, setApplyMessage] = useState("");
const [applyError, setApplyError] = useState<string | null>(null);
const [appError, setAppError] = useState<string | null>(null);
const sectionHeadingRef = useRef<HTMLHeadingElement>(null);
const sectionButtonRefs = useRef<(HTMLButtonElement | null)[]>([]);
@@ -201,11 +205,7 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
retry: false,
refetchOnWindowFocus: false,
});
const complete = clientApi.onboard.completeSetup.useMutation({
onError(error) {
showErrorNotification({ title: t("review.errorTitle"), message: error.message });
},
});
const complete = clientApi.onboard.completeSetup.useMutation();
const dockerData = docker.data;
const discoveredIntegrations = dockerData?.integrations ?? emptyDiscoveredIntegrations;
const discoveredApps = dockerData?.apps ?? emptyDiscoveredApps;
@@ -234,6 +234,18 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
() => new Set(discoveredIntegrations.map((integration) => integration.kind)),
[discoveredIntegrations],
);
const incompleteIntegrationSignature = JSON.stringify(
drafts
.filter((draft) => !isIntegrationDraftComplete(draft))
.map((draft) => ({
id: draft.id,
hasUrl: draft.url.trim().length > 0,
secrets: draft.secrets.map((secret) => ({ kind: secret.kind, hasValue: secret.value.trim().length > 0 })),
})),
);
const hasIncompleteIntegrations = incompleteIntegrationSignature !== "[]";
const incompleteIntegrationsConfirmed =
hasIncompleteIntegrations && confirmedIncompleteIntegrationSignature === incompleteIntegrationSignature;
useEffect(() => {
if (!docker.data) return;
@@ -326,11 +338,30 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
if (next) selectSection(next.id);
};
const selectSection = (section: StudioSection) => {
const changeSection = (section: StudioSection) => {
if (section !== activeSection) sounds.swoosh();
setActiveSection(section);
};
const selectSection = (section: StudioSection) => {
if (
section === "review" &&
activeSection !== "review" &&
hasIncompleteIntegrations &&
!incompleteIntegrationsConfirmed
) {
setIncompleteIntegrationConfirmationOpened(true);
return;
}
changeSection(section);
};
const confirmReviewNavigation = () => {
setConfirmedIncompleteIntegrationSignature(incompleteIntegrationSignature);
setIncompleteIntegrationConfirmationOpened(false);
changeSection("review");
};
const handleSectionKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {
const nextIndex =
event.key === "Home"
@@ -368,7 +399,12 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
const applySetupAsync = async () => {
if (isApplying) return;
if (hasIncompleteIntegrations && !incompleteIntegrationsConfirmed) {
setIncompleteIntegrationConfirmationOpened(true);
return;
}
setIsApplying(true);
setApplyError(null);
setAppError(null);
setAppErrorSourceId(null);
setApplyProgress(5);
@@ -483,8 +519,14 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
setApplyMessage(t("review.progress.done"));
setApplyProgress(100);
await revalidatePathActionAsync("/init");
} catch {
} catch (error) {
let message = t("common.unknownError");
if (error instanceof Error && error.message.trim().length > 0) {
message = error.message;
}
sounds.error();
setApplyError(message);
showErrorNotification({ title: t("review.errorTitle"), message });
setApplyProgress(0);
setIsApplying(false);
}
@@ -570,10 +612,10 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
},
applyProgress,
applyMessage,
applyError,
appError,
appErrorSourceId,
};
const hasIncompleteIntegrations = drafts.some((draft) => !isIntegrationDraftComplete(draft));
const selectedAppWithoutAddress = discoveredApps.find(
(app) => selectedAppIds.includes(app.sourceId) && (discoveredAppUrls[app.sourceId] ?? "").trim().length === 0,
);
@@ -590,153 +632,122 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
}
setAppError(null);
setAppErrorSourceId(null);
if (hasIncompleteIntegrations) {
setIncompleteIntegrationConfirmationOpened(true);
} else {
move(1);
}
move(1);
} else {
move(1);
}
};
return (
<main
className={classes.page}
style={
{
"--studio-glow-color": primaryColor,
"--studio-secondary-glow-color": secondaryColor,
} as CSSProperties
}
>
<OnboardingBackdrop />
<div className={classes.shell}>
<Group className={classes.topbar} justify="center" mb="lg">
<OnboardingWordmark
primaryColor={primaryColor}
secondaryColor={secondaryColor.toLowerCase() === initialSecondaryColor ? undefined : secondaryColor}
/>
</Group>
<>
<Modal
opened={incompleteIntegrationConfirmationOpened}
onClose={() => setIncompleteIntegrationConfirmationOpened(false)}
title={t("connect.incompleteConfirmation")}
centered
>
<Stack gap="md">
<Text size="sm">{t("connect.incompleteConfirmation")}</Text>
<Group justify="flex-end" gap="xs">
<Button variant="default" onClick={() => setIncompleteIntegrationConfirmationOpened(false)}>
{tCommon("cancel")}
</Button>
<Button onClick={confirmReviewNavigation}>{tCommon("confirm")}</Button>
</Group>
</Stack>
</Modal>
<main
className={classes.page}
style={
{
"--studio-glow-color": primaryColor,
"--studio-secondary-glow-color": secondaryColor,
} as CSSProperties
}
>
<OnboardingBackdrop />
<div className={classes.shell}>
<Group className={classes.topbar} justify="center" mb="lg">
<OnboardingWordmark
primaryColor={primaryColor}
secondaryColor={secondaryColor.toLowerCase() === initialSecondaryColor ? undefined : secondaryColor}
/>
</Group>
<Paper className={classes.studio} radius="lg">
<div className={classes.studioGrid}>
<nav className={classes.rail} aria-label={t("navigationLabel")}>
<Timeline
active={activeIndex}
bulletSize={32}
lineWidth={2}
color={primaryColor}
className={classes.timeline}
classNames={{ itemBullet: classes.timelineBullet }}
>
{sectionDefinitions.map((section, index) => {
const Icon = section.icon;
const active = section.id === activeSection;
return (
<Timeline.Item
key={section.id}
bullet={<Icon size={16} aria-hidden />}
title={
<UnstyledButton
ref={(node) => {
sectionButtonRefs.current[index] = node;
}}
className={classes.timelineButton}
data-active={active}
onClick={() => selectSection(section.id)}
onKeyDown={(event) => handleSectionKeyDown(event, index)}
aria-label={`${t(`navigation.${section.id}`)} (${index + 1}/${sectionDefinitions.length})`}
aria-current={active ? "step" : undefined}
aria-controls="onboarding-studio-section"
tabIndex={active ? 0 : -1}
>
<Stack gap={0} align="flex-start">
<Text className={classes.timelineLabel} size="sm" fw={active ? 650 : 500}>
{t(`navigation.${section.id}`)}
</Text>
<Text className={classes.timelineLabel} size="xs" c="dimmed">
{index + 1} / {sectionDefinitions.length}
</Text>
</Stack>
</UnstyledButton>
}
/>
);
})}
</Timeline>
</nav>
<section id="onboarding-studio-section" className={classes.content} aria-labelledby="studio-section-title">
<div key={activeSection}>
<StudioSectionContent section={activeSection} {...sectionProps} />
</div>
<Group className={classes.stickyActions} justify="space-between" wrap="nowrap">
<Button
className={classes.backAction}
size="sm"
variant="default"
leftSection={<IconArrowLeft size={16} />}
aria-label={t("back")}
disabled={activeIndex === 0 || isApplying}
onClick={() => move(-1)}
<Paper className={classes.studio} radius="lg">
<div className={classes.studioGrid}>
<nav className={classes.rail} aria-label={t("navigationLabel")}>
<Timeline
active={activeIndex}
bulletSize={32}
lineWidth={2}
color={primaryColor}
className={classes.timeline}
classNames={{ itemBullet: classes.timelineBullet }}
>
{t("back")}
</Button>
{activeSection === "review" ? (
<Button size="sm" loading={isApplying} onClick={continueOnboarding}>
{t("buildBoard")}
</Button>
) : (
<Group className={classes.primaryActions} gap="xs" wrap="nowrap">
{activeSection === "connect" && hasIncompleteIntegrations ? (
<Popover
opened={incompleteIntegrationConfirmationOpened}
onDismiss={() => setIncompleteIntegrationConfirmationOpened(false)}
transitionProps={{ duration: 0 }}
position="top-end"
width={320}
shadow="md"
withArrow
trapFocus
>
<Popover.Target>
<Button
size="sm"
disabled={continueDisabled}
rightSection={<IconArrowRight size={16} />}
aria-haspopup="dialog"
aria-expanded={incompleteIntegrationConfirmationOpened}
onClick={() => setIncompleteIntegrationConfirmationOpened((opened) => !opened)}
{sectionDefinitions.map((section, index) => {
const Icon = section.icon;
const active = section.id === activeSection;
return (
<Timeline.Item
key={section.id}
bullet={<Icon size={16} aria-hidden />}
title={
<UnstyledButton
ref={(node) => {
sectionButtonRefs.current[index] = node;
}}
className={classes.timelineButton}
data-active={active}
onClick={() => selectSection(section.id)}
onKeyDown={(event) => handleSectionKeyDown(event, index)}
aria-label={`${t(`navigation.${section.id}`)} (${index + 1}/${sectionDefinitions.length})`}
aria-current={active ? "step" : undefined}
aria-controls="onboarding-studio-section"
tabIndex={active ? 0 : -1}
>
{t("continue")}
</Button>
</Popover.Target>
<Popover.Dropdown role="dialog" aria-label={t("connect.incompleteConfirmation")}>
<Stack gap="sm">
<Text size="sm">{t("connect.incompleteConfirmation")}</Text>
<Group justify="flex-end" gap="xs">
<Button
size="xs"
variant="default"
onClick={() => setIncompleteIntegrationConfirmationOpened(false)}
>
{tCommon("cancel")}
</Button>
<Button
size="xs"
onClick={() => {
setIncompleteIntegrationConfirmationOpened(false);
move(1);
}}
>
{tCommon("confirm")}
</Button>
</Group>
</Stack>
</Popover.Dropdown>
</Popover>
) : (
<Stack gap={0} align="flex-start">
<Text className={classes.timelineLabel} size="sm" fw={active ? 650 : 500}>
{t(`navigation.${section.id}`)}
</Text>
<Text className={classes.timelineLabel} size="xs" c="dimmed">
{index + 1} / {sectionDefinitions.length}
</Text>
</Stack>
</UnstyledButton>
}
/>
);
})}
</Timeline>
</nav>
<section
id="onboarding-studio-section"
className={classes.content}
aria-labelledby="studio-section-title"
>
<div key={activeSection}>
<StudioSectionContent section={activeSection} {...sectionProps} />
</div>
<Group className={classes.stickyActions} justify="space-between" wrap="nowrap">
<Button
className={classes.backAction}
size="sm"
variant="default"
leftSection={<IconArrowLeft size={16} />}
aria-label={t("back")}
disabled={activeIndex === 0 || isApplying}
onClick={() => move(-1)}
>
{t("back")}
</Button>
{activeSection === "review" ? (
<Button size="sm" loading={isApplying} onClick={continueOnboarding}>
{t("buildBoard")}
</Button>
) : (
<Group className={classes.primaryActions} gap="xs" wrap="nowrap">
<Button
size="sm"
disabled={continueDisabled}
@@ -745,15 +756,15 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
>
{t("continue")}
</Button>
)}
</Group>
)}
</Group>
</section>
</div>
</Paper>
</div>
</main>
</Group>
)}
</Group>
</section>
</div>
</Paper>
</div>
</main>
</>
);
};
@@ -807,6 +818,7 @@ interface StudioSectionProps {
setRightSidebar: (value: boolean) => void;
applyProgress: number;
applyMessage: string;
applyError: string | null;
appError: string | null;
appErrorSourceId: string | null;
}
@@ -1920,6 +1932,11 @@ const Review = (props: StudioSectionProps) => {
</Stack>
</Paper>
) : null}
{props.applyError ? (
<Alert color="red" icon={<IconAlertCircle size={18} />} title={t("errorTitle")} role="alert">
{props.applyError}
</Alert>
) : null}
</Stack>
);
};