Skip to content

Simulator Last Successful Combo Cache Plan

Background

The simulator page allows developers to paste mapHex, optional pathHex, and optional roomProperties for real-time rendering. Refreshing the page currently risks losing in-progress data.

Goal And Scope

Persist the last successfully rendered combination locally so developers can refresh and continue without data loss.

In scope:

  • Save input combo after successful render.
  • Restore input combo on page load.
  • Fallback to built-in demo defaults when no cache hit exists.
  • Provide an explicit cache clear action.

Out of scope:

  • Cross-device sync.
  • Server-side persistence.
  • IndexedDB migration.

Chosen Approach

  • Use browser localStorage with key rayRobotMap:simulator:lastSuccessfulCombo:v1.
  • Store payload with version and timestamp:
    • mapHex
    • pathHex
    • roomProperties
  • Read and validate cache shape at startup.
  • Only persist when full render completes without layer errors.
  • Keep render behavior unchanged for optional inputs.
  • Add 清除缓存 action to remove stored combo manually.

Impacted Files Or Modules

  • docs/.vitepress/theme/components/MapPlayground.vue

Verification Checklist

  • npm run lint passes (project lint scope currently covers src only).
  • npm run docs:build passes.
  • npx tsc --noEmit still fails due existing unrelated test typing issues in test/core/application/Interaction.test.ts.

最后更新于: