Skip to content

Commit 9abf817

Browse files
committed
refactor: unify host runtime and remove adapters
1 parent 8908bca commit 9abf817

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+716
-18498
lines changed

PUBLISHING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
The `publish-package.yml` workflow publishes `@srl-labs/clab-ui` to GitHub Packages.
1111

12-
No wrapper packages are published separately; consume core/explorer/inspect APIs from
12+
No wrapper packages are published separately; consume browser runtime, core, explorer, and inspect APIs from
1313
`@srl-labs/clab-ui` subpath exports.
1414

1515
## Local publish (manual)
@@ -36,5 +36,4 @@ node scripts/set-clab-package-source.mjs --source=github --version=<version>
3636
npm install
3737
```
3838

39-
Host adapters (`@srl-labs/clab-adapter-vscode`, `@srl-labs/clab-adapter-api`,
40-
`@srl-labs/clab-adapter-memory`) are workspace packages used for integration and testing.
39+
Browser-side runtime integration is owned by `@srl-labs/clab-ui/host`.

README.md

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Primary consumer today: [`vscode-containerlab`](https://github.com/srl-labs/vsco
1212

1313
- React UI and topology editing logic used by containerlab webviews
1414
- Shared parsing/core utilities used by the extension host
15-
- A local browser dev harness (`npm run dev`) for fast UI iteration
15+
- A standalone-backed local development flow (`npm run dev`) that exercises the real browser/runtime integration
1616
- Build tooling that produces webview-ready assets in `dist/`
1717

1818
---
@@ -32,12 +32,8 @@ Primary consumer today: [`vscode-containerlab`](https://github.com/srl-labs/vsco
3232

3333
| Component | Package | Status | Notes |
3434
| --- | --- | --- | --- |
35-
| Main UI package | `@srl-labs/clab-ui` | Published | Published to GitHub Packages |
36-
| Host contract | `@srl-labs/clab-host-contract` | Workspace-only | `private: true` |
37-
| API adapter | `@srl-labs/clab-adapter-api` | Workspace-only | `private: true` |
38-
| VS Code adapter | `@srl-labs/clab-adapter-vscode` | Workspace-only | `private: true` |
39-
| Memory adapter | `@srl-labs/clab-adapter-memory` | Workspace-only | Used by local dev harness |
40-
| Standalone app | N/A | Planned | Dev harness exists; production standalone distribution is not complete yet |
35+
| Main UI package | `@srl-labs/clab-ui` | Published | Owns the shared browser-side host contract and constructors |
36+
| Standalone app | `@srl-labs/clab-standalone` | Workspace app | Local dev/runtime host backed by the API proxy server |
4137

4238
---
4339

@@ -63,28 +59,27 @@ npx playwright install chromium
6359

6460
## Getting Started
6561

66-
Start the dev harness:
62+
Start the standalone-backed dev flow:
6763

6864
```bash
6965
npm run dev
7066
```
7167

7268
Then open `http://localhost:5173`.
7369

74-
Dev harness runtime model:
70+
Local dev runtime model:
7571

76-
- Pure frontend runtime (no Node middleware backend in this repo)
77-
- In-memory topology host using shared `TopologyHostCore`
78-
- File/session persistence in browser `localStorage`
79-
- Reset action restores seeded topologies from `dev/topologies-original/`
72+
- Browser frontend served by the standalone Vite app
73+
- Fastify backend proxy for auth, topology snapshot/command, files, and lifecycle actions
74+
- Shared `ClabUiHost` runtime used by both standalone and VS Code webviews
8075

8176
---
8277

8378
## Common Commands
8479

8580
| Command | Description |
8681
| --- | --- |
87-
| `npm run dev` | Run Vite dev harness from `dev/` |
82+
| `npm run dev` | Run the standalone-backed local development flow |
8883
| `npm run build` | Build production webview assets into `dist/` |
8984
| `npm run build:watch` | Build in dev mode (inline sourcemaps, no minify) |
9085
| `npm run build:dev` | Build in dev mode (same output profile as `build:watch`) |
@@ -143,8 +138,8 @@ Frequently used exports:
143138

