3.7 KiB
3.7 KiB
spec, created, status
| spec | created | status |
|---|---|---|
| docs/specs/tasks/requirements/archive-confirmation.md | 2026-07-15 | completed |
Implementation Plan: Archive Confirmation Preference
Overview
Extend the existing per-user JSON settings contract with a default-true archive confirmation preference. Hydrate it into frontend state, expose an optimistic General settings toggle, and let the shared archive dialog execute immediately with cascade disabled when confirmation is off so every current archive surface inherits the behavior.
Backend
- Add
ConfirmTaskArchive boolto the user settings model and DTO plus*boolPATCH fields inapps/backend/internal/user/dto/dto.goandapps/backend/internal/user/service/service.go. - Preserve missing-field compatibility in
apps/backend/internal/user/store/sqlite.goby decoding the stored JSON field through a pointer and defaulting it totrue. - Include
confirm_task_archivein stored JSON, user settings events, and the Go boot-payload mapping. - Cover defaulting, explicit false persistence, patch application, and DTO mapping with focused Go tests.
Frontend
- Add
confirm_task_archiveto HTTP/WS types andconfirmTaskArchiveto the settings slice, boot/SSR mapping, and WS update handler, defaulting missing values totrue. - Add a Confirm before archiving tasks switch to a dedicated Task Actions section under General settings, with optimistic persistence and rollback on failure.
- Update
TaskArchiveConfirmDialogto read the preference. On an open transition while confirmation is disabled, invokeonConfirm({ cascade: false }), close the controlled state, and render no dialog content.
Tests
- Default true and explicit false:
apps/backend/internal/user/store/sqlite_test.go,apps/backend/internal/user/service/service_test.go, andapps/backend/internal/user/dto/dto_test.go. - Frontend mapping and live updates:
apps/web/lib/ssr/user-settings.test.tsandapps/web/lib/ws/handlers/users.test.ts. - Dialog behavior:
apps/web/components/task/task-archive-confirm-dialog.test.tsxverifies enabled confirmation and confirmation-free single execution withcascade: false. - Settings rollback:
apps/web/components/settings/archive-confirmation-settings.test.tsxverifies optimistic update, persistence payload, disabled state, and rollback.
E2E Tests
- Desktop: disable confirmation, archive from the sidebar, assert no alert dialog and task removal.
- Mobile: disable confirmation, archive through the mobile task switcher, assert no alert dialog and task removal.
- Use the existing production-build E2E fixtures and user-settings reset path.
Implementation Waves
Verification
make -C apps/backend fmt
rtk go test ./internal/user/... ./internal/backendapp/...
cd apps && pnpm --filter @kandev/web test -- --run lib/ssr/user-settings.test.ts lib/ws/handlers/users.test.ts components/task/task-archive-confirm-dialog.test.tsx components/settings/archive-confirmation-settings.test.tsx
cd apps/web && pnpm e2e:run tests/task/archive-confirmation-preference.spec.ts
cd apps/web && pnpm e2e:run --no-build --project mobile-chrome tests/task/mobile-archive-confirmation-preference.spec.ts
make -C apps/backend lint
cd apps/web && pnpm run typecheck && pnpm run lint
Risks
- React Strict Mode can replay effects, so the confirmation bypass must guard one archive execution per open transition.
- Existing user rows omit the new boolean; both backend JSON decoding and frontend fallback must fail safely to confirmation enabled.