Repository navigation
Implement holding detail panels and buy/sell trade previews #134
Description
Goal
Complete the desktop side panel, mobile holding view, and direct-cash buy/sell editor from the design.
Current behavior
The current modal and generic transaction/transfer editors do not match the prototype detail and Record trade interactions; their independent fetches and mutation flows need coordinated refresh.
Desired behavior
Implement a desktop holding panel and mobile sheet/detail view with quantity, remaining average cost, native current price/as-of, net invested and return coverage; market price ranges with buy/sell markers and the agreed average-cost reference; and ordered trade history. Aggregate multiple trades on a chart day without overwriting markers, retain their actual dates, and label prices in quote currency. A manual holding shows value-history steps, cost if known, last-valued date and Update value instead of market Buy/Sell controls, following the manual asset contract.
Record trade opens from the page or selected holding, supports Buy/Sell, quantity, executed unit price, date, Pay from/Deposit to cash account, explicit actual cash for different currencies and fee fields per the trade contract. Show draft-only latest-price/FX suggestions, exact totals/currency, position after, average-cost or sale-gain preview, oversell errors and the established insufficient-cash warning policy. Do not silently use latest price for an old execution.
Reuse AmountInput string drafts and AlertContext. Validate locally and on the API, retain all form input on errors, prevent duplicate submissions, and only close/refresh on success. Linked history edits/deletions act on the whole pair and update all affected overview/account/history snapshots. Use one owned data flow with lazy detail history to avoid duplicate fetches and stale selected-account objects. Preserve unsaved-editor navigation protection, accessible focus/escape handling, locks/archive restrictions, privacy and both themes.
Acceptance criteria
- Desktop/mobile panels show correct market/manual fields and source dates; unknown cost, stale quotes and chart failures remain understandable.
- Multiple same-day buys/sells appear in chart interaction and history with correct quote currency and no fabricated execution data.
- A buy and a sell through the editor produce the exact previewed units/cash, including fractional crypto, fees and cross-currency actual cash.
- Oversells, locked/archived accounts, future dates, failed saves and repeated clicks preserve drafts and cannot create duplicate or partial records.
- Manual value save, pair edit/delete and trade success refresh affected views together; focus, back/navigation, privacy and responsive states are tested.
References or visuals
Parent: #123. Milestone: Investment Page Rework.
Design: user-supplied Investments Redesign.dc.html, sections 1a (desktop), 1b (mobile), and the holdings-table screenshot in the Codex conversation. Its generated prices, fixed FX, dates and sample holdings are visual fixtures, not calculation rules or migration data.
Branch from the fetched epic/123-investment-rework tip, use this sub-issue number in the branch name, and target its PR to that epic. Final integration into main requires completion of the epic and explicit user approval.
Implementation dependencies: #131. Native blocked-by relationships record these prerequisites.
Accounting contract from #126
Review checkpoint: MR #136; version 1 contract. Apply the reviewed contract when this prerequisite is integrated; this note does not start this child or approve a merge.
Use the contract execution/cash/fee fields and exact preview rules. Remaining average cost differs from an all-buys average after sales/rebuys. Explicit actual cash is required across currencies; entered fees are included once in that cash amount. Show known native/reporting metrics independently, and use the covered-start/method for Estimated return. Manual total assets versus per-unit manual prices must not be multiplied twice; manual appraisal is not a buy. Historical price suggestions must not become actual old executions. Preserve multiple same-day trade markers, client-calendar future-date errors and all form drafts on failed pair writes.
Implementation review checkpoint
MR #145 targets epic/123-investment-rework from feature/134-investment-detail-trades. It implements the holding panels, native price/trade chart, manual value controls and dedicated cash-linked Buy/Sell editor. Pair editing pins saved versions; deletion reverses both legs. Previewed units/cash come from the server planner. Lost-response retries retain the original payload/key across refresh and cannot silently become another trade; the 24-hour recovery window is enforced.
Local verification: 432 client, 190 API, 51 MCP and 26 deployment tests passed; all workspace/integration types, client lint and build passed. Worker/D1 detail suite: five passing tests, including full-sale retry after a refreshed zero holding. Browser checks used synthetic fixtures only. Supplied-export rehearsal preserved financial records/rowids and source revision across 19 tables; integrity/foreign keys passed, original unchanged, disposable copy removed. This child adds no schema migration and no production/main mutation. All 11 CI checks passed on final commit 71f952a, including Node 22/26 client tests and 208 Worker/D1 integration tests (two existing skips).
Leave this issue open until the user verifies and merges this child into the epic. #135 remains the complete integrated release audit; this MR does not finish or release #123.
Activity