Skip to content

feat(agent): add reset controls for sessions and memory#985

Merged
Nikhil (shadowfax92) merged 1 commit into
devfrom
polecat/onyx/bosmain-5j4@moxnggvf
May 9, 2026
Merged

feat(agent): add reset controls for sessions and memory#985
Nikhil (shadowfax92) merged 1 commit into
devfrom
polecat/onyx/bosmain-5j4@moxnggvf

Conversation

@shadowfax92
Copy link
Copy Markdown
Contributor

Fixes #418

Verification:

  • Passed: bunx biome check on changed files
  • Passed: git diff --check origin/dev...HEAD
  • Local blocked: bun --env-file=.env.development test ./tests/api/routes/memory-soul-reset.test.ts cannot resolve @hono/zod-validator from an origin/dev route import in this refinery worktree.
  • Local blocked: server bun run typecheck cannot find tsc; tracked as bosmain-woi.
  • Local blocked: agent bun run typecheck cannot find wxt; tracked as bosmain-090.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

✅ Tests passed — 1225/1229

Suite Passed Failed Skipped
agent 80/80 0 0
build 9/9 0 0
eval 93/93 0 0
server-agent 261/261 0 0
server-api 205/205 0 0
server-browser 4/4 0 0
server-integration 9/10 0 1
server-lib 242/242 0 0
server-root 60/63 0 3
server-skills 31/31 0 0
server-tools 231/231 0 0

View workflow run

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 9, 2026

Greptile Summary

This PR adds user-facing reset controls for sessions and memory, wiring together new server-side DELETE endpoints for /memory and /soul with a new "Reset Data" settings page and a "Clear sessions" button in the chat history panel.

  • Server: DELETE /memory removes the entire memory directory and recreates it empty; DELETE /soul writes the default SOUL_TEMPLATE back to disk. Both endpoints are covered by a new integration test using a tmp-directory fixture.
  • Reset Data page: New ResetDataPage at /settings/reset-data with per-action confirmation dialogs; correctly optimistically clears the TanStack Query cache then invalidates to trigger a refetch.
  • Clear sessions: handleClearAll fetches all paginated remote conversation IDs, deletes them in batches of 10, then clears local storage and resets the active conversation. LocalChatHistory gets the same capability for unauthenticated users.

Confidence Score: 4/5

Safe 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

Filename Overview
packages/browseros-agent/apps/agent/entrypoints/sidepanel/history/ChatHistory.tsx Adds handleClearAll with paginated remote deletion and local storage clear; per-mutation onSuccess invalidations fire during bulk delete, causing unnecessary refetches
packages/browseros-agent/apps/agent/entrypoints/app/reset-data/ResetDataPage.tsx New settings page for resetting memory and SOUL.md with confirmation dialogs; correctly optimistically clears query cache and invalidates after server DELETE
packages/browseros-agent/apps/server/src/api/routes/memory.ts Adds DELETE endpoint that removes the memory directory and recreates it empty; correctly handles missing directory with force flag
packages/browseros-agent/apps/server/src/api/routes/soul.ts Adds DELETE endpoint that delegates to resetSoulTemplate(), writing the default SOUL_TEMPLATE back to disk
packages/browseros-agent/apps/server/src/lib/soul.ts Exports SOUL_TEMPLATE and adds resetSoulTemplate() function; clean implementation that reuses writeSoul()
packages/browseros-agent/apps/agent/lib/conversations/conversationStorage.ts Adds clearConversations() that wipes local storage and execution history atomically; straightforward addition
packages/browseros-agent/apps/agent/lib/execution-history/storage.ts Adds clearConversationExecutionHistory() that resets the storage object to {}; clean and consistent with existing remove pattern
packages/browseros-agent/apps/agent/entrypoints/sidepanel/history/components/ConversationList.tsx Adds onClearAll prop with confirmation dialog and loading state; correctly hides button when no conversations exist
packages/browseros-agent/apps/agent/entrypoints/sidepanel/history/local/LocalChatHistory.tsx Wires clearConversations and resetConversation into handleClearAll for the local (unauthenticated) history path
packages/browseros-agent/apps/server/tests/api/routes/memory-soul-reset.test.ts New integration tests for DELETE /memory and DELETE /soul routes; uses tmp directory isolation and verifies file state post-reset
packages/browseros-agent/apps/agent/entrypoints/app/memory/useMemoryContent.ts Exports MEMORY_QUERY_KEY constant to allow external cache invalidation from ResetDataPage

Sequence Diagram

sequenceDiagram
    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
Loading
Prompt To Fix All With AI
Fix 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

@shadowfax92 Nikhil (shadowfax92) merged commit f54eff4 into dev May 9, 2026
33 of 34 checks passed
@shadowfax92 Nikhil (shadowfax92) deleted the polecat/onyx/bosmain-5j4@moxnggvf branch May 9, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to clear all sessions and reset memory

1 participant