module Web.View.AgentRegistrations.Show where import Web.View.Prelude import Web.View.AgentRegistrations.Index (trustBadge, statusBadge) data ShowView = ShowView { agent :: !AgentRegistration , policies :: ![ModelRoutingPolicy] , recentProposals :: ![AgentProposal] , mPerformance :: !(Maybe AgentPerformanceRecord) } instance View ShowView where html ShowView { .. } = [hsx|

{agent.name}

{agent.slug}

{trustBadge agent.trustLevel} {statusBadge agent.isActive} Edit {when agent.isActive [hsx| Deactivate |]} Compute Performance

Provider

{agent.provider}

Model

{agent.modelName}

Description

{fromMaybe "—" agent.description}

{performancePanel mPerformance}

Routing Policies

{if null policies then [hsx|

No routing policies. Add one.

|] else policiesTable}

Recent Proposals (last 10)

{if null recentProposals then [hsx|

No proposals yet.

|] else proposalsTable}
|] where policiesTable = [hsx|
{forEach policies \p -> [hsx| |]}
Task Type Priority Active
{p.taskType} {show p.priority} {statusBadge p.isActive}
|] proposalsTable = [hsx|
{forEach recentProposals \p -> [hsx| |]}
Type Status Tokens In/Out Created
{p.proposalType} {p.status} {maybe "—" show p.tokensIn} / {maybe "—" show p.tokensOut} {timeAgo p.createdAt}
|] performancePanel :: Maybe AgentPerformanceRecord -> Html performancePanel Nothing = [hsx|
No performance snapshot available. Click "Compute Performance" to generate one.
|] performancePanel (Just p) = let total = p.proposalsAccepted + p.proposalsRejected acceptPct = if total > 0 then (100 * p.proposalsAccepted) `div` total else 0 in [hsx|

Performance (30-day snapshot)

{show p.proposalsGenerated}

Generated

{show p.proposalsAccepted}

Accepted

{show p.proposalsRejected}

Rejected

{show acceptPct}%

Acceptance rate

{case p.meanConfidence of Nothing -> [hsx|

Mean confidence: —

|] Just c -> [hsx|

Mean confidence: {printf "%.2f" c :: String}

|] }
|]