Skip to content

fix: show Clear All button on History page header#690

Open
RajdeepKushwaha5 wants to merge 2 commits intoaccomplish-ai:mainfrom
RajdeepKushwaha5:fix/history-clear-all-accessibility
Open

fix: show Clear All button on History page header#690
RajdeepKushwaha5 wants to merge 2 commits intoaccomplish-ai:mainfrom
RajdeepKushwaha5:fix/history-clear-all-accessibility

Conversation

@RajdeepKushwaha5
Copy link
Contributor

@RajdeepKushwaha5 RajdeepKushwaha5 commented Mar 10, 2026

Summary

The dedicated /history page rendered <TaskHistory showTitle={false} />, which permanently hid the "Clear All" button — it lived inside {showTitle && …} inside the component. Users had no way to clear history from the History page.

Root cause

TaskHistory renders the Clear All action only when showTitle={true}. The History page always passes showTitle={false} (to avoid a duplicate heading), so the button was never visible.

Fix

Move the Clear All action to the History page header itself, independent of TaskHistory. The button is conditionally rendered only when tasks exist, and triggers a confirmation dialog before clearing.

Changes

  • apps/web/src/client/pages/History.tsx — Added useTaskStore, confirmation dialog before clearing, and a "Clear All" button in the page header (only visible when history is non-empty)
  • apps/web/__tests__/integration/renderer/pages/History.integration.test.tsx — 8 new integration tests covering button visibility, confirmation flow, and store interaction

How to test

  1. pnpm dev
  2. Run a task so history is populated
  3. Navigate to the History page (/history)
  4. A "Clear All" button appears in the top-right of the header
  5. Clicking it shows a confirmation; confirming clears all history

This contribution was developed with AI assistance (GitHub Copilot).

Summary by CodeRabbit

  • New Features

    • History page now displays a localized "Clear All" control in the header when tasks exist; tapping it shows a confirmation dialog and, upon confirmation, clears all tasks and updates the header layout.
  • Tests

    • New integration tests validate History page structure, TaskHistory title behavior, Clear All visibility, confirmation dialog, and clear-all interactions.

Copilot AI review requested due to automatic review settings March 10, 2026 07:27
@orcaman
Copy link
Contributor

orcaman commented Mar 10, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

History page now reads tasks from the task store, shows a localized "Clear All" control only when tasks exist, prompts for confirmation, and calls clearHistory on confirm. A new integration test file validates visibility and confirmation-driven behavior.

Changes

Cohort / File(s) Summary
Integration Tests
apps/web/__tests__/integration/renderer/pages/History.integration.test.tsx
Adds integration tests that stub useTaskStore, Header, and TaskHistory; verifies page structure, "Clear All" visibility with/without tasks, and confirmation dialog behavior for clearing history.
History Page Component
apps/web/src/client/pages/History.tsx
Integrates useTaskStore, reads tasks, adds i18n (useTranslation('common')), conditionally renders a localized "Clear All" button, and implements handleClearAll to confirm and call clearHistory with error handling.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User
  participant Page as HistoryPage
  participant Store as TaskStore

  User->>Page: Click "Clear All"
  Page->>User: show confirmation dialog
  alt User confirms
    Page->>Store: clearHistory()
    Store-->>Page: success
    Page-->>User: update UI (no tasks)
  else User cancels
    Page-->>User: no action
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐇 I tap the page, a tiny hop,
"Clear all?" — a pop-up makes me stop.
One brave click, the history clears,
I nibble new tasks, no old frontiers.
— a rabbit's cheerful hop

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: adding a Clear All button to the History page header, which matches the primary objective and code modifications across both source and test files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the /history page so users can clear task history even when TaskHistory is rendered with showTitle={false} (which previously hid the “Clear all” action).

Changes:

  • Add a “Clear all” button to the History page header, shown only when history is non-empty, with a confirmation prompt before clearing.
  • Wire the button to useTaskStore().clearHistory().
  • Add integration tests covering visibility and confirmation/clearing behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/web/src/client/pages/History.tsx Adds header-level “Clear all” action driven by task store state and confirmation prompt.