144139
Notes:
145140

146-
- The workspace also ships host adapter packages, but they are not published externally yet.
147-
- Current UI host context APIs are imported from service subpaths (for example `@srl-labs/clab-ui/services/topologyHostClient`).
141+
- Browser runtime integration is exposed from `@srl-labs/clab-ui/host`.
142+
- Current UI host context APIs are still imported from service subpaths (for example `@srl-labs/clab-ui/services/topologyHostClient`).
148143

149144
---
150145

@@ -153,28 +148,18 @@ Notes:
153148
The UI currently uses host messaging via `services/topologyHostClient`:
154149

155150
```ts
156-
import { App } from "@srl-labs/clab-ui";
157-
import { setHostContext } from "@srl-labs/clab-ui/services/topologyHostClient";
158-
import { refreshTopologySnapshot } from "@srl-labs/clab-ui/services/topologyHostCommands";
151+
import { createWindowClabUiHost, setClabUiHost } from "@srl-labs/clab-ui/host";
159152

160-
setHostContext({
161-
path: "labs/my-lab.clab.yml",
162-
mode: "edit",
163-
deploymentState: "undeployed"
164-
});
165-
166-
await refreshTopologySnapshot();
153+
setClabUiHost(createWindowClabUiHost());
167154
```
168155

169-
The adapter packages in `packages/adapter-*` are part of the transport direction but are currently workspace-only.
170-
171156
---
172157

173158
## Troubleshooting
174159

175160
- `npm install` fails with engine mismatch: ensure Node `>= 24` (`node -v`).
176161
- Playwright tests fail before opening a browser: run `npx playwright install chromium`.
177-
- Dev harness state feels stale: clear browser localStorage keys `containerlab-gui.dev.in-memory-labs.v1` and `containerlab-gui.dev.session.v1`.
162+
- Local dev flow cannot reach the backend: ensure the standalone dev server on `http://localhost:3000` is starting successfully.
178163

179164
---
180165

@@ -193,8 +178,8 @@ Detailed steps: [`PUBLISHING.md`](PUBLISHING.md)
193178

194179
---
195180

196-
## Standalone Roadmap Note
181+
## Standalone Runtime
197182

198-
The standalone browser experience exists today as a dev harness (`npm run dev`) and is useful for UI iteration and testing.
183+
The standalone browser experience is the supported local development runtime for `containerlab-gui`.
199184

200-
A fully supported standalone distribution is planned but not complete yet. Until that lands, the production integration target remains `vscode-containerlab`.
185+
It uses the same browser-side host contract as VS Code, with only platform-specific differences in backend transport and shell behavior.

apps/standalone/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { registerTopologyEventsProxy } from "./topologyEventsProxy.js";
2020

2121
const PORT = parseInt(process.env.PORT ?? "3000", 10);
2222
const DEFAULT_CLAB_API_URL = process.env.CLAB_API_URL ?? "http://localhost:8080";
23-
const VITE_DEV_URL = process.env.VITE_DEV_URL ?? "http://localhost:5174";
23+
const VITE_DEV_URL = process.env.VITE_DEV_URL ?? "http://localhost:5173";
2424
const IS_DEV = process.env.NODE_ENV !== "production";
2525

2626
async function start(): Promise<void> {

apps/standalone/server/topologyProxy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/**
22
* Topology host protocol endpoints.
33
*
4-
* Exposes /api/topology/snapshot and /api/topology/command — the same
5-
* endpoints the dev harness uses, so the UI's topologyHostClient.ts
6-
* works without changes.
4+
* Exposes /api/topology/snapshot and /api/topology/command so the shared
5+
* UI topologyHostClient.ts works unchanged across standalone and VS Code hosts.
76
*
87
* Each lab gets a TopologyHostCore backed by ClabApiFileSystemAdapter.
98
*/

0 commit comments

Comments
 (0)