[GH-ISSUE #5765] fix(nuxt-port): clearAllChats uses magic -1 sentinel and optimistic clear #5560

Closed
opened 2026-06-07 16:36:39 -04:00 by yindo · 1 comment
Owner

Originally created by @raelli on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5765

Summary

`nuxt-frontend/core/application/useWorkspaceChats.ts` — `clearAllChats()` calls `api.deleteChat(-1)` where `-1` is a magic sentinel meaning "delete all". Two problems:

  1. Leaky abstraction — `-1` is an upstream API implementation detail bleeding into the application layer composable. A dedicated `clearAllChats()` port method would be more semantically honest and easier to mock in tests.
  2. Optimistic clear before confirmation — the composable clears local state before the API call confirms success for all records. A partial server failure leaves the UI showing an empty list when records still exist.

Fix

  • Add a `clearAllChats(): Promise<{ error: string | null }>` method to `WorkspaceChatsApiPort`
  • Implement it in the infrastructure adapter (maps to the same `DELETE /api/system/workspace-chats/-1` endpoint)
  • Update `clearAllChats()` in `useWorkspaceChats` to call the port method and only clear local state on confirmed success

Acceptance criteria

  • `WorkspaceChatsApiPort` has a `clearAllChats()` method
  • `useWorkspaceChats.clearAllChats()` clears local state only after the API confirms success
  • No `deleteChat(-1)` in application layer code
  • Tests cover the partial-failure case (API returns error, local state preserved)
Originally created by @raelli on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5765 ## Summary \`nuxt-frontend/core/application/useWorkspaceChats.ts\` — \`clearAllChats()\` calls \`api.deleteChat(-1)\` where \`-1\` is a magic sentinel meaning "delete all". Two problems: 1. **Leaky abstraction** — \`-1\` is an upstream API implementation detail bleeding into the application layer composable. A dedicated \`clearAllChats()\` port method would be more semantically honest and easier to mock in tests. 2. **Optimistic clear before confirmation** — the composable clears local state before the API call confirms success for all records. A partial server failure leaves the UI showing an empty list when records still exist. ## Fix - Add a \`clearAllChats(): Promise<{ error: string | null }>\` method to \`WorkspaceChatsApiPort\` - Implement it in the infrastructure adapter (maps to the same \`DELETE /api/system/workspace-chats/-1\` endpoint) - Update \`clearAllChats()\` in \`useWorkspaceChats\` to call the port method and only clear local state on confirmed success ## Acceptance criteria - [ ] \`WorkspaceChatsApiPort\` has a \`clearAllChats()\` method - [ ] \`useWorkspaceChats.clearAllChats()\` clears local state only after the API confirms success - [ ] No \`deleteChat(-1)\` in application layer code - [ ] Tests cover the partial-failure case (API returns error, local state preserved)
yindo closed this issue 2026-06-07 16:36:39 -04:00
Author
Owner

@timothycarambat commented on GitHub (Jun 6, 2026):

Closing this. the referenced file (nuxt-frontend/core/application/useWorkspaceChats.ts) and framework (Nuxt) don't exist in this project. AnythingLLM uses React, not Nuxt/Vue.

The -1 sentinel for "delete all" is intentional and well-understood at the API level — it's not a leaky abstraction.

This issue appears to be LLM-generated. Please don't file AI-hallucinated issues against real projects.

<!-- gh-comment-id:4640180343 --> @timothycarambat commented on GitHub (Jun 6, 2026): Closing this. the referenced file (`nuxt-frontend/core/application/useWorkspaceChats.ts`) and framework (Nuxt) don't exist in this project. AnythingLLM uses React, not Nuxt/Vue. The `-1` sentinel for "delete all" is intentional and well-understood at the API level — it's not a leaky abstraction. This issue appears to be LLM-generated. Please don't file AI-hallucinated issues against real projects.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5560