Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(cindy-make): 调整预检继续与取消按钮

Lizi4c0eebe409c5
diff --git a/apps/desktop/src/renderer/components/chat/CindyMakeDoctorCard.tsx b/apps/desktop/src/renderer/components/chat/CindyMakeDoctorCard.tsx
index a7f6bc2bec..167b6dae20 100644
--- a/apps/desktop/src/renderer/components/chat/CindyMakeDoctorCard.tsx
+++ b/apps/desktop/src/renderer/components/chat/CindyMakeDoctorCard.tsx
@@ -250,6 +250,7 @@ export function MakeDoctorReportCard({
showSource = true,
compactPrepare = false,
readOnly = false,
+ showUpstreamActions = true,
}: {
report: MakeDoctorReport;
request?: string;
@@ -272,6 +273,8 @@ export function MakeDoctorReportCard({
showSource?: boolean;
compactPrepare?: boolean;
readOnly?: boolean;
+ /** Settings preflight places the personal-version action beside Cancel. */
+ showUpstreamActions?: boolean;
}) {
const { t } = useTranslation();
const [expanded, setExpanded] = useState(true);
@@ -716,7 +719,8 @@ export function MakeDoctorReportCard({
{!readOnly &&
(upstream?.status === 'found' || upstream?.status === 'notFound') &&
!decision &&
- !searching && (
+ !searching &&
+ showUpstreamActions && (
<div className="flex shrink-0 flex-wrap justify-end gap-2">
<Button
variant="secondary"
diff --git a/apps/desktop/src/renderer/components/cindy-make/CindyMakePreflightDialog.tsx b/apps/desktop/src/renderer/components/cindy-make/CindyMakePreflightDialog.tsx
index add80f9555..c5fa887524 100644
--- a/apps/desktop/src/renderer/components/cindy-make/CindyMakePreflightDialog.tsx
+++ b/apps/desktop/src/renderer/components/cindy-make/CindyMakePreflightDialog.tsx
@@ -156,11 +156,7 @@ export function CindyMakePreflightDialog({
report={report}
request={request}
startingCode={starting}
- onChoose={(choice) => {
- if (submitting.current) return;
- if (choice === 'wait') onOpenChange(false);
- else void start();
- }}
+ showUpstreamActions={false}
onRecheck={() => {
if (!submitting.current && current()) {
setFailed(false);
@@ -180,12 +176,24 @@ export function CindyMakePreflightDialog({
{t('cindyMake.code.preparationFailed')}
</p>
)}
- <div className="flex justify-end">
+ <div className="flex flex-wrap justify-end gap-2">
<Dialog.Close asChild>
<Button variant="secondary" disabled={starting}>
{t('settings.cindyMake.create.cancel')}
</Button>
</Dialog.Close>
+ {report?.status === 'completed' &&
+ ['found', 'notFound'].includes(report.upstream?.status ?? '') && (
+ <Button
+ variant="primary"
+ className="border-[var(--border-default)] enabled:hover:border-[var(--button-primary-hover)] enabled:active:border-[var(--button-primary-pressed)]"
+ disabled={starting}
+ loading={starting}
+ onClick={() => void start()}
+ >
+ {t('cindyMake.upstream.personal')}
+ </Button>
+ )}
</div>
</Dialog.Content>
</Dialog.Portal>
diff --git a/apps/desktop/src/renderer/components/cindy-make/__tests__/CindyMakePreflightDialog.test.tsx b/apps/desktop/src/renderer/components/cindy-make/__tests__/CindyMakePreflightDialog.test.tsx
index 5fdc4499f9..4e60da247d 100644
--- a/apps/desktop/src/renderer/components/cindy-make/__tests__/CindyMakePreflightDialog.test.tsx
+++ b/apps/desktop/src/renderer/components/cindy-make/__tests__/CindyMakePreflightDialog.test.tsx
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
import { StrictMode } from 'react';
-import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';
import { MAKE_DOCTOR_CHECK_IDS, type MakeDoctorReport } from '../../../../shared/cindyMakeDoctor';
@@ -135,14 +135,17 @@ describe('Make preflight confirmation boundary', () => {
},
);
- it.each(['cancel', 'wait'])('creates no task on %s', async (choice) => {
+ it('closes to wait for upstream without creating a task', async () => {
const view = open();
await finishChecks();
- fireEvent.click(
- screen.getByRole('button', {
- name: choice === 'wait' ? 'cindyMake.upstream.wait' : 'settings.cindyMake.create.cancel',
- }),
- );
+ expect(screen.queryByRole('button', { name: 'cindyMake.upstream.wait' })).toBeNull();
+ const card = screen.getByRole('region', { name: 'cindyMake.title' });
+ expect(within(card).queryByRole('button', { name: 'cindyMake.upstream.personal' })).toBeNull();
+ const buttons = screen.getAllByRole('button');
+ const cancel = screen.getByRole('button', { name: 'settings.cindyMake.create.cancel' });
+ const personal = screen.getByRole('button', { name: 'cindyMake.upstream.personal' });
+ expect(buttons.indexOf(cancel)).toBeLessThan(buttons.indexOf(personal));
+ fireEvent.click(screen.getByRole('button', { name: 'settings.cindyMake.create.cancel' }));
expect(view.close).toHaveBeenCalledWith(false);
expect(h.create).not.toHaveBeenCalled();
});