diff --git a/AGENTS.md b/AGENTS.md index 4479102..9c792a5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,7 +32,7 @@ Written requirements override AI-generated reference-image labels. If an ambiguo - Cycles and cross-household references are rejected. - Item-level dynamic inheritance (`parent effective − child exclusions + child additions`) is correct through deep descendants. - Task availability obeys effective dates and all ancestor dependency blockers, independently of user-facing column. -- Exactly **six** columns; user sees one `Column` field and completion reopen restores the immediate prior column. +- Exactly **six** task column values. The Board groups the three planning horizons under Future by default and can show them separately per user and view. The task has one `Column` field, and reopening restores its immediate prior column. - Server filter AST uses validated parameterized compilation, matching effective inherited values; view base + active quick filters combine via AND. - Recurrence trees remap **internal** edges to new instances, preserve **external** edges and deduplicate job retries. - Concurrent edits do not silently destroy same-field changes, and Undo does not clobber newer edits. @@ -48,7 +48,7 @@ Protect **behavior, not implementation details**. Use focused Vitest domain/data - Task cards show soft epic-colored backgrounds and monochrome icon/text variants per theme. **XS–XL** precedes precise time estimates visually. - A **place** is a named physical location (e.g. Sandvreten); Outdoors is better represented as a tag. - Quick-filter chips are **saved, shareable, expressive filters** with per-view presence and per-user toggle state. -- **v1.0:** manual place selection, no live GPS, no push delivery, no integrated automated cloud backup. **v1.1:** GPS + notifications. **v1.3:** Restic/Rclone Google Drive and Dropbox backup. +- **v1.0:** app-wide current place from browser geolocation with permission. **v1.1:** notifications and push delivery. **v1.3:** Restic/Rclone Google Drive and Dropbox backup. ## Definition of done for changes diff --git a/README.md b/README.md index 8838deb..a3d559a 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ comments/mentions, files/photos, search and live household synchronization are l tested. Shared filters/views and Board interactions are locally tested. **Stage 4 (hierarchy/inheritance/dependencies) is next**, followed by **6 → 8**. This is not yet the complete Milestone 1 Viable Product. Stages 7 and 5 are prioritized for -meaningful household use and evaluation; the full M1 scope remains unchanged. -Automatic GPS and notifications follow in M2, integrated cloud backup in M4. +meaningful household use and evaluation. Automatic current place is part of M1. +Notifications follow in M2 and integrated cloud backup in M4. ## Start here diff --git a/apps/api/drizzle/0006_board_future_columns.sql b/apps/api/drizzle/0006_board_future_columns.sql new file mode 100644 index 0000000..7005402 --- /dev/null +++ b/apps/api/drizzle/0006_board_future_columns.sql @@ -0,0 +1 @@ +ALTER TABLE "user_view_states" ADD COLUMN "split_future_columns" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/api/drizzle/0007_remove_manual_place_context.sql b/apps/api/drizzle/0007_remove_manual_place_context.sql new file mode 100644 index 0000000..f7b1aaf --- /dev/null +++ b/apps/api/drizzle/0007_remove_manual_place_context.sql @@ -0,0 +1 @@ +DROP TABLE "user_view_contexts"; \ No newline at end of file diff --git a/apps/api/drizzle/meta/0006_snapshot.json b/apps/api/drizzle/meta/0006_snapshot.json new file mode 100644 index 0000000..40f4ba5 --- /dev/null +++ b/apps/api/drizzle/meta/0006_snapshot.json @@ -0,0 +1,2148 @@ +{ + "id": "7df1bcd5-60fe-448e-aeff-9b0fe976ad02", + "prevId": "0fbf5761-8ace-4331-80f3-4c26d60d2a10", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.installation": { + "name": "installation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_challenges": { + "name": "auth_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "challenge": { + "name": "challenge", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "binding_hash": { + "name": "binding_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "context": { + "name": "context", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.passkey_credentials": { + "name": "passkey_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "transports": { + "name": "transports", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_user_idx": { + "name": "credential_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "passkey_credentials_user_id_users_id_fk": { + "name": "passkey_credentials_user_id_users_id_fk", + "tableFrom": "passkey_credentials", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.households": { + "name": "households", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memberships": { + "name": "memberships", + "schema": "", + "columns": { + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "household_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "membership_user_idx": { + "name": "membership_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memberships_household_id_households_id_fk": { + "name": "memberships_household_id_households_id_fk", + "tableFrom": "memberships", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memberships_user_id_users_id_fk": { + "name": "memberships_user_id_users_id_fk", + "tableFrom": "memberships", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "memberships_household_id_user_id_pk": { + "name": "memberships_household_id_user_id_pk", + "columns": [ + "household_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.security_events": { + "name": "security_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_id": { + "name": "subject_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "security_events_actor_id_users_id_fk": { + "name": "security_events_actor_id_users_id_fk", + "tableFrom": "security_events", + "tableTo": "users", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "security_events_subject_id_users_id_fk": { + "name": "security_events_subject_id_users_id_fk", + "tableFrom": "security_events", + "tableTo": "users", + "columnsFrom": [ + "subject_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "authenticated_at": { + "name": "authenticated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "session_user_idx": { + "name": "session_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.smtp_settings": { + "name": "smtp_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "encrypted": { + "name": "encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account_tokens": { + "name": "account_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "token_purpose", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "verifies_email": { + "name": "verifies_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "household_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_tokens_user_id_users_id_fk": { + "name": "account_tokens_user_id_users_id_fk", + "tableFrom": "account_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_tokens_household_id_households_id_fk": { + "name": "account_tokens_household_id_households_id_fk", + "tableFrom": "account_tokens", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deployment_admin": { + "name": "deployment_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en'" + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.planning_entities": { + "name": "planning_entities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "entity_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'house'" + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'blue'" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "radius": { + "name": "radius", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "sort_order": { + "name": "sort_order", + "type": "double precision", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "entity_household_idx": { + "name": "entity_household_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_entities_household_id_households_id_fk": { + "name": "planning_entities_household_id_households_id_fk", + "tableFrom": "planning_entities", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.planning_settings": { + "name": "planning_settings", + "schema": "", + "columns": { + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "size_thresholds": { + "name": "size_thresholds", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[60,240,480,1440]'::jsonb" + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + } + }, + "indexes": {}, + "foreignKeys": { + "planning_settings_household_id_households_id_fk": { + "name": "planning_settings_household_id_households_id_fk", + "tableFrom": "planning_settings", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_activities": { + "name": "task_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "fields": { + "name": "fields", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "task_activities_task_id_tasks_id_fk": { + "name": "task_activities_task_id_tasks_id_fk", + "tableFrom": "task_activities", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_activities_actor_id_users_id_fk": { + "name": "task_activities_actor_id_users_id_fk", + "tableFrom": "task_activities", + "tableTo": "users", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_assignees": { + "name": "task_assignees", + "schema": "", + "columns": { + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "task_assignees_task_id_tasks_id_fk": { + "name": "task_assignees_task_id_tasks_id_fk", + "tableFrom": "task_assignees", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_assignees_user_id_users_id_fk": { + "name": "task_assignees_user_id_users_id_fk", + "tableFrom": "task_assignees", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_assignees_task_id_user_id_pk": { + "name": "task_assignees_task_id_user_id_pk", + "columns": [ + "task_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_entities": { + "name": "task_entities", + "schema": "", + "columns": { + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "task_entities_task_id_tasks_id_fk": { + "name": "task_entities_task_id_tasks_id_fk", + "tableFrom": "task_entities", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_entities_entity_id_planning_entities_id_fk": { + "name": "task_entities_entity_id_planning_entities_id_fk", + "tableFrom": "task_entities", + "tableTo": "planning_entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_entities_task_id_entity_id_pk": { + "name": "task_entities_task_id_entity_id_pk", + "columns": [ + "task_id", + "entity_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "status": { + "name": "status", + "type": "task_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'todo'" + }, + "planning_bucket": { + "name": "planning_bucket", + "type": "planning_bucket", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'someday'" + }, + "preceding_column": { + "name": "preceding_column", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "epic_id": { + "name": "epic_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "high": { + "name": "high", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "size": { + "name": "size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "estimate_minutes": { + "name": "estimate_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deadline_date": { + "name": "deadline_date", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deadline_time": { + "name": "deadline_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "field_versions": { + "name": "field_versions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "sort_order": { + "name": "sort_order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_by": { + "name": "completed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "trashed_at": { + "name": "trashed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "task_household_order_idx": { + "name": "task_household_order_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "task_epic_idx": { + "name": "task_epic_idx", + "columns": [ + { + "expression": "epic_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tasks_household_id_households_id_fk": { + "name": "tasks_household_id_households_id_fk", + "tableFrom": "tasks", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tasks_epic_id_planning_entities_id_fk": { + "name": "tasks_epic_id_planning_entities_id_fk", + "tableFrom": "tasks", + "tableTo": "planning_entities", + "columnsFrom": [ + "epic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_created_by_users_id_fk": { + "name": "tasks_created_by_users_id_fk", + "tableFrom": "tasks", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_completed_by_users_id_fk": { + "name": "tasks_completed_by_users_id_fk", + "tableFrom": "tasks", + "tableTo": "users", + "columnsFrom": [ + "completed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.attachments": { + "name": "attachments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "preview": { + "name": "preview", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "attachment_task_idx": { + "name": "attachment_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "attachments_household_id_households_id_fk": { + "name": "attachments_household_id_households_id_fk", + "tableFrom": "attachments", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "attachments_task_id_tasks_id_fk": { + "name": "attachments_task_id_tasks_id_fk", + "tableFrom": "attachments", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_comments": { + "name": "task_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "comment_task_idx": { + "name": "comment_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_comments_task_id_tasks_id_fk": { + "name": "task_comments_task_id_tasks_id_fk", + "tableFrom": "task_comments", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_comments_author_id_users_id_fk": { + "name": "task_comments_author_id_users_id_fk", + "tableFrom": "task_comments", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.filter_versions": { + "name": "filter_versions", + "schema": "", + "columns": { + "filter_id": { + "name": "filter_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "snapshot": { + "name": "snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "filter_versions_filter_id_saved_filters_id_fk": { + "name": "filter_versions_filter_id_saved_filters_id_fk", + "tableFrom": "filter_versions", + "tableTo": "saved_filters", + "columnsFrom": [ + "filter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "filter_versions_author_id_users_id_fk": { + "name": "filter_versions_author_id_users_id_fk", + "tableFrom": "filter_versions", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "filter_versions_filter_id_version_pk": { + "name": "filter_versions_filter_id_version_pk", + "columns": [ + "filter_id", + "version" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.saved_filters": { + "name": "saved_filters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "creator_id": { + "name": "creator_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "builtin": { + "name": "builtin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "expression": { + "name": "expression", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "filter_builtin_idx": { + "name": "filter_builtin_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "builtin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "saved_filters_household_id_households_id_fk": { + "name": "saved_filters_household_id_households_id_fk", + "tableFrom": "saved_filters", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "saved_filters_creator_id_users_id_fk": { + "name": "saved_filters_creator_id_users_id_fk", + "tableFrom": "saved_filters", + "tableTo": "users", + "columnsFrom": [ + "creator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_order_versions": { + "name": "task_order_versions", + "schema": "", + "columns": { + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "task_order_versions_household_id_households_id_fk": { + "name": "task_order_versions_household_id_households_id_fk", + "tableFrom": "task_order_versions", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_view_contexts": { + "name": "user_view_contexts", + "schema": "", + "columns": { + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "current_place_id": { + "name": "current_place_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_view_contexts_household_id_households_id_fk": { + "name": "user_view_contexts_household_id_households_id_fk", + "tableFrom": "user_view_contexts", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_view_contexts_user_id_users_id_fk": { + "name": "user_view_contexts_user_id_users_id_fk", + "tableFrom": "user_view_contexts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_view_contexts_current_place_id_planning_entities_id_fk": { + "name": "user_view_contexts_current_place_id_planning_entities_id_fk", + "tableFrom": "user_view_contexts", + "tableTo": "planning_entities", + "columnsFrom": [ + "current_place_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_view_contexts_household_id_user_id_pk": { + "name": "user_view_contexts_household_id_user_id_pk", + "columns": [ + "household_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_view_states": { + "name": "user_view_states", + "schema": "", + "columns": { + "view_id": { + "name": "view_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "favorite": { + "name": "favorite", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "active_filters": { + "name": "active_filters", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "split_future_columns": { + "name": "split_future_columns", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_view_states_view_id_saved_views_id_fk": { + "name": "user_view_states_view_id_saved_views_id_fk", + "tableFrom": "user_view_states", + "tableTo": "saved_views", + "columnsFrom": [ + "view_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_view_states_user_id_users_id_fk": { + "name": "user_view_states_user_id_users_id_fk", + "tableFrom": "user_view_states", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_view_states_view_id_user_id_pk": { + "name": "user_view_states_view_id_user_id_pk", + "columns": [ + "view_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.saved_views": { + "name": "saved_views", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "creator_id": { + "name": "creator_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "builtin": { + "name": "builtin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "presentation": { + "name": "presentation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expression": { + "name": "expression", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "quick_filters": { + "name": "quick_filters", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "sort": { + "name": "sort", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "epic_lanes": { + "name": "epic_lanes", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "show_empty_lanes": { + "name": "show_empty_lanes", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "card_properties": { + "name": "card_properties", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "view_builtin_idx": { + "name": "view_builtin_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "builtin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "saved_views_household_id_households_id_fk": { + "name": "saved_views_household_id_households_id_fk", + "tableFrom": "saved_views", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "saved_views_creator_id_users_id_fk": { + "name": "saved_views_creator_id_users_id_fk", + "tableFrom": "saved_views", + "tableTo": "users", + "columnsFrom": [ + "creator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.household_role": { + "name": "household_role", + "schema": "public", + "values": [ + "admin", + "member" + ] + }, + "public.token_purpose": { + "name": "token_purpose", + "schema": "public", + "values": [ + "bootstrap", + "invite", + "recovery", + "verify_email" + ] + }, + "public.planning_bucket": { + "name": "planning_bucket", + "schema": "public", + "values": [ + "someday", + "within_year", + "within_month", + "ready" + ] + }, + "public.entity_kind": { + "name": "entity_kind", + "schema": "public", + "values": [ + "epic", + "place", + "resource", + "tag" + ] + }, + "public.task_status": { + "name": "task_status", + "schema": "public", + "values": [ + "todo", + "in_progress", + "done" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/drizzle/meta/0007_snapshot.json b/apps/api/drizzle/meta/0007_snapshot.json new file mode 100644 index 0000000..b4c685a --- /dev/null +++ b/apps/api/drizzle/meta/0007_snapshot.json @@ -0,0 +1,2062 @@ +{ + "id": "30801e6c-0f98-4202-9757-feed1a8f4290", + "prevId": "7df1bcd5-60fe-448e-aeff-9b0fe976ad02", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.installation": { + "name": "installation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_challenges": { + "name": "auth_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "challenge": { + "name": "challenge", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "binding_hash": { + "name": "binding_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "context": { + "name": "context", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.passkey_credentials": { + "name": "passkey_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "transports": { + "name": "transports", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_user_idx": { + "name": "credential_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "passkey_credentials_user_id_users_id_fk": { + "name": "passkey_credentials_user_id_users_id_fk", + "tableFrom": "passkey_credentials", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.households": { + "name": "households", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memberships": { + "name": "memberships", + "schema": "", + "columns": { + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "household_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "membership_user_idx": { + "name": "membership_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memberships_household_id_households_id_fk": { + "name": "memberships_household_id_households_id_fk", + "tableFrom": "memberships", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memberships_user_id_users_id_fk": { + "name": "memberships_user_id_users_id_fk", + "tableFrom": "memberships", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "memberships_household_id_user_id_pk": { + "name": "memberships_household_id_user_id_pk", + "columns": [ + "household_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.security_events": { + "name": "security_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_id": { + "name": "subject_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "security_events_actor_id_users_id_fk": { + "name": "security_events_actor_id_users_id_fk", + "tableFrom": "security_events", + "tableTo": "users", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "security_events_subject_id_users_id_fk": { + "name": "security_events_subject_id_users_id_fk", + "tableFrom": "security_events", + "tableTo": "users", + "columnsFrom": [ + "subject_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "authenticated_at": { + "name": "authenticated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "session_user_idx": { + "name": "session_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.smtp_settings": { + "name": "smtp_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "encrypted": { + "name": "encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account_tokens": { + "name": "account_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "token_purpose", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "verifies_email": { + "name": "verifies_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "household_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_tokens_user_id_users_id_fk": { + "name": "account_tokens_user_id_users_id_fk", + "tableFrom": "account_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_tokens_household_id_households_id_fk": { + "name": "account_tokens_household_id_households_id_fk", + "tableFrom": "account_tokens", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deployment_admin": { + "name": "deployment_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en'" + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.planning_entities": { + "name": "planning_entities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "entity_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'house'" + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'blue'" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "radius": { + "name": "radius", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "sort_order": { + "name": "sort_order", + "type": "double precision", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "entity_household_idx": { + "name": "entity_household_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_entities_household_id_households_id_fk": { + "name": "planning_entities_household_id_households_id_fk", + "tableFrom": "planning_entities", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.planning_settings": { + "name": "planning_settings", + "schema": "", + "columns": { + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "size_thresholds": { + "name": "size_thresholds", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[60,240,480,1440]'::jsonb" + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + } + }, + "indexes": {}, + "foreignKeys": { + "planning_settings_household_id_households_id_fk": { + "name": "planning_settings_household_id_households_id_fk", + "tableFrom": "planning_settings", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_activities": { + "name": "task_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "fields": { + "name": "fields", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "task_activities_task_id_tasks_id_fk": { + "name": "task_activities_task_id_tasks_id_fk", + "tableFrom": "task_activities", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_activities_actor_id_users_id_fk": { + "name": "task_activities_actor_id_users_id_fk", + "tableFrom": "task_activities", + "tableTo": "users", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_assignees": { + "name": "task_assignees", + "schema": "", + "columns": { + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "task_assignees_task_id_tasks_id_fk": { + "name": "task_assignees_task_id_tasks_id_fk", + "tableFrom": "task_assignees", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_assignees_user_id_users_id_fk": { + "name": "task_assignees_user_id_users_id_fk", + "tableFrom": "task_assignees", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_assignees_task_id_user_id_pk": { + "name": "task_assignees_task_id_user_id_pk", + "columns": [ + "task_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_entities": { + "name": "task_entities", + "schema": "", + "columns": { + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "task_entities_task_id_tasks_id_fk": { + "name": "task_entities_task_id_tasks_id_fk", + "tableFrom": "task_entities", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_entities_entity_id_planning_entities_id_fk": { + "name": "task_entities_entity_id_planning_entities_id_fk", + "tableFrom": "task_entities", + "tableTo": "planning_entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_entities_task_id_entity_id_pk": { + "name": "task_entities_task_id_entity_id_pk", + "columns": [ + "task_id", + "entity_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "status": { + "name": "status", + "type": "task_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'todo'" + }, + "planning_bucket": { + "name": "planning_bucket", + "type": "planning_bucket", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'someday'" + }, + "preceding_column": { + "name": "preceding_column", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "epic_id": { + "name": "epic_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "high": { + "name": "high", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "size": { + "name": "size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "estimate_minutes": { + "name": "estimate_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deadline_date": { + "name": "deadline_date", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deadline_time": { + "name": "deadline_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "field_versions": { + "name": "field_versions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "sort_order": { + "name": "sort_order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_by": { + "name": "completed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "trashed_at": { + "name": "trashed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "task_household_order_idx": { + "name": "task_household_order_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "task_epic_idx": { + "name": "task_epic_idx", + "columns": [ + { + "expression": "epic_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tasks_household_id_households_id_fk": { + "name": "tasks_household_id_households_id_fk", + "tableFrom": "tasks", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tasks_epic_id_planning_entities_id_fk": { + "name": "tasks_epic_id_planning_entities_id_fk", + "tableFrom": "tasks", + "tableTo": "planning_entities", + "columnsFrom": [ + "epic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_created_by_users_id_fk": { + "name": "tasks_created_by_users_id_fk", + "tableFrom": "tasks", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_completed_by_users_id_fk": { + "name": "tasks_completed_by_users_id_fk", + "tableFrom": "tasks", + "tableTo": "users", + "columnsFrom": [ + "completed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.attachments": { + "name": "attachments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "preview": { + "name": "preview", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "attachment_task_idx": { + "name": "attachment_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "attachments_household_id_households_id_fk": { + "name": "attachments_household_id_households_id_fk", + "tableFrom": "attachments", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "attachments_task_id_tasks_id_fk": { + "name": "attachments_task_id_tasks_id_fk", + "tableFrom": "attachments", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_comments": { + "name": "task_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "comment_task_idx": { + "name": "comment_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_comments_task_id_tasks_id_fk": { + "name": "task_comments_task_id_tasks_id_fk", + "tableFrom": "task_comments", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_comments_author_id_users_id_fk": { + "name": "task_comments_author_id_users_id_fk", + "tableFrom": "task_comments", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.filter_versions": { + "name": "filter_versions", + "schema": "", + "columns": { + "filter_id": { + "name": "filter_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "snapshot": { + "name": "snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "filter_versions_filter_id_saved_filters_id_fk": { + "name": "filter_versions_filter_id_saved_filters_id_fk", + "tableFrom": "filter_versions", + "tableTo": "saved_filters", + "columnsFrom": [ + "filter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "filter_versions_author_id_users_id_fk": { + "name": "filter_versions_author_id_users_id_fk", + "tableFrom": "filter_versions", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "filter_versions_filter_id_version_pk": { + "name": "filter_versions_filter_id_version_pk", + "columns": [ + "filter_id", + "version" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.saved_filters": { + "name": "saved_filters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "creator_id": { + "name": "creator_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "builtin": { + "name": "builtin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "expression": { + "name": "expression", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "filter_builtin_idx": { + "name": "filter_builtin_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "builtin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "saved_filters_household_id_households_id_fk": { + "name": "saved_filters_household_id_households_id_fk", + "tableFrom": "saved_filters", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "saved_filters_creator_id_users_id_fk": { + "name": "saved_filters_creator_id_users_id_fk", + "tableFrom": "saved_filters", + "tableTo": "users", + "columnsFrom": [ + "creator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_order_versions": { + "name": "task_order_versions", + "schema": "", + "columns": { + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "task_order_versions_household_id_households_id_fk": { + "name": "task_order_versions_household_id_households_id_fk", + "tableFrom": "task_order_versions", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_view_states": { + "name": "user_view_states", + "schema": "", + "columns": { + "view_id": { + "name": "view_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "favorite": { + "name": "favorite", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "active_filters": { + "name": "active_filters", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "split_future_columns": { + "name": "split_future_columns", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_view_states_view_id_saved_views_id_fk": { + "name": "user_view_states_view_id_saved_views_id_fk", + "tableFrom": "user_view_states", + "tableTo": "saved_views", + "columnsFrom": [ + "view_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_view_states_user_id_users_id_fk": { + "name": "user_view_states_user_id_users_id_fk", + "tableFrom": "user_view_states", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_view_states_view_id_user_id_pk": { + "name": "user_view_states_view_id_user_id_pk", + "columns": [ + "view_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.saved_views": { + "name": "saved_views", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "household_id": { + "name": "household_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "creator_id": { + "name": "creator_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "builtin": { + "name": "builtin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "presentation": { + "name": "presentation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expression": { + "name": "expression", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "quick_filters": { + "name": "quick_filters", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "sort": { + "name": "sort", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "epic_lanes": { + "name": "epic_lanes", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "show_empty_lanes": { + "name": "show_empty_lanes", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "card_properties": { + "name": "card_properties", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "view_builtin_idx": { + "name": "view_builtin_idx", + "columns": [ + { + "expression": "household_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "builtin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "saved_views_household_id_households_id_fk": { + "name": "saved_views_household_id_households_id_fk", + "tableFrom": "saved_views", + "tableTo": "households", + "columnsFrom": [ + "household_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "saved_views_creator_id_users_id_fk": { + "name": "saved_views_creator_id_users_id_fk", + "tableFrom": "saved_views", + "tableTo": "users", + "columnsFrom": [ + "creator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.household_role": { + "name": "household_role", + "schema": "public", + "values": [ + "admin", + "member" + ] + }, + "public.token_purpose": { + "name": "token_purpose", + "schema": "public", + "values": [ + "bootstrap", + "invite", + "recovery", + "verify_email" + ] + }, + "public.planning_bucket": { + "name": "planning_bucket", + "schema": "public", + "values": [ + "someday", + "within_year", + "within_month", + "ready" + ] + }, + "public.entity_kind": { + "name": "entity_kind", + "schema": "public", + "values": [ + "epic", + "place", + "resource", + "tag" + ] + }, + "public.task_status": { + "name": "task_status", + "schema": "public", + "values": [ + "todo", + "in_progress", + "done" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json index 948d6a3..9d55d49 100644 --- a/apps/api/drizzle/meta/_journal.json +++ b/apps/api/drizzle/meta/_journal.json @@ -43,6 +43,20 @@ "when": 1793554120517, "tag": "0005_jazzy_blue_shield", "breakpoints": true + }, + { + "idx": 6, + "version": "7", + "when": 1794426391312, + "tag": "0006_board_future_columns", + "breakpoints": true + }, + { + "idx": 7, + "version": "7", + "when": 1794431683525, + "tag": "0007_remove_manual_place_context", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/api/src/content/routes.ts b/apps/api/src/content/routes.ts index 294d61c..3a60c35 100644 --- a/apps/api/src/content/routes.ts +++ b/apps/api/src/content/routes.ts @@ -191,6 +191,7 @@ export async function registerContentRoutes( body: paging.extend({ q: z.string().trim().min(1).max(200), filterIds: z.array(z.uuid()).max(50).default([]), + currentPlaceId: z.uuid().nullable().optional(), }), response: { 200: z.object({ @@ -208,6 +209,7 @@ export async function registerContentRoutes( r.body.q, r.body.offset, r.body.filterIds, + r.body.currentPlaceId, ), ); app.get( diff --git a/apps/api/src/content/search.ts b/apps/api/src/content/search.ts index 9e0e5a3..ab55a02 100644 --- a/apps/api/src/content/search.ts +++ b/apps/api/src/content/search.ts @@ -15,6 +15,7 @@ export async function searchContent( q: string, offset: number, filterIds: string[], + currentPlaceId?: string | null, ) { return db.transaction( async (tx) => { @@ -25,7 +26,7 @@ export async function searchContent( tx, actor, householdId, - { filterIds, offset: 0, limit: Number.MAX_SAFE_INTEGER }, + { filterIds, currentPlaceId, offset: 0, limit: Number.MAX_SAFE_INTEGER }, true, ) : null; diff --git a/apps/api/src/content/service.ts b/apps/api/src/content/service.ts index 76c6743..31caacf 100644 --- a/apps/api/src/content/service.ts +++ b/apps/api/src/content/service.ts @@ -142,8 +142,9 @@ export class ContentService { q: string, offset: number, filterIds: string[] = [], + currentPlaceId?: string | null, ) { - return searchContent(this.db, actor, householdId, q, offset, filterIds); + return searchContent(this.db, actor, householdId, q, offset, filterIds, currentPlaceId); } async file(actor: Actor, householdId: string, id: string) { await this.tasks.scope(this.db, actor, householdId); diff --git a/apps/api/src/views/compiler.ts b/apps/api/src/views/compiler.ts index 693ebca..b2dede6 100644 --- a/apps/api/src/views/compiler.ts +++ b/apps/api/src/views/compiler.ts @@ -3,7 +3,7 @@ import { Temporal } from '@js-temporal/polyfill'; import { parseExpression, type FilterExpression, type FilterValue } from '@tendly/shared'; export type FilterContext = { userId: string; - currentPlaceId: string | null; + currentPlaceId: string | null | undefined; timezone: string; now: number; }; @@ -17,7 +17,8 @@ export function compileFilter( if (!value || typeof value !== 'object' || Array.isArray(value)) return value; if (value.token === 'CURRENT_USER') return [context.userId]; if (value.token === 'CURRENT_PLACE') { - if (!context.currentPlaceId) warnings.add('choose_current_place'); + // A known position outside all saved places still matches tasks that can be done anywhere. + if (context.currentPlaceId === undefined) warnings.add('current_place_unavailable'); return context.currentPlaceId ? [context.currentPlaceId] : []; } return Temporal.Instant.fromEpochMilliseconds(context.now) diff --git a/apps/api/src/views/routes.ts b/apps/api/src/views/routes.ts index ea88d2c..64db1d2 100644 --- a/apps/api/src/views/routes.ts +++ b/apps/api/src/views/routes.ts @@ -8,7 +8,6 @@ import { viewFieldsSchema, savedViewSchema, viewStateSchema, - viewContextSchema, viewCatalogSchema, taskQuerySchema, taskQueryResultSchema, @@ -140,6 +139,7 @@ export async function registerViewRoutes(server: FastifyInstance, accounts: Acco baseVersion: z.number().int().min(0), favorite: z.boolean().optional(), activeFilters: z.array(z.uuid()).max(50).optional(), + splitFutureColumns: z.boolean().optional(), }), response: { 200: viewStateSchema }, }, @@ -153,26 +153,6 @@ export async function registerViewRoutes(server: FastifyInstance, accounts: Acco r.body, ), ); - app.put( - '/api/v1/households/:householdId/view-context', - { - schema: { - params: scope, - body: z.object({ - baseVersion: z.number().int().min(0), - currentPlaceId: z.uuid().nullable(), - }), - response: { 200: viewContextSchema }, - }, - }, - async (r) => - service.contextWrite( - await actor(r), - r.params.householdId, - r.body.baseVersion, - r.body.currentPlaceId, - ), - ); app.post( '/api/v1/households/:householdId/task-query', { schema: { params: scope, body: taskQuerySchema, response: { 200: taskQueryResultSchema } } }, diff --git a/apps/api/src/views/schema.ts b/apps/api/src/views/schema.ts index a71c682..e2c7c64 100644 --- a/apps/api/src/views/schema.ts +++ b/apps/api/src/views/schema.ts @@ -10,7 +10,6 @@ import { uniqueIndex, } from 'drizzle-orm/pg-core'; import { households, users } from '../accounts/schema.js'; -import { entities } from '../tasks/schema.js'; import type { FilterExpression, ViewFields } from '@tendly/shared'; const identity = () => ({ id: uuid('id').primaryKey().defaultRandom(), @@ -71,25 +70,10 @@ export const viewStates = pgTable( version: integer('version').notNull().default(1), favorite: boolean('favorite').notNull().default(false), activeFilters: jsonb('active_filters').$type().notNull().default([]), + splitFutureColumns: boolean('split_future_columns').notNull().default(false), }, (t) => [primaryKey({ columns: [t.viewId, t.userId] })], ); -export const viewContexts = pgTable( - 'user_view_contexts', - { - householdId: uuid('household_id') - .notNull() - .references(() => households.id, { onDelete: 'cascade' }), - userId: uuid('user_id') - .notNull() - .references(() => users.id, { onDelete: 'cascade' }), - version: integer('version').notNull().default(1), - currentPlaceId: uuid('current_place_id').references(() => entities.id, { - onDelete: 'set null', - }), - }, - (t) => [primaryKey({ columns: [t.householdId, t.userId] })], -); export const taskOrderVersions = pgTable('task_order_versions', { householdId: uuid('household_id') .primaryKey() diff --git a/apps/api/src/views/service.ts b/apps/api/src/views/service.ts index 3c87cda..82ca400 100644 --- a/apps/api/src/views/service.ts +++ b/apps/api/src/views/service.ts @@ -1,4 +1,4 @@ -import { and, asc, desc, eq, inArray } from 'drizzle-orm'; +import { and, asc, desc, eq, inArray, isNotNull } from 'drizzle-orm'; import { z } from 'zod'; import { allTasks, @@ -22,7 +22,6 @@ import { filterVersions, views, viewStates, - viewContexts, taskOrderVersions, } from './schema.js'; import { defaultFilters, defaultView } from './defaults.js'; @@ -67,7 +66,7 @@ export class ViewService { } async catalog(actor: Actor, householdId: string) { await this.initialize(actor, householdId); - const [filterRows, viewRows, stateRows, context] = await Promise.all([ + const [filterRows, viewRows, stateRows] = await Promise.all([ this.db .select({ row: filters, creator: users.name }) .from(filters) @@ -85,7 +84,6 @@ export class ViewService { .from(viewStates) .innerJoin(views, eq(views.id, viewStates.viewId)) .where(and(eq(views.householdId, householdId), eq(viewStates.userId, actor.user.id))), - this.context(actor, householdId), ]); return { filters: filterRows.map(({ row, creator }) => @@ -95,19 +93,8 @@ export class ViewService { savedViewSchema.parse({ ...row, creator: creator ?? 'Tendly' }), ), states: Object.fromEntries(stateRows.map(({ state }) => [state.viewId, state])), - context, }; } - async context(actor: Actor, householdId: string, db: QueryDatabase = this.db) { - await this.tasks.scope(db, actor, householdId); - const [row] = await db - .select() - .from(viewContexts) - .where( - and(eq(viewContexts.householdId, householdId), eq(viewContexts.userId, actor.user.id)), - ); - return row ?? { version: 0, currentPlaceId: null }; - } async references(db: QueryDatabase, householdId: string, expression: unknown) { const tree = parseExpression(expression); const walk = async (node: FilterExpression): Promise => { @@ -353,7 +340,11 @@ export class ViewService { householdId: string, id: string, baseVersion: number, - changes: { favorite?: boolean | undefined; activeFilters?: string[] | undefined }, + changes: { + favorite?: boolean | undefined; + activeFilters?: string[] | undefined; + splitFutureColumns?: boolean | undefined; + }, ) { return this.db.transaction(async (tx) => { await this.tasks.scope(tx, actor, householdId, true); @@ -371,10 +362,11 @@ export class ViewService { if (changes.activeFilters?.some((id) => !view.quickFilters.includes(id))) throw new AccountError('invalid_filter_reference'); const value = { - ...changes, + favorite: changes.favorite ?? old?.favorite ?? false, activeFilters: changes.activeFilters ? [...new Set(changes.activeFilters)] : (old?.activeFilters ?? []), + splitFutureColumns: changes.splitFutureColumns ?? old?.splitFutureColumns ?? false, version: baseVersion + 1, }; const [row] = await tx @@ -385,33 +377,19 @@ export class ViewService { return row!; }); } - async contextWrite( - actor: Actor, - householdId: string, - baseVersion: number, - currentPlaceId: string | null, - ) { - return this.db.transaction(async (tx) => { - await this.tasks.scope(tx, actor, householdId, true); - const old = await this.context(actor, householdId, tx); - if (old.version !== baseVersion) throw new AccountError('personal_state_conflict', 409); - if (currentPlaceId) - await this.references(tx, householdId, { - type: 'predicate', - field: 'places', - operator: 'IN', - value: [currentPlaceId], - }); - const [row] = await tx - .insert(viewContexts) - .values({ householdId, userId: actor.user.id, version: baseVersion + 1, currentPlaceId }) - .onConflictDoUpdate({ - target: [viewContexts.householdId, viewContexts.userId], - set: { version: baseVersion + 1, currentPlaceId }, - }) - .returning(); - return row!; - }); + private async currentPlace(db: QueryDatabase, householdId: string, id?: string | null) { + if (id == null) return id; + // A deleted, archived or foreign place cannot supply context for this request. + const [place] = await db.select({ id: entities.id }).from(entities).where(and( + eq(entities.id, id), + eq(entities.householdId, householdId), + eq(entities.kind, 'place'), + eq(entities.archived, false), + isNotNull(entities.latitude), + isNotNull(entities.longitude), + isNotNull(entities.radius), + )); + return place?.id; } async query(actor: Actor, householdId: string, input: TaskQuery, includeArchived = false) { return this.db.transaction( @@ -465,7 +443,7 @@ export class ViewService { ...definitions.filter((f) => !f.deleted).map((f) => f.expression), ...(input.expression ? [parseExpression(input.expression)] : []), ]; - const context = await this.context(actor, householdId, db); + const currentPlaceId = await this.currentPlace(db, householdId, input.currentPlaceId); const [order] = await db .select() .from(taskOrderVersions) @@ -477,7 +455,7 @@ export class ViewService { expressions, { userId: actor.user.id, - currentPlaceId: context.currentPlaceId, + currentPlaceId, timezone: household.timezone, now: Date.now(), }, diff --git a/apps/api/src/views/views.integration.test.ts b/apps/api/src/views/views.integration.test.ts index 0aab86e..d74dbe4 100644 --- a/apps/api/src/views/views.integration.test.ts +++ b/apps/api/src/views/views.integration.test.ts @@ -101,7 +101,9 @@ afterAll(async () => { } }); it('uses typed set semantics, nested NOT and context values, with missing context never broadening a match', async () => { - const place = await tasks.entityWrite(actor, home, { kind: 'place', name: 'Home' }), + const place = await tasks.entityWrite(actor, home, { + kind: 'place', name: 'Home', latitude: 59.3, longitude: 18.1, radius: 100, + }), away = await tasks.entityWrite(actor, home, { kind: 'place', name: 'Away' }); const car = await tasks.entityWrite(actor, home, { kind: 'resource', name: 'Car' }), trailer = await tasks.entityWrite(actor, home, { kind: 'resource', name: 'Trailer' }); @@ -152,13 +154,17 @@ it('uses typed set semantics, nested NOT and context values, with missing contex children: [rule('places', 'COMPATIBLE', { token: 'CURRENT_PLACE' })], }), ); - expect(missing).toMatchObject({ count: 0, warnings: ['choose_current_place'] }); - await service.contextWrite(actor, home, 0, place.id); + expect(missing).toMatchObject({ count: 0, warnings: ['current_place_unavailable'] }); + const here = and(base, rule('places', 'COMPATIBLE', { token: 'CURRENT_PLACE' })); expect( - (await query(and(base, rule('places', 'COMPATIBLE', { token: 'CURRENT_PLACE' })))).items.map( - (t) => t.id, - ), + (await query(here, { currentPlaceId: place.id })).items.map((t) => t.id), ).toEqual([a.id, b.id]); + const outside = await query(here, { currentPlaceId: null }); + expect(outside.items.map((t) => t.id)).toEqual([a.id]); + expect(outside.warnings).toEqual([]); + const hereFilter = await service.filterWrite(actor, home, definition('Here', here)); + const searchHere = await new ContentService(db).search(actor, home, 'sets', 0, [hereFilter.id], place.id); + expect(searchHere.items.map((hit) => hit.id)).toEqual([a.id, b.id]); expect( ( await query( @@ -226,12 +232,22 @@ it('filters and sorts the whole set before paging or counting and treats SQL-lik query({ type: 'predicate', field: 'title', operator: 'GT', value: 'x' } as FilterExpression), ).rejects.toThrow(); }); -it('combines the shared base and chips with AND while keeping toggles and favorites personal and per view', async () => { +it('combines the shared base and chips with AND and keeps view preferences personal', async () => { const catalog = await service.catalog(actor, home), board = catalog.views.find((v) => v.builtin === 'board')!, now = catalog.views.find((v) => v.builtin === 'now')!, high = catalog.filters.find((f) => f.builtin === 'high')!; - await service.stateWrite(actor, home, board.id, 0, { activeFilters: [high.id], favorite: true }); + const first = await service.stateWrite(actor, home, board.id, 0, { + activeFilters: [high.id], + favorite: true, + }); + expect(first.splitFutureColumns).toBe(false); + await service.stateWrite(actor, home, board.id, first.version, { splitFutureColumns: true }); + expect((await service.catalog(actor, home)).states[board.id]).toMatchObject({ + activeFilters: [high.id], + favorite: true, + splitFutureColumns: true, + }); const enabled = await service.query(actor, home, { viewId: board.id, offset: 0, limit: 100 }); expect(enabled.items.every((t) => t.high)).toBe(true); const personal = await service.catalog(member, home); @@ -240,6 +256,8 @@ it('combines the shared base and chips with AND while keeping toggles and favori await expect(service.stateWrite(actor, home, board.id, 0, { activeFilters: [] })).rejects.toThrow( 'personal_state_conflict', ); + expect(await service.stateWrite(actor, home, board.id, first.version + 1, { favorite: false })) + .toMatchObject({ activeFilters: [high.id], favorite: false, splitFutureColumns: true }); const revised = await service.viewWrite( actor, home, @@ -297,14 +315,18 @@ it('scopes every new route and rejects cross-household references and move ancho const foreignEntity = await tasks.entityWrite(intruder, foreign, { kind: 'place', name: 'Secret', + latitude: 59.3, + longitude: 18.1, + radius: 100, }), foreignTask = await tasks.create(intruder, foreign, { title: 'Secret task' }); await expect( service.filterWrite(actor, home, definition('Leak', rule('places', 'IN', [foreignEntity.id]))), ).rejects.toThrow('invalid_filter_reference'); - await expect(service.contextWrite(actor, home, 1, foreignEntity.id)).rejects.toThrow( - 'invalid_filter_reference', - ); + const invalidPlace = await query(rule('places', 'COMPATIBLE', { token: 'CURRENT_PLACE' }), { + currentPlaceId: foreignEntity.id, + }); + expect(invalidPlace).toMatchObject({ count: 0, warnings: ['current_place_unavailable'] }); await expect(query(allTasks, { filterIds: [randomUUID()] })).rejects.toThrow( 'invalid_filter_reference', ); @@ -327,7 +349,6 @@ it('scopes every new route and rejects cross-household references and move ancho ['PUT', `/views/${view.id}`, { baseVersion: 1, changes: view }], ['POST', `/views/${view.id}/command`, { baseVersion: 1, command: 'delete' }], ['PUT', `/views/${view.id}/state`, { baseVersion: 0, favorite: true }], - ['PUT', '/view-context', { baseVersion: 0, currentPlaceId: null }], ['POST', '/task-query', { viewId: view.id }], ['POST', `/tasks/${task.id}/move`, { baseVersion: 1, orderVersion: 0, beforeId: null }], ['POST', '/search', { q: 'private', filterIds: [filter.id] }], diff --git a/apps/web/src/content/Search.tsx b/apps/web/src/content/Search.tsx index 7cdcf47..0a15903 100644 --- a/apps/web/src/content/Search.tsx +++ b/apps/web/src/content/Search.tsx @@ -1,9 +1,11 @@ import { routeUrl, type Route } from '../navigation/routes.js'; import { useViewCatalog, filterName } from '../views/api.js'; +import { FilterWarnings, useCurrentPlace, usesCurrentPlace } from '../views/CurrentPlace.js'; import { useEffect, useState } from 'react'; import { useInfiniteQuery } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { api, result } from '../accounts/api.js'; +import { defined } from '../tasks/api.js'; export function Search({ householdId, openTask, @@ -16,6 +18,7 @@ export function Search({ openLibrary: (id: string) => void; }) { const { t } = useTranslation(); + const currentPlace = useCurrentPlace(); const catalog = useViewCatalog(householdId); const filterIds = route.filters, input = route.q; const setFilterIds = (ids: string[]) => onSearch(input, ids); @@ -26,14 +29,14 @@ export function Search({ return () => clearTimeout(timer); }, [input]); const search = useInfiniteQuery({ - queryKey: ['planning', householdId, 'search', q, filterIds], + queryKey: ['planning', householdId, 'search', q, filterIds, { currentPlaceId: currentPlace.id }], enabled: !!q, initialPageParam: 0, queryFn: ({ pageParam }) => result( api.POST('/api/v1/households/{householdId}/search', { params: { path: { householdId } }, - body: { q, offset: pageParam, filterIds }, + body: defined({ q, offset: pageParam, filterIds, currentPlaceId: currentPlace.id }), }), ), getNextPageParam: (last) => last.nextOffset ?? undefined, @@ -64,24 +67,21 @@ export function Search({ + onChange={(e) => { + if (e.target.checked && usesCurrentPlace(f.expression)) currentPlace.request(); setFilterIds( e.target.checked ? [...filterIds, f.id] : filterIds.filter((id) => id !== f.id), - ) - } + ); + }} /> {filterName(f, t)} ))} - {search.data?.pages[0]?.warnings.map((w) => ( -

