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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ and listed with their assets on the

### Fixed

- A link to a service or container of a lane shared with you (its port, in
the list and on its page) opens it: a click opens the forward to it on
your machine, as **Open** in the pool area does, and keeps the link's
path. Before, it pointed at `localhost:<port>` of the lane's node, where
nothing on your machine listens.
- A lane's failed start on a node no longer stays on its start page after
the lane or the stack stopped: stopping the lane, stopping the main tree
(`devstack down`) or starting the lane here clears it, and the dashboard
Expand Down
4 changes: 3 additions & 1 deletion docs/pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ next one.

They also **view** it ([ADR-0040](adr/0040-a-shared-lane-can-be-watched-like-ones-own.md),
amended 2026-10-20): a click on it opens the same pages as one's own lane,
read only. They see its state, its services' and containers' logs, its
read only. A click on a service's or container's link there opens the
forward to it as `devstack open` does, the link's path kept. They see its
state, its services' and containers' logs, its
events, its command runs and its usage, never its environment, and change
nothing: no restart, no stop. Logs show what the services print: share a
lane only where that is fine. The node asks the coordinator at least every
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/ContainerRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ const extraUrls = computed(() => webUrls.value.filter((u) => !props.container!.p
<div class="meta">
<template v-if="container">
<template v-for="p in container.ports" :key="p">
<a v-if="urlFor(p)" class="tag port-link" :href="urlFor(p)" target="_blank" rel="noopener" :title="`open ${urlFor(p)}`" data-testid="container-url">{{ hostPort(p) }}</a>
<a v-if="urlFor(p)" class="tag port-link" :href="urlFor(p)" @click="stack.followLink($event, urlFor(p)!)" @auxclick="stack.followLink($event, urlFor(p)!)" target="_blank" rel="noopener" :title="`open ${urlFor(p)}`" data-testid="container-url">{{ hostPort(p) }}</a>
<span v-else class="tag" :title="p">{{ hostPort(p) }}</span>
</template>
<a v-for="u in extraUrls" :key="u" class="tag port-link" :href="u" target="_blank" rel="noopener" data-testid="container-url">{{ u.replace(/^https?:\/\//, '') }}</a>
<a v-for="u in extraUrls" :key="u" class="tag port-link" :href="u" @click="stack.followLink($event, u)" @auxclick="stack.followLink($event, u)" target="_blank" rel="noopener" data-testid="container-url">{{ u.replace(/^https?:\/\//, '') }}</a>
<span v-if="!container.ports.length" class="faint">no published ports</span>
<span v-if="refuses" class="tag" :title="refuses" data-testid="container-unmanaged">not in the stack file</span>
<button
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/ServiceRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function open(e: MouseEvent) {
<div class="meta">
<span v-if="service.hot_reload" class="tag hot" title="hot-reload mode: the toolchain's watcher runs from the source tree" data-testid="service-hot-reload">hot reload</span>
<span v-if="service.build_id" class="tag" :title="`running build ${service.build_id}`" data-testid="service-build">{{ shortBuild(service.build_id) }}</span>
<a v-if="service.port" class="m port-link" :href="serviceUrl(service)" target="_blank" rel="noopener" :title="`open ${serviceUrl(service)}`" data-testid="service-url"><Icon name="link" :size="12" />:{{ service.port }}</a>
<a v-if="service.port" class="m port-link" :href="serviceUrl(service)" @click="stack.followLink($event, serviceUrl(service))" @auxclick="stack.followLink($event, serviceUrl(service))" target="_blank" rel="noopener" :title="`open ${serviceUrl(service)}`" data-testid="service-url"><Icon name="link" :size="12" />:{{ service.port }}</a>
<span v-if="service.pid" class="m hide-sm">pid {{ service.pid }}</span>
<span v-if="service.kind !== 'service'" class="m">{{ kindLabel(service) }}</span>
</div>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/stores/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ export const usePool = defineStore('pool', () => {
/** Every lane shared with this machine, with its pool. */
const shared = computed(() => pools.value.flatMap((p) => (sharedBy.value[p.name] ?? []).map((l) => ({ ...l, pool: p.name }))));

/** Open a service of a shared lane: a forward here, then the page. */
async function openShared(pool: string, lease: string, service: string) {
/** Open a service of a shared lane: a forward here, then the page; `path` (`/ui?x#y`) after its address. */
async function openShared(pool: string, lease: string, service: string, path = '') {
const r = await act<{ url: string; port: number; warning?: string }>({
label: `Open ${service}`,
path: at(paths.poolSharedOpen(lease), pool),
Expand All @@ -342,7 +342,7 @@ export const usePool = defineStore('pool', () => {
// Its node or owner runs another devstack: a failure there may be why.
if (r.body.warning) useUi().toast('warning', `${service}: another devstack`, r.body.warning, 12_000);
// The scheme comes from the lane's owner: open web pages only.
const url = webUrl(r.body.url);
const url = webUrl(r.body.url.replace(/\/$/, '') + path);
if (url) window.open(url, '_blank', 'noopener');
else useUi().toast('error', `Not opening ${service}`, `The lane shares it as ${r.body.url}; only http and https addresses are opened.`);
}
Expand Down
29 changes: 29 additions & 0 deletions ui/src/stores/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,34 @@ export const useStack = defineStore('stack', () => {
return true;
}

/**
* A click on a link of the lane shown. A shared lane's links name its ports
* on the node, where nothing on this machine listens: the click opens a
* forward here to the service on that port instead (ADR-0035), the link's
* path kept. A link of one's own stack is followed as it is.
*/
function followLink(e: MouseEvent, url: string) {
const r = shared.value;
// The context menu's "open in new tab" is not caught: it gets the link as it is.
if (!r || e.button > 1) return;
e.preventDefault();
let u: URL;
try {
u = new URL(url);
} catch {
return;
}
const port = Number(u.port) || (u.protocol === 'https:' ? 443 : 80);
const l = sharedLane.value;
const svc = l?.services.find((s) => (s.here || s.port) === port);
if (!l || !svc) {
useUi().toast('error', `Not opening ${u.host}`, `${l ? `${l.owner_name} shares` : 'This lane shares'} nothing on port ${port}.`);
return;
}
const path = u.pathname === '/' && !u.search && !u.hash ? '' : u.pathname + u.search + u.hash;
void usePool().openShared(r.pool, r.lease, svc.name, path);
}

async function runCommand(name: string): Promise<number | null> {
if (refuseReadOnly()) return null;
if (!id.value) return null;
Expand Down Expand Up @@ -768,6 +796,7 @@ export const useStack = defineStore('stack', () => {
running,
readOnly,
sharedLane,
followLink,
runningLanes,
mainIdle,
events,
Expand Down
44 changes: 44 additions & 0 deletions ui/src/stores/stores.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,50 @@ describe('stack store', () => {
expect(useUi().toasts.some((x) => x.title === 'Read only')).toBe(true);
});

it("a shared lane's link opens a forward here to the service on its port (ADR-0035)", async () => {
fake.on('/hub/session', ok({ version: '0.9.8' }));
fake.on('/hub/pools', ok([{ name: 'default', joined: true, state: 'approved', coordinator: 'https://c' }]));
const services = [
{ name: 'web', port: 4300, scheme: 'http', here: 4300 },
{ name: 'map', port: 8290, scheme: 'http', here: 8290 },
];
fake.on('/hub/pool/shared', ok([{ lease: 'ab12', repo: 'crm', lane: 'fix', owner: 'o', owner_name: 'anna', node: { id: 'n', name: 'build', api: 'https://n' }, services }]));
// Its owner's port is taken here: the forward is on another one.
fake.on(/\/hub\/pool\/shared\/ab12\/open/, ok({ url: 'http://localhost:51000', port: 51000 }));
const opened: string[] = [];
vi.spyOn(window, 'open').mockImplementation((url) => {
opened.push(String(url));
return null;
});
const hub = useHub();
await hub.init();
fake.stream('/hub/events').handlers.onMessage({ type: 'stacks', stacks: [] });
await usePool().load();
const stack = useStack();
stack.select('shared~default~ab12');
const click = () => new MouseEvent('click', { cancelable: true });

const e = click();
stack.followLink(e, 'http://localhost:8290/ui?x=1');
expect(e.defaultPrevented).toBe(true);
await vi.waitFor(() => expect(opened).toEqual(['http://localhost:51000/ui?x=1']));
const sent = fake.requests.filter((r) => r.path.startsWith('/hub/pool/shared/ab12/open'));
expect(sent.map((r) => r.body)).toEqual([{ service: 'map' }]);

// A port the lane does not share opens nothing, and says so.
const none = click();
stack.followLink(none, 'http://localhost:9999');
expect(none.defaultPrevented).toBe(true);
expect(useUi().toasts.some((x) => x.title === 'Not opening localhost:9999')).toBe(true);
});

it("one's own stack's links are followed as they are", async () => {
const stack = await shownStack();
const e = new MouseEvent('click', { cancelable: true });
stack.followLink(e, 'http://localhost:8290');
expect(e.defaultPrevented).toBe(false);
});

it('a lane removed while shown gives way to the main tree', async () => {
const stack = await shownStack();
const feat = { name: 'feat', path: '/src/feat', number: 1, active: true, port_offset: 100, owns_main: false, running: 2, services: 3 };
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/ContainerDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const kv = computed(() => {
<div class="subtitle">
container · {{ group }}
<template v-for="u in (container?.urls ?? []).filter((x) => webUrl(x))" :key="u">
· <a :href="u" target="_blank" rel="noopener" data-testid="container-url">{{ u.replace(/^https?:\/\//, '') }} <Icon name="external" :size="12" /></a>
· <a :href="u" @click="stack.followLink($event, u)" @auxclick="stack.followLink($event, u)" target="_blank" rel="noopener" data-testid="container-url">{{ u.replace(/^https?:\/\//, '') }} <Icon name="external" :size="12" /></a>
</template>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/ServiceDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const kv = computed(() => {
<div class="subtitle">
{{ kindLabel(svc) }}
<template v-if="svc.build_id"> · running build <span class="mono">{{ shortBuild(svc.build_id) }}</span></template>
<template v-if="svc.port"> · <a :href="serviceUrl(svc)" target="_blank" rel="noopener" data-testid="service-url">{{ serviceUrl(svc).replace(/^https?:\/\//, '') }} <Icon name="external" :size="12" /></a></template>
<template v-if="svc.port"> · <a :href="serviceUrl(svc)" @click="stack.followLink($event, serviceUrl(svc))" @auxclick="stack.followLink($event, serviceUrl(svc))" target="_blank" rel="noopener" data-testid="service-url">{{ serviceUrl(svc).replace(/^https?:\/\//, '') }} <Icon name="external" :size="12" /></a></template>
</div>
</div>
</div>
Expand Down