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

22 lines
3.2 KiB
Markdown

# RP14 — Preserve backtest creation work during strategy inspection
Parent E12. Priority P2 / Medium draft and save recovery defect. Complexity S. Dependencies R02 and W03. Owner continuation authorizes this correction.
Verified baseline: `CreateBacktestDialog.tsx` guards Close with `pending.current` and `confirmDiscard(edited)`, but its child `StrategySelection.tsx` renders a normal immutable-version link. Disabled fieldsets do not disable anchors, and the unload warning does not intercept router navigation. The dialog's own link silently discards an edited draft or unmounts during Save, after which the accepted response is ignored. `/tmp/stock-bot-rp14-baseline.log` records two failing regressions against `dcffa2ea` using the existing backtest UI harness.
Scope: add a dialog-local guard for ordinary same-tab links using existing pending/discard state. Reject navigation during a pending save, including a Save/link click before rerender. When idle, use the existing discard confirmation. Preserve clean navigation and modified-click/new-tab inspection. Do not call the Close callback merely to follow a link. No shared selector policy, global router blocker, persistent drafts, new modal, backend API, request retry redesign or financial changes.
Ownership: implementation agent owns `apps/stock/web-app/src/features/backtest/components/CreateBacktestDialog.tsx` and `test/integration/backtest-run-controls.test.tsx`. Root owns shared browser tests, planning records and commits. Independent review required. Other navigation surfaces remain outside this correction.
Acceptance/tests:
- Declining discard keeps the route and exact form/strategy values, without saving or creating a run.
- Accepted discard and clean same-tab navigation still reach the immutable version.
- During Save, the link cannot abandon the dialog or trigger a discard prompt; one accepted save invokes completion once and opens its saved definition.
- Modified clicks, middle clicks and explicit new-context links remain available without discarding the current form or pending request. Already-prevented events stay untouched.
- A failed save returns to ordinary dirty-draft confirmation. Existing Close, double-submit and late-unmount behavior remains covered.
- Actual browser coverage declines navigation, delays the committed save response, attempts navigation while pending, then releases it and opens exactly one saved definition with the original parameters and zero runs/dispatches.
Gates: focused backtest and strategy UI regressions, application/authored types, lint/build, root repository check and full browser suite against disposable fixtures. Conditional performance work and paper/live activation stay deferred.
Accepted October 27, 2026; implementation `0d022ecc`. Independent backtest/strategy UI review passed 72 tests / 488 assertions. Root full check passed, including 1,364 integration and 150 Rust tests. All 21 browser scenarios passed / 783 assertions, including declined navigation and a held committed save response followed by exactly one original saved definition and zero runs/dispatches. Application/authored types, lint, formatting and build passed. [Combined evidence](../../real-data-research.md) records validation and scope.