diff --git a/ui/src/components/RestartBanner.test.ts b/ui/src/components/RestartBanner.test.ts index fcc9aa0f..bdff8e36 100644 --- a/ui/src/components/RestartBanner.test.ts +++ b/ui/src/components/RestartBanner.test.ts @@ -71,6 +71,27 @@ describe('the restart banner', () => { expect(el.querySelector('[data-testid="banner-restart-stack"]')?.textContent).toContain('Reload'); }); + it('marks its Reload as skippable with Shift, unless main restarts with fresh data', async () => { + const { el, configChanged } = await mounted('0.9.8'); + configChanged.value = true; + await nextTick(); + const button = () => el.querySelector('[data-testid="banner-restart-stack"]')!; + expect(button().querySelector('[data-testid="shift-hint"]')).not.toBeNull(); + expect(button().getAttribute('title')).toContain('Shift-click skips the confirmation'); + const snapshot = (profile: string) => ({ + type: 'snapshot', + stack: { name: 'shop', repo: '/src/shop', version: '0.9.8', services: [], infra: [], groups: [], commands: [], profile, profiles: [{ name: 'e2e', fresh: false }, { name: 'acc', fresh: true }] }, + }); + const events = (t.current as FakeTransport).stream('/hub/stacks/shop/api/v1/events'); + events.handlers.onMessage(snapshot('acc') as never); + await nextTick(); + expect(button().querySelector('[data-testid="shift-hint"]')).toBeNull(); + expect(button().getAttribute('title')).toBeNull(); + events.handlers.onMessage(snapshot('e2e') as never); + await nextTick(); + expect(button().querySelector('[data-testid="shift-hint"]')).not.toBeNull(); + }); + it('says another devstack is installed, and that the changed stack file applies with it', async () => { const { el, configChanged } = await mounted('0.9.7'); expect(el.querySelector('[data-testid="daemon-outdated"]')?.textContent).toContain('shop runs devstack 0.9.7, devstack 0.9.8 is installed.'); diff --git a/ui/src/components/RestartBanner.vue b/ui/src/components/RestartBanner.vue index a0a46912..9d7c1b3c 100644 --- a/ui/src/components/RestartBanner.vue +++ b/ui/src/components/RestartBanner.vue @@ -9,6 +9,8 @@ import { restartLanesText } from '@/lib/lanes'; import { useHub } from '@/stores/hub'; import { useStack } from '@/stores/stack'; import Icon from './icons/Icon.vue'; +import ShiftHint from './ShiftHint.vue'; +import { SHIFT_SKIP_HINT } from '@/stores/ui'; const props = defineProps<{ configChanged: boolean }>(); @@ -42,9 +44,9 @@ const canRestart = computed(() => !stack.readOnly && !!stack.entry); {{ ' ' }}{{ lanesText }} The stack file changed since {{ name ?? 'the stack' }} started. It applies after a restart. - + - {{ stack.busy.stack === 'restart' ? 'Reloading…' : 'Reload' }} + {{ stack.busy.stack === 'restart' ? 'Reloading…' : 'Reload' }} diff --git a/ui/src/components/ShiftHint.vue b/ui/src/components/ShiftHint.vue new file mode 100644 index 00000000..fd69dbb9 --- /dev/null +++ b/ui/src/components/ShiftHint.vue @@ -0,0 +1,39 @@ + + + + + + + + + diff --git a/ui/src/components/Sidebar.vue b/ui/src/components/Sidebar.vue index 2a4f7482..266ca3f6 100644 --- a/ui/src/components/Sidebar.vue +++ b/ui/src/components/Sidebar.vue @@ -42,10 +42,11 @@ import { import { useHub } from '@/stores/hub'; import { connectedTo, usePool } from '@/stores/pool'; import { useStack } from '@/stores/stack'; -import { useUi } from '@/stores/ui'; +import { SHIFT_SKIP_HINT, useUi } from '@/stores/ui'; import AddStackDialog from './AddStackDialog.vue'; import GuestTile from './GuestTile.vue'; import Icon from './icons/Icon.vue'; +import ShiftHint from './ShiftHint.vue'; const hub = useHub(); const stack = useStack(); @@ -544,13 +545,13 @@ function toggleFavourite(s: StackEntry) { - + @@ -798,7 +799,7 @@ function toggleFavourite(s: StackEntry) { data-testid="sidebar-stack-menu-list" > Open - {{ hub.stopping[menu.s.id] ? 'Stopping…' : 'Stop all…' }} + {{ hub.stopping[menu.s.id] ? 'Stopping…' : 'Stop all…' }} Copy path {{ favourites.has(menu.s.id) ? 'Remove from favourites' : 'Add to favourites' }} @@ -824,11 +825,11 @@ function toggleFavourite(s: StackEntry) { class="opt danger" role="menuitem" :disabled="menu.s.running" - :title="menu.s.running ? 'Stop it first: a running stack is listed again at once' : 'Remove it from the dashboard; nothing on disk changes'" + :title="menu.s.running ? 'Stop it first: a running stack is listed again at once' : `Remove it from the dashboard; nothing on disk changes. ${SHIFT_SKIP_HINT}.`" data-testid="sidebar-menu-remove" @click="removeStack(menu!.s)" > - Remove from the dashboard… + Remove from the dashboard… @@ -928,6 +929,13 @@ function toggleFavourite(s: StackEntry) { color: var(--text-muted); cursor: pointer; } +.head-btn { + position: relative; +} +.ctx-menu .menu-hint { + margin-left: auto; + padding-left: 12px; +} .head-btn:disabled { color: var(--text-faint); cursor: default; diff --git a/ui/src/components/UpstreamFilters.vue b/ui/src/components/UpstreamFilters.vue index 4dfded44..0329d946 100644 --- a/ui/src/components/UpstreamFilters.vue +++ b/ui/src/components/UpstreamFilters.vue @@ -8,8 +8,9 @@ import { api, paths } from '@/api'; import type { FilterAnswer, McpUpstream, UpstreamFilter } from '@/api/types'; import { act } from '@/lib/actions'; import { type FilterForm, filterForm, filterFrom, filterSummary, veilqLinear } from '@/lib/filters'; -import { useUi } from '@/stores/ui'; +import { SHIFT_SKIP_HINT, useUi } from '@/stores/ui'; import Icon from '@/components/icons/Icon.vue'; +import ShiftHint from '@/components/ShiftHint.vue'; const props = defineProps<{ upstreams: McpUpstream[] }>(); const ui = useUi(); @@ -180,7 +181,7 @@ const ready = computed(() => { Change - Remove + Remove diff --git a/ui/src/components/icons/icons.ts b/ui/src/components/icons/icons.ts index f0c641d4..d9432bf7 100644 --- a/ui/src/components/icons/icons.ts +++ b/ui/src/components/icons/icons.ts @@ -36,6 +36,8 @@ export const icons = { chevronLeft: '', arrowUp: '', arrowUpDown: '', + // Lucide arrow-big-up: the Shift key. + shift: '', arrowDown: '', search: '', eye: '', diff --git a/ui/src/stores/stack.ts b/ui/src/stores/stack.ts index b0f80abf..94fb5648 100644 --- a/ui/src/stores/stack.ts +++ b/ui/src/stores/stack.ts @@ -1452,6 +1452,15 @@ export const useStack = defineStore('stack', () => { /** What a restart does to the started lanes (ADR-0052). */ const restartLanes = computed(() => restartPlan(lanesOf.value === id.value ? lanes.value : [], entry.value?.daemon?.carries_lanes)); + /** + * A restart starts main again with a profile that has fresh data: its + * volumes go, so Shift-click does not skip that confirmation. + */ + const restartFresh = computed(() => { + const profile = mainView.value?.profile ?? undefined; + return !!profile && !!view.value?.profiles?.find((p) => p.name === profile)?.fresh; + }); + /** * Down, wait until the daemon is gone, up: picks up the installed devstack * and a changed stack file. The daemon leaves its lanes to the next one @@ -1465,7 +1474,7 @@ export const useStack = defineStore('stack', () => { const lanesText = restartLanesText(restartLanes.value); // The main tree starts again with the profile it runs with (ADR-0041 point 2). const profile = mainView.value?.profile ?? undefined; - const fresh = !!profile && !!view.value?.profiles?.find((p) => p.name === profile)?.fresh; + const fresh = restartFresh.value; const profileText = profile ? ` main starts again with the profile ${profile}${fresh ? ', with fresh data: its volumes go' : ''}.` : ''; const ok = await ui.confirm({ title: `Reload ${name}`, @@ -1694,5 +1703,5 @@ export const useStack = defineStore('stack', () => { startStack, stopStack, removeContainers, - restartStack, restartLanes, shareLane }; + restartStack, restartLanes, restartFresh, shareLane }; }); diff --git a/ui/src/stores/ui.ts b/ui/src/stores/ui.ts index 02d62d9e..c05509ed 100644 --- a/ui/src/stores/ui.ts +++ b/ui/src/stores/ui.ts @@ -6,6 +6,9 @@ export type ThemePref = 'system' | 'light' | 'dark'; export type ToastKind = 'success' | 'error' | 'info' | 'warning'; export type Toast = { id: number; kind: ToastKind; title: string; message?: string }; +/** What a button whose confirmation Shift can skip says of it (tooltip and ShiftHint). */ +export const SHIFT_SKIP_HINT = 'Shift-click skips the confirmation'; + export type ConfirmRequest = { title: string; text: string; diff --git a/ui/src/views/StackPage.vue b/ui/src/views/StackPage.vue index 879e304b..74989a72 100644 --- a/ui/src/views/StackPage.vue +++ b/ui/src/views/StackPage.vue @@ -20,11 +20,13 @@ import { laneView } from '@/lib/stackRoutes'; import { statusLook } from '@/lib/status'; import { useHub } from '@/stores/hub'; import { useStack } from '@/stores/stack'; +import { SHIFT_SKIP_HINT } from '@/stores/ui'; import AgentPrompt from '@/components/AgentPrompt.vue'; import Icon from '@/components/icons/Icon.vue'; import PathMenu from '@/components/PathMenu.vue'; import PortGraph from '@/components/PortGraph.vue'; import RestartBanner from '@/components/RestartBanner.vue'; +import ShiftHint from '@/components/ShiftHint.vue'; import StackFileBanner from '@/components/StackFileBanner.vue'; import { refusedForPorts, runningHolders, shiftLabel } from '@/lib/shift'; import StatusPill from '@/components/StatusPill.vue'; @@ -275,11 +277,11 @@ const singletons = computed(() => services.value.filter((s) => s.singleton)); - - Reload + + Reload - - Stop all + + Stop all @@ -295,18 +297,18 @@ const singletons = computed(() => services.value.filter((s) => s.singleton)); :key="h.id" type="button" class="btn" - :title="`Stop and remove the containers of ${h.name} (devstack down there); their volumes stay`" + :title="`Stop and remove the containers of ${h.name} (devstack down there); their volumes stay. ${SHIFT_SKIP_HINT}.`" :data-testid="`remove-containers-${h.id}`" @click="removeContainers(h.id, h.name)" > - Remove containers of {{ h.name }} + Remove containers of {{ h.name }} Its containers run though its daemon does not, and hold {{ ownHeld.join(', ') }}: Docker started them again, or a stop kept them. Another stack cannot start on those ports. - - Remove containers + + Remove containers