Skip to content

fix(chat): improve delete all chats button#1106

Merged
benoitf merged 2 commits intokortex-hub:mainfrom
fbricon:GH-477
Mar 18, 2026
Merged

fix(chat): improve delete all chats button#1106
benoitf merged 2 commits intokortex-hub:mainfrom
fbricon:GH-477

Conversation

@fbricon
Copy link
Contributor

@fbricon fbricon commented Mar 16, 2026

  • fix(chat): reset chat view when deleting all chats
  • fix(chat): improve delete all chats button visibility
delete-all-chats-always-on.mp4

Fixes #477

@fbricon fbricon requested a review from a team as a code owner March 16, 2026 18:26
@fbricon fbricon requested review from benoitf and bmahabirbu and removed request for a team March 16, 2026 18:26
@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e02b749-2516-4fc4-84e8-cb91708d393c

📥 Commits

Reviewing files that changed from the base of the PR and between 09bd1cd and 34f0b57.

📒 Files selected for processing (2)
  • packages/renderer/src/lib/chat/components/sidebar-history/history.svelte
  • tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/renderer/src/lib/chat/components/sidebar-history/history.svelte

📝 Walkthrough

Walkthrough

Clear current chat selection and navigate to root after deleting all chats; make the chat list scrollable and move the "Delete all chats" control into a fixed bottom group; update Playwright smoke test to validate deletion behaviors and post-delete UI state.

Changes

Cohort / File(s) Summary
Sidebar History Component
packages/renderer/src/lib/chat/components/sidebar-history/history.svelte
Import and clear currentChatId.value when all chats are deleted and navigate to /. Wrap main history group in flex-1 overflow-auto. Move delete-all control into a bottom flex-shrink-0 SidebarGroup and replace with a full-width ghost Button (layout/spacing reflow).
Chat Smoke Tests
tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts
Adjust tests for delete flows: verify behavior after deleting single vs all chats, assert suggested messages visibility and zero conversation messages after delete-all, and update related assertions/timeouts for model-selection and visibility.

Sequence Diagram

