Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ui/src/components/RestartBanner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
6 changes: 4 additions & 2 deletions ui/src/components/RestartBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>();

Expand Down Expand Up @@ -42,9 +44,9 @@ const canRestart = computed(() => !stack.readOnly && !!stack.entry);
<template v-if="lanesText">{{ ' ' }}{{ lanesText }}</template>
</span>
<span v-else class="grow"><strong>The stack file changed since {{ name ?? 'the stack' }} started.</strong> It applies after a restart.</span>
<button v-if="canRestart" type="button" class="btn btn-primary btn-sm" :disabled="!!stack.busy.stack" data-testid="banner-restart-stack" @click="stack.restartStack()">
<button v-if="canRestart" type="button" class="btn btn-primary btn-sm" :disabled="!!stack.busy.stack" :title="stack.restartFresh ? undefined : `${SHIFT_SKIP_HINT}.`" data-testid="banner-restart-stack" @click="stack.restartStack()">
<span v-if="stack.busy.stack === 'restart'" class="spinner" /><Icon v-else name="restart" :size="14" />
{{ stack.busy.stack === 'restart' ? 'Reloading…' : 'Reload' }}
{{ stack.busy.stack === 'restart' ? 'Reloading…' : 'Reload' }}<ShiftHint v-if="!stack.restartFresh && stack.busy.stack !== 'restart'" />
</button>
</div>
</template>
Expand Down
39 changes: 39 additions & 0 deletions ui/src/components/ShiftHint.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script setup lang="ts">
// Marks a button whose confirmation Shift-click skips (ui.confirm, `skippable`).
// Only for a dialog that is skippable: not on one marked `skippable: false`.
// Hidden from screen readers; the button's own title or label says it.
import { SHIFT_SKIP_HINT } from '@/stores/ui';
import Icon from './icons/Icon.vue';

defineProps<{
/** A small badge in the button's bottom-right corner, for an icon-only button (which needs position: relative). */
corner?: boolean;
}>();
</script>

<template>
<span class="shift-hint" :class="{ corner }" :title="SHIFT_SKIP_HINT" aria-hidden="true" data-testid="shift-hint">
<Icon name="shift" :size="corner ? 9 : 11" :stroke-width="2.25" />
</span>
</template>

