Skip to content

Close SPEC.md audit gaps: chat trade pricing, frontend test mocks, test layout#8

Open
kplayz wants to merge 4 commits intoed-donner:mainfrom
kplayz:ashish/spec-gap-closure
Open

Close SPEC.md audit gaps: chat trade pricing, frontend test mocks, test layout#8
kplayz wants to merge 4 commits intoed-donner:mainfrom
kplayz:ashish/spec-gap-closure

Conversation

@kplayz
Copy link
Copy Markdown

@kplayz kplayz commented Apr 21, 2026

Summary

Closes three gaps identified by the SPEC.md audit (convoy hq-cv-9a2s0):

  • fin-a3ibackend/app/chat.py auto-executed LLM trades using a hardcoded $150 placeholder. Extracted execute_trade_core() in portfolio.py as the shared trade engine; chat now reuses it so every auto-executed trade reads the live price from price_cache and goes through the same validation + snapshot path as manual trades. Adds a regression test verifying the live cache price is recorded.
  • fin-z4x — 4 failing tests in frontend/src/__tests__/PortfolioPage.test.tsx. Updated the lightweight-charts mock to the v5 API (addSeries(LineSeries, …) + exporting LineSeries), fixed MockEventSource to expose addEventListener/removeEventListener, and added a ResizeObserver stub in setup.ts (used by recharts' ResponsiveContainer). All 37 frontend tests now pass.
  • fin-5m5 — Moved docker-compose.test.yml into test/ per SPEC.md §4; adjusted build.context to .. and the playwright volume mount to .:/work. docker compose -f test/docker-compose.test.yml config validates cleanly.

Test plan

  • cd backend && uv run pytest48/48 passing (was 47; added test_chat_trade_uses_live_cache_price)
  • cd frontend && npx vitest run37/37 passing (was 33/37)
  • cd frontend && npm run build — static export succeeds
  • docker compose -f test/docker-compose.test.yml config — paths resolve
  • E2E sweep with docker compose -f test/docker-compose.test.yml up --abort-on-container-exit (not run locally; CI should cover)

🤖 Generated with Claude Code

kplayz added 4 commits April 21, 2026 10:19
… (fin-a3i)

LLM-driven trades now read live prices from price_cache instead of the
$150 hardcoded placeholder, and reuse the same validation + snapshot
logic as manual trades. Extract execute_trade_core() in portfolio.py
as the shared helper; chat._execute_trade() becomes a thin adapter.
The history accumulator in useMarketData pushed into the same array
reference each SSE event. Recharts' <LineChart data={...}> freezes the
incoming array for internal memoization, so the next event's .push()
threw 'Cannot add property N, object is not extensible' and the page
went blank. Build a new array each tick so the frozen prior reference
stays untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant