Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(routines): use shared Select for session mode and restore routine UI fixture
Chris49d369996919
diff --git a/apps/desktop/scripts/fixtures/bot-routines/routines-fixture.tsx b/apps/desktop/scripts/fixtures/bot-routines/routines-fixture.tsxindex d7de393aed..cd41e05fdf 100644--- a/apps/desktop/scripts/fixtures/bot-routines/routines-fixture.tsx+++ b/apps/desktop/scripts/fixtures/bot-routines/routines-fixture.tsx@@ -1,3 +1,4 @@+import { MemoryRouter } from 'react-router-dom';import { mountPage, subscription, forbid } from '../../ui-page/harness';import { BotRoutines } from '../../../src/renderer/features/bots/BotRoutines';import { BotAutonomySettings } from '../../../src/renderer/features/bots/BotAutonomySettings';@@ -37,7 +38,7 @@ mountPage({maker: { onBotAutonomyChanged: subscription('autonomy') },};},- render: () => <div className="mx-auto w-full max-w-xl p-4"><BotRoutines botId="fixture" embedded+ render: () => <MemoryRouter><div className="mx-auto w-full max-w-xl p-4"><BotRoutines botId="fixture" embeddedheader={<BotAutonomySettings botId="fixture" botName="Cindy" allowSchedulerFollow={false} onAllowSchedulerFollowChange={() => {}} />}- /></div>,+ /></div></MemoryRouter>,});diff --git a/apps/desktop/scripts/fixtures/bot-routines/ui-page.mjs b/apps/desktop/scripts/fixtures/bot-routines/ui-page.mjsindex 460268f4c7..99903bba56 100644--- a/apps/desktop/scripts/fixtures/bot-routines/ui-page.mjs+++ b/apps/desktop/scripts/fixtures/bot-routines/ui-page.mjs@@ -3,12 +3,17 @@ export default {name: 'bot-routines', entry: './routines-fixture.tsx',viewport: { width: 440, height: 900 },real: 'BotRoutines list/editor, BotAutonomySettings, cronToHuman and standard switches',- notCovered: 'Host persistence, real scheduler execution, plugin events and native Mobile (no routine management entry)',- stubs: { 'src/renderer/features/bots/botStore': { partial: 'export const useBotProfiles=()=>[];' } },+ notCovered: 'Host persistence, real scheduler execution, plugin events, routine model picker and native Mobile (no routine management entry)',+ stubs: {+ 'src/renderer/features/bots/botStore': { partial: 'export const useBotProfiles=()=>[];' },+ // The model picker needs signed-in model access; its own page covers it.+ 'src/renderer/features/bots/BotTaskModelEditor': 'export function BotTaskModelEditor(){return null;}',+ },cases: {default: { about: 'Paused, enabled, queued, running; exact hourly and selected-hour schedules; independent follow-up scope' },'save-error': { about: 'Failed pause keeps the enabled switch; retry saves without running' },history: { about: 'Failure result is readable before expanding run details' },+ 'session-mode': { about: 'Run session choice: persistent context or a new isolated session per trigger' },},async ready(page) { await page.getByRole('button', { name: /Daily project summary/ }).waitFor(); },async check(page, ui) {@@ -19,6 +24,18 @@ export default {await ui.capture('failed-run');return;}+ if (ui.case === 'session-mode') {+ await page.getByRole('button', { name: 'Daily project summary', exact: true }).click();+ const mode = page.getByRole('combobox', { name: await ui.t('routines.sessionMode') });+ await mode.click();+ const fresh = page.getByRole('option', { name: await ui.t('routines.sessionModeFresh') });+ await fresh.waitFor();+ await ui.capture('session-mode-open');+ await fresh.click();+ assert.equal((await mode.textContent())?.includes(await ui.t('routines.sessionModeFresh')), true);+ await ui.capture('session-mode-fresh');+ return;+ }await toggle.click();if (ui.case === 'save-error') {await page.getByRole('alert').waitFor();diff --git a/apps/desktop/src/renderer/features/bots/BotRoutines.tsx b/apps/desktop/src/renderer/features/bots/BotRoutines.tsxindex 0eab366165..5d71d78afe 100644--- a/apps/desktop/src/renderer/features/bots/BotRoutines.tsx+++ b/apps/desktop/src/renderer/features/bots/BotRoutines.tsx@@ -17,6 +17,7 @@ import type {} from '@cindy/maker-scheduler';import { Button } from '@/components/ui/button';import { Input, Textarea } from '@/components/ui/input';+import { Select } from '@/components/ui/select';import { Switch } from '@/components/ui/switch';import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';import { Spinner } from '@/components/ui/spinner';@@ -428,20 +429,22 @@ export function BotRoutines({fastMode: route.fastMode, agentDeviceId: route.agentDeviceId ?? null,} : null })}/>}- <label className="block space-y-2">- <span className={fieldLabelClass}>{t('routines.sessionMode')}</span>- <select- aria-label={t('routines.sessionMode')}- className="w-full rounded-full border border-[var(--border-default)] bg-[var(--surface-elevated)] px-3 py-2 text-12"+ <div className="space-y-2">+ <span aria-hidden className={fieldLabelClass}>{t('routines.sessionMode')}</span>+ <Select+ label={t('routines.sessionMode')}+ className="w-full"disabled={busy || saved?.builtin === 'nightly-learning'}value={draft.sessionMode ?? 'persistent'}- onChange={(event) => setDraft({ ...draft, sessionMode: event.target.value as 'persistent' | 'fresh' })}- >- <option value="persistent">{t('routines.sessionModePersistent')}</option>- <option value="fresh">{t('routines.sessionModeFresh')}</option>- </select>- <p className="text-12 text-[var(--text-secondary)]">{t('routines.sessionModeHint')}</p>- </label>+ options={[+ { value: 'persistent', label: t('routines.sessionModePersistent') },+ { value: 'fresh', label: t('routines.sessionModeFresh') },+ ]}+ onValueChange={(value) => setDraft({ ...draft, sessionMode: value as 'persistent' | 'fresh' })}+ aria-describedby="routine-session-mode-hint"+ />+ <p id="routine-session-mode-hint" className="text-12 text-[var(--text-secondary)]">{t('routines.sessionModeHint')}</p>+ </div><fieldset disabled={!!saved?.builtin} className="min-w-0 space-y-5"><details className="space-y-3"><summary className="min-h-8 cursor-pointer rounded-full py-2 focus-visible:outline focus-visible:outline-[var(--focus-ring)]">{t('routines.advancedSettings')}</summary>diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botRoutines.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botRoutines.test.tsxindex 1e138ea456..e6008bfae0 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botRoutines.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botRoutines.test.tsx@@ -141,12 +141,16 @@ it('saves enabled state and does not run a routine just by saving', async () =>});it('saves the selected session mode without executing a routine', async () => {const api = setup();+ const scrollIntoView = HTMLElement.prototype.scrollIntoView;+ HTMLElement.prototype.scrollIntoView = vi.fn();render(<BotRoutines botId="bot" />);fireEvent.click(await screen.findByText('Daily report'));- fireEvent.change(screen.getByLabelText('routines.sessionMode'), { target: { value: 'fresh' } });+ fireEvent.keyDown(screen.getByRole('combobox', { name: 'routines.sessionMode' }), { key: 'ArrowDown' });+ fireEvent.click(await screen.findByRole('option', { name: 'routines.sessionModeFresh' }));fireEvent.click(screen.getByRole('button', { name: 'routines.save' }));await waitFor(() => expect(api.save).toHaveBeenCalledWith('bot', expect.objectContaining({ sessionMode: 'fresh' }), 'daily'));expect(api.runNow).not.toHaveBeenCalled();+ HTMLElement.prototype.scrollIntoView = scrollIntoView;});it('requires confirmation for deletion, then refreshes the list', async () => {const api = setup();