Skip to main content

Fix: Strategy Parameter Deletion Visibility + Hydration Race

Problem​

Users could remove a strategy parameter key in the bot Strategy tab, save, and then force reload to see the key appear again (for example swingStrength). This looked like deletion failed.

Root Cause​

Two issues combined:

  1. Schema-defined parameters were treated as removable keys in the UI

    • The UI rebuilt parameter rows from strategy schema + legacy defaults + bot params on reload.
    • If a key existed in the strategy schema, it was re-listed, even when the bot override was removed.
  2. Hydration race between bot-level params and branch strategy params

    • fetchBot and fetchBotStrategy both seeded editable params.
    • The fallback bot-level seed could overwrite branch-aware strategy params after reload.

Changes Made​

File: services/frontend/src/routes/bots/BotDetailPage.tsx

  • Added descriptor source metadata (legacy | schema | bot).
  • Updated row actions:
    • Custom (bot) keys can be removed.
    • Schema/legacy keys now show Reset action (clear override) instead of remove.
  • Added hydration guard ref so bot-level seed does not clobber branch strategy seed once strategy params are hydrated.

Behavior After Fix​

  • Removing a custom key persists and stays removed.
  • Schema-defined keys are no longer falsely removable; users reset value overrides instead.
  • Force reload no longer reintroduces stale values due to hydration ordering.

Validation​

  • pnpm --filter @quantago/frontend typecheck ✅
  • pnpm --filter @quantago/frontend lint ✅ (existing warnings only, no new errors)