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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ and listed with their assets on the
the chosen order. Marking moves the stack at once. Favourites live in
the browser's `localStorage`, as the order does.

### Fixed

- **The restart banner shows in a lane's views again** (ADR-0081). "The
stack file changed since the stack started" and "another devstack is
installed", each with its Restart stack button, moved to the stack's page
and were gone from every lane's view, where the stack file gets edited.
Both pages show the same banner now; a lane's says it of the lane's own
stack file.

## [0.35.0] - 2026-11-03

A connection to a shared lane is to the lane, not to its lease: it
Expand Down
11 changes: 11 additions & 0 deletions docs/adr/0081-a-stack-has-a-page-every-lane-the-same-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,14 @@ sidebar listing `main` under every stack, also one without worktrees.
`main`'s Stop.
- The stack's page is where a port graph and a port shift for several
stacks on one machine (#387) go.

## Addendum 2026-11-03: the restart banner stands above the lanes' views too

Point 3 put the restart banner (another devstack installed, a changed stack
file) on the stack's page, and a lane's view lost it, although a stack file
is edited in a lane's worktree and the banner is where its Restart stack
button was found. The banner (`RestartBanner`) stands above the stack's page
and above every lane's views, `main` included, with its Restart stack
button: the page says it of the main tree's stack file, a lane's view of the
shown lane's own. The stack-level actions in the page's header stay on the
page; the banner is the one stack-level control a lane's view shows.
83 changes: 83 additions & 0 deletions ui/src/components/RestartBanner.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// The restart banner (a changed stack file, another devstack installed): the
// same one above the stack's page and a lane's views, with its Restart stack
// button.
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { createApp, h, nextTick, ref } from 'vue';
import { createPinia, setActivePinia } from 'pinia';
import type { StackEntry } from '@/api/types';
import { FakeTransport, ok } from '@/test/fake';

const t = vi.hoisted(() => ({ current: null as FakeTransport | null }));

vi.mock('@/api', async (importOriginal) => {
const real = await importOriginal<typeof import('@/api')>();
return {
...real,
api: () => {
if (!t.current) throw new Error('no fake transport');
return t.current;
},
};
});

const { useHub } = await import('@/stores/hub');
const { useStack } = await import('@/stores/stack');
const RestartBanner = (await import('./RestartBanner.vue')).default;

const entry = (version: string): StackEntry => ({
id: 'shop',
name: 'shop',
file: '/src/shop/devstack.toml',
repo: '/src/shop',
running: true,
daemon: { pid: 1, port: 7000, started: 0, version },
last_seen: null,
});

beforeEach(() => {
localStorage.clear();
document.body.innerHTML = '';
setActivePinia(createPinia());
const fake = new FakeTransport();
t.current = fake;
fake.on('/hub/session', ok({ version: '0.9.8' }));
});

/** The banner as a view mounts it: the daemon runs `daemonVersion`, the hub's is 0.9.8; `lane` is the one shown. */
async function mounted(daemonVersion: string, lane: string | null = null) {
const hub = useHub();
await hub.init();
(t.current as FakeTransport).stream('/hub/events').handlers.onMessage({ type: 'stacks', stacks: [entry(daemonVersion)] });
useStack().select('shop', { lane, remember: false });
const configChanged = ref(false);
const el = document.createElement('div');
document.body.appendChild(el);
createApp({ render: () => h(RestartBanner, { configChanged: configChanged.value }) }).mount(el);
await nextTick();
return { el, configChanged };
}

describe('the restart banner', () => {
it('says nothing while neither the stack file nor the devstack version differs', async () => {
const { el } = await mounted('0.9.8');
expect(el.querySelector('.banner')).toBeNull();
});

it.each([null, 'feat'])('says the stack file changed, with the restart button, in the lane %s', async (lane) => {
const { el, configChanged } = await mounted('0.9.8', lane);
configChanged.value = true;
await nextTick();
expect(el.querySelector('[data-testid="config-changed"]')?.textContent).toContain('The stack file changed since shop started.');
expect(el.querySelector('[data-testid="banner-restart-stack"]')?.textContent).toContain('Restart stack');
});

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.');
expect(el.textContent).not.toContain('applies the changed stack file');
configChanged.value = true;
await nextTick();
expect(el.querySelector('[data-testid="config-changed"]')).toBeNull();
expect(el.textContent).toContain('and applies the changed stack file');
});
});
59 changes: 59 additions & 0 deletions ui/src/components/RestartBanner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<script setup lang="ts">
// The stack's daemon should restart: it runs another devstack than the one
// installed, or a stack file changed since it started. Above the stack's page
// and above every lane's views, since a lane is where a stack file gets edited
// (ADR-0081); the page says it of the main tree's file, a lane's view of the
// shown lane's own.
import { computed } from 'vue';
import { restartLanesText } from '@/lib/lanes';
import { useHub } from '@/stores/hub';
import { useStack } from '@/stores/stack';
import Icon from './icons/Icon.vue';

const props = defineProps<{ configChanged: boolean }>();

const hub = useHub();
const stack = useStack();

const hubDown = computed(() => hub.status === 'unreachable' || hub.stream === 'error');
const name = computed(() => stack.entry?.name ?? stack.mainView?.name ?? null);
/** The daemon runs another devstack than the hub: a restart of the stack starts it with the installed one. */
const daemonOutdated = computed(() => {
const d = stack.entry?.daemon?.version;
const h = hub.version;
return d && h && d !== h ? { daemon: d, hub: h } : null;
});
const reason = computed(() => {
if (!stack.running || hubDown.value) return null;
if (daemonOutdated.value) return 'version';
if (props.configChanged) return 'config';
return null;
});
const lanesText = computed(() => restartLanesText(stack.restartLanes));
const canRestart = computed(() => !stack.readOnly && !!stack.entry);
</script>