<style scoped>
.shift-hint {
display: inline-flex;
align-items: center;
margin-left: 2px;
color: currentColor;
opacity: 0.55;
transition: opacity 0.12s;
}
:is(button, .btn):hover:not(:disabled) > .shift-hint {
opacity: 0.9;
}
.shift-hint.corner {
position: absolute;
right: 0;
bottom: 0;
margin: 0;
pointer-events: auto;
}
</style>
20 changes: 14 additions & 6 deletions ui/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -544,13 +545,13 @@ function toggleFavourite(s: StackEntry) {
<button
type="button"
class="head-btn"
title="Stop all stacks… (Shift-click skips the confirmation)"
:title="`Stop all stacks… (${SHIFT_SKIP_HINT})`"
aria-label="Stop all stacks"
:disabled="!runningStacks.length || stoppingAll"
data-testid="sidebar-stop-all"
@click="stopAll()"
>
<span v-if="stoppingAll" class="spinner sm" aria-hidden="true" /><Icon v-else name="power" :size="14" />
<span v-if="stoppingAll" class="spinner sm" aria-hidden="true" /><template v-else><Icon name="power" :size="14" /><ShiftHint corner /></template>
</button>
<button type="button" class="head-btn" title="Add a stack…" aria-label="Add a stack" data-testid="sidebar-add-stack" @click="adding = true">
<Icon name="plus" :size="14" />
Expand Down Expand Up @@ -798,7 +799,7 @@ function toggleFavourite(s: StackEntry) {
data-testid="sidebar-stack-menu-list"
>
<button type="button" class="opt" role="menuitem" @click="(closeMenu(), openStack(menu!.s))"><Icon name="layers" :size="14" /> Open</button>
<button v-if="menu.s.running" type="button" class="opt" role="menuitem" :disabled="!!hub.stopping[menu.s.id]" data-testid="sidebar-menu-stop" @click="stopStack(menu!.s)"><Icon name="power" :size="14" /> {{ hub.stopping[menu.s.id] ? 'Stopping…' : 'Stop all…' }}</button>
<button v-if="menu.s.running" type="button" class="opt" role="menuitem" :disabled="!!hub.stopping[menu.s.id]" :title="`${SHIFT_SKIP_HINT}.`" data-testid="sidebar-menu-stop" @click="stopStack(menu!.s)"><Icon name="power" :size="14" /> {{ hub.stopping[menu.s.id] ? 'Stopping…' : 'Stop all…' }}<ShiftHint class="menu-hint" /></button>
<button type="button" class="opt" role="menuitem" @click="copyPath(menu!.s)"><Icon name="copy" :size="14" /> Copy path</button>
<button type="button" class="opt" role="menuitem" data-testid="sidebar-menu-fav" @click="toggleFavourite(menu!.s)">
<Icon name="star" :size="14" /> {{ favourites.has(menu.s.id) ? 'Remove from favourites' : 'Add to favourites' }}
Expand All @@ -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)"
>
<Icon name="trash" :size="14" /> Remove from the dashboard…
<Icon name="trash" :size="14" /> Remove from the dashboard…<ShiftHint v-if="!menu.s.running" class="menu-hint" />
</button>
</div>
</Teleport>
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions ui/src/components/UpstreamFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -180,7 +181,7 @@ const ready = computed(() => {
</div>
<div class="actions">
<button type="button" class="btn btn-ghost btn-sm" @click="startEdit(i)">Change</button>
<button type="button" class="btn btn-ghost btn-sm" :disabled="busy" @click="remove(i)">Remove</button>
<button type="button" class="btn btn-ghost btn-sm" :disabled="busy" :title="`${SHIFT_SKIP_HINT}.`" @click="remove(i)">Remove<ShiftHint /></button>
</div>
</li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/icons/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const icons = {
chevronLeft: '<path d="m15 18-6-6 6-6"/>',
arrowUp: '<path d="m5 12 7-7 7 7"/><path d="M12 19V5"/>',
arrowUpDown: '<path d="m21 16-4 4-4-4"/><path d="M17 20V4"/><path d="m3 8 4-4 4 4"/><path d="M7 4v16"/>',
// Lucide arrow-big-up: the Shift key.
shift: '<path d="M9 18v-6H5l7-7 7 7h-4v6H9z"/>',
arrowDown: '<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',
search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',
eye: '<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>',
Expand Down
13 changes: 11 additions & 2 deletions ui/src/stores/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}`,
Expand Down Expand Up @@ -1694,5 +1703,5 @@ export const useStack = defineStore('stack', () => {
startStack,
stopStack,
removeContainers,
restartStack, restartLanes, shareLane };
restartStack, restartLanes, restartFresh, shareLane };
});
3 changes: 3 additions & 0 deletions ui/src/stores/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 10 additions & 8 deletions ui/src/views/StackPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -275,11 +277,11 @@ const singletons = computed(() => services.value.filter((s) => s.singleton));
<div v-if="changes" class="actions">
<!-- No start of the stack: each tree starts on its own card, main too; the daemon comes with the first (ADR-0095). -->
<template v-if="stack.running">
<button type="button" class="btn" :disabled="!!stack.busy.stack" title="Start its daemon again with the installed devstack and the current stack file; the lanes are carried over. Shift-click skips the confirmation." data-testid="action-restart-stack" @click="stack.restartStack()">
<span v-if="stack.busy.stack === 'restart'" class="spinner" /><Icon v-else name="restart" :size="14" /> Reload
<button type="button" class="btn" :disabled="!!stack.busy.stack" :title="`Start its daemon again with the installed devstack and the current stack file; the lanes are carried over.${stack.restartFresh ? '' : ` ${SHIFT_SKIP_HINT}.`}`" data-testid="action-restart-stack" @click="stack.restartStack()">
<span v-if="stack.busy.stack === 'restart'" class="spinner" /><Icon v-else name="restart" :size="14" /> Reload<ShiftHint v-if="!stack.restartFresh" />
</button>
<button type="button" class="btn btn-stop" :disabled="!!stack.busy.stack" title="Every tree stops, main and each lane, with its services and containers; the daemon ends with the last. Shift-click skips the confirmation." data-testid="action-stack-stop" @click="stack.stopStack()">
<span v-if="stack.busy.stack === 'stop'" class="spinner" /><Icon v-else name="power" :size="14" /> Stop all
<button type="button" class="btn btn-stop" :disabled="!!stack.busy.stack" :title="`Every tree stops, main and each lane, with its services and containers; the daemon ends with the last. ${SHIFT_SKIP_HINT}.`" data-testid="action-stack-stop" @click="stack.stopStack()">
<span v-if="stack.busy.stack === 'stop'" class="spinner" /><Icon v-else name="power" :size="14" /> Stop all<ShiftHint />
</button>
</template>
</div>
Expand 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 }}<ShiftHint />
</button>
</div>
<div v-if="!hubDown && ownContainers" class="banner warn" data-testid="stack-own-containers">
<Icon name="alert" :size="18" />
<span class="grow">Its containers run though its daemon does not<template v-if="ownHeld.length">, and hold {{ ownHeld.join(', ') }}</template>: Docker started them again, or a stop kept them. Another stack cannot start on those ports.</span>
<button v-if="changes && stack.id" type="button" class="btn" title="Stop and remove its containers (devstack down); their volumes stay" data-testid="remove-own-containers" @click="removeContainers(stack.id, stack.entry?.name ?? 'this stack')">
Remove containers
<button v-if="changes && stack.id" type="button" class="btn" :title="`Stop and remove its containers (devstack down); their volumes stay. ${SHIFT_SKIP_HINT}.`" data-testid="remove-own-containers" @click="removeContainers(stack.id, stack.entry?.name ?? 'this stack')">
Remove containers<ShiftHint />
</button>
</div>
<div v-if="!hubDown && stack.entry?.start_error && !stack.running" class="banner warn" data-testid="stack-start-error">
Expand Down
Loading