stock-bot/docs/development/backlog/tasks/RP06.md

15 lines
3.7 KiB
Markdown

# RP06 — Preserve settings and captured preparation across backtest tabs
Parent E12. Priority P1 / High custody defect. Complexity M. Dependency RP03. Owner continuation authorizes this correction; ADR-006 and financial semantics stay unchanged.
Evidence: `BacktestDetailPageV2.renderTabContent` mounts canonical setup only in the settings case. Any other tab unmounts it and `DatasetPreparation`, destroying a preview or ambiguous retention retry. `useUnsavedWarning` protects browser unload only, so an ordinary same-page tab click silently loses the exact captured input. The page also clears the configure flag on every run-ID change, although the edited template still belongs to the same backtest.
Scope: keep settings lazily mounted after the first visit for the current backtest; hide them accessibly while other tabs render. Preserve policy/strategy drafts, loaded source metadata, captured preview and unconfirmed retention retry across tabs and same-backtest run selections. Scope ownership to the backtest ID; changing it disposes/fences the previous editor and never renders old inputs for the new owner. Explicit close/discard and authoritative saved-definition updates keep their existing semantics. Do not start settings/catalog requests before first visit, duplicate the editor or trigger hidden saves/runs. No persistent browser draft store, global router blocker, framework or financial change. Leaving this backtest/reloading remains outside the in-memory preservation guarantee.
Files/locks: `apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx`, existing `test/integration/backtest-run-controls.test.tsx` and narrowly scoped lifecycle tests. Do not edit CanonicalSetup or its transport (RP05 ownership). Root owns shared browser tests and planning state. React lifecycle implementation agent; independent review.
Acceptance/tests: demonstrate the original loss before changing code; ordinary name/policy changes survive Settings → Runs → Settings; capture and ambiguous-retention retry retain exactly the same input/hash without another source read; late completion while hidden stays owned by the same template; same-backtest run navigation preserves the draft. Other tabs cannot expose/focus hidden settings, and entering a backtest does not eagerly fetch the catalog. Changing backtest ID clears the old editor and fences late completion; explicit discard/save still work. Verify zero unintended template/run writes during navigation, with a real browser retention retry scenario. Existing polling, cancellation, archived and legacy-history behavior must pass.
Gates: focused page/lifecycle tests, application/authored-test types, strict lint, production build; root full repository and Chromium suite. Parallel with RP05 because the parent owns mounting while the child owns dataset choice. No broad navigation refactor; the main regression risks are stale ownership, hidden focusable inputs and newly eager requests.
Accepted October 27, 2026: the original name-draft loss was reproduced before the fix. One lazily mounted settings panel now survives same-backtest tabs/run URLs; another backtest disposes it. Independent review passed 45 lifecycle tests / 279 assertions; broader implementer suites passed 198 / 967. Root full repository gate and both real browser regressions passed: unsaved name survives index-to-run navigation without changing the saved definition, and a committed retention response can be lost, followed by tab changes and exact retry after source removal, without a source reread. Hidden controls are absent from accessible role queries. [Combined evidence](../../real-data-research.md) records the in-memory scope; no persistent draft or general navigation framework was added.