Skip to content

feat(web): save tasks in indexeddb#1453

Merged
tyler-dane merged 14 commits intomainfrom
feat/1407-indexeddb
Feb 19, 2026
Merged

feat(web): save tasks in indexeddb#1453
tyler-dane merged 14 commits intomainfrom
feat/1407-indexeddb

Conversation

@tyler-dane
Copy link
Contributor

  • Introduced new test files for task creation and persistence using Playwright.
  • Implemented utility functions for preparing the task page, creating tasks, and verifying task visibility.
  • Updated local task repository to utilize IndexedDB for task storage, enhancing data persistence across page reloads.
  • Added migration utility to transfer tasks from localStorage to IndexedDB, ensuring data integrity and improved performance.

This commit enhances the testing framework for task management, ensuring robust functionality and user experience.

Closes #1411

Copilot AI review requested due to automatic review settings February 16, 2026 03:46
@tyler-dane tyler-dane changed the title feat(tests): add end-to-end tests for task creation and persistence feat(web): save tasks in indexeddb Feb 16, 2026
Copy link
Contributor

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

This PR migrates task storage from localStorage to IndexedDB to improve consistency with event storage (which already uses IndexedDB per issue #1404). The migration includes a one-time automatic data migration from localStorage to IndexedDB, updates to the task repository layer to use async operations, and comprehensive test coverage including unit tests and end-to-end tests.

Changes:

  • Added new IndexedDB storage utilities for task CRUD operations with proper error handling
  • Implemented automatic migration from localStorage to IndexedDB on app initialization
  • Updated task hooks and repository to use async IndexedDB operations instead of synchronous localStorage
  • Added comprehensive test coverage for storage utilities, migration, and e2e task workflows

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
packages/web/src/common/utils/storage/task.storage.util.ts New utility functions for task CRUD operations in IndexedDB
packages/web/src/common/utils/storage/task.storage.util.test.ts Comprehensive unit tests for IndexedDB task storage utilities
packages/web/src/common/utils/storage/task-migration.util.ts One-time migration logic from localStorage to IndexedDB with validation
packages/web/src/common/utils/storage/task-migration.util.test.ts Tests for migration scenarios including edge cases and error handling
packages/web/src/common/utils/storage/compass-local.db.ts Added version 2 schema with tasks table to existing Dexie database
packages/web/src/common/utils/app-init.util.ts Integrated task migration into app initialization flow
packages/web/src/common/utils/app-init.util.test.ts Tests for initialization with migration
packages/web/src/views/Day/hooks/tasks/useTaskEffects.ts Converted to async operations with IndexedDB, added race condition guards
packages/web/src/views/Day/hooks/tasks/useTaskEffects.test.ts Updated tests for async behavior
packages/web/src/views/Day/hooks/tasks/useTaskActions.ts Updated task actions to use async IndexedDB operations
packages/web/src/views/Day/hooks/tasks/useTaskActions.test.ts Updated action tests for async behavior
packages/web/src/common/repositories/task/task.repository.ts Changed interface methods to return Promises
packages/web/src/common/repositories/task/local.task.repository.ts Implemented async methods using IndexedDB utilities
packages/web/src/common/repositories/task/local.task.repository.test.ts Updated repository tests for async operations
e2e/utils/task-test-utils.ts New e2e test utilities for task creation and verification
e2e/tasks/task-persistence.spec.ts E2e test verifying task persistence across page reloads
e2e/tasks/create-task.spec.ts E2e test for task creation workflow

- Introduced new test files for task creation and persistence using Playwright.
- Implemented utility functions for preparing the task page, creating tasks, and verifying task visibility.
- Updated local task repository to utilize IndexedDB for task storage, enhancing data persistence across page reloads.
- Added migration utility to transfer tasks from localStorage to IndexedDB, ensuring data integrity and improved performance.

This commit enhances the testing framework for task management, ensuring robust functionality and user experience.
- Added move method to LocalTaskRepository and TaskRepository interface.
- Introduced TaskSessionService to manage task sessions and handle loading, updating, and saving tasks.
- Created utility functions for task repository management, including getTaskRepository for selecting local or cloud storage.
- Implemented migration logic from local to cloud storage with error handling.
- Updated TaskProvider to utilize TaskSessionService for managing task state.
- Added tests for task migration and session management functionalities.
- Removed obsolete useTaskEffects hook and related tests.
Copilot AI review requested due to automatic review settings February 17, 2026 03:55
Copy link
Contributor

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

Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.

…edback

- Added loading state handling in TaskList and Tasks components to improve user experience during task loading.
- Updated useTaskListInputFocus to prevent focusing on input when tasks are loading.
- Enhanced TaskContext to include isLoadingTasks state for better task management.
- Modified Tasks component to display loading message and handle empty task states.
- Refactored useTaskActions to block actions while tasks are loading.
- Implemented tests to ensure loading state is handled correctly and does not interfere with task actions.
- Removed obsolete task session service and related tests to streamline task management logic.
Copilot AI review requested due to automatic review settings February 19, 2026 00:52
Copy link
Contributor

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

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

Comments suppressed due to low confidence (3)

packages/web/src/tests/utils/storage/indexeddb.test.util.ts:9

  • clearCompassLocalDb resolves immediately on deleteDatabase(...).onblocked, which can leave the IndexedDB state intact (e.g., if a Dexie connection from a prior test is still open). This can cause cross-test contamination/flakiness. Consider closing the Dexie connection and/or falling back to clearing the relevant object stores when deletion is blocked (similar to the e2e reset helper).
export async function clearCompassLocalDb(): Promise<void> {
  await new Promise<void>((resolve) => {
    const request = indexedDB.deleteDatabase(COMPASS_LOCAL_DB_NAME);
    request.onsuccess = () => resolve();
    request.onerror = () => resolve();
    request.onblocked = () => resolve();
  });

packages/web/src/views/Day/view/DayViewContent.test.tsx:50

  • The new addTask test helper doesn’t wait for tasks to finish loading before clicking "Create new task" / typing. Since TaskList now blocks creating tasks while isLoadingTasks is true, this can make the tests flaky (input may never appear). Consider reusing the shared clickCreateTaskButton/addTasks + waitForTaskListReady helpers (which already wait for "Loading tasks..." to disappear) or adding an explicit wait here before interacting.
    packages/web/src/views/Day/view/DayViewContent.test.tsx:72
  • beforeEach only clears localStorage, but tasks now persist in IndexedDB. Without also clearing the compass-local IndexedDB between tests, this suite can leak tasks across tests (especially when running the file in watch mode or when a prior test created tasks). Consider calling clearCompassLocalDb() (or a store-level clear) here as well, similar to other updated task tests.

@tyler-dane tyler-dane merged commit 04f655a into main Feb 19, 2026
11 checks passed
@tyler-dane tyler-dane deleted the feat/1407-indexeddb branch February 19, 2026 11:26
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.

Migrate task storage from localStorage to IndexedDB for consistency

2 participants