- {t(w)} -

- ))} + {q && search.isFetching &&

{t('loading')}

} {search.isError && (

@@ -91,6 +91,7 @@ export function Search({ {q && !search.isFetching && !search.isError && + !search.data?.pages[0]?.warnings.length && !search.data?.pages.some((p) => p.items.length) && (

{t('noSearchResults')}

)} diff --git a/apps/web/src/style.css b/apps/web/src/style.css index d61e51d..e29bb79 100644 --- a/apps/web/src/style.css +++ b/apps/web/src/style.css @@ -92,6 +92,9 @@ p { margin: .65rem 0; } .workspace-main { min-width: 0; padding: 2.5rem clamp(1.25rem,3vw,3rem); } .page-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 2rem; } .page-heading h1 { font-size: 2.1rem; margin: .25rem 0 .5rem; } +.view-title { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; } +.view-settings-button { background: var(--tint); font-size: .85rem; padding: .5rem .75rem; } +.view-layout-option { font-size: .85rem; } .eyebrow { font-size: .8rem; color: var(--muted); margin: 0; } .page-heading .muted { margin-bottom: 0; font-size: .9rem; } .now-list { display: grid; gap: .65rem; max-width: 760px; } @@ -107,11 +110,11 @@ p { margin: .65rem 0; } .card-metadata>span { display: inline-flex; align-items: center; gap: .25rem; } .deadline.overdue { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; } .card-avatar { border: 1px solid currentColor; border-radius: 50%; min-width: 20px; height: 20px; justify-content: center; } -.size-chip { font-size: .72rem; font-weight: 600; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #80808018; flex-shrink: 0; } +.size-chip { font-size: .72rem; font-weight: 600; width: 30px; height: 30px; justify-content: center; border-radius: 50%; background: #80808018; flex-shrink: 0; } .card-complete { width: 44px; flex-shrink: 0; padding: 0; border: 0; border-radius: 0; background: transparent; } .card-complete>span { width: 19px; height: 19px; display: grid; place-items: center; border: 1.5px solid currentColor; border-radius: 4px; } .completed .card-content strong { text-decoration: line-through; } -.board { display: grid; grid-template-columns: repeat(6,minmax(245px,1fr)); gap: 1rem; overflow-x: auto; padding: .25rem .25rem 1.5rem; align-items: start; } +.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(245px,1fr); gap: 1rem; overflow-x: auto; padding: .25rem .25rem 1.5rem; align-items: start; } .board-column { min-width: 0; border-radius: 14px; background: var(--surface); padding: .5rem; border: 1px solid var(--line); } .board-column>header { display: flex; align-items: center; justify-content: space-between; padding: 0 .25rem .45rem .5rem; } .board-column h2 { font-size: .85rem; margin: 0; } @@ -255,9 +258,6 @@ button.primary:hover:not(:disabled) { background:var(--accent); } .quick-filter-bar { display: flex; align-items: center; gap: .5rem; overflow-x: auto; padding: .25rem 0; } .filter-chip { flex-shrink: 0; border-radius: 999px; font-size: .85rem; min-height: 38px; padding: .45rem .85rem; } .filter-chip[aria-pressed=true] { border-color: var(--accent); background: var(--accent); color: var(--surface); } -.view-secondary-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; } -.current-place { display: flex; align-items: center; gap: .65rem; margin: 0; font-size: .8rem; font-weight: 400; } -.current-place select { width: auto; max-width: 220px; min-height: 36px; padding: .35rem .6rem; } .favorite-views { max-height: 35vh; overflow-y: auto; } .dialog-wide { width: min(1100px,calc(100vw - 3rem)); } .filter-editor-layout { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(220px,1fr); gap: 1.5rem; align-items: start; margin: 1rem 0; } @@ -301,8 +301,6 @@ button.primary:hover:not(:disabled) { background:var(--accent); } .filter-group { padding: .45rem; } .filter-rule { grid-template-columns: minmax(0,1fr); } .filter-chip { min-height: 44px; } - .view-secondary-controls { gap: .5rem; } - .current-place { flex-wrap: wrap; } .definition-list .button-row { flex-wrap: wrap; } .card-move { min-width: 28px; } .order-end { display: none; } @@ -459,9 +457,6 @@ a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; } .page-heading { margin-bottom: 1rem; } .workspace-main { padding-top: 1.5rem; } -.view-secondary { margin-block: .4rem .8rem; } -.view-secondary>summary { width: fit-content; color: var(--muted); font-size: .85rem; min-height: 44px; padding-block: .7rem; cursor: pointer; } -.view-secondary-controls { margin-top: .25rem; } .empty-state { padding: 2rem 1rem; } @media (min-width: 721px) and (max-width: 1024px) { .workspace,.nav-collapsed { grid-template-columns: 160px minmax(0,1fr); } diff --git a/apps/web/src/tasks/Workspace.tsx b/apps/web/src/tasks/Workspace.tsx index 7bb22da..0b3d8ef 100644 --- a/apps/web/src/tasks/Workspace.tsx +++ b/apps/web/src/tasks/Workspace.tsx @@ -3,12 +3,14 @@ import { NavigationContext, useWorkspaceNavigation } from '../navigation/Navigat import { routeUrl, type WorkspaceView } from '../navigation/routes.js'; import { useViewCatalog, viewName } from '../views/api.js'; import { QuickBar } from '../views/QuickBar.js'; +import { CurrentPlaceContext, FilterWarnings, useDetectedPlace } from '../views/CurrentPlace.js'; +import { ViewEditor } from '../views/Editors.js'; import { ViewLibrary } from '../views/Library.js'; import { TaskPresentation, type Move } from '../views/TaskPresentation.js'; import { Search } from '../content/Search.js'; import { useHouseholdEvents } from './useHouseholdEvents.js'; import { useEffect, useRef, useState, type FormEvent } from 'react'; -import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query'; +import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { House, @@ -39,6 +41,7 @@ import { patchTask, EditFailure, defined } from './api.js'; import { Library } from './Library.js'; type HistoryEntry = { current: Task; inverse: TaskChanges; forward: TaskChanges }; +type ViewStateChanges = { activeFilters?: string[]; splitFutureColumns?: boolean }; export function Workspace({ account, refresh, @@ -66,6 +69,8 @@ export function Workspace({ const activeView = catalog.data?.views.find( (v) => !v.deleted && (view === 'custom' ? v.id === customViewId : v.builtin === view), ); + const viewState = activeView ? catalog.data?.states[activeView.id] : undefined; + const [editingView, setEditingView] = useState(false); const [captureEpic, setCaptureEpic] = useState(null); const [moveUndo, setMoveUndo] = useState<{ task: Task; @@ -94,6 +99,26 @@ export function Workspace({ }), ), }); + const currentPlace = useDetectedPlace(entities.data); + const updateViewState = useMutation({ + mutationFn: ({ householdId, viewId, baseVersion, changes }: { + householdId: string; + viewId: string; + baseVersion: number; + changes: ViewStateChanges; + }) => + result(api.PUT('/api/v1/households/{householdId}/views/{id}/state', { + params: { path: { householdId, id: viewId } }, + body: { baseVersion, ...changes }, + })), + onMutate: () => setError(''), + onError: (e) => setError(e instanceof Error ? e.message : 'operation_failed'), + onSettled: (_result, _error, { householdId }) => queries.invalidateQueries({ queryKey: ['planning', householdId] }), + }); + function saveViewState(changes: ViewStateChanges) { + if (!activeView) return; + updateViewState.mutate({ householdId: id, viewId: activeView.id, baseVersion: viewState?.version ?? 0, changes }); + } const members = useQuery({ queryKey: ['planning', id, 'members'], enabled: !!id, @@ -106,7 +131,7 @@ export function Workspace({ orderVersion: number; warnings: string[]; }>({ - queryKey: ['planning', id, 'tasks', activeView?.id], + queryKey: ['planning', id, 'tasks', activeView?.id, { currentPlaceId: currentPlace.id }], enabled: !!id && !!activeView, initialPageParam: 0, getNextPageParam: (last) => last.nextOffset ?? undefined, @@ -114,7 +139,7 @@ export function Workspace({ result( api.POST('/api/v1/households/{householdId}/task-query', { params: { path: { householdId: id } }, - body: { viewId: activeView!.id, offset: Number(pageParam), limit: 100 }, + body: defined({ viewId: activeView!.id, currentPlaceId: currentPlace.id, offset: Number(pageParam), limit: 100 }), }), ), refetchInterval: 30_000, @@ -122,11 +147,11 @@ export function Workspace({ const householdTasks = useQuery({ queryKey: ['planning', id, 'has-tasks'], enabled: !!id && !!list.data && !list.data.pages.some(page => page.items.length), - queryFn: () => result(api.GET('/api/v1/households/{householdId}/tasks', { - params: { path: { householdId: id }, query: { view: 'board', limit: 1 } }, + queryFn: () => result(api.POST('/api/v1/households/{householdId}/task-query', { + params: { path: { householdId: id } }, body: { limit: 1 }, })), }); - const activeFilters = activeView ? catalog.data?.states[activeView.id]?.activeFilters ?? [] : []; + const activeFilters = viewState?.activeFilters ?? []; const detail = useQuery({ queryKey: ['planning', id, 'task', selected], enabled: !!id && !!selected, @@ -349,6 +374,7 @@ export function Workspace({ return ( +
-
{t('viewOptions')}{catalog.context.currentPlaceId ? ' · ' + (entities.find(e => e.id === catalog.context.currentPlaceId)?.name ?? '') : ''}
- - -
{error && (

{t(error)} @@ -298,7 +259,6 @@ export function QuickBar({ onClose={() => setEditing(null)} /> )} - {editView && setEditView(false)} />} ); } diff --git a/apps/web/src/views/TaskPresentation.tsx b/apps/web/src/views/TaskPresentation.tsx index 874412c..adadc56 100644 --- a/apps/web/src/views/TaskPresentation.tsx +++ b/apps/web/src/views/TaskPresentation.tsx @@ -5,6 +5,12 @@ import { columns, type Task, type Entity, type SavedView, type TaskColumn } from import type { Member } from '../tasks/TaskFields.js'; import { EntityIcon, epicStyle } from '../tasks/identity.js'; import { Dialog } from '../components/ui/dialog.js'; + +type BoardColumn = TaskColumn | 'future'; +const futureColumns = new Set(['someday', 'within_year', 'within_month']); +const groupedColumns = ['future', ...columns.filter((column) => !futureColumns.has(column))] as const; +const taskColumnFor = (column: BoardColumn): TaskColumn => column === 'future' ? 'someday' : column; + export type Move = { beforeId?: string | null; afterId?: string | null; @@ -20,6 +26,7 @@ export function TaskPresentation({ open, taskHref, column, setColumn, + splitFutureColumns, complete, create, move, @@ -31,6 +38,7 @@ export function TaskPresentation({ open: (task: Task) => void; taskHref: (task: Task) => string; column: TaskColumn; setColumn: (column: TaskColumn) => void; + splitFutureColumns: boolean; complete: (task: Task) => void; create: (column: TaskColumn, epicId?: string | null) => void; move: (task: Task, changes: Move) => Promise; @@ -48,17 +56,26 @@ export function TaskPresentation({ swipe = useRef({ x: 0, y: 0 }), lastSwipe = useRef(0); const [dropTarget, setDropTarget] = useState(''); - const drop = (event: React.DragEvent, target: string, changes: Move) => { + const boardColumns: readonly BoardColumn[] = splitFutureColumns ? columns : groupedColumns; + const boardColumnFor = (column: TaskColumn): BoardColumn => + !splitFutureColumns && futureColumns.has(column) ? 'future' : column; + const activeColumn = boardColumnFor(column); + const drop = (event: React.DragEvent, changes: Move, destination?: BoardColumn) => { event.preventDefault(); event.stopPropagation(); setDropTarget(''); if (dragged.current) { const task = dragged.current; dragged.current = null; - void move(task, changes).catch(() => {}); + // Reordering within Future must preserve the card's planning horizon. + const column = destination !== undefined && (destination !== 'future' || !futureColumns.has(task.column)) + ? taskColumnFor(destination) + : undefined; + if (column !== undefined || Object.keys(changes).length > 0) + void move(task, { ...changes, ...(column !== undefined ? { column } : {}) }).catch(() => {}); } }; - const droppable = (target: string, changes: Move) => ({ + const droppable = (target: string, changes: Move, destination?: BoardColumn) => ({ onDragOver: (event: React.DragEvent) => { if (dragged.current) { event.preventDefault(); @@ -66,18 +83,18 @@ export function TaskPresentation({ setDropTarget(target); } }, - onDrop: (event: React.DragEvent) => drop(event, target, changes), + onDrop: (event: React.DragEvent) => drop(event, changes, destination), 'data-drop': dropTarget === target, }); const card = (task: Task) => (

task.epicId === (epic?.id ?? null) && - (!mobile || view.presentation !== 'board' || task.column === column), + (!mobile || view.presentation !== 'board' || boardColumnFor(task.column) === activeColumn), ), ); return ( @@ -124,10 +141,10 @@ export function TaskPresentation({ {view.presentation === 'board' && (
) : (
- {columns.map((c) => ( -
-
-

{t('column_' + c)} {laneItems.filter(task => task.column === c).length}

- +
+
{columnItems.map(card)}
+ - -
- {laneItems.filter((task) => task.column === c).map(card)} -
- -
- ))} + + ); + })}
); return view.epicLanes ? ( diff --git a/apps/web/src/views/i18n.ts b/apps/web/src/views/i18n.ts index 7be4ddf..fb42ce3 100644 --- a/apps/web/src/views/i18n.ts +++ b/apps/web/src/views/i18n.ts @@ -59,11 +59,20 @@ export const viewCopy: Record = { daysFromToday: ['Days from today', 'Dagar från idag'], yes: ['Yes', 'Ja'], no: ['No', 'Nej'], - noCurrentPlace: ['No place selected', 'Ingen plats vald'], - choose_current_place: [ - 'Select your current place to evaluate this filter.', - 'Välj din aktuella plats för att använda filtret.', - ], + locatingCurrentPlace: ['Finding your current place…', 'Hämtar din aktuella plats…'], + locationRequired: ['This filter uses your current place.', 'Det här filtret använder din aktuella plats.'], + useMyLocation: ['Use my location', 'Använd min plats'], + locationPermissionDenied: [ + 'Allow location access in your browser to use this filter.', + 'Tillåt platsåtkomst i webbläsaren för att använda filtret.', + ], + locationUnavailable: ['Could not get your location.', 'Det gick inte att hämta din position.'], + locationUnsupported: ['Location access is unavailable in this browser.', 'Platsåtkomst är inte tillgänglig i den här webbläsaren.'], + locationUnconfigured: [ + 'Add coordinates and a radius to a place in the library to use this filter.', + 'Lägg till koordinater och en radie för en plats i biblioteket för att använda filtret.', + ], + locationNoMatch: ['You are outside your saved places.', 'Du befinner dig utanför dina sparade platser.'], previewMatches: ['{{count}} matching tasks', '{{count}} matchande uppgifter'], previewDraft: ['Live preview · unsaved draft', 'Liveförhandsvisning · osparat utkast'], previewResults: ['Show matching tasks', 'Visa matchande uppgifter'], @@ -109,6 +118,8 @@ export const viewCopy: Record = { favorite: ['Favorite', 'Favorit'], openView: ['Open view', 'Öppna vy'], viewOptions: ['View settings', 'Vyinställningar'], + splitFutureColumns: ['Show separate future columns', 'Visa framtidskolumner separat'], + column_future: ['Future', 'Framtid'], presentation: ['Presentation', 'Presentation'], presentation_list: ['List', 'Lista'], presentation_board: ['Board', 'Board'], diff --git a/apps/web/src/views/place-detection.test.ts b/apps/web/src/views/place-detection.test.ts new file mode 100644 index 0000000..2fa08ff --- /dev/null +++ b/apps/web/src/views/place-detection.test.ts @@ -0,0 +1,21 @@ +import { expect, it } from 'vitest'; +import type { Entity } from '@tendly/shared'; +import { isGeocodedPlace, nearestPlace } from './place-detection.js'; + +it('chooses the closest configured place inside its radius', () => { + const position = { latitude: 59.3, longitude: 18.1 }; + const place: Entity = { + id: 'home', kind: 'place', name: 'Home', description: '', icon: 'house', color: 'blue', + version: 1, order: 0, archived: false, radius: 100, ...position, + }; + const places = [ + { ...place, id: 'nearby', latitude: 59.3005 }, + { ...place, id: 'without-radius', radius: null }, + { ...place, id: 'archived', archived: true }, + { ...place, id: 'tag', kind: 'tag' as const }, + place, + ].filter(isGeocodedPlace); + expect(places.map((place) => place.id)).toEqual(['nearby', 'home']); + expect(nearestPlace(places, position)?.id).toBe('home'); + expect(nearestPlace(places, { ...position, latitude: 59.31 })).toBeNull(); +}); diff --git a/apps/web/src/views/place-detection.ts b/apps/web/src/views/place-detection.ts new file mode 100644 index 0000000..e440eab --- /dev/null +++ b/apps/web/src/views/place-detection.ts @@ -0,0 +1,28 @@ +import type { Entity } from '@tendly/shared'; + +type Coordinates = { latitude: number; longitude: number }; +type GeocodedPlace = Entity & Coordinates & { radius: number }; + +export function isGeocodedPlace(place: Entity): place is GeocodedPlace { + return place.kind === 'place' && !place.archived && + place.latitude !== null && place.longitude !== null && place.radius !== null; +} + +export function nearestPlace(places: GeocodedPlace[], position: Coordinates) { + const radians = Math.PI / 180; + let nearest: GeocodedPlace | null = null; + let nearestDistance = Infinity; + for (const place of places) { + const latitude = (place.latitude - position.latitude) * radians; + const longitude = (place.longitude - position.longitude) * radians; + const haversine = Math.sin(latitude / 2) ** 2 + + Math.cos(position.latitude * radians) * Math.cos(place.latitude * radians) * + Math.sin(longitude / 2) ** 2; + const distance = 2 * 6_371_000 * Math.asin(Math.sqrt(Math.min(1, haversine))); + if (distance <= place.radius && distance < nearestDistance) { + nearest = place; + nearestDistance = distance; + } + } + return nearest; +} diff --git a/docs/architecture/decisions/0005-filters-views-ordering.md b/docs/architecture/decisions/0005-filters-views-ordering.md index 4bdc67f..e61e76a 100644 --- a/docs/architecture/decisions/0005-filters-views-ordering.md +++ b/docs/architecture/decisions/0005-filters-views-ordering.md @@ -10,7 +10,8 @@ revision creates a new revision. Deletion is reversible and removes a filter fro all effective quick bars, retaining references for restoration. Built-in Now and Board cannot be deleted and have explicit reset commands. A view's quick-bar order, sort, card properties and epic-lane configuration are shared; favorites and enabled -chips are versioned separately per user/view. Current Place is personal per household. +chips are versioned separately per user/view. As of 2026-11-11, Current Place is detected +on the device for the active household and shared across the workspace. The public AST has typed predicates and AND/OR/NOT groups. Validation limits each expression to 150 nodes, ten nesting levels and 50 children per group; fields, @@ -54,9 +55,11 @@ as unfinished options here. - `GET view-catalog`; shared `POST/PUT filters`, filter version history and commands. - Shared `POST/PUT views` and reset/delete/restore commands; personal `PUT views/:id/state`. -- Personal `PUT view-context`; `POST task-query`, `POST search`, `POST tasks/:id/move`. +- `POST task-query`, `POST search` and `POST tasks/:id/move`. Query and search accept + the detected place ID per request. The browser keeps the device coordinates. - Migration 0005 adds definitions, filter history, personal states/context and order revisions. Existing tasks, content and file records are untouched. Built-ins are initialized idempotently for existing and new households under a write lock. +- Migration 0007 removes stored manual Current Place selections. - OpenAPI and the generated client describe the interfaces; recursive AST validation remains authoritative on the server. Every operation checks fresh household access. diff --git a/docs/architecture/technical-architecture.md b/docs/architecture/technical-architecture.md index eb78bf3..0b85aa5 100644 --- a/docs/architecture/technical-architecture.md +++ b/docs/architecture/technical-architecture.md @@ -82,7 +82,7 @@ The schema below describes logical entities, **not a mandate for exact table nam | `templates`, `recurrence_series`, `occurrences` | Shared template engine, recurrence rules, schedule instance uniqueness | | `views`, `filters`, `filter_versions` | Household-defined views/filter JSONB, creators, history | | `view_quick_filters` | View-specific ordering of reusable filter IDs | -| `user_view_state` | Personal favorites, active chips per view | +| `user_view_state` | Personal favorites, active chips and split Future column preference per view | | `comments`, `attachments`, `task_activities` | Content and audit metadata, file paths not public URLs | | `notification_settings` (v1.1) | Per-user preferences; delivery jobs | | `app_settings`, `household_settings` | Defaults and secrets references, never plaintext credentials in responses | @@ -107,7 +107,9 @@ type TaskColumn = 'someday' | 'within_year' | 'within_month' | 'todo' | 'in_prog - Else if `status==='in_progress'`, column `in_progress`. - Else map `planningBucket: someday→someday, within_year→within_year, within_month→within_month, ready→todo`. -Maintain valid combinations via one domain-level `moveTaskToColumn` operation. The bucket survives work and completion so planning context is retained. Record the **immediate visible pre-Done column** on transition into Done, not the first-ever planning bucket. Reopen to that column, with a safe fallback if a record predates this feature. The UI and API filtering expose `TaskColumn` as a single user-visible field; never require editing status and bucket independently. +Maintain valid combinations via one domain-level `moveTaskToColumn` operation. The bucket survives work and completion so planning context is retained. On completion record the **exact pre-Done `TaskColumn`**. Reopen to that column, with a safe fallback for older records. Task editing and API filtering use the same `TaskColumn` values. + +Board presentation groups the three future task columns by default. The client groups the returned `TaskColumn` values and sends canonical column values for task moves. The layout preference is stored in the personal view state. A separate `available`/`blocked` database field is **not** authoritative. Derive availability using the Product Specification's date/dependency constraints. Never move cards automatically because a date passed or a dependency changed. @@ -154,7 +156,7 @@ Store saved filter ASTs in PostgreSQL **JSONB**, with version entries and `creat - Scope/filter at the server. For effective inherited properties, resolve them in batches within database queries or a bounded server filtering pipeline; pagination/sorting must operate on **fully filtered effective results**, not only raw rows from the current page. - All view types, live previews and search-filter combinations use the **same evaluator**, so matching sets cannot disagree between Now, Board and custom views. - A view's filter composition is exactly `base AND each active quick filter`; quick-filter availability/order is shared, personal on/off switches are stored per user/view. Editing a shared definition propagates to every reference and creates a restorable version. Prevent filter self-references/cycles if such references are introduced in the future; they are not required in v1. -- Expose `Column` to the builder, not internal status/planningBucket selectors. Display meaningful feedback if the Current Place token lacks a chosen place; avoid silently interpreting it as a physical location. +- Expose `Column` to the builder. A single browser geolocation watcher supplies Current Place across the signed-in workspace. The browser resolves the closest configured place inside its radius. POST filter requests send its household place ID, explicit `null` for a known position outside the configured radii, or omit the field when the position is unknown. The server validates the place within the household and evaluates the filter. Device coordinates and place history are never stored by the server. - Manual card order is shared globally and must remain stable under filtering and view switching; sorting by other properties is a presentation/query choice. ## 6. Templates and recurrence engine @@ -231,4 +233,4 @@ Explain domain invariants in concise inline comments **why**, not narrating obvi ## 12. Explicit non-goals for initial architecture -No proprietary managed backend, no Redis, no RLS v1, no tRPC, no collaborative rich-text CRDT/OT, no required App Store client, no full offline mutation engine, no automatically published production updates, no mandatory live GPS or push for v1.0, and no integrated cloud backup before v1.3. All these exclusions are scoped to approved milestones, not permanent bans on future development. +No proprietary managed backend, no Redis, no RLS v1, no tRPC, no collaborative rich-text CRDT/OT, no required App Store client, no full offline mutation engine, no automatically published production updates, no push for v1.0, and no integrated cloud backup before v1.3. All these exclusions are scoped to approved milestones, not permanent bans on future development. diff --git a/docs/design/ux-ui-specification.md b/docs/design/ux-ui-specification.md index afd6ce3..f832052 100644 --- a/docs/design/ux-ui-specification.md +++ b/docs/design/ux-ui-specification.md @@ -83,20 +83,20 @@ The home screen is a **vertical task list**, not a board, KPI panel or agenda ca - Apply the Product Specification's default base filter: **Within a Month, To Do, In Progress**, with satisfied dependencies and effective earliest-start date reached. - Render a horizontal **view-specific quick-filter chip bar** above tasks. Chips are saved filters, not hardcoded property dropdowns. Multiple active chips narrow via AND. -- Show a compact location selector when the user wants to set their current place (manual in v1.0); location does not filter tasks unless an explicit base/quick filter uses it. +- Use the app-wide detected Current Place when an explicit base or quick filter references it. - Support simple sensible empty states: *no actionable tasks* versus *filters have zero matches*; show active chips and a clear reset action. -- When the household has no current tasks, invite the user to create the first one. An empty Now view with other tasks offers Board. Keep view settings and manual place selection in a secondary disclosure; show the selected place in its summary. +- When the household has no current tasks, invite the user to create the first one. An empty Now view with other tasks offers Board. Show the **View settings** button beside the view heading. - Keep create-task easy to reach regardless of scroll position. ## 6. Board and saved views ### Workflow display -The board has **exactly six** visible column choices, translated by locale: Someday, Within a Year, Within a Month, To Do, In Progress and Done. They map to the **single `Column` property**. Do not show an additional editable “Planning horizon” or “Work status” field; these are implementation concepts. +The board defaults to **Future**, **To Do**, **In Progress** and **Done**, translated by locale. Place the **View settings** button beside the Board heading, followed by the **Show separate future columns** checkbox. The checkbox replaces Future with Someday, Within a Year and Within a Month, in that order. Save this choice per user and board view. The single task `Column` field continues to expose the six exact choices. **Desktop:** multiple columns side by side, horizontal overflow on smaller desktops, drag between columns and optional epic swimlanes. **Mobile:** exactly one active column shown at once, with swipe between columns **and** a direct column selector. With epic grouping, use collapsible sections within the active mobile column; desktop lanes are collapsible horizontal swimlanes. Global epic ordering applies everywhere. The Unassigned epic lane is last, empty lanes hidden unless that view requests them. -At tablet widths up to 1024px, use the single-column board with a direct selector and compact navigation. Column choices display counts for the currently loaded results; they do not claim to count unloaded pages. The selected column is retained in the workspace address. +At tablet widths up to 1024px, use the single-column board with a direct selector and compact navigation. The selector and swipe order use the current four- or six-column layout. Selecting Future shows the combined results for the three planning horizons. Column counts reflect the currently loaded results. The workspace address retains the selected task column and shows Future in grouped mode when that column is Someday, Within a Year or Within a Month. A view can be **Board** or **List** and records base filter, selected quick-filter chips, sorting (manual/default, deadline, High, effort, created date), epic lanes on/off, empty-lane visibility, visible card properties and subtask-as-card mode. Only group by epic; assignee/place are filter predicates, not lanes. All views are shared; users personally favorite views for their navigation. @@ -108,11 +108,13 @@ Built-in Now/Board views are editable and resettable but not deletable. View edi A horizontal, scrollable set of **saved filter chips**, specific to the active view. A tap/click toggles. Selected chips remain active across sessions for **that user and that view**. A `+` opens the shared filter library / create flow. Right-click or long-press opens Edit, Duplicate and Delete. Ensure buttons work equally well on touch and keyboard. Do not invent permanent `All / Now` segmented controls inconsistent with the underlying saved filter model. +**At my current place** matches tasks that can be done at the automatically detected place or anywhere. Turning on the filter triggers the browser's location permission request when needed. If a saved or draft filter needs permission, offer **Use my location** with the results. Place coordinates and radii are edited in the library. + After creating a filter from this bar, offer an explicit **Add to this view** action. Saving the definition and attaching it to a view are separate, recoverable operations; other views and personal active toggles remain unchanged. Closing, cancelling or navigating away from an edited filter/view asks whether to keep editing or discard the unsaved changes. Reload/close warns about these in-memory drafts; unlike task recovery copies, filter/view drafts are not persisted across reloads. Dialog replacement must move focus into the new dialog. ### Visual filter builder -Use nested groups and typed controls for AND/OR/NOT, field choice, operator and values. Fields are expressed in domain/user terms (`Column`, `Size`, `Place`, `Available`, `Requires resource`, etc.); never expose `planningBucket` as a second task selection. Dynamic operands include Today, Current User and manually selected Current Place, with GPS becoming available later. +Use nested groups and typed controls for AND/OR/NOT, field choice, operator and values. Fields are expressed in domain/user terms (`Column`, `Size`, `Place`, `Available`, `Requires resource`, etc.); never expose `planningBucket` as a second task selection. Dynamic operands include Today, Current User and automatically detected Current Place. - **Live matching count and results** as edits are made, without committing changes to a saved definition. - **Desktop:** a side panel/adjacent editor leaves results visible; **mobile:** full-screen editor with a preview switch/area. diff --git a/docs/implementation/acceptance-criteria.md b/docs/implementation/acceptance-criteria.md index d0a4275..a8b28bd 100644 --- a/docs/implementation/acceptance-criteria.md +++ b/docs/implementation/acceptance-criteria.md @@ -21,7 +21,11 @@ These scenarios define **observable behavior**. Use automated coverage for the m **Given** user A belongs only to household A, **when** they forge task IDs, file IDs, dependency IDs, query scopes, WebSocket subscriptions or write payloads belonging to household B, **then** no household-B data is disclosed or modified. Cross-household parenting/dependency/relations are denied, including in bulk operations and worker jobs. -### AC-04 — Exactly six columns, correct lifecycle +### AC-04 — Board layout and task column lifecycle + +**Given** a Board view without a personal layout preference, **then** it shows Future, To Do, In Progress and Done. **When** a user enables **Show separate future columns** beside **View settings** in the heading, **then** Future is replaced by Someday, Within a Year and Within a Month for that user and view across sessions. Task column values, filters and sort order are preserved. On mobile the selector and swipe navigation follow the chosen layout. + +**Given** Future is grouped, **when** a user adds a task there or drags a card there from another board column, **then** the task's column is Someday. Reordering a card within Future preserves its column. **Given** task T in Within a Year, **when** moved to In Progress and then Done, **then** it visually appears in the correct columns and retains its planning bucket internally. **When** T is reopened from Done, **then** it returns to **In Progress** (the immediately prior visible column), not Within a Year. **When** a deadline passes, its column does not auto-change. Neither `Waiting` nor separate UI `Planning Horizon`/`Work Status` selectors appear. @@ -55,7 +59,7 @@ These scenarios define **observable behavior**. Use automated coverage for the m ### AC-12 — Places OR and resources semantics -**Given** manually selected current place Sandvreten and a place-compatibility filter, **then** a task with places `[Grankottevägen 30, Sandvreten]` matches; one with only Grankottevägen 30 does not; a task with no place matches everywhere. **Given** available resources include `Car` but not `Trailer`, a task requiring Car is feasible, one requiring both Car and Trailer is not, and one requiring neither is feasible. A `Requires Car` filter has different meaning from `Feasible with Car`. +**Given** automatically detected current place Sandvreten and a place-compatibility filter, **then** a task with places `[Grankottevägen 30, Sandvreten]` matches; one with only Grankottevägen 30 does not; a task with no place matches everywhere. **Given** available resources include `Car` but not `Trailer`, a task requiring Car is feasible, one requiring both Car and Trailer is not, and one requiring neither is feasible. A `Requires Car` filter has different meaning from `Feasible with Car`. ### AC-13 — Epic colors and lanes @@ -109,11 +113,11 @@ These scenarios define **observable behavior**. Use automated coverage for the m **Before** merging a release PR, type checking, linting, relevant behavior tests and builds pass. Focus tests on security isolation, inheritance, cycles, filtering, recurrence, conflict logic and persistence. There is **no required coverage percentage** and no requirement to automate every acceptance scenario as a distinct test. Nontrivial invariants are documented in understandable source comments. -## M2 / v1.1 — Smart Assistance - ### AC-26 — Automatic current place -With location permission granted and coordinates inside a configured place radius, Current Place is detected; a manual override is honored. Without permission, the app continues functioning with manual selection. Current location matching respects task-place OR semantics. No movement history is retained. +Opening the app leaves the browser permission prompt closed. Activating **At my current place** triggers it when needed. With permission granted and coordinates inside a configured radius, Current Place is detected for all views, search and filter previews. As the device moves, the matches update. Outside every configured radius, **At my current place** shows tasks that can be done anywhere. When permission is denied, location-dependent filters explain why their context is unavailable and other views and filters still work. The app retains no movement history. + +## M2 / v1.1 — Smart Assistance ### AC-27 — Notification relevance diff --git a/docs/implementation/delivery-stages.md b/docs/implementation/delivery-stages.md index 1994547..a95b96e 100644 --- a/docs/implementation/delivery-stages.md +++ b/docs/implementation/delivery-stages.md @@ -23,7 +23,7 @@ is not the M1 release gate; every remaining M1 requirement still applies. | **5 — priority 2** | Filter AST/builder/preview/history, quick bars, shared views, global ordering, Board interactions for available task model | 3 and Stage 7 sync/search foundations; Stage 4 integration below | Matching consistency, pagination, personal/shared state, accessible drag alternatives; household evaluation | 12–16, 21–23 where applicable | | 4 | Hierarchy, inheritance, effective dependency graph, availability, warnings; integration with existing filters/views/search/sync/Undo | 3, 7, 5 | Deep trees, inherited exclusions, graph races, independent actionable children; existing views/preview/search agree on effective values | 06–12 and hierarchy-dependent parts of 14–16, 20–22 | | 6 | Templates, recurrence, archive/Trash and safe worker jobs; integration with content/search/sync/Undo/settings | 4, 5, 7 | Clone/remap/retry, preserve instances, no parent archive with unfinished descendants, unresolved deleted blockers | 17–18, 20 and lifecycle-dependent parts of 19, 21–23 | -| 8 | Complete VP acceptance, usability/accessibility, backup/restore drill, release docs/images | All preceding stages | All M1 scenarios, fresh-host restoration, household review, no release blockers | 01–25 | +| 8 | Complete VP acceptance, usability/accessibility, backup/restore drill, release docs/images | All preceding stages | All M1 scenarios, fresh-host restoration, household review, no release blockers | 01–26 | ## Dependencies in the revised order diff --git a/docs/implementation/implementation-plan.md b/docs/implementation/implementation-plan.md index fee5fff..e3da8a6 100644 --- a/docs/implementation/implementation-plan.md +++ b/docs/implementation/implementation-plan.md @@ -14,8 +14,8 @@ Prioritize coherent core workflows (capture → plan → find actionable task | Milestone / indicative release | Outcome | Core distinction | |---|---|---| -| **M1 / 1.0.0 — Viable Product** | Family can replace its previous task planner | Complete baseline features, no push/GPS/cloud backup | -| **M2 / 1.1.0 — Smart Assistance** | Location-aware and proactive | Automatic geolocation, in-app and push notifications/reminders | +| **M1 / 1.0.0 — Viable Product** | Family can replace its previous task planner | Complete baseline features including automatic Current Place | +| **M2 / 1.1.0 — Smart Assistance** | Proactive reminders | In-app and push notifications/reminders | | **M3 / 1.2.0 — Stability & Usability** | Improved through real usage | Performance, reliability, measured UX fixes | | **M4 / 1.3.0 — Automated Backup & Recovery** | Integrated encrypted offsite recovery | Restic/Rclone, Google Drive + Dropbox, admin UI | @@ -33,18 +33,18 @@ Release numbers are indicative; patch releases may occur between milestones. M4 ### 3.2 Real task domain -- Tasks with six visible columns (Someday, Within a Year, Within a Month, To Do, In Progress, Done), one column control; separate internal status/planning bucket; restore immediate pre-Done column on reopen. +- Tasks with six column values (Someday, Within a Year, Within a Month, To Do, In Progress, Done), one column control, separate internal status/planning bucket and restoration of the immediate pre-Done column on reopen. - Full tasks/subtasks at unlimited depths, drag/menu reparenting, cycle checks, progress and independent completion, warned completion of unfinished parent. - Dynamic inheritance, including explicit none/false and **item-wise additions/exclusions** for places/resources/tags; inherited dependency blocking and explicit deadline/start overrides. - Epics (single/optional), globally sorted, curated light/dark colors and icons, configurable Board lanes, Unassigned and archive/delete semantics. -- Named places with manual current-location selection and optional stored coordinates/radius (automatic geolocation is **M2**), resources, tags, assignees, dates, boolean High, configurable XS–XL and optional exact estimate. +- Named places with optional coordinates and radius, automatic Current Place via browser geolocation, resources, tags, assignees, dates, boolean High, configurable XS–XL and optional exact estimate. - Finish-to-Start dependencies and Related to links, cycle protection, server-evaluated availability and blocked-start warnings. - Completion/reopen metadata, activity log, 30d completed auto-archive (only without unfinished descendants) and 30d soft-delete Trash with restore/permanent-delete role constraints. ### 3.3 Everyday UI: usable on phone and desktop - **Now** as landing view: actionable tasks from Within a Month/To Do/In Progress by default, plus view-scoped quick-filter bar. -- **Board**: all six columns, desktop drag/drop and epic lanes, mobile one-column-at-a-time navigation with swipe/select, expandable epic sections. +- **Board** groups the three planning horizons under Future by default, with a personal toggle per view to show all six columns. Desktop supports drag and drop and epic lanes. Mobile supports swipe, a column selector and expandable epic sections. - Additional shared Board/List views with base filter, configurable quick chips, personal favorites/toggles, card-metadata choices, sort and optional epic lanes/subtask-as-card mode. - **Advanced reusable filter builder is M1 core, not later polish:** nested AND/OR/NOT, dynamic values, safe effective-property evaluation, live preview, shared editing and restorable versions. - One-field title capture, contextual defaults, detailed inline task edits, autosave, focused Undo/Redo, conflict feedback and responsive task panels. @@ -86,8 +86,7 @@ and lifecycle/recurrence integration with content, sync, Undo and settings. Use same server domain resolvers throughout and preserve existing household data. See the delivery plan for dependencies and acceptance ownership. -M1 scope and the M2–M4 milestones are unchanged. **Stage 8 quality and integration -are mandatory**; completion of the two priority stages does not constitute M1 acceptance. +**Stage 8 quality and integration are mandatory** for M1 acceptance. ### 3.6 Definition of Done for M1 @@ -95,13 +94,12 @@ A fresh installer can deploy the versioned images behind HTTPS with persisted vo ## 4. M2 — Smart Assistance and notifications -- Browser Geolocation API for current place, configurable radius, permission management and manual override; do not record movement history. - In-app notification center + Web Push in supported browsers/installed PWAs. - Events: deadline approaching, overdue once by default, assignment, task becomes actionable, comment, @mention. - Per-user categories, default reminder 24h before deadline, additional per-task reminders, quiet hours with deferred delivery, no deadline reminders after Done. - Review actual use and simplify quick creation, filter access and task details without changing the approved domain model. -**M2 done when:** users can select/detect their current place and filter location-compatible tasks, reliably receive configured notifications in supported clients, and the notification flow is useful rather than noisy. Deliver with clear guidance about OS/browser push limitations. +**M2 done when:** users reliably receive configured notifications in supported clients and the notification flow is useful rather than noisy. Deliver with clear guidance about OS/browser push limitations. ## 5. M3 — Stability and usability from actual usage diff --git a/docs/product/product-specification.md b/docs/product/product-specification.md index ff0cfb0..fb63ca2 100644 --- a/docs/product/product-specification.md +++ b/docs/product/product-specification.md @@ -12,7 +12,7 @@ Two core questions drive the product: **What can I do now?** and **What do we ne The product is household-owned, not tied to a proprietary cloud service. It runs through Docker and is accessible over HTTPS; installation must remain portable across supported hosts. -**Release meaning:** Milestone 1 / v1.0 is a **viable product**, not a stripped-down MVP. The initial release must be usable for the household's real tasks. Geolocation automation, push notifications and cloud backup come in later releases; the implementation plan is authoritative about when features ship. +**Release meaning:** Milestone 1 / v1.0 is a **viable product**, not a stripped-down MVP. The initial release must be usable for the household's real tasks. Push notifications and cloud backup come in later releases. The implementation plan is authoritative about when features ship. ## 2. Accounts, households and roles @@ -30,7 +30,7 @@ The product is household-owned, not tied to a proprietary cloud service. It runs ### 3.1 One user-facing column -The task UI has **exactly six columns**, in this order: +The task's `Column` field has **exactly six values**, in this order: | Internal column identifier | English | Swedish | |---|---|---| @@ -43,7 +43,7 @@ The task UI has **exactly six columns**, in this order: No `Waiting` column, and no separate planning-horizon selector in the task UI. A column represents **intention**, not a literal date range: the system must not move cards between these columns merely because time passes or a deadline expires. -Internally `status` is `todo | in_progress | done` and, while `status=todo`, `planningBucket` selects `someday | within_year | within_month | ready` (`ready` renders as **To Do**). The planning bucket is retained even when work starts or completes. A completion transition remembers the **immediately preceding user-facing column**; reopening a completed task restores that column, normally **In Progress** if that is where it was just before completion. A deliberate direct move to another column supersedes automatic reopening. The UI always exposes a single `Column` field; filters use that same six-value abstraction. +Internally `status` is `todo | in_progress | done` and, while `status=todo`, `planningBucket` selects `someday | within_year | within_month | ready` (`ready` renders as **To Do**). The planning bucket is retained even when work starts or completes. A completion transition remembers the **exact preceding `Column` value**. Reopening a completed task restores that value, normally **In Progress** if that is where it was just before completion. A deliberate direct move to another column supersedes automatic reopening. The UI always exposes a single `Column` field. Filters use those same six values. ### 3.2 Task properties @@ -58,7 +58,7 @@ Each task has at least: required title; optional rich-text description; column; Availability is **derived**, not a manually controlled workflow state. A task is actionable when its effective earliest-start date is absent or reached **and** all its own and ancestor-inherited blocking dependencies are complete. An overridden earlier start date on a subtask may make it available before its parent's start date, unless a blocking dependency prevents it; parents do not impose status-based gating on descendants. A task can be manually moved to In Progress while blocked, but a warning is required; no automatic status changes occur when dependencies change. -A task's **place and required resources** are contextual filter criteria, not intrinsic blockers: a task can be actionable but irrelevant to the user's current location or available equipment. No GPS detection is needed in v1.0; the user can manually choose a current place. +A task's **place and required resources** are contextual filter criteria, not intrinsic blockers: a task can be actionable but irrelevant to the user's current location or available equipment. When browser permission is granted, the app detects Current Place automatically and uses it across views, search and filter previews. **Default Now view:** only tasks in `within_month`, `todo` or `in_progress` that are actionable and not trashed/archived. Other constraints (size, place, resources, assignees) come from saved quick filters. The base filter can be customized by users with normal view-edit permissions. @@ -89,7 +89,9 @@ When epic lanes are enabled in a Board: desktop shows collapsible horizontal swi ### Places -Places mean **specific usable locations**, e.g. `Grankottevägen 30`, `Sandvreten`, not categorical descriptions such as `Outdoor` (use a tag for Outdoor). A place has name, icon, color and optionally coordinates/radius. A task may match multiple places with **OR semantics**: it can be performed at any one of them. No place means anywhere. Users may manually select current place in v1; automatic geolocation is later. +Places mean **specific usable locations**, e.g. `Grankottevägen 30`, `Sandvreten`, not categorical descriptions such as `Outdoor` (use a tag for Outdoor). A place has name, icon, color and optional coordinates and radius. A task can be performed at any one of its listed places. A task with no place can be done anywhere. + +The app requests browser location permission when the user turns on **At my current place** or another filter that uses Current Place. A restored filter can reuse permission already granted by the browser. When the position is available, the browser compares it to the active household's configured place radii. If several places match, the one with the nearest centre supplies Current Place. Outside every configured radius, **At my current place** matches tasks that can be done anywhere. When location is unavailable, location-dependent filters explain the missing context. The app keeps coordinates in the browser and records no movement history. ### Resources @@ -138,13 +140,14 @@ The definition of each filter and the list of chips assigned to the view are sha Every household may have shared saved views with name, icon, color, creator, Board/List presentation, base filter, quick-filter bar contents, sort order, epic-lane mode, whether subtasks show as separate cards, and chosen visible card properties. Each user selects navigation favorites independently. -The built-in **Now** and **Board** views are customizable and resettable but not deletable. Board normally shows all six workflow columns, optionally narrowed by its base/quick filters. Manual ordering is shared globally across views. A saved view can configure manual order (default), deadline, priority, effort or creation date sorting. Do not group by place/assignee. +The built-in **Now** and **Board** views are customizable and resettable but not deletable. Board views default to **Future**, **To Do**, **In Progress** and **Done**. Future displays tasks from Someday, Within a Year and Within a Month together. The **Show separate future columns** option beside **View settings** restores the six-column layout and is saved per user and view across sessions. Both layouts use the same task column values, filters and view sort order. Manual ordering is shared globally across views. A saved view can configure manual order (default), deadline, priority, effort or creation date sorting. Do not group by place/assignee. Cards prioritize title, epic identity, high-priority badge when present, size (not precise minutes), deadline (if set), subtask progress and assignee chips/avatars. Other metadata is configurable per view or shown in details. No task-specific icon editor is required for v1; the epic icon is the primary card icon. ### Creating/editing tasks - One-field quick capture, global `+`, desktop shortcut `N`. When created without context, new tasks go to **Someday**; in a known column/epic lane, inherit that context. Creating from a filtered view may prefill *unambiguous* filter properties, but must not silently invent ambiguous ones. +- Adding a task in Future or dropping a card into Future from another board column uses **Someday**. Dragging between positions or epic lanes within Future preserves the task's exact column. The task's `Column` field and the separate board columns allow choosing an exact planning horizon. - Optional expanded creation for all task properties and immediate subtasks. - Desktop drag to reorder/change column/move epic, or drop onto another task to reparent with a clear affordance; mobile uses menus and long-press for appropriate local rearrangements. - Autosave for normal task editing, with discreet pending/error state. Support multi-step Undo/Redo where practical; Undo must not overwrite another user's concurrent changes. Filter building is an explicit Save/Cancel exception. @@ -176,9 +179,9 @@ Language follows browser/device locale initially; personal setting can override. The first release is self-hosted using Docker Compose and persistent PostgreSQL plus file storage; the full app works through HTTPS. Initial install includes secure passkeys, household roles, SMTP configuration, CLI manual PostgreSQL/file backup and documented restore. The app is an online-first installable PWA; full offline edits/sync are **future only**. -**Milestone 1 / v1.0:** all core task, hierarchy, availability, dependencies, epics, manual place selection, resources, tags, dates, estimates, filter/view builder, recurrence/templates, collaboration, rich text, attachments, search, admin/users/passkeys, localization, themes and everyday mobile/desktop UI. +**Milestone 1 / v1.0:** all core task, hierarchy, availability, dependencies, epics, automatic current place, resources, tags, dates, estimates, filter/view builder, recurrence/templates, collaboration, rich text, attachments, search, admin/users/passkeys, localization, themes and everyday mobile/desktop UI. -**Milestone 2 / v1.1:** automatic GPS-based current place, notification center, device push and personal deadline/event reminders, plus UX improvements. +**Milestone 2 / v1.1:** notification center, device push and personal deadline/event reminders, plus UX improvements. **Milestone 3 / v1.2:** measured performance and usability/reliability refinements from real use. @@ -191,7 +194,7 @@ Unscheduled future concepts (not commitments): offline modifications and conflic 1. **Parent with resources Car and Ladder:** child locally excludes Car. Parent later adds Trailer; child effectively requires Ladder and Trailer, not Car. 2. **Deadline:** parent due Oct 30; child explicitly due Nov 5. The system warns about the later deadline but allows it. Parent changing its own date does not change the child's explicit override. 3. **Dependency:** B depends on A; B is excluded by Now until A is completed (assuming other conditions pass); reopened A reblocks B without forcing any column changes. -4. **Current location:** with manually chosen Sandvreten and the corresponding place-compatibility filter, include tasks tagged Sandvreten or no place; exclude those tagged only Grankottevägen 30. A multi-place task matches any listed place. +4. **Current location.** With Sandvreten detected and **At my current place** active, include tasks with Sandvreten or no place. Exclude tasks whose only place is Grankottevägen 30. A multi-place task matches any listed place. 5. **Recurring chain:** a winterization template's `Drain pipes` depends on its `Turn off pump`. Next year's `Drain pipes` must depend on next year's `Turn off pump`, not last year's. 6. **Multiuser saved filter:** editing the shared filter definition changes every view that uses it, but does not reset anyone's individual on/off toggle state. diff --git a/packages/shared/openapi.json b/packages/shared/openapi.json index 057acd8..4c411eb 100644 --- a/packages/shared/openapi.json +++ b/packages/shared/openapi.json @@ -27081,43 +27081,25 @@ "format": "uuid", "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" } + }, + "splitFutureColumns": { + "type": "boolean" } }, "required": [ "version", "favorite", - "activeFilters" + "activeFilters", + "splitFutureColumns" ], "additionalProperties": false } - }, - "context": { - "type": "object", - "properties": { - "version": { - "type": "integer", - "minimum": -9007199254740991, - "maximum": 9007199254740991 - }, - "currentPlaceId": { - "nullable": true, - "type": "string", - "format": "uuid", - "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" - } - }, - "required": [ - "version", - "currentPlaceId" - ], - "additionalProperties": false } }, "required": [ "filters", "views", - "states", - "context" + "states" ], "additionalProperties": false } @@ -55130,6 +55112,9 @@ "format": "uuid", "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" } + }, + "splitFutureColumns": { + "type": "boolean" } }, "required": [ @@ -55184,275 +55169,16 @@ "format": "uuid", "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" } - } - }, - "required": [ - "version", - "favorite", - "activeFilters" - ], - "additionalProperties": false - } - } - } - }, - "400": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "401": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "403": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "404": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "409": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "413": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "415": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "429": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "500": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - }, - "503": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - }, - "required": [ - "error" - ], - "additionalProperties": false - } - } - } - } - } - } - }, - "/api/v1/households/{householdId}/view-context": { - "put": { - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "baseVersion": { - "type": "integer", - "minimum": 0, - "maximum": 9007199254740991 - }, - "currentPlaceId": { - "nullable": true, - "type": "string", - "format": "uuid", - "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" - } - }, - "required": [ - "baseVersion", - "currentPlaceId" - ] - } - } - } - }, - "parameters": [ - { - "schema": { - "type": "string", - "format": "uuid", - "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" - }, - "in": "path", - "name": "householdId", - "required": true - } - ], - "responses": { - "200": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "version": { - "type": "integer", - "minimum": -9007199254740991, - "maximum": 9007199254740991 }, - "currentPlaceId": { - "nullable": true, - "type": "string", - "format": "uuid", - "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" + "splitFutureColumns": { + "type": "boolean" } }, "required": [ "version", - "currentPlaceId" + "favorite", + "activeFilters", + "splitFutureColumns" ], "additionalProperties": false } @@ -55824,6 +55550,12 @@ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" } }, + "currentPlaceId": { + "nullable": true, + "type": "string", + "format": "uuid", + "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" + }, "offset": { "default": 0, "type": "integer", @@ -60331,6 +60063,12 @@ "format": "uuid", "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" } + }, + "currentPlaceId": { + "nullable": true, + "type": "string", + "format": "uuid", + "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" } }, "required": [ diff --git a/packages/shared/src/generated/api.ts b/packages/shared/src/generated/api.ts index 5cfe1dc..2c0cccf 100644 --- a/packages/shared/src/generated/api.ts +++ b/packages/shared/src/generated/api.ts @@ -6210,13 +6210,9 @@ export interface paths { version: number; favorite: boolean; activeFilters: string[]; + splitFutureColumns: boolean; }; }; - context: { - version: number; - /** Format: uuid */ - currentPlaceId: string | null; - }; }; }; }; @@ -7808,6 +7804,7 @@ export interface paths { baseVersion: number; favorite?: boolean; activeFilters?: string[]; + splitFutureColumns?: boolean; }; }; }; @@ -7822,165 +7819,7 @@ export interface paths { version: number; favorite: boolean; activeFilters: string[]; - }; - }; - }; - /** @description Default Response */ - 400: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 401: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 403: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 404: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 409: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 413: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 415: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 429: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 500: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - /** @description Default Response */ - 503: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - error: string; - }; - }; - }; - }; - }; - post?: never; - delete?: never; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; - "/api/v1/households/{householdId}/view-context": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - get?: never; - put: { - parameters: { - query?: never; - header?: never; - path: { - householdId: string; - }; - cookie?: never; - }; - requestBody: { - content: { - "application/json": { - baseVersion: number; - /** Format: uuid */ - currentPlaceId: string | null; - }; - }; - }; - responses: { - /** @description Default Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": { - version: number; - /** Format: uuid */ - currentPlaceId: string | null; + splitFutureColumns: boolean; }; }; }; @@ -8148,6 +7987,8 @@ export interface paths { }; }; filterIds?: string[]; + /** Format: uuid */ + currentPlaceId?: string | null; /** @default 0 */ offset?: number; /** @default 50 */ @@ -10405,6 +10246,8 @@ export interface paths { q: string; /** @default [] */ filterIds?: string[]; + /** Format: uuid */ + currentPlaceId?: string | null; }; }; }; diff --git a/packages/shared/src/views.ts b/packages/shared/src/views.ts index 0b31672..65f46e0 100644 --- a/packages/shared/src/views.ts +++ b/packages/shared/src/views.ts @@ -215,22 +215,19 @@ export const viewStateSchema = z.object({ version: z.number().int(), favorite: z.boolean(), activeFilters: z.array(z.uuid()), -}); -export const viewContextSchema = z.object({ - version: z.number().int(), - currentPlaceId: z.uuid().nullable(), + splitFutureColumns: z.boolean(), }); export const viewCatalogSchema = z.object({ filters: z.array(savedFilterSchema), views: z.array(savedViewSchema), states: z.record(z.uuid(), viewStateSchema), - context: viewContextSchema, }); export const taskQuerySchema = z.object({ viewId: z.uuid().optional(), replaceFilterId: z.uuid().optional(), expression: expressionSchema.optional(), filterIds: z.array(z.uuid()).max(50).optional(), + currentPlaceId: z.uuid().nullable().optional(), offset: z.number().int().min(0).max(100000).default(0), limit: z.number().int().min(1).max(100).default(50), }); diff --git a/tests/views.spec.ts b/tests/views.spec.ts index f2e0220..c07c111 100644 --- a/tests/views.spec.ts +++ b/tests/views.spec.ts @@ -130,6 +130,11 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes .filter({ hasText: `${run} board` }) .click(); await expect(page.getByRole('heading', { name: `${run} board`, exact: true })).toBeVisible(); + const header = page.locator('.view-title'); + await expect(header.getByRole('button', { name: 'View settings', exact: true })).toBeVisible(); + await expect(header.getByRole('checkbox', { name: 'Show separate future columns' })).toBeVisible(); + await expect(page.getByRole('combobox', { name: 'Current place', exact: true })).toHaveCount(0); + await expect(page.getByRole('heading', { name: 'Future 1', exact: true })).toBeVisible(); await expect(page.locator('.epic-lane>summary').last()).toContainText('Unassigned'); await page.getByRole('button', { name: `${run} ready`, exact: true }).click(); await expect(page.getByRole('link', { name: `${run} large`, exact: true })).toHaveCount(0); @@ -138,7 +143,6 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes // though its underlying view stays mounted. await page.getByRole('link', { name: `${run} small`, exact: true }).click(); await page.getByRole('button', { name: 'Back to tasks', exact: true }).click(); - await page.locator('.view-secondary>summary').click(); await page.getByRole('button', { name: 'View settings', exact: true }).click(); await page.getByLabel('View name', { exact: true }).fill('Unsaved view'); await page.goForward(); @@ -148,6 +152,12 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes await page.goBack(); await expect(page.getByRole('dialog')).toHaveCount(0); + const splitFuture = page.getByRole('checkbox', { name: 'Show separate future columns' }); + await expect(splitFuture).not.toBeChecked(); + await splitFuture.click(); + await expect(splitFuture).toBeChecked(); + await expect(page.getByRole('heading', { name: /^Future \d+$/ })).toHaveCount(0); + await expect(page.getByRole('heading', { name: /^Within a Month/ }).first()).toBeVisible(); await page.reload(); await page .getByRole('navigation', { name: 'Views', exact: true }) @@ -157,6 +167,7 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes 'aria-pressed', 'true', ); + await expect(page.getByRole('heading', { name: /^Within a Month/ }).first()).toBeVisible(); const mobile = await browser.newContext({ viewport: { width: 390, height: 844 }, locale: 'en-US', @@ -173,6 +184,7 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes 'false', ); await expect(member.getByRole('link', { name: `${run} large`, exact: true })).toBeVisible(); + await expect(member.getByRole('option', { name: 'Future (1)', exact: true })).toHaveCount(1); // Shared editing propagates, while the other member's toggle remains off. await page.getByRole('button', { name: `${run} ready`, exact: true }).focus(); await page.keyboard.press('Shift+F10'); @@ -232,7 +244,7 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes await md.getByRole('combobox', { name: 'Epic', exact: true }).selectOption(''); await md.getByRole('button', { name: 'Move task', exact: true }).click(); await expect(md).toHaveCount(0); - await member.getByRole('combobox', { name: 'Column', exact: true }).selectOption('within_month'); + await member.getByRole('combobox', { name: 'Column', exact: true }).selectOption('future'); await expect(member.getByRole('link', { name: `${run} small`, exact: true })).toBeVisible(); expect(await member.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe( true, @@ -250,14 +262,45 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes await dialog.getByLabel('What needs doing?', { exact: true }).fill(`${run} contextual`); await dialog.getByRole('button', { name: 'Add task', exact: true }).click(); await expect(lane.getByRole('link', { name: `${run} contextual`, exact: true })).toBeVisible(); + const year = await create('/tasks', { + title: `${run} year`, + column: 'within_year', + epicId: garden.id, + }); + await splitFuture.click(); + await expect(splitFuture).not.toBeChecked(); + const future = lane.locator('.board-column').filter({ + has: page.getByRole('heading', { name: 'Future 2', exact: true }), + }); + await expect(future.getByRole('link', { name: year.title, exact: true })).toBeVisible(); + await drag( + page, + future.getByRole('button', { name: `Move task · ${year.title}`, exact: true }), + future.getByRole('link', { name: `${run} contextual`, exact: true }), + ); + await expect(future.locator('.card-open').first()).toHaveText(year.title); + await drag( + page, + lane.getByRole('button', { name: `Move task · ${run} large`, exact: true }), + future.getByRole('link', { name: `${run} contextual`, exact: true }), + ); + await lane.getByRole('button', { name: 'Add task · Future', exact: true }).click(); + await dialog.getByLabel('What needs doing?', { exact: true }).fill(`${run} future capture`); + await dialog.getByRole('button', { name: 'Add task', exact: true }).click(); + await expect(lane.getByRole('link', { name: `${run} future capture`, exact: true })).toBeVisible(); const all = (await (await page.request.get(prefix + '/tasks?limit=100')).json()).items; expect(all.find((task: { title: string }) => task.title === `${run} contextual`)).toMatchObject({ column: 'within_month', epicId: garden.id, }); + expect(all.find((task: { id: string }) => task.id === year.id)?.column).toBe('within_year'); + expect(all.find((task: { title: string }) => task.title === `${run} large`)?.column).toBe('someday'); + expect(all.find((task: { title: string }) => task.title === `${run} future capture`)).toMatchObject({ + column: 'someday', + epicId: garden.id, + }); // Pace the next phase instead of relaxing the production account rate limit. await page.waitForTimeout(Math.max(0, 61000 - (Date.now() - started))); - if ((await page.locator('.view-secondary').getAttribute('open')) === null) await page.locator('.view-secondary>summary').click(); await page.getByRole('button', { name: 'View settings', exact: true }).click(); await dialog.getByRole('combobox', { name: 'Presentation', exact: true }).selectOption('list'); await dialog.getByRole('combobox', { name: 'Sorting', exact: true }).selectOption('effort'); @@ -301,3 +344,73 @@ test('shared nested filters and views, personal chips, preview, conflicts, lanes expect(browserErrors).toEqual([]); await mobile.close(); }); + +test('activating the location filter starts browser location across Board, Now and search', async ({ page, context }) => { + const homePosition = { latitude: 60.5, longitude: 18.3 }; + const workPosition = { latitude: 60.6, longitude: 18.3 }; + await context.grantPermissions(['geolocation']); + await context.setGeolocation(homePosition); + await context.addInitScript(() => { + const watch = navigator.geolocation.watchPosition.bind(navigator.geolocation); + let watchCount = 0; + navigator.geolocation.watchPosition = (...args) => { + document.documentElement.dataset.locationWatches = String(++watchCount); + return watch(...args); + }; + }); + await recover(context, page, 'owner@example.test'); + + const account = (await (await page.request.get('/api/v1/auth/session')).json()).account; + const prefix = `/api/v1/households/${account.households[0].id}`; + const headers = { origin: new URL(page.url()).origin }; + const run = 'GPS ' + Date.now().toString(36); + const create = async (path: string, data: unknown) => { + const response = await page.request.post(prefix + path, { headers, data }); + expect(response.ok(), await response.text()).toBe(true); + return response.json(); + }; + const home = await create('/entities', { name: `${run} home`, kind: 'place', radius: 100, ...homePosition }); + const work = await create('/entities', { name: `${run} work`, kind: 'place', radius: 100, ...workPosition }); + await create('/tasks', { title: `${run} at home`, column: 'todo', places: [home.id] }); + await create('/tasks', { title: `${run} at work`, column: 'todo', places: [work.id] }); + await create('/tasks', { title: `${run} anywhere`, column: 'todo' }); + + const chip = page.getByRole('button', { name: 'At my current place', exact: true }); + const task = (suffix: string) => page.getByRole('link', { name: `${run} ${suffix}`, exact: true }); + const entitiesLoaded = page.waitForResponse(response => response.url().endsWith('/entities')); + await page.goto('/?view=board'); + await entitiesLoaded; + await expect(chip).toHaveAttribute('aria-pressed', 'false'); + await expect(task('at work')).toBeVisible(); + await expect(page.locator('html')).not.toHaveAttribute('data-location-watches', /.+/); + await chip.click(); + await expect(page.locator('html')).toHaveAttribute('data-location-watches', '1'); + await expect(task('at home')).toBeVisible(); + await expect(task('anywhere')).toBeVisible(); + await expect(task('at work')).toHaveCount(0); + + await context.setGeolocation(workPosition); + await expect(task('at work')).toBeVisible(); + await expect(task('at home')).toHaveCount(0); + await page.reload(); + await expect(task('at work')).toBeVisible(); + await expect(page.locator('html')).toHaveAttribute('data-location-watches', '1'); + + await page.getByRole('navigation', { name: 'Tendly', exact: true }) + .getByRole('button', { name: 'Now', exact: true }).click(); + if (await chip.getAttribute('aria-pressed') === 'false') await chip.click(); + await expect(task('at work')).toBeVisible(); + await expect(task('at home')).toHaveCount(0); + + await page.goto('/?view=search'); + await page.getByRole('searchbox').fill(run); + await page.getByText('Filter tasks and their comments', { exact: true }).click(); + await page.getByRole('checkbox', { name: 'At my current place', exact: true }).check(); + const hits = page.locator('.search-results'); + await expect(hits.getByText(`${run} at work`, { exact: true })).toBeVisible(); + await expect(hits.getByText(`${run} at home`, { exact: true })).toHaveCount(0); + + await context.setGeolocation({ latitude: 61, longitude: 18.3 }); + await expect(hits.getByText(`${run} anywhere`, { exact: true })).toBeVisible(); + await expect(hits.getByText(`${run} at work`, { exact: true })).toHaveCount(0); +});