feat(agent): add reset controls for sessions and memory#985
Conversation
✅ Tests passed — 1225/1229
|
Greptile SummaryThis PR adds user-facing reset controls for sessions and memory, wiring together new server-side DELETE endpoints for
Confidence Score: 4/5Safe to merge; the destructive operations are guarded by confirmation dialogs and the server endpoints behave correctly in tests. The new reset paths are well-structured and covered by tests. The one issue worth noting is that each individual deletion in the bulk-clear loop fires the existing mutation's onSuccess handler, which calls queryClient.invalidateQueries once per conversation — producing unnecessary GraphQL refetches proportional to the history size before the final explicit invalidation. packages/browseros-agent/apps/agent/entrypoints/sidepanel/history/ChatHistory.tsx — the bulk-delete loop reuses the same mutation that auto-invalidates on every success. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant ResetDataPage
participant ChatHistory
participant Server
participant QueryCache
Note over ResetDataPage: Reset Memory / SOUL.md
User->>ResetDataPage: click Reset button
ResetDataPage->>ResetDataPage: setPendingAction (opens dialog)
User->>ResetDataPage: confirm
ResetDataPage->>Server: DELETE /memory or /soul
Server-->>ResetDataPage: "{ success: true }"
ResetDataPage->>QueryCache: setQueryData(MEMORY_QUERY_KEY, '')
ResetDataPage->>QueryCache: "invalidateQueries(MEMORY_QUERY_KEY | SOUL_QUERY_KEY)"
QueryCache-->>ResetDataPage: triggers refetch
Note over ChatHistory: Clear All Sessions
User->>ChatHistory: click Clear sessions
ChatHistory->>ChatHistory: setShowClearAllDialog(true)
User->>ChatHistory: confirm
ChatHistory->>ChatHistory: getAllRemoteConversationIds() paginates if needed
loop batches of 10
ChatHistory->>Server: deleteConversation(rowId) x10
Server-->>ChatHistory: success
ChatHistory->>QueryCache: invalidateQueries per-mutation onSuccess
end
ChatHistory->>ChatHistory: clearConversations() local storage
ChatHistory->>ChatHistory: resetConversation()
ChatHistory->>QueryCache: invalidateQueries final
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/browseros-agent/apps/agent/entrypoints/sidepanel/history/ChatHistory.tsx:94-117
**Per-deletion invalidations flood during bulk clear**
The `deleteConversationMutation` carries an `onSuccess` handler (line 61–68) that calls `queryClient.invalidateQueries` after every single deletion. When `handleClearAll` iterates through batches of 10, each of the N successful mutations fires that handler and triggers a refetch of the full conversation list. For a user with a large history this issues N unnecessary GraphQL requests before the explicit `invalidateQueries` on line 108. Consider passing a `silent` option or using a separate mutation without the auto-invalidate handler for the bulk-delete path.
Reviews (1): Last reviewed commit: "feat: add reset controls for sessions an..." | Re-trigger Greptile |
Fixes #418
Verification: