lib(renderer): add safeJson helper; migrate 6 JSON.parse try/catch call sites
This commit is contained in:
1 parent
a07b42e493
commit
be0ff5a041
8 files changed
+46
-48
No files matched your search
@@ -9,6 +9,7 @@ import type { AgentRecord, ApprovalRecord } from "@shared/types";
|
||||
import { useT } from "../../i18n";
|
||||
import { getAgentInitials } from "../../lib/formatters";
|
||||
import { unwrap } from "../../lib/desktop";
|
||||
import { safeJson } from "../../lib/safe-json";
|
||||
import { ActionButton, EmptyState, Panel, StatusPill } from "../ui";
|
||||
import {
|
||||
type HiringStage,
|
||||
@@ -44,7 +45,8 @@ export function HiringPipeline({ agents, approvals, onRefresh, onNavigateToAgent
|
||||
const approval = hireApprovals.find(a => {
|
||||
if (a.relatedAgentId === agent.id) return true;
|
||||
if (!a.payloadJson) return false;
|
||||
try { return JSON.parse(a.payloadJson).agentId === agent.id; } catch { return false; }
|
||||
const payload = safeJson<{ agentId?: string }>(a.payloadJson, {});
|
||||
return payload.agentId === agent.id;
|
||||
}) ?? null;
|
||||
return {
|
||||
agent,
|
||||
|
||||
Reference in new issue
Block a user