fix(plugins): keep Try it and Switch back toasts up for 10s (#35650)

This commit is contained in:
Neil
2026-10-28 21:25:02 -07:00
committed by GitHub
parent 4a24d5aacd
commit 7fa6e265bf
5 changed files with 19 additions and 0 deletions
@@ -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
@@ -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) }
})
})
@@ -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<boolean>
value0: label
}),
{
duration: PLUGIN_ACTION_TOAST_DURATION_MS,
action: {
label: translate('auto.components.settings.pluginThemeApply.switchBack', 'Switch back'),
onClick: () => void useAppStore.getState().updateSettings(previous)
@@ -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 = {
@@ -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)