Skip to content

feat(droid): add downscale/upscale API for worker management#8105

Merged
h0lybyte merged 2 commits intodevfrom
trunk/droid-downscale-1773663575
Mar 16, 2026
Merged

feat(droid): add downscale/upscale API for worker management#8105
h0lybyte merged 2 commits intodevfrom
trunk/droid-downscale-1773663575

Conversation

@h0lybyte
Copy link
Member

Summary

  • Adds window.kbve.downscale() — terminates canvas worker, mod workers, gateway worker pool, and overlay manager while keeping DB + WS SharedWorkers alive for session persistence
  • Adds window.kbve.upscale() — re-initializes all terminated workers back to full capacity
  • Adds window.kbve.scaleLevel() — returns current scale level ('full' or 'minimal')
  • Emits droid-downscale and droid-upscale events on the droid event bus
  • Exports downscale, upscale, getScaleLevel, and DroidScaleLevel type from @kbve/droid

Use case: The isometric game page needs pthread/WASM thread headroom. Before loading the game WASM, it can call await window.kbve.downscale() to free up worker threads, then await window.kbve.upscale() when navigating away.

Test plan

  • nx build droid passes
  • ESLint + Prettier pass via pre-commit
  • Manual test: call window.kbve.downscale() in console, verify canvas/overlay stop, DB+WS still work
  • Manual test: call window.kbve.upscale() to restore full functionality

Adds window.kbve.downscale() and window.kbve.upscale() to control droid
worker thread usage at runtime. Downscale terminates canvas worker, mod
workers, gateway pool, and overlay — keeping only DB + WS SharedWorkers
for session persistence. Upscale restores full capacity. Designed for
pages that need pthread/WASM thread headroom (e.g. isometric game).
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

13 new Playwright tests covering: initial full mode, downscale to minimal,
overlay/canvas teardown, DB+WS persistence, event emission, idempotency,
upscale restoration, and full cycle error-free operation.
@h0lybyte h0lybyte merged commit 16fe596 into dev Mar 16, 2026
4 checks passed
@h0lybyte h0lybyte deleted the trunk/droid-downscale-1773663575 branch March 16, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant