Files
k d50c05b120 fix: pre-launch UI hardening + KOL reduce-action type, proxy IP relay, settings redesign
Frontend half of the pre-launch audit campaign:

- types/index.ts + kol/KolPageClient.tsx: add missing 'reduce' KolAction
  (backend emits it; frontend lacked the type + color/label maps → undefined
  styling). Adds ACTION_COLOR/actionLabel/postActionLabel entries.
- proxy/[...path]/route.ts: relay real client IP (x-forwarded-for / x-real-ip)
  so the backend rate limiter buckets per-user instead of per-Next-server (BUG-02).
- Settings/BotConfigPanel redesign, paper-mode clarity, copy cleanup.
- Assorted page/display fixes, loading states, Pagination component.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 11:57:43 +08:00

30 lines
861 B
TypeScript

'use client'
import { useWsSubscribe } from './wsContext'
interface Handlers {
// BUG-08 fix: backend now broadcasts SOL/TRUMP/BNB/DOGE/LINK/AAVE ticks
// in addition to BTC/ETH — widen asset to string.
onPrice?: (asset: string, price: number) => void
onNewPost?: (post: object) => void
}
type PriceMsg = { type: 'price'; asset: string; price: number }
type PostMsg = { type: 'new_post'; post: object }
/**
* Subscribe to price ticks and new-post events from the shared WebSocket.
* Delegates to WsProvider's singleton connection — no new socket is opened.
*/
export function usePriceSocket(handlers: Handlers) {
useWsSubscribe('price', (msg) => {
const m = msg as PriceMsg
handlers.onPrice?.(m.asset, m.price)
})
useWsSubscribe('new_post', (msg) => {
const m = msg as PostMsg
handlers.onNewPost?.(m.post)
})
}