diff --git a/CHANGELOG.md b/CHANGELOG.md index 24aca2bb..0b669d86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/adr/0081-a-stack-has-a-page-every-lane-the-same-view.md b/docs/adr/0081-a-stack-has-a-page-every-lane-the-same-view.md index 9591b463..6413a653 100644 --- a/docs/adr/0081-a-stack-has-a-page-every-lane-the-same-view.md +++ b/docs/adr/0081-a-stack-has-a-page-every-lane-the-same-view.md @@ -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. diff --git a/ui/src/components/RestartBanner.test.ts b/ui/src/components/RestartBanner.test.ts new file mode 100644 index 00000000..90df69b8 --- /dev/null +++ b/ui/src/components/RestartBanner.test.ts @@ -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(); + 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'); + }); +}); diff --git a/ui/src/components/RestartBanner.vue b/ui/src/components/RestartBanner.vue new file mode 100644 index 00000000..8d36b5c2 --- /dev/null +++ b/ui/src/components/RestartBanner.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/ui/src/views/StackLayout.vue b/ui/src/views/StackLayout.vue index 68f3c968..96f86684 100644 --- a/ui/src/views/StackLayout.vue +++ b/ui/src/views/StackLayout.vue @@ -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'; @@ -157,6 +158,7 @@ function isActive(name: string) { {{ hub.dockerStarting ? 'Starting…' : `Start ${dockerDown.starter}` }} + - +