sequenceDiagram
    participant User
    participant Sidebar
    participant State
    participant Router

    User->>Sidebar: Click "Delete all chats"
    Sidebar->>State: deleteAllChats()
    State-->>Sidebar: chats cleared
    Sidebar->>State: clear currentChatId.value
    Sidebar->>Router: navigate("/")
    Router-->>Sidebar: navigation complete
    Sidebar-->>User: UI shows empty history / suggested messages
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: improving the delete all chats button, which aligns with the primary objective in the linked issue.
Description check ✅ Passed The description provides relevant context about resetting chat view and improving button visibility, directly relating to the changeset modifications.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #477: making the delete all chats button always visible at the bottom without scrolling [#477].
Out of Scope Changes check ✅ Passed All changes are scoped to the chat sidebar delete functionality. The test addition for delete behavior is directly related to the implementation requirements [#477].
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/renderer/src/lib/chat/components/sidebar-history/history.svelte (1)

98-115: ⚠️ Potential issue | 🟠 Major

Gate the reset/navigation on a successful bulk delete.

currentChatId.value = undefined and router.goto('/') run as soon as the delete starts, so a failed window.inferenceDeleteAllChats() still kicks the user back to the empty view. Also, packages/renderer/src/lib/chat/route/CustomChat.svelte:6-8 falls back to currentChatId.value, so keeping the reset behind if (chatId) can still leave a deleted chat selected when the route param is absent. Move both side effects into the success path and clear the store unconditionally there.

💡 Possible fix
 async function handleDeleteAllChats(): Promise<void> {
   const deleteAllPromise = window.inferenceDeleteAllChats();
+  const hadActiveChat = Boolean(chatId ?? currentChatId.value);

   toast.promise(deleteAllPromise, {
     loading: 'Deleting all chats...',
     success: () => {
+      currentChatId.value = undefined;
+      if (hadActiveChat) {
+        router.goto('/');
+      }
       chatHistory.refetch().catch((err: unknown) => {
         console.error('Failed to refetch chat history', err);
       });
       return 'All chats deleted successfully';
     },
     error: 'Failed to delete all chats',
   });
-
-  if (chatId) {
-    currentChatId.value = undefined;
-    router.goto('/');
-  }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/renderer/src/lib/chat/components/sidebar-history/history.svelte`
around lines 98 - 115, The delete handler currently clears currentChatId and
navigates away immediately; change handleDeleteAllChats so the side effects run
only on successful completion of window.inferenceDeleteAllChats(): move
currentChatId.value = undefined and router.goto('/') into the toast.promise
success branch (after chatHistory.refetch), and in that success block clear the
store unconditionally (do not gate on the original chatId) so
CustomChat.svelte's fallback won't keep a deleted chat selected; leave no
navigation or store mutation on error and keep the existing chatHistory.refetch
error handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts`:
- Around line 145-150: The TODO and workaround disagree: you only strip colons
from selectedModelName but then still include a literal "model:" in testMessage,
which defeats the workaround; update the code so the final test message contains
no colon by either removing the literal "model:" label or removing/escaping
colons when composing testMessage (modify the usage around
chatPage.getSelectedModelName and the selectedModelName variable and the
testMessage construction) and tighten the TODO comment to state whether the bug
is "any colon in the message breaks history" or "only colons inside model names
break history" so future readers know why colons are being stripped.

---

Outside diff comments:
In `@packages/renderer/src/lib/chat/components/sidebar-history/history.svelte`:
- Around line 98-115: The delete handler currently clears currentChatId and
navigates away immediately; change handleDeleteAllChats so the side effects run
only on successful completion of window.inferenceDeleteAllChats(): move
currentChatId.value = undefined and router.goto('/') into the toast.promise
success branch (after chatHistory.refetch), and in that success block clear the
store unconditionally (do not gate on the original chatId) so
CustomChat.svelte's fallback won't keep a deleted chat selected; leave no
navigation or store mutation on error and keep the existing chatHistory.refetch
error handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59088660-22fb-4b0a-95b4-bb655807b759

📥 Commits

Reviewing files that changed from the base of the PR and between 5b6bbf8 and c1dd5fd.

📒 Files selected for processing (2)
  • packages/renderer/src/lib/chat/components/sidebar-history/history.svelte
  • tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...lib/chat/components/sidebar-history/history.svelte 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/renderer/src/lib/chat/components/sidebar-history/history.svelte`:
- Around line 112-115: The current code clears currentChatId.value and calls
router.goto('/') immediately before waiting for inferenceDeleteAllChats() to
complete, so move the state reset and navigation into the success path after
inferenceDeleteAllChats() resolves; specifically, await or .then the
inferenceDeleteAllChats() call and only set currentChatId.value = undefined and
call router.goto('/') on success, while adding a catch to handle failures (and
avoid clearing selection or navigating on error) so the local selection remains
if deletion fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f9b408c9-ad38-4852-b840-a33f0af9db0b

📥 Commits

Reviewing files that changed from the base of the PR and between c1dd5fd and 1cc98ac.

📒 Files selected for processing (2)
  • packages/renderer/src/lib/chat/components/sidebar-history/history.svelte
  • tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts

Comment on lines +112 to +115
if (chatId) {
currentChatId.value = undefined;
router.goto('/');
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Move route/state reset to delete-all success path

At Line 112, currentChatId is cleared and navigation happens before inferenceDeleteAllChats() resolves. If deletion fails, users are still redirected and local selection is lost.

💡 Suggested fix
   toast.promise(deleteAllPromise, {
     loading: 'Deleting all chats...',
     success: () => {
       chatHistory.refetch().catch((err: unknown) => {
         console.error('Failed to refetch chat history', err);
       });
+      if (chatId) {
+        currentChatId.value = undefined;
+        router.goto('/');
+      }
       return 'All chats deleted successfully';
     },
     error: 'Failed to delete all chats',
   });
-
-  if (chatId) {
-    currentChatId.value = undefined;
-    router.goto('/');
-  }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/renderer/src/lib/chat/components/sidebar-history/history.svelte`
around lines 112 - 115, The current code clears currentChatId.value and calls
router.goto('/') immediately before waiting for inferenceDeleteAllChats() to
complete, so move the state reset and navigation into the success path after
inferenceDeleteAllChats() resolves; specifically, await or .then the
inferenceDeleteAllChats() call and only set currentChatId.value = undefined and
call router.goto('/') on success, while adding a catch to handle failures (and
avoid clearing selection or navigating on error) so the local selection remains
if deletion fails.

await chatPage.verifyStopButtonHidden();
});

