All tickets
SUP-176
Empty agent edit advances updatedAt timestamp
Description
Summary
Editing an agent and submitting with no actual field changes still advances the agent's `updatedAt` timestamp, making it look like the agent was modified when it wasn't.
Root cause (verified in src/store/index.ts)
`updateAgent` unconditionally sets a new `updatedAt` on every call, regardless of whether `updates` differs from the current agent:
```ts
updateAgent: (id, updates) => set((state) => ({
agents: state.agents.map((agent) =>
agent.id === id
? { ...agent, ...updates, updatedAt: new Date().toISOString() }
: agent
)
})),
```
The only current caller is src/pages/AgentCreator.tsx, which always calls `updateAgent(id, data)` on form submit in edit mode, even if the form values are identical to the existing agent:
```ts
const handleSubmit = (data) => {
if (isEditMode && id) {
updateAgent(id, data);
} else {
addAgent(data);
}
navigate('/agents');
};
```
`createdAt` is not affected — only `updatedAt` is incorrectly advanced on no-op edits.
Suggested fix
Suppress no-op edits at the caller (AgentCreator.tsx), not inside the store, since updatedAt is meant to record "a matching update was invoked":
1. In handleSubmit, compare submitted `data` against `currentAgent`'s editable fields.
2. If nothing differs, skip calling `updateAgent` (just navigate away).
3. If something differs, call `updateAgent` as today.
Consider auditing other store actions (updateCall, updateUserPreferences) for the same no-op pattern.
Acceptance criteria
- Submitting the edit form with unchanged values does not change `updatedAt` (or `createdAt`).
- Submitting the edit form with changed values still advances `updatedAt` as before.
Files
- src/store/index.ts
- src/pages/AgentCreator.tsx
Reference: SUP-171
Activity
- Ticket created · 10/25/2026, 8:08:42 AM