feat: configure demo defaults via env vars (#26)

* feat(core): configure default demo plugins via env vars [Minor]

- parse NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS in AppShell [Minor]

- inject defaultEnabled in layersSlice initLayer [Patch]

- document demo defaults in .env.example [Patch]

* fix(core): enable plugin polling on boot and fix gps ID string [Patch]

---------

Co-authored-by: Antigravity AI <[email protected]>
This commit is contained in:
SilvertakanaandAntigravity AI authored and GitHub committed 2026-04-16 01:20:05 +12:00
1 parent b10e7d0a7f
commit 67ca2abdbc
6 files changed
+153 -6

No files matched your search

+5 -1
View File
@@ -1,7 +1,11 @@
DATABASE_URL=file:./data/wwv.db
# Default plugins enabled on boot for demo edition
# Comma-separated list of plugin IDs
NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS=iranwarlive,satellite,gps_jamming
# Edition: "local" | "cloud" | "demo"
NEXT_PUBLIC_WWV_EDITION=local
NEXT_PUBLIC_WWV_EDITION=demo
# Auth Secret (REQUIRED for Docker — generate with: openssl rand -hex 32)
# Must be stable across container restarts to preserve sessions.
+4
View File
@@ -48,6 +48,10 @@ ACLED_PASSWORD=
# Generate any random string, then set the same value in the marketplace instance config.
WWV_BRIDGE_TOKEN=
# Default plugins enabled on boot for demo edition
# Comma-separated list of plugin IDs
NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS=
# Edition: "local" | "cloud" | "demo"
NEXT_PUBLIC_WWV_EDITION=local
@@ -0,0 +1,124 @@
# Demo Default Plugins Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Enable specific plugins by default on the demo edition via environment variables so the user is immediately impressed.
**Architecture:** Update `layersSlice.ts` to accept an optional `defaultEnabled` parameter in `initLayer`. In `AppShell.tsx`, look up `NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS` when the edition is `demo`, and pass the flag true to `initLayer` for matching plugins during registration. Document the variable in `.env.example`.
**Tech Stack:** Next.js, Zustand, TypeScript.
---
### Task 1: Update layer slice definition
**Files:**
- Modify: `src/core/state/layersSlice.ts`
- [ ] **Step 1: Write the implementation**
Update `initLayer` in `src/core/state/layersSlice.ts` to accept a second parameter:
```typescript
// Add defaultEnabled parameter to the interface
export interface LayersSlice {
// ...
initLayer: (pluginId: string, defaultEnabled?: boolean) => void;
}
// ...
// Use the parameter in the state updater
initLayer: (pluginId, defaultEnabled = false) =>
set((state) => ({
layers: {
...state.layers,
[pluginId]: state.layers[pluginId] || { enabled: defaultEnabled, entityCount: 0, loading: false },
},
})),
```
- [ ] **Step 2: Commit**
```bash
git add src/core/state/layersSlice.ts
npm run commit -- "feat: add defaultEnabled param to initLayer in layers slice"
```
### Task 2: Apply default configuration in AppShell
**Files:**
- Modify: `src/components/layout/AppShell.tsx`
- [ ] **Step 1: Write the implementation**
Add `isDemo` import at the top of `src/components/layout/AppShell.tsx`:
```typescript
import { isDemo } from "@/core/edition";
```
In `AppShell.tsx`, around line 71, inside `startPlatform()`, fetch the value from the environment if the instance is demo:
```typescript
// Fetch disabled built-in plugins before registration
let disabledIds = new Set<string>();
// ... (keep existing try/catch block)
// Setup demo defaults
const demoDefaultPlugins = new Set<string>();
if (isDemo) {
const envVar = process.env.NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS || "";
envVar.split(",").forEach(s => {
const clean = s.trim();
if (clean) demoDefaultPlugins.add(clean);
});
}
```
Then update the `pluginManager` registration loop to inject the boolean for `initLayer`:
```typescript
for (const plugin of pluginRegistry.getAll()) {
await pluginManager.registerPlugin(plugin);
initLayer(plugin.id, demoDefaultPlugins.has(plugin.id));
}
```
- [ ] **Step 2: Run test to verify it passes**
Run type checks to verify no compilation issues:
`npx tsc --noEmit`
- [ ] **Step 3: Commit**
```bash
git add src/components/layout/AppShell.tsx
npm run commit -- "feat: parse and apply default demo plugins via NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS"
```
### Task 3: Document environment definitions
**Files:**
- Modify: `.env.example`
- Modify: `.env`
- [ ] **Step 1: Write the implementation**
Update `.env.example` and `.env` around the `NEXT_PUBLIC_WWV_EDITION=local` definition:
```dotenv
# Default plugins enabled on boot for demo edition
# Comma-separated list of plugin IDs (e.g. aviation,maritime,iranwarlive)
NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS=
# Edition: "local" | "cloud" | "demo"
NEXT_PUBLIC_WWV_EDITION=local
```
- [ ] **Step 2: Commit**
```bash
git add .env.example .env
npm run commit -- "docs: add NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS to env templates"
```
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "worldwideview",
"version": "1.8.3",
"version": "1.9.0",
"private": true,
"scripts": {
"setup": "node scripts/setup.mjs",
+16 -1
View File
@@ -45,6 +45,7 @@ import ReloadToast from "@/components/ui/ReloadToast";
import ErrorToast from "@/components/ui/ErrorToast";
import UnverifiedPluginBatchDialog from "@/components/marketplace/UnverifiedPluginBatchDialog";
import { FeedbackDialog } from "@/components/common/FeedbackDialog";
import { isDemo } from "@/core/edition";
import { injectHostGlobals } from "@/core/plugins/hostGlobals";
import { initLogCatcher } from "@/lib/logCatcher";
@@ -80,6 +81,16 @@ export function AppShell() {
// Non-critical — load all built-ins if endpoint fails
}
// Setup demo defaults
const demoDefaultPlugins = new Set<string>();
if (isDemo) {
const envVar = process.env.NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS || "";
envVar.split(",").forEach(s => {
const clean = s.trim();
if (clean) demoDefaultPlugins.add(clean);
});
}
const builtIns = [
new AviationPlugin(),
new MaritimePlugin(),
@@ -113,7 +124,11 @@ export function AppShell() {
for (const plugin of pluginRegistry.getAll()) {
await pluginManager.registerPlugin(plugin);
initLayer(plugin.id);
const shouldEnable = demoDefaultPlugins.has(plugin.id);
initLayer(plugin.id, shouldEnable);
if (shouldEnable) {
await pluginManager.enablePlugin(plugin.id);
}
}
console.log("[AppShell] Platform Ready. Waiting for globe tiles...");
+3 -3
View File
@@ -14,7 +14,7 @@ export interface LayersSlice {
setLayerEnabled: (pluginId: string, enabled: boolean) => void;
setEntityCount: (pluginId: string, count: number) => void;
setLayerLoading: (pluginId: string, loading: boolean) => void;
initLayer: (pluginId: string) => void;
initLayer: (pluginId: string, defaultEnabled?: boolean) => void;
}
export const createLayersSlice: StateCreator<AppStore, [], [], LayersSlice> = (set) => ({
@@ -50,11 +50,11 @@ export const createLayersSlice: StateCreator<AppStore, [], [], LayersSlice> = (s
[pluginId]: { ...state.layers[pluginId], loading },
},
})),
initLayer: (pluginId) =>
initLayer: (pluginId, defaultEnabled = false) =>
set((state) => ({
layers: {
...state.layers,
[pluginId]: state.layers[pluginId] || { enabled: false, entityCount: 0, loading: false },
[pluginId]: state.layers[pluginId] || { enabled: defaultEnabled, entityCount: 0, loading: false },
},
})),
});