* feat(testing): add Playwright E2E infrastructure and stabilize test suite
- Add Playwright E2E configuration and ui-navigation / plugin-system tests
- Add GitHub Actions workflow for Playwright CI tests
- Add test helpers and fixtures (e2e-mock-plugin)
- fix(testing): resolve UnverifiedPluginBatchDialog UI blocking issue in E2E tests
- fix(testing): limit Playwright to 2 workers locally to avoid Next.js/Prisma exhaustion
- fix(api): replace deprecated processAuthCodeResponse with authorizationCodeGrant
- test(ui): add data-testid to PanelToggleArrows and AppShell
* Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* fix(ci): restrict GITHUB_TOKEN permissions to read contents
* docs(e2e): document Playwright infrastructure and mock plugin lifecycle
* fix(e2e): explicitly load .env in teardown and fix dev command pathing
* fix(ci): resolve playwright environment setup and database initialization
Changes:
- Patch: Added pnpm run setup step to .github/workflows/playwright.yml to generate .env in CI
- Patch: Added explicit loadEnv() helper to ests/global.setup.ts and ests/global.teardown.ts to ensure database credentials are fresh
- Patch: Hardened scripts/safe-db-push.mjs to detect missing DATABASE_URL and explicitly prompt for pnpm run setup rather than assuming production
- Patch: Updated scripts/dev.mjs to execute pnpm exec next dev instead of raw
ext dev to resolve pathing issues
- Patch: Bumped version in package.json to 2.14.4
---------
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
The setup page unconditionally displays a banner telling users to run
scripts/migrate-legacy.mjs, but that script does not exist in the repo
or the Docker image. Every user hitting /setup sees a broken command,
including fresh installs with no legacy data.
The docker-entrypoint.sh already detects prisma/dev.db and logs a
migration warning for actual upgraders.
Closes#129
* feat(dx): implement worktree DB orchestration and graceful dev teardown
- feat(dx): [Minor] Implement deterministic port binding per git worktree
to mitigate Docker port conflicts during parallel development.
- feat(dx): [Minor] Implement graceful development environment teardown
using a custom node orchestrator (scripts/dev.mjs) replacing CLI concurrently,
enabling cross-platform tree-kill and optional DB stopping on exit.
- build(deps): Add tree-kill for process termination.
- fix(dx): Prevent rm -rf from orphaning Docker volumes by adding
a db:prune script and tying volume cleanup to git-wt remove.
* fix: update openid-client api usage to v6 and resolve db import
- Migrated processAuthCodeResponse to authorizationCodeGrant
- Updated db import to export prisma client correctly
- Updated unit tests with v6 openid-client mocks
- Bumped version to 2.13.1
* fix(ci): setup .env from example in local dev CI test
- Add PBKDF2 + AES-256-GCM encryption for credentials
- Update Prisma schema to include MarketplaceCredential
- Implement comprehensive SSRF utility with IP pinning
- Harden /api/camera/proxy and stream proxy with safeFetch
- Fix openid-client PKCE generator usage
- Update workspace configurations and ADRs
- Bump version to 2.10.0 (Minor)
Primitive collections (points, billboards, labels, polylines) were
attached directly to the Cesium Viewer instance as `_wwvX` properties
behind `(viewer as any)` casts. This created hidden coupling, blocked
multi-viewer setups, and left ~11 `as any` casts across three files.
Replace the viewer-mutation pattern with a module-level
`WeakMap<CesiumViewer, PrimitiveCollections>`:
- `initPrimitiveCollections` now writes into the WeakMap
- `getCollections` reads from the WeakMap and returns a destructurable
shape with optional fields, preserving the existing call pattern
- `AnimationLoop` and `useEntityRendering` use `getCollections(viewer)`
instead of direct `(viewer as any)._wwvX` reads
- Zero `(viewer as any)._wwv*` remain; collections GC cleanly when
the viewer is dropped
Adds `src/core/globe/EntityRenderer.test.ts` with 7 tests covering:
- WeakMap roundtrip (init populates, getCollections retrieves, per-viewer
isolation, graceful no-scene)
- Defer-clone behaviour from the previous commit (no clone on
iconUrl/model path; clone on auto-SVG path; original untouched)
Refs #95
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`renderSingleEntity` was cloning `options` for every entity via
`const effectiveOptions = { ...options }`, even when the auto-SVG
fallback below didn't need to mutate it. With 10k+ entities per
render pass this adds avoidable GC pressure in the hot loop.
The clone is now deferred into the auto-SVG branch that actually
mutates, so entities that arrive with `iconUrl` set (or `type === "model"`)
pass `options` through by reference with zero allocation.
Refs #95
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replace `(window as any)._wwvFrameCount = frame` with a typed
`declare global { interface Window { _wwvFrameCount?: number } }`
and a plain `window._wwvFrameCount = frame` assignment.
The external plugin contract (a window-published frame counter for
throttling) is preserved; only the cast is removed.
Refs #95
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds an adapter that pulls `man_made=surveillance` nodes from the
OpenStreetMap Overpass API as location-only camera markers. The geometry
alone is useful as a "where do public / government cameras exist" overlay
alongside the live DOT feeds — most OSM surveillance nodes don't have
stream URLs, but their tags (operator, camera:type, surveillance:type)
are surfaced via `properties.extra` for filtering.
The query is bounded to a list of major metros (~30km radius around SF,
LA, NYC, London, Paris, Tokyo, Raleigh) to keep the response size sane;
operators who want fuller coverage can extend the query in-source. Output
is capped at 3000 nodes per fetch.
Cache TTL is 7 days (overrides the default 24h) since OSM data changes
slowly and Overpass is shared infrastructure that politely asks consumers
not to poll aggressively.
Built on top of the CameraAdapter pattern from the camera adapter
refactor PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds North Carolina DOT as a sixth source for `/api/camera/traffic`.
~770 cameras statewide, no API key required, direct JPEG snapshots.
NCDOT exposes a two-step API: a bulk endpoint that returns only
`{ id, latitude, longitude }` per camera, and a per-camera detail
endpoint with the rest (locationName, mileMarker, roadId, countyId,
imageURL, status). The adapter fans out the detail fetches with a
bounded concurrency of 20, lands the initial population in ~15 seconds,
and the registry's per-adapter cache holds it for 24h after that.
Cameras with `status !== "OK"` are filtered out. The adapter is built
on top of the CameraAdapter pattern introduced in the camera adapter
refactor PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Two related bugs in the local-engine detection path:
1. Hardcoded port 5000 — should be 5001
wwv-data-engine's docker-compose.yaml binds the engine to port 5001
(and has since the v2 refactor), but engineManifest.ts polls
`localhost:5000/manifest` to detect it. The detection always
reported "no local engine" even when one was running, falling back
to the cloud engine on every plugin toggle.
Bonus pain: macOS hijacks port 5000 for the AirPlay Receiver, which
returns 403 to any GET request. On any macOS dev machine, this
produced a misleading 403 in the browser console even when no
engine was running at all. Famous local-dev gotcha that ate dev
time.
2. NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL is ignored
Every other code path in the app honors this env var as the
override for the engine URL — `resolveEngineUrl`, plugin context
injection, the radio-garden plugin, etc. But `engineManifest` ran
its own detection independently against hardcoded localhost. So
even when the operator pointed plugins at a custom engine URL,
manifest detection failed silently.
Fix: read `NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL` first (normalizing
ws[s]:// → http[s]:// and stripping a trailing /stream), then fall
back to localhost:5001 if not set. Same approach used elsewhere in
the codebase.
Side effects:
- Symptoms in the browser console downstream of this bug (notably
the spurious 403 on `localhost:5000/manifest` and the cascade of
"seeder not running" 404s when plugins fall back to the cloud
engine that doesn't have that seeder) clear up.
- Existing engineManifest unit tests still pass — they mock fetch
and don't care about the URL shape.
Worth adding a test for the env-var precedence in a follow-up; left
out of this PR to keep the diff to the one-file behaviour fix.
The setup page's `.logo` and `.button` rules use
`rgb(var(--accent-rgb, 200, 30, 30))`. Because CSS `var()` only treats
the value after the first comma as the *fallback*, the syntax
intends "use --accent-rgb if defined, otherwise fall back to
`200, 30, 30`."
The fallback never triggers in practice: `theme-tokens.css` defines
`--accent-rgb: 255, 255, 255` at the `:root` level, so the variable
is always set when the setup page renders. `rgb(255, 255, 255)`
combined with the rules' `color: #fff` gives white-on-white — the
"Sign In" button text and the "W" logo are invisible on the page.
The setup flow is pre-auth and pre-theme; it shouldn't be inheriting
the accent. Replace the var() lookups with an explicit brand red
(`rgb(200, 30, 30)`) so the page is readable regardless of which
theme is active in the rest of the app.
Affected rules: `.logo` background, `.button` background, `.input:focus`
border. Three identical edits.
Consolidates four overlapping test-infra PRs (#113, #114, #117, #118)
into a single coherent batch. Each contributing PR has redundancies
with one or more of the others; together they ship a real ~134-test
expansion of the unit suite plus mutation-testing infrastructure.
Same shape as #110 / #111: small, focused, behavior-pinning tests
against load-bearing systems. Each test answers one question — *what
specific regression does it catch that I'd otherwise find from a user
bug report?* Tests pin observable contracts (events emitted, cache
entries written, public-API state) rather than internal mechanics, so
they survive refactors during the longer-term migration toward the
six-interface architecture.
## What's in this PR
### Stryker mutation testing (new in this batch)
- `stryker.config.json` — hybrid config: `coverageAnalysis: "perTest"`
for the 5–10× speedup on a real codebase, `ignoreStatic: true` to
drop false-positive mutants in module-load code, and a `mutate`
scope of `src/core/**` + `src/lib/**` covering the logic-heavy
layers without dragging the React component surface into noise.
- `.github/workflows/mutation-testing.yml` — runs Stryker on a weekly
schedule (Sundays 22:00 US Eastern / 03:00 UTC Monday) plus
`workflow_dispatch` for on-demand validation. Per-PR triggering
would be too expensive (10–30 min per run even with `perTest`).
- `package.json` — adds `@stryker-mutator/core`, `@stryker-mutator/vitest-runner`,
and `fast-check` as devDependencies. New `test:mutate` script.
### New test files (22 added)
Plugin lifecycle and loaders:
- `src/core/plugins/PluginManager.test.ts` — orchestrator lifecycle:
register, enable, disable, data-flow contract, getAllEntities
filters by enabled, updateTimeRange, destroy, togglePlugin,
loadFromManifest. 11 tests.
- `src/core/plugins/loadPluginFromManifest.test.ts`
- `src/core/plugins/validateManifest.test.ts`
- `src/core/plugins/loaders/mapGeoJsonToEntities.test.ts`
- `src/core/plugins/loaders/mapJsonToEntities.test.ts`
Data layer:
- `src/core/data/DataUtils.test.ts`
- `src/core/data/WsClient.test.ts`
State (9 Zustand slices + the integration tests):
- `src/core/state/StateSlices.test.ts`
- `src/core/state/configSlice.test.ts`
- `src/core/state/dataSlice.test.ts`
- `src/core/state/favoritesSlice.test.ts`
- `src/core/state/filterSlice.test.ts`
- `src/core/state/geojsonSlice.test.ts`
- `src/core/state/globeSlice.test.ts`
- `src/core/state/layersSlice.test.ts`
- `src/core/state/timelineSlice.test.ts`
- `src/core/state/uiSlice.test.ts`
Filters:
- `src/core/filters/filterEngine.test.ts`
Library:
- `src/lib/AuthConfig.test.ts`
- `src/lib/analytics.test.ts`
- `src/lib/origin.test.ts`
### Test files extended (9 modified)
Property-based and edge-case additions to existing tests, drawn from
the upstream PRs:
- `src/core/plugins/loaders/getNestedValue.test.ts` (+46 lines)
- `src/lib/geojson/converter.test.ts` (+31)
- `src/lib/geojson/normalizer.test.ts` (+52)
- `src/lib/rateLimit.test.ts` (+44)
- `src/core/plugins/loaders/DeclarativePlugin.test.ts` (+147 — type
fixes for `DataSourceConfig.method`/`pollInterval`/`format`)
- `src/lib/marketplace/cors.test.ts` (+5)
- `src/lib/marketplace/marketplaceToken.test.ts` (+21)
- `src/core/filters/filterEngine.test.ts` (type-corrected — uses
`latitude`/`longitude` not `position.lat`/`lon`, nested
`range: { min, max, step }` config, etc.)
## What's *not* in this PR (intentionally)
- **Duplicate tests for code already on main.** #113 originally
included `.spec.ts` versions of `CacheLayer`, `DataBus`,
`PollingManager`, `cors`, `marketplaceToken`, `repository`,
`rateLimit`, `edition`, and `seedDefaultPlugins` — all of which are
already tested via `.test.ts` files on main from #110 + prior. Vitest
picks up both `.test.ts` and `.spec.ts`, so keeping both would double
the maintenance burden without adding signal. Dropped.
- **Tautological tests.** A few accessors-only tests from #113
(`getEntities` returning the cached array, `getAllPlugins().length`
equals N) were dropped per the test-writing bar set on #110/#111:
each test must catch a specific bug class that two different broken
implementations would fail differently on.
- **`version` bump in `package.json`.** Three of the contributing PRs
bumped the version line independently (2.9.5, 2.9.10, 2.9.10), each
conflicting with the others. Reserve version bumps for explicit
release commits — feature/test PRs should leave the version field
alone to avoid this conflict hairball.
- **A duplicate `stryker.conf.json`.** #114 used that filename; #117
used `stryker.config.json`. Stryker accepts both but only loads one
(alphabetical resolution). Picked `stryker.config.json` as the
canonical name.
## Verification
```
Test Files 38 passed (38)
Tests 271 passed (271)
```
137 tests on main before this PR; +134 from this consolidation, no
regressions. Type check clean (`pnpm exec tsc --noEmit`).
## Replaces
- PR #113 (test/improve-coverage) — most of its 18 truly-new files
are included here; the 9 duplicate-of-main entries are not.
- PR #114 (chore/stryker-setup) — its CI workflow shape is here with
the trigger changed to weekly+manual instead of per-PR.
- PR #117 (chore/stryker-and-fast-check) — its full deps and test
additions are here.
- PR #118 (test/improve-project-coverage) — the type-corrected
versions of its 6 test files are here, including the typefix commit
pushed to that branch earlier.
Each of those PRs should be closed once this lands, with a comment
referencing this PR for credit.
Co-Authored-By: silvertakana <[email protected]>
This commit includes the work done by the Flash subagent to add comprehensive TSDoc comments to src/components/panels, src/core/state, and src/core/plugins, improving IDE intellisense and codebase maintainability.
Replace direct Ion fallback with a 3-tier chain per maintainer feedback:
1. Google XYZ tiles (free, no API key)
2. Bing via Cesium Ion (free shared token)
3. OSM as last resort
useImageryManager catch block still falls to OSM if createImageryProvider
throws at runtime (e.g. direct Bing key failure, ArcGIS down).
WorldWideView's Vitest setup is already wired and CI already runs
\`pnpm test\` on every PR. What's missing is tests for the systems
that actually break: the plugin lifecycle plumbing (data bus, cache,
polling) and the camera adapter aggregator that the UI hits on every
layer toggle.
This PR adds a focused first batch — 12 tests across 4 files — covering
the most common failure modes we've actually seen in practice. The
intent is to land the patterns alongside the tests so the next
contributor (human or agent) can copy the shape rather than improvise.
## What's tested
| File | Coverage | Tests |
| ---- | -------- | ----- |
| src/core/data/DataBus.test.ts | emit/subscribe round-trip, unsubscribe correctness, handler-failure isolation | 3 |
| src/core/data/CacheLayer.test.ts | memory-tier get/set, TTL expiry + eviction | 2 |
| src/core/data/PollingManager.test.ts | immediate-run on start(), interval scheduling, stop() cancels | 3 |
| src/app/api/camera/adapters/registry.test.ts | resolveSources for "all" / null / "none" / mixed-with-unknowns | 4 |
Each test answers one question: what regression does it catch that
we'd otherwise find by user bug report?
## Config change
vitest.config.ts now includes \`src/app/**/*.{test,spec}.*\` so API-route
tests under \`src/app/api\` are picked up by \`pnpm test\`. Previously only
\`src/lib\`, \`src/core\`, \`src/plugins\`, and \`packages\` were scanned —
api-route handlers had no test home.
## Docs
\`docs/testing.md\` gets four new sections:
- **Patterns** — plain-function, stateful-singleton, mock-with-vi.mock,
fake-timers — with a callout for the \`runOnlyPendingTimersAsync\`
double-counting gotcha we hit while writing PollingManager tests.
- **What NOT to Test (Yet)** — Cesium-heavy components, live DB
round-trips, dynamic plugin imports.
- **Philosophy** — small focused suite > large expensive one, test
pure logic, add a test when you fix a bug.
Original overview/test-types/run-commands sections are unchanged.
## Verification
Locally (Node 22 + pnpm 9.15.4):
\`\`\`
Test Files 17 passed (17)
Tests 127 passed (127)
\`\`\`
Existing 115 tests still pass; new 12 land cleanly.
## What's next (not in this PR)
The list of load-bearing systems still without coverage:
- PluginManager (the central plugin lifecycle orchestrator)
- The new plugin-backend supervisor + proxy (PR #100)
- The agent bus (PR #79)
- Plugin marketplace install/uninstall round-trip
- React component tests for LayerPanel and DataBusSubscriber
Worth a follow-up batch once the patterns from this PR are familiar.
Co-authored-by: Sapphire <sapphire@tiktokcoach>
The aggregator uses `Promise.allSettled`, so the request takes as long
as the slowest adapter. Today ny511 (without a real API key) returns
empty after ~5s — fast adapters (cached) come back in <50ms but the
client waits 5s+ for the aggregate response.
With a 4s per-adapter cap, the stuck source rejects fast and either
its stale cache or an empty list is served; healthy adapters return on
their own cadence.
Concrete latency before this commit, all 7 adapters in parallel:
caltrans: 0.04s gdot: 0.02s tfl: 0.01s
ny511: 5.03s wsdot: 0.02s ncdot: 0.02s
osm-surveillance:0.03s
total: ~10s
Adds an opt-in agent integration surface that lets a trusted external
tool (running as the same logged-in user) drive the running WWV browser
session — fly the globe, toggle layers, focus entities — by POSTing
JSON actions to the server, which fans them out over SSE to every
connected browser tab belonging to that user.
The motivating use case is an MCP server (a Model Context Protocol
adapter): an LLM agent calls a tool like `globe_fly_to({lat, lon})`,
the MCP server posts to `/api/agent/publish`, the browser subscriber
re-emits the action onto the existing client-side `dataBus`, and the
React + Cesium app handles it the same way it would handle any UI
button click. Read-only camera / engine queries already work via the
existing REST surface — this PR adds the missing write path.
What's added:
- `src/lib/agent/bus.ts` — process-local AgentBus singleton, scoped
per user. Subscriptions live in a `Map<userId, Map<connId, sub>>`
so user A's publish never reaches user B's stream, even though
both run on the same Node process.
- `src/app/api/agent/stream/route.ts` — SSE channel. Auth-gated. Sends
initial `:connected` + `retry:3000` directives and a `:hb` heartbeat
every 25s so intermediary proxies (Caddy, Nginx, CDNs) don't tear
down a "stalled" connection.
- `src/app/api/agent/publish/route.ts` — POST endpoint. Accepts JSON
AgentAction shapes (`fly_to`, `face_towards`, `layer_toggle`,
`highlight_layer`, `select_entity`, `ping`), broadcasts only to the
publishing user's bus bucket. Returns `{delivered, subscribers}` so
the caller knows how many tabs received the command.
- `src/components/layout/AgentBusSubscriber.tsx` — browser EventSource
client. Re-emits received actions onto `dataBus` (`cameraGoTo`,
`cameraFaceTowards`, `layerToggled`, `entitySelected`) — every plugin
is already listening on those channels, so no plugin changes needed.
- `AppShell.tsx` — mounts `AgentBusSubscriber` next to the existing
`DataBusSubscriber`. Two lines.
- `src/app/api/build/route.ts` — `/api/build` returns build id +
timestamp + public flag state. Pairs with a one-line console.log
the subscriber prints on mount so a stale-bundle / config-mismatch
is visible at a glance instead of looking like a feature regression.
Default off via `NEXT_PUBLIC_WWV_AGENT_BUS_ENABLED=true`. An unintended
deployment doesn't open a remote-control channel for users who didn't
opt in.
What's changed in the Dockerfile:
- Adds ARG declarations for the new vars (`NEXT_PUBLIC_WWV_AGENT_BUS_ENABLED`,
`NEXT_PUBLIC_WWV_BUILD_ID`, `NEXT_PUBLIC_WWV_BUILD_AT`).
- Stamps the build with millisecond-precision id + ISO timestamp
(`/app/.build-id`, `/app/.build-at`); both copied into the runner
stage for `/api/build` to read.
- Writes `/app/.env.production.local` from declared ARGs *before*
`next build` runs. Docker doesn't reliably promote ARGs into the
Node child-process environment for the build command, so
`process.env.NEXT_PUBLIC_*` references that previously inlined
through Webpack's DefinePlugin sometimes fell back to runtime
polyfill access (`tV.env.NEXT_PUBLIC_X`) that resolves to `undefined`
in the browser. Writing the env file is the documented Next.js path
and behaves the same on every host.
Default-off, no schema changes, no plugin changes, fully backwards-compatible
on operators who don't opt in.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Migrated wwv-plugin-gps-jamming to local-plugins and fixed WebSocket payload handling (Patch)
- Migrated wwv-plugin-fortiguard to local-plugins and refactored API proxy fetch logic (Patch)
- Migrated wwv-plugin-nz-traffic-cameras to local-plugins (Patch)
- Cleaned up tutorial plugin wwv-plugin-iss from tree (Patch)
- Added scripts/migrate-plugin.mjs for automation (Patch)