diff --git a/src/renderer/src/components/plugins/state/plugin-action-toast.ts b/src/renderer/src/components/plugins/state/plugin-action-toast.ts new file mode 100644 index 00000000000..de52b9c859e --- /dev/null +++ b/src/renderer/src/components/plugins/state/plugin-action-toast.ts @@ -0,0 +1,2 @@ +// Why: sonner's 4s default hides Try it / Switch back before users reach them; hover still pauses. +export const PLUGIN_ACTION_TOAST_DURATION_MS = 10_000 diff --git a/src/renderer/src/components/plugins/state/plugin-theme-apply.test.ts b/src/renderer/src/components/plugins/state/plugin-theme-apply.test.ts index e1088c60a4c..472e86afd65 100644 --- a/src/renderer/src/components/plugins/state/plugin-theme-apply.test.ts +++ b/src/renderer/src/components/plugins/state/plugin-theme-apply.test.ts @@ -105,6 +105,7 @@ it('fills both slots from a light and dark pair, plus icon and terminal themes', }) expect(settings.terminalPluginPalettes).toHaveLength(2) expect(toast.success).toHaveBeenCalledWith('Now using Ember', { + duration: 10_000, action: { label: 'Switch back', onClick: expect.any(Function) } }) }) diff --git a/src/renderer/src/components/plugins/state/plugin-theme-apply.ts b/src/renderer/src/components/plugins/state/plugin-theme-apply.ts index 776d1e96ce1..f0f3cb2943b 100644 --- a/src/renderer/src/components/plugins/state/plugin-theme-apply.ts +++ b/src/renderer/src/components/plugins/state/plugin-theme-apply.ts @@ -7,6 +7,7 @@ import { resolveDocumentTheme } from '@/lib/document-theme' import { pluginAppThemeSlotUpdate } from '../../../../../shared/plugin-theme-settings' import { withTerminalPluginPalettes } from '@/lib/terminal-plugin-palettes' import { useAppStore } from '@/store' +import { PLUGIN_ACTION_TOAST_DURATION_MS } from './plugin-action-toast' import { usePluginIconThemeStore } from '@/store/plugin-icon-themes' import { usePluginThemeStore, usePluginTerminalThemeStore } from '@/store/plugin-themes' @@ -136,6 +137,7 @@ export async function applyPluginThemesNow(pluginKey: string): Promise value0: label }), { + duration: PLUGIN_ACTION_TOAST_DURATION_MS, action: { label: translate('auto.components.settings.pluginThemeApply.switchBack', 'Switch back'), onClick: () => void useAppStore.getState().updateSettings(previous) diff --git a/src/renderer/src/components/plugins/state/use-plugin-install-action.test.tsx b/src/renderer/src/components/plugins/state/use-plugin-install-action.test.tsx index e5769a628c3..d16e5fe8346 100644 --- a/src/renderer/src/components/plugins/state/use-plugin-install-action.test.tsx +++ b/src/renderer/src/components/plugins/state/use-plugin-install-action.test.tsx @@ -120,6 +120,18 @@ describe('usePluginInstallAction', () => { expect(toast.success).not.toHaveBeenCalled() }) + it('keeps the Try it toast up long enough to click', async () => { + const { hook } = setup() + await act(async () => hook.current?.install(listing)) + expect(toast.success).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ + duration: 10_000, + action: expect.objectContaining({ label: 'Try it' }) + }) + ) + }) + it('approves exactly the fingerprint the page showed for a plugin that runs code', async () => { const { hook } = setup() const codeListing = { diff --git a/src/renderer/src/components/plugins/state/use-plugin-install-action.ts b/src/renderer/src/components/plugins/state/use-plugin-install-action.ts index 53e028f45de..ac3ae958237 100644 --- a/src/renderer/src/components/plugins/state/use-plugin-install-action.ts +++ b/src/renderer/src/components/plugins/state/use-plugin-install-action.ts @@ -7,6 +7,7 @@ import type { import { pluginExecutionProfile } from '../../../../../shared/plugins/contributions/plugin-execution-profile' import { translate } from '@/i18n/i18n' import { pluginInstallErrorMessage } from '../presentation/plugin-error-presentation' +import { PLUGIN_ACTION_TOAST_DURATION_MS } from './plugin-action-toast' import { applyPluginThemesNow } from './plugin-theme-apply' import type { PluginPagePreview } from './use-plugin-catalog' import { previewMatchesListing } from './use-plugin-page-model' @@ -166,6 +167,7 @@ export function usePluginInstallAction({ { value0: preview.manifest.name } ), { + duration: PLUGIN_ACTION_TOAST_DURATION_MS, action: { label: translate('auto.components.settings.pluginInstallAction.tryIt', 'Try it'), onClick: () => onTryPlugin(pluginKey)