fix: add error handling for agent env vars save and sprites-exec JSON errors

- Agent env vars: auto-save now awaits response and shows alert on failure
- sprites-exec v0.1.4: detect JSON error responses (e.g., auth failures) before binary parsing
This commit is contained in:
Ajax Davis 2026-01-14 23:48:43 +10:00
parent b5fa46f6be
commit 69ae0dda2f
3 changed files with 42 additions and 9 deletions

View file

@ -1029,14 +1029,26 @@ export default function AgentDetailPage(): React.ReactElement {
<div className="bg-surface border border-border rounded-lg p-6">
<EnvVarsEditor
value={envVars}
onChange={(newEnvVars) => {
onChange={async (newEnvVars) => {
setEnvVars(newEnvVars);
// Auto-save env vars
fetch(`/api/agents/${agentId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ envVars: newEnvVars }),
});
// Auto-save env vars with error handling
try {
const response = await fetch(`/api/agents/${agentId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ envVars: newEnvVars }),
});
const result = await response.json();
if (!result.success) {
console.error('Failed to save env vars:', result.error);
alert(
'Failed to save environment variables: ' + (result.error || 'Unknown error')
);
}
} catch (err) {
console.error('Failed to save env vars:', err);
alert('Failed to save environment variables. Please try again.');
}
}}
title="Environment Variables"
description="Passed to tools at runtime. Agent vars override collection vars. Changes are saved automatically."