apps/web/tests/integration/renderer/pages/History.integration.test.tsx Adds integration coverage for button visibility and confirmation flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +13
const handleClearAll = () => {
if (confirm(t('confirmClear'))) {
clearHistory();
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

clearHistory is an async store action (returns a Promise). Calling it without await/error handling can lead to unhandled promise rejections if accomplish.clearTaskHistory() fails. Consider making handleClearAll async and awaiting clearHistory() (with a try/catch to surface an error), or explicitly prefixing with void and handling failures elsewhere.

Suggested change
const handleClearAll = () => {
if (confirm(t('confirmClear'))) {
clearHistory();
const handleClearAll = async () => {
if (confirm(t('confirmClear'))) {
try {
await clearHistory();
} catch (error) {
console.error('Failed to clear task history:', error);
}

Copilot uses AI. Check for mistakes.
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.

🧹 Nitpick comments (1)
apps/web/src/client/pages/History.tsx (1)

11-15: Handle potential clearHistory rejection.

clearHistory is an async function (see taskStore.ts:496-500). Calling it without await and without a .catch() means any failure (IPC error, storage issue) results in an unhandled promise rejection and leaves the user without feedback.

♻️ Proposed fix to handle errors
-  const handleClearAll = () => {
+  const handleClearAll = async () => {
     if (confirm(t('confirmClear'))) {
-      clearHistory();
+      try {
+        await clearHistory();
+      } catch (error) {
+        console.error('Failed to clear history:', error);
+      }
     }
   };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/client/pages/History.tsx` around lines 11 - 15, handleClearAll
calls the async function clearHistory without awaiting or catching errors, which
can produce unhandled promise rejections; make handleClearAll async, await
clearHistory() inside a try/catch and handle failures (e.g., log the error and
show user feedback via alert/toast using t(...) or similar) so any IPC/storage
error is caught and reported instead of being unhandled.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/src/client/pages/History.tsx`:
- Around line 11-15: handleClearAll calls the async function clearHistory
without awaiting or catching errors, which can produce unhandled promise
rejections; make handleClearAll async, await clearHistory() inside a try/catch
and handle failures (e.g., log the error and show user feedback via alert/toast
using t(...) or similar) so any IPC/storage error is caught and reported instead
of being unhandled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee613542-d316-4402-8c44-184eb6caeb39

📥 Commits

Reviewing files that changed from the base of the PR and between 6a5a2f7 and 3ca4068.

📒 Files selected for processing (2)
  • apps/web/__tests__/integration/renderer/pages/History.integration.test.tsx
  • apps/web/src/client/pages/History.tsx

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.

🧹 Nitpick comments (1)
apps/web/src/client/pages/History.tsx (1)

11-19: Consider using a React dialog component instead of native confirm().

The native browser confirm() is synchronous/blocking and cannot be styled to match the application's design system. It also has accessibility limitations (no keyboard focus management, no customizable ARIA labels).

Given the PR description mentions "opens a confirmation dialog before clearing," consider using a proper dialog component (e.g., from your existing UI library) for a consistent UX.

Additionally, when clearHistory() fails, the error is only logged to console—the user has no indication the operation failed. Consider adding a toast notification or inline error state.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/client/pages/History.tsx` around lines 11 - 19, Replace the
synchronous native confirm() call in handleClearAll with a proper React dialog
component from our UI library (e.g., the existing ConfirmDialog / Modal
component) so the confirmation is non-blocking and styleable; open the dialog
when the user triggers clear, and call clearHistory() in the dialog’s confirm
handler (retain the i18n string t('confirmClear') as the dialog message). Also
surface failures to the user instead of only console.error by hooking into the
app’s notification/toast system (or setting an inline error state) inside the
catch block of the clearHistory() call so users see a friendly error message
when the operation fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/src/client/pages/History.tsx`:
- Around line 11-19: Replace the synchronous native confirm() call in
handleClearAll with a proper React dialog component from our UI library (e.g.,
the existing ConfirmDialog / Modal component) so the confirmation is
non-blocking and styleable; open the dialog when the user triggers clear, and
call clearHistory() in the dialog’s confirm handler (retain the i18n string
t('confirmClear') as the dialog message). Also surface failures to the user
instead of only console.error by hooking into the app’s notification/toast
system (or setting an inline error state) inside the catch block of the
clearHistory() call so users see a friendly error message when the operation
fails.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2089051-eb2e-48d3-8d39-a87141616326

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca4068 and 412eb37.

📒 Files selected for processing (1)
  • apps/web/src/client/pages/History.tsx

The History page passed showTitle={false} to TaskHistory which hid the
Clear All button entirely. The button was unreachable for users on the
dedicated /history route.

- Move the Clear All button into the History page header alongside the
  title, so it's always visible when history exists
- Add 8 integration tests for the History page covering button
  visibility (shown/hidden) and click interactions (confirm / cancel)

Fixes accomplish-ai#685
@RajdeepKushwaha5 RajdeepKushwaha5 force-pushed the fix/history-clear-all-accessibility branch from 412eb37 to 67a1060 Compare March 12, 2026 09:17
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.

🧹 Nitpick comments (1)
apps/web/src/client/pages/History.tsx (1)

11-19: Consider using a custom confirmation dialog instead of native confirm().

The native confirm() blocks the main thread and offers no styling or accessibility customization. A custom modal component would provide a more consistent UX and better accessibility.

Additionally, the error handling only logs to console — the user receives no feedback if clearHistory() fails.

💡 Example approach with error feedback
+import { useState } from 'react';
+// Assume a toast/notification system exists in the app
+
 export default function HistoryPage() {
+  const [showConfirmDialog, setShowConfirmDialog] = useState(false);
   // ...
 
   const handleClearAll = async () => {
-    if (confirm(t('confirmClear'))) {
-      try {
-        await clearHistory();
-      } catch (error) {
-        console.error('Failed to clear task history:', error);
-      }
+    try {
+      await clearHistory();
+    } catch (error) {
+      console.error('Failed to clear task history:', error);
+      // Show user-visible error notification
     }
   };

Then trigger handleClearAll from a custom confirmation dialog's confirm action rather than using confirm().

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/client/pages/History.tsx` around lines 11 - 19, Replace the
blocking native confirm() call in handleClearAll with your app's custom
confirmation modal/component (so the modal's confirm action invokes
handleClearAll or a new confirmedClear function); locate the handler function
handleClearAll and the clearHistory() call and move prompting to a styled,
accessible modal (use the existing translation key t('confirmClear') for text).
Also add user-facing error feedback when clearHistory() fails (e.g., show a
toast or set an error state that renders an inline alert) instead of only
console.error so users are informed of failures. Ensure the modal is cancellable
and that handleClearAll only calls clearHistory() after the modal confirm
action.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/src/client/pages/History.tsx`:
- Around line 11-19: Replace the blocking native confirm() call in
handleClearAll with your app's custom confirmation modal/component (so the
modal's confirm action invokes handleClearAll or a new confirmedClear function);
locate the handler function handleClearAll and the clearHistory() call and move
prompting to a styled, accessible modal (use the existing translation key
t('confirmClear') for text). Also add user-facing error feedback when
clearHistory() fails (e.g., show a toast or set an error state that renders an
inline alert) instead of only console.error so users are informed of failures.
Ensure the modal is cancellable and that handleClearAll only calls
clearHistory() after the modal confirm action.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb90e556-78c6-4518-bf90-531bbf4ce0ea

📥 Commits

Reviewing files that changed from the base of the PR and between 412eb37 and 67a1060.

📒 Files selected for processing (2)
  • apps/web/__tests__/integration/renderer/pages/History.integration.test.tsx
  • apps/web/src/client/pages/History.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/tests/integration/renderer/pages/History.integration.test.tsx

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.

3 participants