Skip to content

Commit c57d1de

Browse files
committed
Mitigate validate agents error
1 parent 29d6423 commit c57d1de

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

cli/src/components/validation-error-popover.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ export const ValidationErrorPopover: React.FC<ValidationErrorPopoverProps> = ({
7777
</box>
7878

7979
<box style={{ flexDirection: 'column', paddingTop: 1, gap: 0 }}>
80-
{errors.slice(0, 3).map((error) => {
81-
const agentId = error.id.replace(/_\d+$/, '')
82-
const isNetworkError = error.id === NETWORK_ERROR_ID
80+
{errors.slice(0, 3).map((error, index) => {
81+
const errorId = error.id ?? ''
82+
const agentId = errorId.replace(/_\d+$/, '')
83+
const isNetworkError = errorId === NETWORK_ERROR_ID
8384
const agentInfo = loadedAgentsData?.agents.find(
8485
(a) => a.id === agentId,
8586
) as LocalAgentInfo | undefined
@@ -91,7 +92,7 @@ export const ValidationErrorPopover: React.FC<ValidationErrorPopoverProps> = ({
9192
if (isNetworkError) {
9293
return (
9394
<box
94-
key={error.id}
95+
key={errorId || `error-${index}`}
9596
style={{ flexDirection: 'column', paddingTop: 0.5 }}
9697
>
9798
<text style={{ fg: theme.muted, wrapMode: 'word' }}>
@@ -104,7 +105,7 @@ export const ValidationErrorPopover: React.FC<ValidationErrorPopoverProps> = ({
104105
if (agentInfo?.filePath) {
105106
return (
106107
<box
107-
key={error.id}
108+
key={errorId || `error-${index}`}
108109
style={{ flexDirection: 'column', paddingTop: 0.5 }}
109110
>
110111
<text style={{ fg: theme.muted, wrapMode: 'word' }}>
@@ -131,11 +132,11 @@ export const ValidationErrorPopover: React.FC<ValidationErrorPopoverProps> = ({
131132

132133
return (
133134
<box
134-
key={error.id}
135+
key={errorId || `error-${index}`}
135136
style={{ flexDirection: 'column', paddingTop: 0.5 }}
136137
>
137138
<text style={{ fg: theme.muted, wrapMode: 'word' }}>
138-
{`• ${agentId}`}
139+
{`• ${agentId || 'Unknown'}`}
139140
</text>
140141
<text
141142
style={{

cli/src/hooks/use-send-message.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const useSendMessage = ({
103103
onBeforeMessageSend,
104104
mainAgentTimer,
105105
scrollToLatest,
106-
onTimerEvent = () => {},
106+
onTimerEvent = () => { },
107107
isQueuePausedRef,
108108
isProcessingQueueRef,
109109
resumeQueue,
@@ -289,12 +289,13 @@ export const useSendMessage = ({
289289
const errorsToAttach =
290290
validationResult.errors.length === 0
291291
? [
292-
{
293-
id: NETWORK_ERROR_ID,
294-
message:
295-
'Agent validation failed. This may be due to a network issue or temporary server problem. Please try again.',
296-
},
297-
]
292+
// Hide this for now, as validate endpoint may be flaky and we don't want to bother users.
293+
// {
294+
// id: NETWORK_ERROR_ID,
295+
// message:
296+
// 'Agent validation failed. This may be due to a network issue or temporary server problem. Please try again.',
297+
// },
298+
]
298299
: validationResult.errors
299300

300301
setMessages((prev) =>

sdk/src/validate-agents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export async function validateAgents(
143143

144144
// Transform validation errors to the SDK format
145145
const transformedErrors = validationErrors.map((error) => ({
146-
id: error.filePath,
146+
id: error.filePath ?? 'unknown',
147147
message: error.message,
148148
}))
149149

0 commit comments

Comments
 (0)