<template>
<div v-if="reason" class="banner warn" :data-testid="reason === 'version' ? 'daemon-outdated' : 'config-changed'">
<Icon :name="reason === 'version' ? 'alert' : 'file'" :size="18" />
<span v-if="reason === 'version'" class="grow">
<strong>{{ name ?? 'This stack' }} runs devstack {{ daemonOutdated?.daemon }}, devstack {{ daemonOutdated?.hub }} is installed.</strong>
{{ ' ' }}A restart of the stack switches it over<template v-if="configChanged"> and applies the changed stack file</template>.
<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()">
<span v-if="stack.busy.stack === 'restart'" class="spinner" /><Icon v-else name="restart" :size="14" />
{{ stack.busy.stack === 'restart' ? 'Restarting…' : 'Restart stack' }}
</button>
</div>
</template>

<style scoped>
.banner {
flex-wrap: wrap;
}
.grow {
flex: 1 1 240px;
}
</style>
2 changes: 2 additions & 0 deletions ui/src/views/StackLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Icon from '@/components/icons/Icon.vue';
import StackHeader from '@/components/StackHeader.vue';
import LaneStart from '@/components/LaneStart.vue';
import { rememberTab } from '@/lib/lanes';
import RestartBanner from '@/components/RestartBanner.vue';
import SkillsBanner from '@/components/SkillsBanner.vue';
import StackFileBanner from '@/components/StackFileBanner.vue';
import UpgradeBanner from '@/components/UpgradeBanner.vue';
Expand Down Expand Up @@ -157,6 +158,7 @@ function isActive(name: string) {
{{ hub.dockerStarting ? 'Starting…' : `Start ${dockerDown.starter}` }}
</button>
</div>
<RestartBanner v-if="!stack.foreign" :config-changed="!!stack.view?.config_changed && !stack.ending" />
<div v-if="!hubDown && stack.running && stack.view?.watcher_error" class="banner warn" data-testid="watcher-error">
<Icon name="alert" :size="18" />
<span class="grow"><strong>The file watcher does not see every edit.</strong> {{ stack.view.watcher_error }}</span>
Expand Down
30 changes: 3 additions & 27 deletions ui/src/views/StackPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import { api, paths, v1 } from '@/api';
import type { HubPorts, LaneView, Load, PortEntry, PortOverlap, UsageReport } from '@/api/types';
import { ago, bytes, clock, duration, percent, useNow } from '@/lib/format';
import { viaText } from '@/lib/journal';
import { laneLabel, lastTab, MAIN, nodeLabel, restartLanesText, started } from '@/lib/lanes';
import { laneLabel, lastTab, MAIN, nodeLabel, started } from '@/lib/lanes';
import { laneView } from '@/lib/stackRoutes';
import { statusLook } from '@/lib/status';
import { useHub } from '@/stores/hub';
import { useStack } from '@/stores/stack';
import AgentPrompt from '@/components/AgentPrompt.vue';
import Icon from '@/components/icons/Icon.vue';
import PortGraph from '@/components/PortGraph.vue';
import RestartBanner from '@/components/RestartBanner.vue';
import StackFileBanner from '@/components/StackFileBanner.vue';
import { refusedForPorts, runningHolders, shiftLabel } from '@/lib/shift';
import StatusPill from '@/components/StatusPill.vue';
Expand Down Expand Up @@ -68,19 +69,6 @@ const state = computed(() => {
return { tone: 'ok', label: 'running', title: 'Its daemon runs' };
});

// The restart banner (version, changed stack file), from the lane view to here.
const daemonOutdated = computed(() => {
const d = stack.entry?.daemon?.version;
const h = hub.version;
return d && h && d !== h ? { daemon: d, hub: h } : null;
});
const restartReason = computed(() => {
if (!stack.running || hubDown.value) return null;
if (daemonOutdated.value) return 'version';
if (stack.mainView?.config_changed) return 'config';
return null;
});

// ------------------------------------------------------------ lanes

/** The lanes, `main` first, then by label; of a stack that does not run, its worktrees as the hub lists them. */
Expand Down Expand Up @@ -282,19 +270,7 @@ const singletons = computed(() => services.value.filter((s) => s.singleton));
</div>
</header>

<div v-if="restartReason" class="banner warn" :data-testid="restartReason === 'version' ? 'daemon-outdated' : 'config-changed'">
<Icon :name="restartReason === 'version' ? 'alert' : 'file'" :size="18" />
<span v-if="restartReason === 'version'" class="grow">
<strong>{{ name }} runs devstack {{ daemonOutdated?.daemon }}, devstack {{ daemonOutdated?.hub }} is installed.</strong>
{{ ' ' }}A restart of the stack switches it over<template v-if="stack.mainView?.config_changed"> and applies the changed stack file</template>.
<template v-if="restartLanesText(stack.restartLanes)">{{ ' ' }}{{ restartLanesText(stack.restartLanes) }}</template>
</span>
<span v-else class="grow"><strong>The stack file changed since {{ name }} started.</strong> It applies after a restart.</span>
<button v-if="changes" type="button" class="btn btn-primary btn-sm" :disabled="!!stack.busy.stack" 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' ? 'Restarting…' : 'Restart stack' }}
</button>
</div>
<RestartBanner :config-changed="!!stack.mainView?.config_changed" />
<StackFileBanner v-if="!hubDown && changes" />
<div v-if="!hubDown && stack.entry?.start_error && !stack.running" class="banner warn" data-testid="stack-start-error">
<Icon name="alert" :size="18" />
Expand Down