Skip to content

Commit 6404317

Browse files
gcmsgclaude
andcommitted
fix: chart visibility, heartbeat grace period, form alignment, agents page crash
- ReputationChart: larger filled dots (r=4), solid fill for better dark-mode visibility - heartbeat_miss: skip agents registered less than 5 minutes ago (registered_at < cutoff) so new agents aren't immediately penalized - ClaimTokenSection: match button height to input field (h-[38px]) - ProviderAgentsPage: null-safe access on total_calls, success_rate, avg_latency_ms to prevent crash Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 302ea81 commit 6404317

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

internal/reputation/postgres.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ func (s *PostgresStore) UnsetAgentVerified(ctx context.Context, agentID string)
163163
// ListStaleOnlineAgents returns IDs of agents whose status is online but
164164
// whose last heartbeat is older than the given timeout.
165165
func (s *PostgresStore) ListStaleOnlineAgents(ctx context.Context, timeout time.Duration) ([]string, error) {
166+
cutoff := time.Now().UTC().Add(-timeout)
166167
rows, err := s.db.QueryContext(ctx,
167-
`SELECT id FROM agents WHERE status = 'online' AND last_heartbeat < $1`,
168-
time.Now().UTC().Add(-timeout),
168+
`SELECT id FROM agents WHERE status = 'online' AND last_heartbeat < $1 AND registered_at < $1`,
169+
cutoff,
169170
)
170171
if err != nil {
171172
return nil, err

internal/reputation/sqlite.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ func (s *SQLiteStore) UnsetAgentVerified(ctx context.Context, agentID string) er
177177
// ListStaleOnlineAgents returns IDs of agents whose status is online but
178178
// whose last heartbeat is older than the given timeout.
179179
func (s *SQLiteStore) ListStaleOnlineAgents(ctx context.Context, timeout time.Duration) ([]string, error) {
180+
cutoff := time.Now().UTC().Add(-timeout).Format(time.RFC3339)
180181
rows, err := s.db.QueryContext(ctx,
181-
`SELECT id FROM agents WHERE status = 'online' AND last_heartbeat < ?`,
182-
time.Now().UTC().Add(-timeout).Format(time.RFC3339),
182+
`SELECT id FROM agents WHERE status = 'online' AND last_heartbeat < ? AND registered_at < ?`,
183+
cutoff, cutoff,
183184
)
184185
if err != nil {
185186
return nil, err

web/app/src/components/provider/ClaimTokenSection.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@ Full documentation: https://github.com/peerclaw/peerclaw/blob/main/docs/GUIDE.md
187187
/>
188188
</div>
189189
<Button
190-
size="sm"
191190
onClick={handleGenerate}
192191
disabled={generating}
193-
className="shrink-0"
192+
className="shrink-0 h-[38px]"
194193
>
195194
{generating ? (
196195
<Loader2 className="size-4 animate-spin" />

web/app/src/components/public/ReputationChart.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ export function ReputationChart({ events }: { events: ReputationEvent[] }) {
6262
dataKey="score"
6363
stroke="hsl(var(--chart-1))"
6464
strokeWidth={2}
65-
dot={{ r: 3 }}
66-
activeDot={{ r: 5 }}
65+
dot={{ r: 4, fill: "hsl(var(--chart-1))", strokeWidth: 0 }}
66+
activeDot={{ r: 6, fill: "hsl(var(--chart-1))", strokeWidth: 2, stroke: "hsl(var(--card))" }}
67+
connectNulls
6768
/>
6869
</LineChart>
6970
</ResponsiveContainer>

web/app/src/pages/ProviderAgentsPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ export function ProviderAgentsPage() {
105105
</Badge>
106106
</TableCell>
107107
<TableCell className="text-muted-foreground">
108-
{agent.total_calls.toLocaleString()}
108+
{(agent.total_calls ?? 0).toLocaleString()}
109109
</TableCell>
110110
<TableCell className="text-muted-foreground">
111-
{agent.success_rate.toFixed(1)}%
111+
{(agent.success_rate ?? 0).toFixed(1)}%
112112
</TableCell>
113113
<TableCell className="text-muted-foreground">
114-
{agent.avg_latency_ms.toFixed(0)}ms
114+
{(agent.avg_latency_ms ?? 0).toFixed(0)}ms
115115
</TableCell>
116116
</TableRow>
117117
))}

0 commit comments

Comments
 (0)