Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Timetraked is a React 18 + TypeScript time tracking PWA for freelancers and cons
- When fixing a bug, add a regression test as part of the same change.
- Verify version alignment between related dev tools (e.g., vitest + @vitest/coverage) when test errors appear.

### Test File Inventory (~504 JS/TS tests across 44 files, plus 20 Rust unit tests across `src-tauri/src/backup.rs`/`menu.rs`/`quit_flush.rs` run via `cargo test`)
### Test File Inventory (~525 JS/TS tests across 49 files, plus 20 Rust unit tests across `src-tauri/src/backup.rs`/`menu.rs`/`quit_flush.rs` run via `cargo test`)

| File | Coverage |
|---|---|
Expand Down Expand Up @@ -59,6 +59,11 @@ Timetraked is a React 18 + TypeScript time tracking PWA for freelancers and cons
| `src/components/NewTaskForm.test.tsx` | Form render, submit, validation, cancel, FAB toggle |
| `src/components/TaskItem.test.tsx` | Badge render, delete confirm, edit dialog |
| `src/components/PlannedTaskPicker.test.tsx` | Dashboard empty-day picker: ordering, filtering, start vs resume, list cap |
| `src/components/PlannedTaskCard.test.tsx` | Card one-click Start/Resume button: start-day-and-pull, pull, resume, hidden for done/stale/unposted days; category badge text contrast |
| `src/components/KanbanBoard.test.tsx` | Category filter labels by name, stale saved filter reset (not while loading), filtered-out empty state and visible count |
| `src/hooks/useTaskBoardView.test.ts` | Default sort, legacy `priority` sort migration, batched filter updates |
| `src/components/KanbanColumn.test.tsx` | "Add task" in every column opens the new-task sheet with that column's status |
| `src/utils/colorUtils.test.ts` | `getReadableTextColor` black/white pick by WCAG contrast, short hex, unparseable fallback |
| `src/components/ArchiveEditDialog.test.tsx` | Archive edit dialog render, task editing flow, and end-before-start validation (day form and Add Task) |
| `src/components/ArchivedTaskRow.test.tsx` | Inline expandable archived task row editing, including end-before-start validation |
| `src/components/dateParsing.test.ts` | Date parsing utilities |
Expand Down Expand Up @@ -189,7 +194,7 @@ export const MyComponent = () => {
| `src/hooks/useLongPress.ts` | 500 ms hold detector for context menu trigger on touch |
| `src/components/ui/responsive-select.tsx` | `ResponsiveSelect` — branches on `useIsMobile()` to render a native `<select>` on mobile (OS picker) vs the Radix `Select` on desktop; flat `options` array API shared by `NewTaskForm`, `ProjectSheet`, `BackdatedEntryDialog`, `PlannedTaskDialog`, `ArchivedTaskRow`, `KanbanBoardControls` |
| `src/components/PlannedTaskPicker.tsx` | Empty started-day card on the Dashboard: lists in-progress/to-do planned tasks with Start (`pullPlannedTaskToDay`) / Resume (`addPlannedTaskToDay`) buttons. Task Board cards and the Tasks page header can also start the day (`startDayAndPullPlannedTask`, "now" rounded to 15 min, no dialog) |
| `src/hooks/useTaskBoardView.ts` | Kanban board sort (priority/title/newest/oldest) and filter (project/client/category) state; persisted to `localStorage` (`timetracker_task_board_view`) only, never synced to Supabase. Consumed by `KanbanBoard.tsx`/`KanbanBoardControls.tsx` |
| `src/hooks/useTaskBoardView.ts` | Kanban board sort (oldest/newest/title; legacy saved `priority` maps to oldest) and filter (project/client/category) state; `KanbanBoard` resets saved filters that no longer match any task once data loads; persisted to `localStorage` (`timetracker_task_board_view`) only, never synced to Supabase. Consumed by `KanbanBoard.tsx`/`KanbanBoardControls.tsx` |
| `src/components/ArchivedTaskRow.tsx` | Inline expandable row for editing a single task within `ArchiveEditDialog` (replaces the old `TaskEditInArchiveDialog` modal); disables Save and shows an inline alert when the end time is before the start |
| `src/services/localStorageService/recovery.ts` | Lists/previews/restores localStorage schema-mismatch backup keys and desktop (Tauri) disk-backup snapshots; the read side of the write-only backup safety nets |
| `src/hooks/useDataRecovery.ts` | Unifies browser (`recovery.ts`) and desktop (`useElectronBackup`'s `listDiskBackups`/`readDiskBackup`, Tauri-backed) backup sources behind one list/preview/restore API |
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Every Task Board column (In Progress, Blocked, Done — not just To Do) now has an "Add task" button that opens the new-task sheet pre-set to that column's status
— `src/components/KanbanColumn.tsx`
- Task Board cards gain a one-click Start/Resume button that starts the day and pulls the task, pulls it into the running day, or resumes an in-progress task, depending on day state (previously only reachable through the card menu)
— `src/components/PlannedTaskCard.tsx`
- The sign-in form gains `autocomplete="username"`/`"current-password"`, a show/hide password toggle, plain-language error messages linked to the fields via `aria-describedby`, and closes immediately with a toast instead of after a 1-second delay
— `src/components/AuthDialog.tsx`
- Client form fields now carry `section-client` autofill tokens (organization, address lines, postal code, country, contact name, email, URL), and the new-task title has `autocomplete="off"`
Expand Down Expand Up @@ -87,6 +91,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Task Board category badges always used white text, which was unreadable on light category colors. Text is now black or white, whichever has the higher WCAG contrast against the category color
— `src/components/PlannedTaskCard.tsx`, `src/utils/colorUtils.ts` (new)
- Task Board category filter listed raw category ids (e.g. `project-management`) instead of names
— `src/components/KanbanBoard.tsx`, `src/components/KanbanBoardControls.tsx`
- Task Board "Priority" sort removed: nothing ever set a non-default priority, so it always sorted oldest-first. Saved `priority` choices now load as "Oldest first"
— `src/hooks/useTaskBoardView.ts`, `src/components/KanbanBoardControls.tsx`
- A saved Task Board filter that no longer matched any task (deleted task, renamed project) left every column showing "No tasks" with no hint why. Such filters are reset once data loads; when filters hide everything, a "No tasks match the current filters" notice with a Clear button and a "Showing X of Y" count appear
— `src/components/KanbanBoard.tsx`, `src/components/KanbanBoardControls.tsx`, `src/components/KanbanColumn.tsx`
- Signing out never copied account data to the device: `migrateToLocalStorage()` ran after `supabase.auth.signOut()` had ended the session, so it failed with "User not authenticated". `AuthContext` now runs a registered `setBeforeSignOut` handler while the session is still valid, and `TimeTrackingContext` uses it to copy the data when the user chooses "Keep a copy". After a session expiry the copy is still attempted, but only logs a warning on failure. The copy gets at most 5 seconds (`BEFORE_SIGN_OUT_TIMEOUT_MS`) before sign-out proceeds, so a slow or stalled network can't leave the user signed in
— `src/contexts/AuthContext.tsx`, `src/contexts/TimeTrackingContext.tsx`, `src/contexts/AuthContext.test.tsx` (new)
- "Continue without account" in the sign-in dialog was a submit button, so with both fields filled it signed the user in instead of staying in guest mode. It is now `type="button"` and labeled "Use on device"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ See [CHANGELOG.md](CHANGELOG.md) for the full history of changes.
- **Guest-mode data durability** — schema-mismatch backups, write-failure toasts, undo for hard deletes, Tauri desktop disk-based backup snapshots (independent of `localStorage`, including a final flush on app quit), and an in-app "Data Recovery" UI in Settings to preview and restore those backups
- **Self-hosted SQL backend** — opt-in PostgreSQL/MySQL support via a small REST API (`server/`), alongside the existing Supabase and local storage modes
- **Backdated entry creation** — "Add Past Entry" button on Archive page opens a multi-step dialog to log tasks for any past date
- **Kanban planning board** — drag-and-drop task planning view (`KanbanBoard`, `KanbanColumn`, `PlannedTaskCard`); start the day (and a task) straight from the board, or pick a planned task from the Dashboard's empty-day card (`PlannedTaskPicker`); sort and filter controls (by priority/title/date, and by project/client/category) apply across all columns and persist to `localStorage`
- **Kanban planning board** — drag-and-drop task planning view (`KanbanBoard`, `KanbanColumn`, `PlannedTaskCard`); start the day (and a task) straight from the board with each card's one-click Start/Resume button, or pick a planned task from the Dashboard's empty-day card (`PlannedTaskPicker`); sort and filter controls (by date or title, and by project/client/category) apply across all columns and persist to `localStorage`
- Persistent report summaries saved to localStorage; markdown preview/export in the report output panel
- `AppSidebar` collapsible sidebar navigation with live session timer; `PageTitleContext` decouples page header state from layout

Expand Down
94 changes: 94 additions & 0 deletions src/components/KanbanBoard.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, waitFor } from "@testing-library/react";
import { KanbanBoard } from "@/components/KanbanBoard";
import type { PlannedTask } from "@/contexts/TimeTrackingContext";

let plannedTasks: PlannedTask[] = [];
let loading = false;
const categories = [{ id: "design", name: "Design", color: "#000" }];

vi.mock("@/hooks/useTimeTracking", () => ({
useTimeTracking: () => ({
plannedTasks,
categories,
loading,
isDayStarted: false,
isDayStale: false,
}),
}));
vi.mock("@/hooks/use-mobile", () => ({ useIsMobile: () => true }));
vi.mock("@/components/KanbanColumn", () => ({
KanbanColumn: ({ title, tasks, emptyMessage }: { title: string; tasks: PlannedTask[]; emptyMessage: string }) => (
<section aria-label={title}>
{tasks.length === 0 ? emptyMessage : tasks.map((t) => <p key={t.id}>{t.title}</p>)}
</section>
),
}));

const STORAGE_KEY = "timetracker_task_board_view";

const makeTask = (overrides: Partial<PlannedTask>): PlannedTask => ({
id: "t1",
title: "Task",
status: "todo",
priority: 0,
createdAt: "2026-01-01T00:00:00.000Z",
updatedAt: "2026-01-01T00:00:00.000Z",
timeEntries: [],
timeSpent: 0,
...overrides,
}) as PlannedTask;

const savedFilters = () => JSON.parse(localStorage.getItem(STORAGE_KEY)!).filters;

describe("KanbanBoard", () => {
beforeEach(() => {
localStorage.clear();
loading = false;
plannedTasks = [];
});

it("labels category filter options by category name, not id", () => {
plannedTasks = [makeTask({ category: "design" })];
render(<KanbanBoard />);
const select = screen.getByLabelText("Filter by category");
const option = Array.from(select.querySelectorAll("option")).find((o) => o.value === "design");
expect(option).toHaveTextContent("Design");
});

it("resets a saved filter that no longer matches any task", async () => {
localStorage.setItem(
STORAGE_KEY,
JSON.stringify({ sortBy: "oldest", filters: { project: "Gone", client: "all", category: "all" } }),
);
plannedTasks = [makeTask({ title: "Visible", project: "Acme" })];
render(<KanbanBoard />);
await waitFor(() => expect(savedFilters().project).toBe("all"));
expect(screen.getByText("Visible")).toBeInTheDocument();
});

it("keeps saved filters while data is still loading", () => {
localStorage.setItem(
STORAGE_KEY,
JSON.stringify({ sortBy: "oldest", filters: { project: "Acme", client: "all", category: "all" } }),
);
loading = true;
render(<KanbanBoard />);
expect(savedFilters().project).toBe("Acme");
});

it("explains when filters hide every task", () => {
localStorage.setItem(
STORAGE_KEY,
JSON.stringify({ sortBy: "oldest", filters: { project: "Acme", client: "Globex", category: "all" } }),
);
plannedTasks = [
makeTask({ id: "a", project: "Acme", client: "Initech" }),
makeTask({ id: "b", project: "Other", client: "Globex" }),
];
render(<KanbanBoard />);
expect(screen.getByText("No tasks match the current filters.")).toBeInTheDocument();
expect(screen.getByText("Showing 0 of 2")).toBeInTheDocument();
expect(screen.getAllByText("No matching tasks")).toHaveLength(4);
});
});
87 changes: 70 additions & 17 deletions src/components/KanbanBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import React, { useMemo } from "react";
import React, { useEffect, useMemo } from "react";
import { PlannedTask, PlannedTaskStatus } from "@/contexts/TimeTrackingContext";
import { useTimeTracking } from "@/hooks/useTimeTracking";
import { TaskSortOption, useTaskBoardView } from "@/hooks/useTaskBoardView";
import {
TaskBoardFilters,
TaskSortOption,
useTaskBoardView,
} from "@/hooks/useTaskBoardView";
import { KanbanColumn } from "@/components/KanbanColumn";
import { KanbanBoardControls } from "@/components/KanbanBoardControls";
import {
FilterOption,
KanbanBoardControls,
} from "@/components/KanbanBoardControls";
import { Button } from "@/components/ui/button";

const COLUMNS: { status: PlannedTaskStatus; title: string }[] = [
{ status: "todo", title: "To Do" },
Expand All @@ -12,10 +20,17 @@ const COLUMNS: { status: PlannedTaskStatus; title: string }[] = [
{ status: "done", title: "Done" },
];

function uniqueSorted(values: (string | undefined)[]): string[] {
return Array.from(new Set(values.filter((v): v is string => !!v))).sort((a, b) =>
a.localeCompare(b),
);
function uniqueValues(values: (string | undefined)[]): string[] {
return Array.from(new Set(values.filter((v): v is string => !!v)));
}

function toFilterOptions(
values: string[],
getLabel: (value: string) => string = (value) => value,
): FilterOption[] {
return values
.map((value) => ({ value, label: getLabel(value) }))
.sort((a, b) => a.label.localeCompare(b.label));
}

function sortTasks(tasks: PlannedTask[], sortBy: TaskSortOption) {
Expand All @@ -25,39 +40,60 @@ function sortTasks(tasks: PlannedTask[], sortBy: TaskSortOption) {
return sorted.sort((a, b) => a.title.localeCompare(b.title));
case "newest":
return sorted.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
case "oldest":
return sorted.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
default:
return sorted.sort(
(a, b) => a.priority - b.priority || a.createdAt.localeCompare(b.createdAt),
);
return sorted.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
}
}

export const KanbanBoard: React.FC = () => {
const { plannedTasks, isDayStarted, isDayStale } = useTimeTracking();
const { plannedTasks, categories, loading, isDayStarted, isDayStale } =
useTimeTracking();
const {
sortBy,
filters,
hasActiveFilters,
setSortBy,
setFilter,
setFilters,
clearFilters,
} = useTaskBoardView();

const projectOptions = useMemo(
() => uniqueSorted(plannedTasks.map((t) => t.project)),
() => toFilterOptions(uniqueValues(plannedTasks.map((t) => t.project))),
[plannedTasks],
);
const clientOptions = useMemo(
() => uniqueSorted(plannedTasks.map((t) => t.client)),
() => toFilterOptions(uniqueValues(plannedTasks.map((t) => t.client))),
[plannedTasks],
);
const categoryOptions = useMemo(
() => uniqueSorted(plannedTasks.map((t) => t.category)),
[plannedTasks],
() =>
toFilterOptions(
uniqueValues(plannedTasks.map((t) => t.category)),
(id) => categories.find((c) => c.id === id)?.name ?? id,
),
[plannedTasks, categories],
);

// A saved filter can outlive the last task that matched it (task deleted,
// project renamed). Drop it so the board doesn't silently show nothing.
useEffect(() => {
if (loading) return;
const optionsByKey: Record<keyof TaskBoardFilters, FilterOption[]> = {
project: projectOptions,
client: clientOptions,
category: categoryOptions,
};
const stale: Partial<TaskBoardFilters> = {};
(Object.keys(optionsByKey) as (keyof TaskBoardFilters)[]).forEach((key) => {
const value = filters[key];
if (value !== "all" && !optionsByKey[key].some((o) => o.value === value)) {
stale[key] = "all";
}
});
if (Object.keys(stale).length > 0) setFilters(stale);
}, [loading, filters, projectOptions, clientOptions, categoryOptions, setFilters]);

const visibleTasks = useMemo(
() =>
plannedTasks.filter(
Expand All @@ -72,6 +108,9 @@ export const KanbanBoard: React.FC = () => {
const tasksByStatus = (status: PlannedTaskStatus) =>
sortTasks(visibleTasks.filter((t) => t.status === status), sortBy);

const filteredOutEverything =
hasActiveFilters && visibleTasks.length === 0 && plannedTasks.length > 0;

return (
<>
<KanbanBoardControls
Expand All @@ -81,10 +120,23 @@ export const KanbanBoard: React.FC = () => {
clientOptions={clientOptions}
categoryOptions={categoryOptions}
hasActiveFilters={hasActiveFilters}
visibleCount={visibleTasks.length}
totalCount={plannedTasks.length}
onSortChange={setSortBy}
onFilterChange={setFilter}
onClearFilters={clearFilters}
/>
{filteredOutEverything && (
<div
role="status"
className="flex flex-wrap items-center justify-between gap-2 mb-4 rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground"
>
<span>No tasks match the current filters.</span>
<Button variant="outline" size="sm" onClick={clearFilters}>
Clear filters
</Button>
</div>
)}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
{COLUMNS.map(({ status, title }) => (
<KanbanColumn
Expand All @@ -94,6 +146,7 @@ export const KanbanBoard: React.FC = () => {
tasks={tasksByStatus(status)}
isDayStarted={isDayStarted}
isDayStale={isDayStale}
emptyMessage={hasActiveFilters ? "No matching tasks" : "No tasks"}
/>
))}
</div>
Expand Down
Loading
Loading