test('[CHAT-10] Delete all button remains visible without scrolling', async ({ chatPage }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this test did not run as part of pr checks. The provider spec are running on multiple configurations and should be validated in nightly run workflow. I suggest splitting the PRs: one for the core changes and another for the e2e tests

Copy link
Contributor Author

@fbricon fbricon Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1113 contains the e2e tests for the new feature.

This PR keeps the e2e test changes for the fix(chat): reset chat view when deleting all chats commit

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts (1)

147-150: ⚠️ Potential issue | 🟡 Minor

Colon workaround is still self-contradictory in the final test message.

You sanitize colons from selectedModelName, but Line 150 still inserts a literal : (model:), which can still hit the known history-rendering bug.

Suggested fix
-        const testMessage = `Test message for model: "${selectedModelName}"`;
+        const testMessage = `Test message for model "${selectedModelName}"`;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts` around lines
147 - 150, The test still includes a literal colon in the constructed string
which defeats the earlier sanitization of selectedModelName; update how
testMessage is built so it cannot contain a ":" by either removing the
hard-coded colon or ensuring the entire message is sanitized (e.g., build
testMessage without the ":" token or run selectedModelName through the same
replace before interpolation). Modify the code that sets testMessage (the
testMessage variable) to reference the sanitized selectedModelName and avoid
inserting any additional ":" characters.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts`:
- Around line 147-150: The test still includes a literal colon in the
constructed string which defeats the earlier sanitization of selectedModelName;
update how testMessage is built so it cannot contain a ":" by either removing
the hard-coded colon or ensuring the entire message is sanitized (e.g., build
testMessage without the ":" token or run selectedModelName through the same
replace before interpolation). Modify the code that sets testMessage (the
testMessage variable) to reference the sanitized selectedModelName and avoid
inserting any additional ":" characters.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f023d9ca-e1a2-462e-b0e0-5b92d498b6c5

📥 Commits

Reviewing files that changed from the base of the PR and between 1cc98ac and 09bd1cd.

📒 Files selected for processing (2)
  • packages/renderer/src/lib/chat/components/sidebar-history/history.svelte
  • tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/renderer/src/lib/chat/components/sidebar-history/history.svelte

fbricon and others added 2 commits March 17, 2026 14:38
When clicking "delete all chats" while viewing a conversation, the chat
view now properly resets to a fresh conversation state instead of showing
the deleted chat. This is achieved by resetting currentChatId and
navigating to the home route. Enhanced e2e test to verify this behavior.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Fred Bricon <fbricon@gmail.com>
The delete all chats button now only appears when there are chats and
remains visible at the bottom without requiring scrolling. Restructured
the sidebar layout to make the chat list scrollable while keeping the
button sticky at the bottom.

Fixes kortex-hub#477

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Fred Bricon <fbricon@gmail.com>
@benoitf benoitf merged commit 8f95e07 into kortex-hub:main Mar 18, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

always see the delete all chats button in sidebar ?

3 participants