Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

Merge branch 'main' into feat/subtask-indentation

Juane65bbb7d09c2
diff --cc apps/docs/openapi.json
index b7fe63de9,454d08c9b..f1b1a8ee2
--- a/apps/docs/openapi.json
+++ b/apps/docs/openapi.json
@@@ -3268,67 -3284,2709 +3284,2709 @@@
},
"required": [
"id",
- "taskId",
- "fieldId",
- "value"
+ "projectId",
+ "chatId",
+ "threadId",
+ "chatLabel",
+ "botTokenConfigured",
+ "maskedBotToken",
+ "events",
+ "isActive",
+ "createdAt",
+ "updatedAt"
]
},
- "UserAvatar": {
++ "TaskRelation": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
- "url": {
++ "sourceTaskId": {
++ "type": "string"
++ },
++ "targetTaskId": {
++ "type": "string"
++ },
++ "relationType": {
+ "type": "string",
- "description": "Public URL for the stored avatar, served from /api/user/avatar/{id}."
++ "description": "How the two tasks relate: `subtask`, `blocks`, or `related`."
+ },
- "size": {
- "type": "number",
- "description": "Decoded size in bytes."
++ "createdAt": {
++ "type": "string",
++ "format": "date-time"
+ }
+ },
+ "required": [
+ "id",
- "url",
- "size"
++ "sourceTaskId",
++ "targetTaskId",
++ "relationType",
++ "createdAt"
+ ]
+ },
- "UserAvatarDeleted": {
- "type": "object",
- "properties": {
- "deleted": {
- "type": "boolean",
- "description": "False when the user had no uploaded avatar to remove."
+ "TaskRelationWithTasks": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/TaskRelation"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "sourceTask": {
+ "$ref": "#/components/schemas/RelatedTask"
+ },
+ "targetTask": {
+ "$ref": "#/components/schemas/RelatedTask"
+ }
+ },
+ "required": [
+ "sourceTask",
+ "targetTask"
+ ]
}
- },
- "required": [
- "deleted"
]
- }
- },
- "parameters": {}
- },
- "paths": {
- "/instance/status": {
- "get": {
- "operationId": "getInstanceStatus",
- "tags": [
- "Instance"
+ },
+ "RelatedTask": {
+ "type": [
+ "object",
+ "null"
],
- "summary": "Get instance status",
- "description": "Public instance setup status. When hasUsers is false the next signup becomes the instance admin.",
- "security": [],
- "responses": {
- "200": {
- "description": "Instance status",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/InstanceStatus"
- }
- }
- }
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "title": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "isCompleted": {
+ "type": "boolean",
+ "description": "Whether the task is in a final column of its own project."
+ },
+ "priority": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "number": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "projectId": {
+ "type": "string"
+ },
+ "userId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "assigneeName": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "title",
+ "status",
+ "isCompleted",
+ "priority",
+ "number",
+ "projectId",
+ "userId",
+ "assigneeName"
+ ]
+ },
- "TaskRelation": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string"
- },
- "sourceTaskId": {
- "type": "string"
- },
- "targetTaskId": {
- "type": "string"
- },
- "relationType": {
- "type": "string",
- "description": "How the two tasks relate: `subtask`, `blocks`, or `related`."
- },
- "createdAt": {
- "type": "string",
- "format": "date-time"
- }
- },
- "required": [
- "id",
- "sourceTaskId",
- "targetTaskId",
- "relationType",
- "createdAt"
- ]
- },
+ "CreatedExternalLink": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "taskId": {
+ "type": "string"
+ },
+ "integrationId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "resourceType": {
+ "type": "string",
+ "description": "The resource kind: `url` for a manual link, or an integration resource such as `issue` or `pull_request`."
+ },
+ "externalId": {
+ "type": "string",
+ "description": "The provider's resource identifier, or the URL for a manual link."
+ },
+ "url": {
+ "type": "string"
+ },
+ "title": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "metadata": {
+ "description": "Provider-specific payload, parsed from the stored JSON string. Null when the link has no metadata."
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "updatedAt": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ "required": [
+ "id",
+ "taskId",
+ "integrationId",
+ "resourceType",
+ "externalId",
+ "url",
+ "title",
+ "createdAt",
+ "updatedAt"
+ ]
+ },
+ "DeletedExternalLink": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id"
+ ]
+ },
+ "ExternalLink": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "taskId": {
+ "type": "string"
+ },
+ "integrationId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "resourceType": {
+ "type": "string",
+ "description": "The resource kind: `url` for a manual link, or an integration resource such as `issue` or `pull_request`."
+ },
+ "externalId": {
+ "type": "string",
+ "description": "The provider's resource identifier, or the URL for a manual link."
+ },
+ "url": {
+ "type": "string"
+ },
+ "title": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "metadata": {
+ "description": "Provider-specific payload, parsed from the stored JSON string. Null when the link has no metadata."
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "updatedAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "integration": {
+ "$ref": "#/components/schemas/ExternalLinkIntegration"
+ }
+ },
+ "required": [
+ "id",
+ "taskId",
+ "integrationId",
+ "resourceType",
+ "externalId",
+ "url",
+ "title",
+ "createdAt",
+ "updatedAt",
+ "integration"
+ ]
+ },
+ "ExternalLinkIntegration": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "type"
+ ]
+ },
+ "WorkflowRule": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "projectId": {
+ "type": "string"
+ },
+ "integrationType": {
+ "type": "string",
+ "description": "The integration that emits the event, e.g. `github`."
+ },
+ "eventType": {
+ "type": "string",
+ "description": "The provider event that triggers the move, e.g. `pull_request.opened`."
+ },
+ "columnId": {
+ "type": "string",
+ "description": "The column tasks are moved to when the event fires."
+ },
+ "columnName": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "columnSlug": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "updatedAt": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ "required": [
+ "id",
+ "projectId",
+ "integrationType",
+ "eventType",
+ "columnId",
+ "columnName",
+ "columnSlug",
+ "createdAt",
+ "updatedAt"
+ ]
+ },
+ "WorkflowRuleRow": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "projectId": {
+ "type": "string"
+ },
+ "integrationType": {
+ "type": "string"
+ },
+ "eventType": {
+ "type": "string"
+ },
+ "columnId": {
+ "type": "string"
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "updatedAt": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ "required": [
+ "id",
+ "projectId",
+ "integrationType",
+ "eventType",
+ "columnId",
+ "createdAt",
+ "updatedAt"
+ ]
+ },
+ "PendingInvitation": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "workspaceId": {
+ "type": "string"
+ },
+ "workspaceName": {
+ "type": "string"
+ },
+ "inviterName": {
+ "type": "string"
+ },
+ "expiresAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "status": {
+ "type": "string",
+ "description": "Always `pending` here; expired and accepted ones are filtered out."
+ }
+ },
+ "required": [
+ "id",
+ "email",
+ "workspaceId",
+ "workspaceName",
+ "inviterName",
+ "expiresAt",
+ "createdAt",
+ "status"
+ ]
+ },
+ "InvitationDetails": {
+ "type": "object",
+ "properties": {
+ "valid": {
+ "type": "boolean",
+ "description": "True only when the invitation can still be accepted."
+ },
+ "invitation": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "workspaceName": {
+ "type": "string"
+ },
+ "inviterName": {
+ "type": "string"
+ },
+ "expiresAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "status": {
+ "type": "string"
+ },
+ "expired": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "id",
+ "email",
+ "workspaceName",
+ "inviterName",
+ "expiresAt",
+ "status",
+ "expired"
+ ],
+ "description": "Omitted when the invitation does not exist, was already accepted, or was canceled -- the details are withheld rather than leaked."
+ },
+ "error": {
+ "type": "string",
+ "description": "Why the invitation is unusable, when valid is false."
+ }
+ },
+ "required": [
+ "valid"
+ ]
+ },
+ "WorkspaceMember": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "image": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "role": {
+ "type": "string",
+ "description": "The member's workspace role: a built-in role (owner, admin, member, guest) or a custom role name."
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "email",
+ "image",
+ "role"
+ ]
+ },
+ "CustomFieldDefinition": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "projectId": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "required": {
+ "type": "boolean"
+ },
+ "defaultValue": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "options": {},
+ "position": {
+ "type": "number"
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "updatedAt": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ "required": [
+ "id",
+ "projectId",
+ "name",
+ "type",
+ "required",
+ "defaultValue",
+ "position",
+ "createdAt",
+ "updatedAt"
+ ]
+ },
+ "CustomFieldValue": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "taskId": {
+ "type": "string"
+ },
+ "fieldId": {
+ "type": "string"
+ },
+ "value": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "fieldName": {
+ "type": "string"
+ },
+ "fieldPosition": {
+ "type": "number"
+ },
+ "fieldType": {
+ "type": "string"
+ },
+ "fieldOptions": {}
+ },
+ "required": [
+ "id",
+ "taskId",
+ "fieldId",
+ "value",
+ "fieldName",
+ "fieldPosition",
+ "fieldType"
+ ]
+ },
+ "CustomFieldFilterValues": {
+ "type": "object",
+ "properties": {
+ "fieldId": {
+ "type": "string"
+ },
+ "fieldName": {
+ "type": "string"
+ },
+ "fieldType": {
+ "type": "string"
+ },
+ "values": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "fieldId",
+ "fieldName",
+ "fieldType",
+ "values"
+ ]
+ },
+ "ReorderCustomFieldsResponse": {},
+ "SetCustomFieldValueResponse": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "taskId": {
+ "type": "string"
+ },
+ "fieldId": {
+ "type": "string"
+ },
+ "value": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "taskId",
+ "fieldId",
+ "value"
+ ]
+ },
+ "CurrentUser": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "image": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "role": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "email",
+ "image",
+ "role"
+ ]
+ },
+ "UserAvatar": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string",
+ "description": "Public URL for the stored avatar, served from /api/user/avatar/{id}."
+ },
+ "size": {
+ "type": "number",
+ "description": "Decoded size in bytes."
+ }
+ },
+ "required": [
+ "id",
+ "url",
+ "size"
+ ]
+ },
+ "UserAvatarDeleted": {
+ "type": "object",
+ "properties": {
+ "deleted": {
+ "type": "boolean",
+ "description": "False when the user had no uploaded avatar to remove."
+ }
+ },
+ "required": [
+ "deleted"
+ ]
+ },
+ "AdminUserList": {
+ "type": "object",
+ "properties": {
+ "users": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/AdminUser"
+ }
+ },
+ "total": {
+ "type": "integer",
+ "description": "Number of users matching the search, across all pages."
+ }
+ },
+ "required": [
+ "users",
+ "total"
+ ]
+ },
+ "AdminUser": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "emailVerified": {
+ "type": "boolean"
+ },
+ "image": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "updatedAt": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "role": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "banned": {
+ "type": "boolean"
+ },
+ "banReason": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "banExpires": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "format": "date-time"
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "email",
+ "emailVerified",
+ "image",
+ "createdAt",
+ "updatedAt",
+ "role",
+ "banned",
+ "banReason",
+ "banExpires"
+ ]
+ }
+ },
+ "parameters": {}
+ },
+ "paths": {
+ "/instance/status": {
+ "get": {
+ "operationId": "getInstanceStatus",
+ "tags": [
+ "Instance"
+ ],
+ "summary": "Get instance status",
+ "description": "Public instance setup status. When hasUsers is false the next signup becomes the instance admin.",
+ "security": [],
+ "responses": {
+ "200": {
+ "description": "Instance status",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InstanceStatus"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/public-project/{id}": {
+ "get": {
+ "operationId": "getPublicProject",
+ "tags": [
+ "Projects"
+ ],
+ "summary": "Get a public project board",
+ "description": "Read a public board in bounded task pages. Visibility is checked before loading tasks. Continue through pagination.totalPages for all tasks and through relatedPage/pagination.relatedTotalPages for their complete related records.",
+ "security": [],
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "id",
+ "in": "path"
+ },
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": false,
+ "name": "status",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": false,
+ "name": "priority",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": false,
+ "name": "assigneeId",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 1000000
+ },
+ "required": false,
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 1000000
+ },
+ "required": false,
+ "name": "relatedPage",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 100
+ },
+ "required": false,
+ "name": "limit",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string",
+ "enum": [
+ "createdAt",
+ "priority",
+ "dueDate",
+ "position",
+ "title",
+ "number"
+ ]
+ },
+ "required": false,
+ "name": "sortBy",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string",
+ "enum": [
+ "asc",
+ "desc"
+ ]
+ },
+ "required": false,
+ "name": "sortOrder",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": false,
+ "name": "dueBefore",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": false,
+ "name": "dueAfter",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "A public board page",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PublicBoardPage"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid pagination or filters",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "Project is not public",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Project not found",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "Task list request timed out",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/public-project/{id}/description": {
+ "get": {
+ "operationId": "getPublicProjectDescriptionPage",
+ "tags": [
+ "Projects"
+ ],
+ "summary": "Read a public project description page",
+ "security": [],
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "id",
+ "in": "path"
+ },
+ {
+ "schema": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 2000000000,
+ "default": 0
+ },
+ "required": false,
+ "name": "offset",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string",
+ "pattern": "^[0-9]{1,10}$"
+ },
+ "required": false,
+ "name": "version",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Public project description page",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TaskDescriptionPage"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid description cursor",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Public project not found",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "Description changed or no longer public",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "Description request timed out",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/public-project/{id}/task/{taskId}/description": {
+ "get": {
+ "operationId": "getPublicTaskDescriptionPage",
+ "tags": [
+ "Projects"
+ ],
+ "summary": "Read a public task description page",
+ "security": [],
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "id",
+ "in": "path"
+ },
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "taskId",
+ "in": "path"
+ },
+ {
+ "schema": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 2000000000,
+ "default": 0
+ },
+ "required": false,
+ "name": "offset",
+ "in": "query"
+ },
+ {
+ "schema": {
+ "type": "string",
+ "pattern": "^[0-9]{1,10}$"
+ },
+ "required": false,
+ "name": "version",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Public task description page",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TaskDescriptionPage"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid description cursor",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Public task not found",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "Description changed or no longer public",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "Description request timed out",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/calendar-feed/{token}/calendar.ics": {
+ "get": {
+ "operationId": "getCalendarFeed",
+ "tags": [
+ "Calendar feeds"
+ ],
+ "summary": "Subscribe to a calendar feed",
+ "description": "Read scheduled project tasks using a secret calendar feed link. Anyone with the link can read matching task titles, descriptions, and dates. Responses are streamed; descriptions longer than 4096 characters and titles or calendar names longer than 1024 characters are truncated with an ellipsis.",
+ "security": [],
+ "parameters": [
+ {
+ "schema": {
+ "type": "string",
+ "pattern": "^[a-f0-9]{64}$"
+ },
+ "required": true,
+ "name": "token",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "iCalendar feed",
+ "content": {
+ "text/calendar": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid feed token",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Calendar feed not found or revoked",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/auth/get-session": {
+ "get": {
+ "operationId": "getSession",
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "Get session",
+ "description": "Get the current authenticated session, or null when the caller is not signed in. Served by Better Auth.",
+ "security": [],
+ "responses": {
+ "200": {
+ "description": "Current session details, or null when unauthenticated"
+ }
+ }
+ }
+ },
+ "/asset/{id}": {
+ "get": {
+ "operationId": "getAsset",
+ "tags": [
+ "Assets"
+ ],
+ "summary": "Download asset",
+ "description": "Download an uploaded asset. Readable without signing in only when it belongs to a public project; image types are served inline, everything else as an attachment.",
+ "security": [],
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "id",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "The requested asset binary stream",
+ "content": {
+ "*/*": {
+ "schema": {
+ "type": "string",
+ "format": "binary"
+ }
+ }
+ }
+ },
+ "304": {
+ "description": "Not modified"
+ },
+ "403": {
+ "description": "No access to this asset"
+ },
+ "404": {
+ "description": "Asset not found"
+ }
+ }
+ }
+ },
+ "/user/avatar/{id}": {
+ "get": {
+ "operationId": "getUserAvatar",
+ "tags": [
+ "User"
+ ],
+ "summary": "Download avatar",
+ "description": "Download a user avatar by its avatar ID. Public, immutable, and cache-friendly: the id changes whenever the avatar is replaced.",
+ "security": [],
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "id",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "The avatar image",
+ "content": {
+ "image/*": {
+ "schema": {
+ "type": "string",
+ "format": "binary"
+ }
+ }
+ }
+ },
+ "304": {
+ "description": "Not modified"
+ },
+ "404": {
+ "description": "Avatar not found"
+ }
+ }
+ }
+ },
+ "/config": {
+ "get": {
+ "operationId": "getConfig",
+ "tags": [
+ "Config"
+ ],
+ "summary": "Get config",
+ "description": "Public instance settings: which sign-in methods, registration paths, and features are enabled.",
+ "security": [],
+ "responses": {
+ "200": {
+ "description": "Application settings",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Config"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/auth/organization/accept-invitation": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "acceptOrganizationInvitation",
+ "summary": "Accept Organization Invitation",
+ "description": "Accept an invitation to an organization",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "invitationId": {
+ "type": "string",
+ "description": "The ID of the invitation to accept"
+ }
+ },
+ "required": [
+ "invitationId"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "invitation": {
+ "type": "object",
+ "additionalProperties": {}
+ },
+ "member": {
+ "type": "object",
+ "additionalProperties": {}
+ }
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/add-team-member": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "addOrganizationTeamMember",
+ "summary": "Add Organization Team Member",
+ "description": "The newly created member",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "teamId": {
+ "type": "string",
+ "description": "The team the user should be a member of."
+ },
+ "userId": {
+ "type": "string",
+ "description": "The user Id which represents the user to be added as a member."
+ },
+ "organizationId": {
+ "type": "string",
+ "description": "The organization ID which the team falls under. If not provided, it will default to the user's active organization."
+ }
+ },
+ "required": [
+ "teamId",
+ "userId"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "Unique identifier of the team member"
+ },
+ "userId": {
+ "type": "string",
+ "description": "The user ID of the team member"
+ },
+ "teamId": {
+ "type": "string",
+ "description": "The team ID of the team the team member is in"
+ },
+ "createdAt": {
+ "type": "string",
+ "description": "Timestamp when the team member was created"
+ }
+ },
+ "required": [
+ "id",
+ "userId",
+ "teamId",
+ "createdAt"
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/cancel-invitation": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "cancelOrganizationInvitation",
+ "summary": "Cancel Organization Invitation",
+ "description": "Cancel Organization Invitation",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "invitationId": {
+ "type": "string",
+ "description": "The ID of the invitation to cancel"
+ }
+ },
+ "required": [
+ "invitationId"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/check-slug": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "checkOrganizationSlug",
+ "summary": "Check Organization Slug",
+ "description": "Check Organization Slug",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "slug": {
+ "type": "string",
+ "description": "The organization slug to check. Eg: \"my-org\""
+ }
+ },
+ "required": [
+ "slug"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/create": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "createOrganization",
+ "summary": "Create Organization",
+ "description": "Create an organization",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The name of the organization"
+ },
+ "slug": {
+ "type": "string",
+ "description": "The slug of the organization"
+ },
+ "userId": {
+ "type": "string",
+ "description": "The user id of the organization creator. If not provided, the current user will be used. Should only be used by admins or when called by the server. server-only. Eg: \"user-id\""
+ },
+ "logo": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "The logo of the organization"
+ },
+ "metadata": {
+ "type": "object",
+ "additionalProperties": {},
+ "description": "The metadata of the organization"
+ },
+ "keepCurrentActiveOrganization": {
+ "type": "boolean",
+ "description": "Whether to keep the current active organization active after creating a new one. Eg: true"
+ },
+ "description": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "name",
+ "slug"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {}
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/create-role": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "createOrganizationRole",
+ "summary": "Create Organization Role",
+ "description": "Create Organization Role",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "organizationId": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string",
+ "description": "The name of the role to create"
+ },
+ "permission": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "description": "The permission to assign to the role"
+ },
+ "additionalFields": {
+ "type": "object",
+ "additionalProperties": {}
+ }
+ },
+ "required": [
+ "role",
+ "permission"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/create-team": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "createOrganizationTeam",
+ "summary": "Create Organization Team",
+ "description": "Create a new team within an organization",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The name of the team. Eg: \"my-team\""
+ },
+ "organizationId": {
+ "type": "string",
+ "description": "The organization ID which the team will be created in. Defaults to the active organization. Eg: \"organization-id\""
+ }
+ },
+ "required": [
+ "name"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "Unique identifier of the created team"
+ },
+ "name": {
+ "type": "string",
+ "description": "Name of the team"
+ },
+ "organizationId": {
+ "type": "string",
+ "description": "ID of the organization the team belongs to"
+ },
+ "createdAt": {
+ "type": "string",
+ "description": "Timestamp when the team was created"
+ },
+ "updatedAt": {
+ "type": "string",
+ "description": "Timestamp when the team was last updated"
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "organizationId",
+ "createdAt",
+ "updatedAt"
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/delete": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "deleteOrganization",
+ "summary": "Delete Organization",
+ "description": "Delete an organization",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "organizationId": {
+ "type": "string",
+ "description": "The organization id to delete"
+ }
+ },
+ "required": [
+ "organizationId"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/delete-role": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "deleteOrganizationRole",
+ "summary": "Delete Organization Role",
+ "description": "Delete Organization Role",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "allOf": [
+ {
+ "type": "object",
+ "properties": {
+ "organizationId": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "roleName": {
+ "type": "string",
+ "description": "The name of the role to delete"
+ }
+ },
+ "required": [
+ "roleName"
+ ]
+ },
+ {
+ "type": "object",
+ "properties": {
+ "roleId": {
+ "type": "string",
+ "description": "The id of the role to delete"
+ }
+ },
+ "required": [
+ "roleId"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/get-active-member": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "getOrganizationActiveMember",
+ "summary": "Get Organization Active Member",
+ "description": "Get the member details of the active organization",
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "userId": {
+ "type": "string"
+ },
+ "organizationId": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "userId",
+ "organizationId",
+ "role"
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/get-active-member-role": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "getOrganizationActiveMemberRole",
+ "summary": "Get Organization Active Member Role",
+ "description": "Get Organization Active Member Role",
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/get-full-organization": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "getOrganizationFullOrganization",
+ "summary": "Get Organization Full Organization",
+ "description": "Get the full organization",
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {}
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/get-invitation": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "getOrganizationInvitation",
+ "summary": "Get Organization Invitation",
+ "description": "Get an invitation by ID",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "id",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string"
+ },
+ "organizationId": {
+ "type": "string"
+ },
+ "inviterId": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "expiresAt": {
+ "type": "string"
+ },
+ "organizationName": {
+ "type": "string"
+ },
+ "organizationSlug": {
+ "type": "string"
+ },
+ "inviterEmail": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "email",
+ "role",
+ "organizationId",
+ "inviterId",
+ "status",
+ "expiresAt",
+ "organizationName",
+ "organizationSlug",
+ "inviterEmail"
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/get-role": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "getOrganizationRole",
+ "summary": "Get Organization Role",
+ "description": "Get Organization Role",
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/has-permission": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "hasOrganizationPermission",
+ "summary": "Check Organization Permission",
+ "description": "Check if the user has permission",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "permission": {
+ "type": "object",
+ "additionalProperties": {},
+ "description": "The permission to check"
+ },
+ "permissions": {
+ "type": "object",
+ "additionalProperties": {},
+ "description": "The permission to check"
+ }
+ },
+ "required": [
+ "permissions"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "error": {
+ "type": "string"
+ },
+ "success": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "success"
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/invite-member": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "inviteOrganizationMember",
+ "summary": "Invite Organization Member",
+ "description": "Create or resend an invitation. Email delivery failures return 502; the invitation remains pending and can be resent after correcting SMTP settings.",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "email": {
+ "type": "string",
+ "description": "The email address of the user to invite"
+ },
+ "role": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ ],
+ "description": "The role(s) to assign to the user. It can be `admin`, `member`, owner. Eg: \"member\""
+ },
+ "organizationId": {
+ "type": "string",
+ "description": "The organization ID to invite the user to"
+ },
+ "resend": {
+ "type": "boolean",
+ "description": "Resend the invitation email, if the user is already invited. Eg: true"
+ },
+ "teamId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ ]
+ }
+ },
+ "required": [
+ "email",
+ "role"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string"
+ },
+ "organizationId": {
+ "type": "string"
+ },
+ "inviterId": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "expiresAt": {
+ "type": "string"
+ },
+ "createdAt": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "email",
+ "role",
+ "organizationId",
+ "inviterId",
+ "status",
+ "expiresAt",
+ "createdAt"
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ },
+ "502": {
+ "description": "Invitation saved, but email delivery failed",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "string",
+ "enum": [
+ "INVITATION_EMAIL_FAILED"
+ ]
+ },
+ "message": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "message"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/auth/organization/leave": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "leaveOrganization",
+ "summary": "Leave Organization",
+ "description": "Leave Organization",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "organizationId": {
+ "type": "string",
+ "description": "The organization Id for the member to leave. Eg: \"organization-id\""
+ }
+ },
+ "required": [
+ "organizationId"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganization",
+ "summary": "List Organization",
+ "description": "List all organizations",
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {}
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list-invitations": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganizationInvitations",
+ "summary": "List Organization Invitations",
+ "description": "List Organization Invitations",
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list-members": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganizationMembers",
+ "summary": "List Organization Members",
+ "description": "List Organization Members",
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list-roles": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganizationRoles",
+ "summary": "List Organization Roles",
+ "description": "List Organization Roles",
+ "responses": {
+ "200": {
+ "description": "Success"
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list-team-members": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganizationTeamMembers",
+ "summary": "List Organization Team Members",
+ "description": "List the members of the given team.",
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "Unique identifier of the team member"
+ },
+ "userId": {
+ "type": "string",
+ "description": "The user ID of the team member"
+ },
+ "teamId": {
+ "type": "string",
+ "description": "The team ID of the team the team member is in"
+ },
+ "createdAt": {
+ "type": "string",
+ "description": "Timestamp when the team member was created"
+ }
+ },
+ "required": [
+ "id",
+ "userId",
+ "teamId",
+ "createdAt"
+ ]
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list-teams": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganizationTeams",
+ "summary": "List Organization Teams",
+ "description": "List all teams in an organization",
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "Unique identifier of the team"
+ },
+ "name": {
+ "type": "string",
+ "description": "Name of the team"
+ },
+ "organizationId": {
+ "type": "string",
+ "description": "ID of the organization the team belongs to"
+ },
+ "createdAt": {
+ "type": "string",
+ "description": "Timestamp when the team was created"
+ },
+ "updatedAt": {
+ "type": "string",
+ "description": "Timestamp when the team was last updated"
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "organizationId",
+ "createdAt",
+ "updatedAt"
+ ]
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list-user-invitations": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganizationUserInvitations",
+ "summary": "List Organization User Invitations",
+ "description": "List all invitations a user has received",
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string"
+ },
+ "organizationId": {
+ "type": "string"
+ },
+ "organizationName": {
+ "type": "string"
+ },
+ "inviterId": {
+ "type": "string",
+ "description": "The ID of the user who created the invitation"
+ },
+ "teamId": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "The ID of the team associated with the invitation"
+ },
+ "status": {
+ "type": "string"
+ },
+ "expiresAt": {
+ "type": "string"
+ },
+ "createdAt": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "email",
+ "role",
+ "organizationId",
+ "organizationName",
+ "inviterId",
+ "status",
+ "expiresAt",
+ "createdAt"
+ ]
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/list-user-teams": {
+ "get": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "listOrganizationUserTeams",
+ "summary": "List Organization User Teams",
+ "description": "List all teams that the current user is a part of.",
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {}
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/reject-invitation": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "rejectOrganizationInvitation",
+ "summary": "Reject Organization Invitation",
+ "description": "Reject an invitation to an organization",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "invitationId": {
+ "type": "string",
+ "description": "The ID of the invitation to reject"
+ }
+ },
+ "required": [
+ "invitationId"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "invitation": {
+ "type": "object",
+ "additionalProperties": {}
+ },
+ "member": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "additionalProperties": {}
+ }
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ }
+ }
+ }
+ },
+ "/auth/organization/remove-member": {
+ "post": {
+ "tags": [
+ "Organization Management"
+ ],
+ "operationId": "removeOrganizationMember",
+ "summary": "Remove Organization Member",
+ "description": "Remove a member from an organization",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "memberIdOrEmail": {
+ "type": "string",
+ "description": "The ID or email of the member to remove"
+ },
+ "organizationId": {
+ "type": "string",
+ "description": "The ID of the organization to remove the member from. If not provided, the active organization will be used. Eg: \"org-id\""
+ }
+ },
+ "required": [
+ "memberIdOrEmail"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "member": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "userId": {
+ "type": "string"
+ },
+ "organizationId": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "userId",
+ "organizationId",
+ "role"
+ ]
+ }
+ },
+ "required": [
+ "member"
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
}
}
}
diff --cc apps/web/src/components/list-view/column-section.tsx
index c3ce8adb0,000000000..ff5bde0ab
mode 100644,000000..100644
--- a/apps/web/src/components/list-view/column-section.tsx
+++ b/apps/web/src/components/list-view/column-section.tsx
@@@ -1,186 -1,0 +1,189 @@@
+import { type UniqueIdentifier, useDroppable } from "@dnd-kit/core";
+import {
+ SortableContext,
+ verticalListSortingStrategy,
+} from "@dnd-kit/sortable";
+import { AnimatePresence, motion } from "framer-motion";
+import { Archive, ChevronRight, Plus } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { cn } from "@/lib/cn";
+import { getColumnIcon } from "@/lib/column";
+import { flattenSubtaskRows } from "@/lib/subtask-tree";
+import type { ProjectWithTasks } from "@/types/project";
+import TaskRow from "./task-row";
+
+type Column = ProjectWithTasks["columns"][number];
+
+type ColumnSectionProps = {
+ column: Column;
+ projectSlug: string;
+ activeId: UniqueIdentifier | null;
+ overColumnId: string | null;
+ isExpanded: boolean;
+ expandedTasks: Record<string, boolean>;
+ subtaskChildren: Map<string, string[]>;
+ tasksById: Map<string, Column["tasks"][number]>;
+ relationsLoading: boolean;
++ disableCollectionActions: boolean;
+ toggleSection: (columnId: string) => void;
+ toggleTaskExpanded: (rowId: string) => void;
+ onAddTask: (columnId: string) => void;
+ handleArchiveClick: (column: Column) => void;
+};
+
+// Keep the component identity stable so list updates preserve focus and drag state.
+export default function ColumnSection({
+ column,
+ projectSlug,
+ activeId,
+ overColumnId,
+ isExpanded,
+ expandedTasks,
+ subtaskChildren,
+ tasksById,
+ relationsLoading,
++ disableCollectionActions,
+ toggleSection,
+ toggleTaskExpanded,
+ onAddTask,
+ handleArchiveClick,
+}: ColumnSectionProps) {
+ const { t } = useTranslation();
+ const { setNodeRef } = useDroppable({
+ id: column.id,
+ data: {
+ type: "column",
+ column,
+ },
+ });
+
+ const showDropIndicator = activeId && overColumnId === column.id;
+
+ // A dragged parent collapses for the duration: moving a row while its
+ // children are rendered beneath it has no single correct outcome, and
+ // hiding them keeps the drag to the one row the user grabbed.
+ // Reserving the toggle column on every row keeps the titles aligned, but
+ // only where the group actually has subtasks; a project without any keeps
+ // the original left edge.
+ const rows = flattenSubtaskRows({
+ tasks: column.tasks,
+ children: subtaskChildren,
+ tasksById,
+ // Nothing stays expanded while a drag is in flight. Nested repeats are
+ // not in the SortableContext, so they never receive the transforms
+ // applied to the top-level rows: dragging any task past an expanded
+ // parent would slide the parent while its children stayed put, and the
+ // subtree would visibly split. Collapsing happens once, as the drag
+ // starts, rather than shifting rows under a moving pointer.
+ isExpanded: (rowId) => !activeId && Boolean(expandedTasks[rowId]),
+ });
+
+ // Until the relations arrive, every task looks childless. Holding the
+ // toggle column open means the chevrons appear in place instead of
+ // shifting every title sideways, and aria-busy below says the region is
+ // still resolving rather than settled and flat.
+ const groupHasSubtasks =
+ relationsLoading || rows.some((row) => row.childCount > 0 || row.depth > 0);
+
+ return (
+ <div
+ className={cn(
+ "border-b border-border/50 transition-colors duration-150 overflow-auto",
+ showDropIndicator && "border-l-4 border-l-ring bg-accent/35",
+ )}
+ >
+ <div className="flex items-center justify-between py-2 px-4 bg-muted/60 border-b border-border/50">
+ <button
+ type="button"
+ onClick={() => toggleSection(column.id)}
+ className="flex items-center gap-2 text-sm font-medium text-foreground hover:text-foreground transition-colors"
+ >
+ <ChevronRight
+ className={cn(
+ "w-3 h-3 transition-transform",
+ isExpanded && "rotate-90",
+ )}
+ />
+ <div className="flex items-center gap-2 h-4">
+ {getColumnIcon(column.id, column.isFinal, column.icon)}
+ <div className="flex items-center gap-1">
+ <span className="mt-1 mr-1">{column.name}</span>
+ <span className="text-xs text-muted-foreground mt-0.5">
+ {column.tasks.length}
+ </span>
+ </div>
+ </div>
+ </button>
+
+ <div className="flex items-center gap-1">
+ <button
+ type="button"
+ onClick={() => {
+ onAddTask(column.id);
+ }}
+ className="p-1 hover:bg-accent rounded text-muted-foreground hover:text-foreground transition-colors"
+ title={t("tasks:listView.addTask")}
+ >
+ <Plus className="w-3 h-3" />
+ </button>
+
+ {column.isFinal && column.tasks.length > 0 && (
+ <button
+ type="button"
++ disabled={disableCollectionActions}
+ onClick={() => handleArchiveClick(column)}
+ className="p-1 hover:bg-accent rounded text-muted-foreground hover:text-foreground transition-colors"
+ title={t("tasks:listView.archiveAllTooltip")}
+ >
+ <Archive className="w-3 h-3" />
+ </button>
+ )}
+ </div>
+ </div>
+
+ {isExpanded && (
+ <div
+ ref={setNodeRef}
+ className="bg-card transition-[translate,opacity] duration-150 ease-out starting:-translate-y-1 starting:opacity-0 motion-reduce:starting:translate-y-0"
+ >
+ {/* Only the top-level rows are sortable; the nested repeats share
+ their task id with one of them. */}
+ <SortableContext
+ items={column.tasks}
+ strategy={verticalListSortingStrategy}
+ >
+ <AnimatePresence initial={false} mode="popLayout">
+ {rows.map((row) => (
+ <motion.div
+ key={row.rowId}
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.15, ease: [0.23, 1, 0.32, 1] }}
+ >
+ <TaskRow
+ task={row.task}
+ projectSlug={projectSlug}
+ reserveToggleSpace={groupHasSubtasks}
+ isTaskDragging={activeId === row.task.id}
+ depth={row.depth}
+ rowId={row.rowId}
+ childCount={row.childCount}
+ isExpanded={row.isExpanded}
+ onToggleExpanded={() => toggleTaskExpanded(row.rowId)}
+ />
+ </motion.div>
+ ))}
+ </AnimatePresence>
+ </SortableContext>
+
+ {column.tasks.length === 0 && (
+ <div className="py-6 px-4 text-center text-xs text-muted-foreground">
+ {t("tasks:listView.noTasks")}
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --cc apps/web/src/components/list-view/focus.test.tsx
index 000000000,000000000..05e7a7c02
new file mode 100644
--- /dev/null
+++ b/apps/web/src/components/list-view/focus.test.tsx
@@@ -1,0 -1,0 +1,130 @@@
++import { cleanup, fireEvent, render, screen } from "@testing-library/react";
++import { afterEach, describe, expect, it, vi } from "vite-plus/test";
++import type { ProjectWithTasks } from "@/types/project";
++import ListView from ".";
++
++vi.mock("@tanstack/react-router", () => ({ useNavigate: () => vi.fn() }));
++vi.mock("react-i18next", () => ({
++ useTranslation: () => ({ t: (key: string) => key }),
++}));
++vi.mock("@/hooks/mutations/task/use-update-task", () => ({
++ useUpdateTask: () => ({ mutate: vi.fn() }),
++}));
++vi.mock("@/hooks/use-keyboard-shortcuts", () => ({
++ useRegisterShortcuts: vi.fn(),
++}));
++vi.mock("@/hooks/queries/task-relation/use-get-project-task-relations", () => ({
++ default: () => ({
++ isLoading: false,
++ data: [
++ {
++ sourceTaskId: "parent",
++ targetTaskId: "child",
++ relationType: "subtask",
++ },
++ {
++ sourceTaskId: "child",
++ targetTaskId: "grandchild",
++ relationType: "subtask",
++ },
++ ],
++ }),
++}));
++vi.mock("../bulk-selection/bulk-toolbar", () => ({ default: () => null }));
++vi.mock("../shared/modals/create-task-modal", () => ({ default: () => null }));
++vi.mock("../shared/modals/archive-tasks-modal", () => ({
++ ArchiveTasksModal: () => null,
++}));
++vi.mock("./task-row", () => ({
++ default: ({
++ rowId,
++ childCount,
++ isExpanded,
++ onToggleExpanded,
++ }: {
++ rowId: string;
++ childCount: number;
++ isExpanded: boolean;
++ onToggleExpanded: () => void;
++ }) => (
++ <div>
++ {rowId}
++ {childCount > 0 && (
++ <button
++ type="button"
++ aria-label={`Toggle ${rowId}`}
++ aria-expanded={isExpanded}
++ onClick={onToggleExpanded}
++ >
++ Toggle
++ </button>
++ )}
++ </div>
++ ),
++}));
++
++const project = {
++ id: "project-focus",
++ slug: "FOC",
++ workspaceId: "workspace-1",
++ columns: [
++ {
++ id: "to-do",
++ name: "To Do",
++ isFinal: false,
++ icon: null,
++ tasks: ["parent", "child", "grandchild"].map((id) => ({
++ id,
++ title: id,
++ status: "to-do",
++ })),
++ },
++ ],
++} as ProjectWithTasks;
++
++afterEach(() => {
++ cleanup();
++ localStorage.clear();
++});
++
++describe("ListView focus", () => {
++ it("retains the focused toggle when expanding and collapsing parent and nested rows", () => {
++ render(<ListView project={project} />);
++
++ for (const rowId of ["parent", "parent/child"]) {
++ const toggle = screen.getByRole("button", { name: `Toggle ${rowId}` });
++ toggle.focus();
++ fireEvent.click(toggle);
++
++ expect(toggle).toHaveFocus();
++ expect(toggle).toHaveAttribute("aria-expanded", "true");
++ }
++
++ for (const rowId of ["parent/child", "parent"]) {
++ const toggle = screen.getByRole("button", { name: `Toggle ${rowId}` });
++ toggle.focus();
++ fireEvent.click(toggle);
++
++ expect(toggle).toHaveFocus();
++ expect(toggle).toHaveAttribute("aria-expanded", "false");
++ }
++ });
++
++ it("retains header focus when collapsing and expanding a status group", () => {
++ render(<ListView project={project} />);
++ const header = screen.getByRole("button", { name: /^To Do/ });
++ header.focus();
++
++ fireEvent.click(header);
++ expect(header).toHaveFocus();
++ expect(
++ screen.queryByRole("button", { name: "Toggle parent" }),
++ ).not.toBeInTheDocument();
++
++ fireEvent.click(header);
++ expect(header).toHaveFocus();
++ expect(
++ screen.getByRole("button", { name: "Toggle parent" }),
++ ).toBeInTheDocument();
++ });
++});
diff --cc apps/web/src/components/list-view/index.test.tsx
index f647004c0,9e9f789d3..2149200d7
--- a/apps/web/src/components/list-view/index.test.tsx
+++ b/apps/web/src/components/list-view/index.test.tsx
@@@ -1,35 -1,45 +1,50 @@@
- import { cleanup, fireEvent, render, screen } from "@testing-library/react";
- import { afterEach, describe, expect, it, vi } from "vitest";
+ import {
+ act,
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ } from "@testing-library/react";
+ import { afterEach, expect, it, vi } from "vite-plus/test";
+ import type { DragEndEvent } from "@dnd-kit/core";
import type { ProjectWithTasks } from "@/types/project";
- import ListView from ".";
-
+ import ListView from "./index";
+ const m = vi.hoisted(() => ({
+ props: {} as {
+ sensors?: unknown[];
+ onDragEnd?: (event: DragEndEvent) => void;
+ },
+ archive: {} as {
+ onConfirm?: () => void;
+ disabled?: boolean;
+ taskCount?: number;
+ },
+ mutate: vi.fn(),
+ setProject: vi.fn(),
+ }));
+ vi.mock("@dnd-kit/core", async (original) => ({
+ ...(await original<typeof import("@dnd-kit/core")>()),
+ DndContext: (props: typeof m.props & { children: React.ReactNode }) => {
+ m.props = props;
+ return props.children;
+ },
+ }));
vi.mock("@tanstack/react-router", () => ({ useNavigate: () => vi.fn() }));
- vi.mock("react-i18next", () => ({
- useTranslation: () => ({ t: (key: string) => key }),
+ vi.mock("@/hooks/use-keyboard-shortcuts", () => ({
+ useRegisterShortcuts: () => {},
}));
vi.mock("@/hooks/mutations/task/use-update-task", () => ({
- useUpdateTask: () => ({ mutate: vi.fn() }),
+ useUpdateTask: () => ({ mutate: m.mutate }),
}));
- vi.mock("@/hooks/use-keyboard-shortcuts", () => ({
- useRegisterShortcuts: vi.fn(),
+ vi.mock("@/store/project", () => ({
+ default: () => ({ setProject: m.setProject }),
}));
++// This view groups subtasks under their parents, so it reads the project's
++// relations. The suite mounts ListView without a QueryClientProvider.
+vi.mock("@/hooks/queries/task-relation/use-get-project-task-relations", () => ({
- default: () => ({
- isLoading: false,
- data: [
- {
- sourceTaskId: "parent",
- targetTaskId: "child",
- relationType: "subtask",
- },
- {
- sourceTaskId: "child",
- targetTaskId: "grandchild",
- relationType: "subtask",
- },
- ],
- }),
++ default: () => ({ data: [], isLoading: false }),
+}));
+ vi.mock("./task-row", () => ({ default: () => null }));
vi.mock("../bulk-selection/bulk-toolbar", () => ({ default: () => null }));
vi.mock("../shared/modals/create-task-modal", () => ({ default: () => null }));
vi.mock("../shared/modals/archive-tasks-modal", () => ({
diff --cc apps/web/src/components/list-view/index.tsx
index d0847ec94,e8b64d1e5..249c8061d
--- a/apps/web/src/components/list-view/index.tsx
+++ b/apps/web/src/components/list-view/index.tsx
@@@ -70,61 -76,11 +75,62 @@@ function ListView(
const [isTaskModalOpen, setIsTaskModalOpen] = useState(false);
const [activeColumn, setActiveColumn] = useState<string | null>(null);
const [isArchiveModalOpen, setIsArchiveModalOpen] = useState(false);
- const [columnToArchive, setColumnToArchive] = useState<
- ProjectWithTasks["columns"][number] | null
- >(null);
+ const [columnToArchive, setColumnToArchive] = useState<string | null>(null);
+ const archiveColumn = project.columns.find(
+ (column) => column.id === columnToArchive,
+ );
+ // isLoading rather than isPending: a disabled query is also pending, and an
+ // empty project should not look like it is still fetching.
+ const { data: relations, isLoading: relationsLoading } =
+ useGetProjectTaskRelations(project?.id ?? "");
+
+ const subtaskChildren = useMemo(
+ () => buildSubtaskChildren(relations ?? []),
+ [relations],
+ );
+
+ const tasksById = useMemo(() => {
+ const index = new Map<
+ string,
+ ProjectWithTasks["columns"][number]["tasks"][number]
+ >();
+ for (const column of project?.columns ?? []) {
+ for (const task of column.tasks) {
+ index.set(task.id, task);
+ }
+ }
+ return index;
+ }, [project?.columns]);
+
+ // Per viewer and per project, and only a convenience: a row that cannot be
+ // restored simply starts collapsed.
+ const projectId = project?.id ?? "";
+ const [expanded, setExpanded] = useState(() => ({
+ projectId,
+ rows: readExpandedRows(projectId),
+ }));
+
+ // The board route swaps this component's project rather than remounting it,
+ // so a lazy initializer would keep the previous project's map and then save
+ // it under the new project's key.
+ if (expanded.projectId !== projectId) {
+ setExpanded({ projectId, rows: readExpandedRows(projectId) });
+ }
+
+ const expandedTasks = expanded.rows;
+
+ useEffect(() => {
+ writeExpandedRows(projectId, expandedTasks);
+ }, [projectId, expandedTasks]);
+
+ const toggleTaskExpanded = useCallback((rowId: string) => {
+ setExpanded((previous) => ({
+ ...previous,
+ rows: { ...previous.rows, [rowId]: !previous.rows[rowId] },
+ }));
+ }, []);
+
useEffect(() => {
if (project?.columns) {
const visibleTaskIds = project.columns
@@@ -357,27 -418,9 +369,28 @@@
modifiers={[snapCenterToCursor]}
>
<div className="w-full h-full overflow-auto bg-muted/20">
- <div className="divide-y divide-border/50">
+ <div aria-busy={relationsLoading} className="divide-y divide-border/50">
{project.columns.map((column) => (
- <ColumnSection key={column.id} column={column} />
+ <ColumnSection
+ key={column.id}
+ column={column}
+ projectSlug={project.slug}
+ activeId={activeId}
+ overColumnId={overColumnId}
+ isExpanded={expandedSections[column.id]}
+ expandedTasks={expandedTasks}
+ subtaskChildren={subtaskChildren}
+ tasksById={tasksById}
+ relationsLoading={relationsLoading}
++ disableCollectionActions={disableCollectionActions}
+ toggleSection={toggleSection}
+ toggleTaskExpanded={toggleTaskExpanded}
+ onAddTask={(columnId) => {
+ setIsTaskModalOpen(true);
+ setActiveColumn(columnId);
+ }}
+ handleArchiveClick={handleArchiveClick}
+ />
))}
</div>
</div>
diff --cc apps/web/src/components/list-view/task-row.test.tsx
index bfefdf710,c36b6b9a8..70303a65c
--- a/apps/web/src/components/list-view/task-row.test.tsx
+++ b/apps/web/src/components/list-view/task-row.test.tsx
@@@ -1,6 -1,9 +1,9 @@@
-import { cleanup, render, screen } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
- import { afterEach, describe, expect, it, vi } from "vitest";
+ import { afterEach, describe, expect, it, vi } from "vite-plus/test";
import type Task from "@/types/task";
+ import BacklogTaskRow from "../backlog-list-view/backlog-task-row";
+ import { PublicTaskCard } from "../public-project/task-card";
+ import { PublicTaskRow } from "../public-project/task-row";
import TaskRow from "./task-row";
const useExternalLinks = vi.fn((_taskId: string) => ({ data: [] }));
@@@ -118,145 -162,11 +172,152 @@@ describe("TaskRow", () =>
expect(useExternalLinks).not.toHaveBeenCalled();
expect(useGetLabelsByTask).not.toHaveBeenCalled();
});
+
+ it("shows no subtask toggle when the task has no children", () => {
+ render(<TaskRow task={task} projectSlug="kan" />);
+
+ expect(
+ screen.queryByLabelText("tasks:listView.expandSubtasks"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("keeps the subtask toggle outside the drag activator", () => {
+ render(
+ <TaskRow
+ task={task}
+ projectSlug="kan"
+ rowId="parent/task-1"
+ depth={1}
+ childCount={2}
+ onToggleExpanded={vi.fn()}
+ />,
+ );
+
+ const toggle = screen.getByLabelText("tasks:listView.expandSubtasks");
+ const activator = document.querySelector('[role="button"]');
+
+ // dnd-kit gives its activator role="button". A button nested inside one is
+ // an ambiguous control for assistive technology, so the toggle has to be a
+ // sibling of the draggable region rather than a descendant.
+ expect(activator).not.toBeNull();
+ expect(activator?.contains(toggle)).toBe(false);
+ expect(toggle.closest('[role="button"]')).toBeNull();
+ });
+
+ it("reserves the toggle column so titles stay aligned in a group", () => {
+ const { container: withToggle } = render(
+ <TaskRow
+ task={task}
+ projectSlug="kan"
+ childCount={1}
+ reserveToggleSpace
+ onToggleExpanded={vi.fn()}
+ />,
+ );
+ const { container: withoutToggle } = render(
+ <TaskRow task={task} projectSlug="kan" reserveToggleSpace />,
+ );
+
+ const gutter = (root: HTMLElement) =>
+ root.firstElementChild?.firstElementChild;
+
+ // A row with no children still renders the column, so its number and title
+ // start at the same offset as a sibling that does have one.
+ expect(gutter(withToggle)).not.toBeNull();
+ expect(gutter(withoutToggle)).not.toBeNull();
+ expect(gutter(withoutToggle)?.className).toEqual(
+ gutter(withToggle)?.className,
+ );
+ });
+
+ it("keeps the original left edge when a group has no subtasks", () => {
+ const { container } = render(<TaskRow task={task} projectSlug="kan" />);
+ const draggable = container.querySelector('[role="button"]');
+
+ expect(draggable?.className).toContain("pl-4");
+ });
+
+ it("announces the nesting level, which the indent cannot", () => {
+ render(
+ <TaskRow task={task} projectSlug="kan" rowId="a/b/task-1" depth={2} />,
+ );
+
+ // A nested repeat and its top-level row otherwise expose identical
+ // content, so the hierarchy would be inaudible.
+ expect(screen.getByText("tasks:listView.subtaskLevel")).toBeInTheDocument();
+ });
+
+ it("adds no level announcement to a top-level row", () => {
+ render(<TaskRow task={task} projectSlug="kan" />);
+
+ expect(
+ screen.queryByText("tasks:listView.subtaskLevel"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("names the toggle by its task, not the action alone", () => {
+ render(
+ <TaskRow
+ task={task}
+ projectSlug="kan"
+ childCount={1}
+ onToggleExpanded={vi.fn()}
+ />,
+ );
+
+ // Several rows each offering "Show subtasks" would be indistinguishable,
+ // so the label interpolates the title.
+ expect(interpolations).toContainEqual({ title: "Row from payload" });
+ });
+
+ it("does not announce a repeated row as disabled", () => {
+ render(
+ <TaskRow task={task} projectSlug="kan" rowId="parent/task-1" depth={1} />,
+ );
+
+ // The repeat is not a drag source, but it still opens its task, so the
+ // aria-disabled dnd-kit puts on a disabled sortable must not reach it.
+ const row = screen.getByRole("button", { name: /Row from payload/ });
+ expect(row).not.toHaveAttribute("aria-disabled", "true");
+ expect(row).toHaveAttribute("tabindex", "0");
+ });
+
+ it("opens a repeated row with Space as well as Enter", () => {
+ render(
+ <TaskRow task={task} projectSlug="kan" rowId="parent/task-1" depth={1} />,
+ );
+
+ const row = screen.getByRole("button", { name: /Row from payload/ });
+
+ // The repeat carries button semantics but none of dnd-kit's keyboard
+ // listeners, so Space has to be handled for it to activate like one.
+ fireEvent.keyDown(row, { key: " " });
+ expect(navigate).toHaveBeenCalled();
+
+ navigate.mockClear();
+ fireEvent.keyDown(row, { key: "Enter" });
+ expect(navigate).toHaveBeenCalled();
+ });
+
+ it("labels the toggle by its resulting state", () => {
+ render(
+ <TaskRow
+ task={task}
+ projectSlug="kan"
+ childCount={1}
+ isExpanded
+ onToggleExpanded={vi.fn()}
+ />,
+ );
+
+ const toggle = screen.getByLabelText("tasks:listView.collapseSubtasks");
+ expect(toggle).toHaveAttribute("aria-expanded", "true");
+ });
});
+
+ vi.mock(
+ "@/hooks/queries/custom-field/use-get-custom-field-values-by-project",
+ () => ({
+ default: () => ({ data: [] }),
+ }),
+ );
diff --cc apps/web/src/components/list-view/task-row.tsx
index 22e6c341d,084443a31..afc10ef87
--- a/apps/web/src/components/list-view/task-row.tsx
+++ b/apps/web/src/components/list-view/task-row.tsx
@@@ -2,16 -2,11 +2,11 @@@ import { useSortable } from "@dnd-kit/s
import { CSS } from "@dnd-kit/utilities";
import { useNavigate } from "@tanstack/react-router";
import { format } from "date-fns";
- import {
- Calendar,
- CalendarClock,
- CalendarX,
- ChevronRight,
- GitMerge,
- GitPullRequest,
- } from "lucide-react";
-import { Calendar, CalendarClock, CalendarX } from "lucide-react";
++import { Calendar, CalendarClock, CalendarX, ChevronRight } from "lucide-react";
import { type CSSProperties, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
+ import { TaskProgressBadges } from "@/components/task/task-progress-badges";
+ import { TaskPullRequests } from "@/components/task/task-pull-requests";
import {
AlertDialog,
AlertDialogClose,
@@@ -237,54 -142,9 +194,54 @@@ function TaskRow(
isTaskFocused && "ring-2 ring-inset ring-ring/50",
)}
>
+ {showToggleColumn && (
+ <div
+ className={cn(
+ "flex flex-shrink-0 items-center pl-4",
+ isTaskSelected ? "bg-accent/45" : "group-hover:bg-accent/60",
+ )}
+ >
+ {depth > 0 && (
+ <span
+ aria-hidden="true"
+ className="flex-shrink-0"
+ // Indentation is capped so a deep chain cannot push the title
+ // off the row; the chevrons still convey the nesting.
+ style={{ width: `${Math.min(depth, 6) * 1.25}rem` }}
+ />
+ )}
+
+ {childCount > 0 ? (
+ <button
+ type="button"
+ onClick={onToggleExpanded}
+ aria-expanded={isExpanded}
+ // Named with the task, not just the action: the toggle sits
+ // outside the row's own control, so several identical "Show
+ // subtasks" buttons would be indistinguishable in a rotor.
+ aria-label={
+ isExpanded
+ ? t("tasks:listView.collapseSubtasks", { title: task.title })
+ : t("tasks:listView.expandSubtasks", { title: task.title })
+ }
+ className="flex-shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
+ >
+ <ChevronRight
+ className={cn(
+ "w-3 h-3 transition-transform",
+ isExpanded && "rotate-90",
+ )}
+ />
+ </button>
+ ) : (
+ <span aria-hidden="true" className="w-5 flex-shrink-0" />
+ )}
+ </div>
+ )}
+
<ContextMenu>
<ContextMenuTrigger asChild>
- {/* biome-ignore lint/a11y/noStaticElementInteractions: false positive for onClick and onKeyDown */}
+ {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- false positive for onClick and onKeyDown */}
<div
onClick={handleClick}
onKeyDown={handleKeyDown}
diff --cc apps/web/src/hooks/mutations/task-relation/use-delete-task-relation.ts
index fda36bee2,cab450d2a..a99b457d8
--- a/apps/web/src/hooks/mutations/task-relation/use-delete-task-relation.ts
+++ b/apps/web/src/hooks/mutations/task-relation/use-delete-task-relation.ts
@@@ -6,24 -8,10 +8,25 @@@ function useDeleteTaskRelation(taskId:
return useMutation({
mutationFn: deleteTaskRelation,
- onSuccess: (relation) => {
- void invalidateRelationTaskProject(queryClient, relation.sourceTaskId);
+ onSuccess: (deleted) => {
++ void invalidateRelationTaskProject(queryClient, deleted.sourceTaskId);
+ // Both ends go stale, and only one of them is the task this hook was
+ // opened for. Queries default to refetchOnMount: false, so opening the
+ // other task would otherwise still list the relation.
+ const endpoints = new Set([
+ taskId,
+ deleted.sourceTaskId,
+ deleted.targetTaskId,
+ ]);
+ for (const endpoint of endpoints) {
+ queryClient.invalidateQueries({
+ queryKey: ["task-relations", endpoint],
+ });
+ }
+ // The project-scoped query the list view reads is keyed by neither, and
+ // the prefix covers every project a mounted view holds.
queryClient.invalidateQueries({
- queryKey: ["task-relations", taskId],
+ queryKey: ["task-relations", "project"],
});
},
});
diff --cc apps/web/src/hooks/use-project-websocket-relations.test.tsx
index 9bd4420be,000000000..c6648e96a
mode 100644,000000..100644
--- a/apps/web/src/hooks/use-project-websocket-relations.test.tsx
+++ b/apps/web/src/hooks/use-project-websocket-relations.test.tsx
@@@ -1,215 -1,0 +1,172 @@@
+import {
+ afterEach,
+ beforeEach,
+ describe,
+ expect,
+ it,
+ type MockInstance,
+ vi,
- } from "vitest";
++} from "vite-plus/test";
+
+vi.mock("@kaneo/libs", () => ({
+ windowId: "test-window-id",
+}));
+
+vi.mock("@/lib/auth-client", () => ({
+ authClient: {
+ useSession: () => ({ data: { user: { id: "user-1" } } }),
+ },
+}));
+
+import {
+ QueryClient,
+ QueryClientProvider,
+ useQueryClient,
+} from "@tanstack/react-query";
+import { renderHook } from "@testing-library/react";
+import { createElement, type ReactNode } from "react";
- import { getWsUrl, useProjectWebSocket } from "./use-project-websocket";
-
- describe("getWsUrl", () => {
- beforeEach(() => {
- vi.stubEnv("VITE_API_URL", "http://localhost:1337");
- });
-
- afterEach(() => {
- vi.unstubAllEnvs();
- });
-
- it("builds a ws:// URL from an http API base", () => {
- expect(getWsUrl("project-123")).toBe(
- "ws://localhost:1337/api/ws/project-123?windowId=test-window-id",
- );
- });
-
- it("builds a wss:// URL from an https API base", () => {
- vi.stubEnv("VITE_API_URL", "https://example.com");
- expect(getWsUrl("project-123")).toBe(
- "wss://example.com/api/ws/project-123?windowId=test-window-id",
- );
- });
-
- it("does not append /api when the base already ends with /api", () => {
- vi.stubEnv("VITE_API_URL", "https://example.com/api");
- expect(getWsUrl("p1")).toBe(
- "wss://example.com/api/ws/p1?windowId=test-window-id",
- );
- });
-
- it("trims trailing slashes from the API base", () => {
- vi.stubEnv("VITE_API_URL", "http://localhost:1337///");
- expect(getWsUrl("p1")).toBe(
- "ws://localhost:1337/api/ws/p1?windowId=test-window-id",
- );
- });
-
- it("URL-encodes the projectId", () => {
- expect(getWsUrl("a b/c?d")).toBe(
- "ws://localhost:1337/api/ws/a%20b%2Fc%3Fd?windowId=test-window-id",
- );
- });
- });
++import { useProjectWebSocket } from "./use-project-websocket";
+
+type Socket = {
+ onopen: (() => void) | null;
+ onmessage: ((event: { data: string }) => void) | null;
+ onclose: (() => void) | null;
+ onerror: (() => void) | null;
+ readyState: number;
+ send: ReturnType<typeof vi.fn>;
+ close: ReturnType<typeof vi.fn>;
+};
+
- describe("useProjectWebSocket message handling", () => {
++describe("useProjectWebSocket relation invalidation", () => {
+ let socket: Socket;
+ let invalidate: MockInstance<QueryClient["invalidateQueries"]>;
+
+ function mount() {
+ const client = new QueryClient();
+ invalidate = vi
+ .spyOn(client, "invalidateQueries")
+ .mockResolvedValue(undefined);
+
+ renderHook(
+ () => {
+ useQueryClient();
+ return useProjectWebSocket("project-1");
+ },
+ {
+ wrapper: ({ children }: { children: ReactNode }) =>
+ createElement(QueryClientProvider, { client }, children),
+ },
+ );
+ }
+
+ function receive(message: Record<string, unknown>) {
+ socket.onmessage?.({ data: JSON.stringify(message) });
+ }
+
+ function invalidatedKeys() {
+ return invalidate.mock.calls.map((call) =>
+ JSON.stringify(call[0]?.queryKey),
+ );
+ }
+
+ const projectRelationsKey = JSON.stringify([
+ "task-relations",
+ "project",
+ "project-1",
+ ]);
+
+ beforeEach(() => {
+ vi.stubEnv("VITE_API_URL", "http://localhost:1337");
+ socket = {
+ onopen: null,
+ onmessage: null,
+ onclose: null,
+ onerror: null,
+ readyState: 1,
+ send: vi.fn(),
+ close: vi.fn(),
+ };
+ // `new WebSocket(url)` needs a constructible mock, so this cannot be an
+ // arrow function.
+ vi.stubGlobal(
+ "WebSocket",
+ Object.assign(
+ vi.fn(function mockWebSocket() {
+ return socket;
+ }),
+ { OPEN: 1 },
+ ),
+ );
+ mount();
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ vi.unstubAllGlobals();
+ });
+
+ // The project-scoped relations query is what the list view reads, and no
+ // per-task key reaches it.
+ it("refreshes the project relations on a real relation change", () => {
+ receive({
+ type: "TASK_RELATION_UPDATED",
+ projectId: "project-1",
+ sourceTaskId: "task-1",
+ targetTaskId: "task-2",
+ });
+
+ expect(invalidatedKeys()).toContain(projectRelationsKey);
+ });
+
+ it.each(["TASK_DELETED", "TASK_MOVED"])(
+ "refreshes the project relations on %s",
+ (type) => {
+ receive({ type, projectId: "project-1", taskId: "task-1" });
+
+ expect(invalidatedKeys()).toContain(projectRelationsKey);
+ },
+ );
+
+ // The API publishes task-relation.refresh on every status change, and the
+ // socket relays it as TASK_RELATION_UPDATED with no endpoint ids. That
+ // stales the per-task queries, whose responses embed each linked task's
+ // status, but not the project query, which returns edges alone.
+ it("does not refresh the project relations on a status refresh", () => {
+ receive({ type: "TASK_RELATION_UPDATED", projectId: "project-1" });
+
+ expect(invalidatedKeys()).not.toContain(projectRelationsKey);
+ });
+
+ it("still refreshes the per-task relations on a status refresh", () => {
+ receive({ type: "TASK_RELATION_UPDATED", projectId: "project-1" });
+
+ const predicates = invalidate.mock.calls
+ .map((call) => call[0]?.predicate)
+ .filter(Boolean);
+ expect(predicates).toHaveLength(1);
+
+ const matches = (queryKey: readonly unknown[]) =>
+ // biome-ignore lint/suspicious/noExplicitAny: only queryKey is read
+ predicates[0]?.({ queryKey } as any);
+
+ expect(matches(["task-relations", "task-9"])).toBe(true);
+ expect(matches(["task-relations", "project", "project-1"])).toBe(false);
+ });
+
+ // Creating a task inserts no relation: a subtask is a create followed by a
+ // separate relation mutation, which emits its own event.
+ it.each([
+ "TASK_CREATED",
+ "TASK_UPDATED",
+ "TASK_LABEL_UPDATED",
+ "COMMENT_UPDATED",
+ ])("leaves the project relations alone on %s", (type) => {
+ receive({ type, projectId: "project-1", taskId: "task-1" });
+
+ expect(invalidatedKeys()).not.toContain(projectRelationsKey);
+ });
+
+ it("ignores a malformed message", () => {
+ expect(() => socket.onmessage?.({ data: "{not json" })).not.toThrow();
+ });
+});
diff --cc apps/web/src/hooks/use-project-websocket.ts
index 42ab07c96,fabd85c6f..2c1c6eea3
--- a/apps/web/src/hooks/use-project-websocket.ts
+++ b/apps/web/src/hooks/use-project-websocket.ts
@@@ -1,9 -1,18 +1,19 @@@
+ import { applyBoardReorder } from "@/components/kanban-board/apply-reorder";
+ import {
+ getBoardCacheVersion,
+ markBoardCacheChanged,
+ } from "@/lib/board-cache-version";
import { windowId } from "@kaneo/libs";
import { useQueryClient } from "@tanstack/react-query";
- import { useEffect, useRef } from "react";
+ import { useEffect } from "react";
import { getApiUrl } from "@/fetchers/get-api-url";
import { authClient } from "@/lib/auth-client";
+ import getTask from "@/fetchers/task/get-task";
+ import getLabelsByTask from "@/fetchers/label/get-labels-by-task";
+ import getExternalLinks from "@/fetchers/external-link/get-external-links";
+ import { patchBoardTask } from "@/lib/patch-board-task";
+import { isPerTaskRelationQuery } from "@/lib/relation-query-keys";
+ import type { ProjectWithTasks } from "@/types/project";
export function getWsUrl(projectId: string) {
const base = getApiUrl("ws");
@@@ -29,12 -34,103 +35,107 @@@ export function useProjectWebSocket(pro
useEffect(() => {
if (!projectId || !session?.user?.id) return;
- retriesRef.current = 0;
+ // Each effect owns its sockets and timers. Late events from an old project
+ // or session must not alter the next effect's connection or reconnect it.
+ let disposed = false;
+ let needsReconcile = false;
+ let flushQueued = false;
+ const taskVersions = new Map<string, number>();
+ const refreshingTasks = new Set<string>();
+ let burstReconcileTimer: ReturnType<typeof setTimeout> | null = null;
+ function reconcileBurst() {
+ if (burstReconcileTimer !== null) clearTimeout(burstReconcileTimer);
+ else markBoardCacheChanged(queryClient, projectId);
+ burstReconcileTimer = setTimeout(() => {
+ burstReconcileTimer = null;
+ if (disposed) return;
+ needsReconcile = true;
+ flushPending();
+ }, 200);
+ }
+ const pendingMessages = new Map<string, string>();
+ let activeSocket: WebSocket | null = null;
+ let retries = 0;
+ let retryTimeout: ReturnType<typeof setTimeout> | null = null;
+ let healthyTimeout: ReturnType<typeof setTimeout> | null = null;
+ let requestSequence = 0;
+ const parentCountVersions = new Map<string, number>();
+ let pingInterval: ReturnType<typeof setInterval> | null = null;
+ let fallbackInterval: ReturnType<typeof setInterval> | null = null;
+
+ function invalidateDetails(message: {
+ type: string;
+ taskId?: string;
+ sourceTaskId?: string;
+ targetTaskId?: string;
+ }) {
+ if (message.type === "PROJECT_UPDATED") {
+ queryClient.invalidateQueries({ queryKey: ["projects"] });
+ queryClient.invalidateQueries({ queryKey: ["labels"] });
+ return;
+ }
+
+ if (message.type === "TASK_RELATION_UPDATED") {
+ if (message.sourceTaskId) {
+ queryClient.invalidateQueries({
+ queryKey: ["task", message.sourceTaskId],
+ });
+ queryClient.invalidateQueries({
+ queryKey: ["task-relations", message.sourceTaskId],
+ });
+ }
+ if (message.targetTaskId) {
+ queryClient.invalidateQueries({
+ queryKey: ["task", message.targetTaskId],
+ });
+ queryClient.invalidateQueries({
+ queryKey: ["task-relations", message.targetTaskId],
+ });
+ }
+ if (!message.sourceTaskId && !message.targetTaskId) {
++ // Every per-task relation query, but not the project one: those
++ // responses embed each linked task's status, so a status change
++ // stales them, while the project query returns edges alone and a
++ // prefix match would refetch it needlessly.
+ queryClient.invalidateQueries({
- queryKey: ["task-relations"],
++ predicate: isPerTaskRelationQuery,
+ });
+ }
+ } else {
+ queryClient.invalidateQueries({
+ queryKey: ["task", message.taskId],
+ });
+ }
+
+ if (message.type === "TASK_LABEL_UPDATED") {
+ queryClient.invalidateQueries({
+ queryKey: ["labels", message.taskId],
+ });
+ }
+
+ if (
+ (message.type === "TASK_UPDATED" || message.type === "TASK_MOVED") &&
+ message.taskId
+ ) {
+ queryClient.invalidateQueries({
+ queryKey: ["external-links", message.taskId],
+ });
+ }
+
+ if (message.type === "COMMENT_UPDATED") {
+ queryClient.invalidateQueries({
+ queryKey: ["activities", message.taskId],
+ });
+ queryClient.invalidateQueries({
+ queryKey: ["comments", message.taskId],
+ });
+ }
+ }
function clearPing() {
- if (pingIntervalRef.current) {
- clearInterval(pingIntervalRef.current);
- pingIntervalRef.current = null;
+ if (pingInterval !== null) {
+ clearInterval(pingInterval);
+ pingInterval = null;
}
}
@@@ -55,89 -165,254 +170,280 @@@
};
ws.onmessage = (event) => {
+ if (disposed || activeSocket !== ws) return;
try {
const message = JSON.parse(event.data);
+ if (message.type === "PROJECT_MOVED") {
+ markBoardCacheChanged(queryClient, projectId);
+ for (const queryKey of [
+ ["projects"],
+ ["project", projectId],
+ ["tasks", projectId],
+ ["task"],
+ ["task-relations"],
+ ["external-links"],
+ ]) {
+ queryClient.invalidateQueries({ queryKey });
+ }
+ return;
+ }
++
++ // The list view reads relations per project, and no per-task key
++ // reaches that query. Only the events that can change which edges
++ // belong to the project qualify: an edit, a label or a comment
++ // leaves the edge set alone and would cost every mounted list a
++ // refetch. Creating a task inserts no relation - a subtask is a
++ // create followed by a separate relation mutation, which emits its
++ // own event. TASK_RELATION_UPDATED also carries
++ // `task-relation.refresh`, which the API publishes on every status
++ // change with no endpoint ids; that changes the per-task responses,
++ // which embed task status, but not the project response, which is
++ // edges only.
++ //
++ // This sits ahead of the branching below because several of those
++ // paths return before reaching invalidateDetails.
+ if (
- message.type === "TASK_UPDATED" ||
- message.type === "TASK_CREATED" ||
++ (message.type === "TASK_RELATION_UPDATED" &&
++ (message.sourceTaskId || message.targetTaskId)) ||
+ message.type === "TASK_DELETED" ||
- message.type === "TASK_LABEL_UPDATED" ||
- message.type === "TASK_MOVED" ||
- message.type === "TASK_RELATION_UPDATED" ||
- message.type === "COMMENT_UPDATED"
++ message.type === "TASK_MOVED"
+ ) {
+ queryClient.invalidateQueries({
- queryKey: ["tasks", message.projectId],
++ queryKey: ["task-relations", "project", message.projectId],
+ });
++ }
+
- // The list view reads relations per project, and the per-task keys
- // below do not reach that query. Only the events that can change
- // which edges belong to the project qualify: an edit, a label or a
- // comment leaves the edge set alone and would cost every mounted
- // list a refetch.
- // Creating a task inserts no relation — a subtask is a create
- // followed by a separate relation mutation, which emits its own
- // event. TASK_RELATION_UPDATED also carries `task-relation.refresh`,
- // which the API publishes on every status change with no endpoint
- // ids; that changes the per-task responses, which embed task
- // status, but not the project response, which is edges only.
+ const boardIsLoading =
+ queryClient.getQueryState(["tasks", projectId])?.fetchStatus ===
+ "fetching";
+ if (boardIsLoading) {
if (
- (message.type === "TASK_RELATION_UPDATED" &&
- (message.sourceTaskId || message.targetTaskId)) ||
- message.type === "TASK_DELETED" ||
- message.type === "TASK_MOVED"
+ [
+ "TASK_CREATED",
+ "TASK_DELETED",
+ "TASK_MOVED",
+ "TASKS_REORDERED",
+ ].includes(message.type)
) {
- queryClient.invalidateQueries({
- queryKey: ["task-relations", "project", message.projectId],
- });
- }
-
- if (message.type === "TASK_RELATION_UPDATED") {
- if (message.sourceTaskId) {
- queryClient.invalidateQueries({
- queryKey: ["task", message.sourceTaskId],
- });
- queryClient.invalidateQueries({
- queryKey: ["task-relations", message.sourceTaskId],
- });
+ // Offset pages can skip unrelated boundary tasks when membership
+ // or positions change. Reconcile after this fetch completes.
+ needsReconcile = true;
+ markBoardCacheChanged(queryClient, projectId);
+ const ids =
+ message.type === "TASKS_REORDERED"
+ ? Array.isArray(message.tasks)
+ ? message.tasks.map((task: { id: string }) => task.id)
+ : []
+ : message.taskId
+ ? [message.taskId]
+ : [];
+ for (const id of ids) {
+ queryClient.invalidateQueries({ queryKey: ["task", id] });
+ if (message.type === "TASK_MOVED")
+ queryClient.invalidateQueries({
+ queryKey: ["external-links", id],
+ });
}
- if (message.targetTaskId) {
- queryClient.invalidateQueries({
- queryKey: ["task", message.targetTaskId],
- });
- queryClient.invalidateQueries({
- queryKey: ["task-relations", message.targetTaskId],
- });
- }
- if (!message.sourceTaskId && !message.targetTaskId) {
- // Every per-task relation query, but not the project one:
- // those responses embed each linked task's status, so a status
- // change stales them, while the project query returns edges
- // alone and a prefix match would refetch it needlessly.
- queryClient.invalidateQueries({
- predicate: isPerTaskRelationQuery,
- });
- }
- } else {
- queryClient.invalidateQueries({
- queryKey: ["task", message.taskId],
+ return;
+ }
+ pendingMessages.set(
+ `${message.type}:${message.taskId ?? ""}:${message.sourceTaskId ?? ""}:${message.targetTaskId ?? ""}`,
+ event.data,
+ );
+ return;
+ }
+ if (message.type === "TASKS_REORDERED") {
+ for (const change of Array.isArray(message.tasks)
+ ? message.tasks
+ : []) {
+ queryClient.invalidateQueries({ queryKey: ["task", change.id] });
+ taskVersions.set(
+ change.id,
+ (taskVersions.get(change.id) ?? 0) + 1,
+ );
+ markBoardCacheChanged(queryClient, projectId, change.id);
+ }
+ const board = queryClient.getQueryData<ProjectWithTasks>([
+ "tasks",
+ projectId,
+ ]);
+ if (!board || !Array.isArray(message.tasks)) {
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
});
+ return;
}
-
- if (message.type === "TASK_LABEL_UPDATED") {
- queryClient.invalidateQueries({
- queryKey: ["labels", message.taskId],
+ const knownTasks = new Set([
+ ...board.columns.flatMap((column) =>
+ column.tasks.map((task) => task.id),
+ ),
+ ...board.plannedTasks.map((task) => task.id),
+ ...board.archivedTasks.map((task) => task.id),
+ ]);
+ const statuses = new Set([
+ "planned",
+ "archived",
+ ...board.columns.map((column) => column.slug),
+ ]);
+ if (
+ message.tasks.some(
+ (change: { id: string; status?: string }) =>
+ !knownTasks.has(change.id) ||
+ (change.status && !statuses.has(change.status)),
+ )
+ ) {
+ markBoardCacheChanged(queryClient, projectId);
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
});
}
-
- if (message.type === "COMMENT_UPDATED") {
- queryClient.invalidateQueries({
- queryKey: ["activities", message.taskId],
+ queryClient.setQueryData(
+ ["tasks", projectId],
+ applyBoardReorder(board, message.tasks),
+ );
+ return;
+ }
+ if (
+ message.type === "TASK_UPDATED" ||
+ message.type === "TASK_CREATED" ||
+ message.type === "TASK_DELETED" ||
+ message.type === "TASK_LABEL_UPDATED" ||
+ message.type === "TASK_MOVED" ||
+ message.type === "TASK_RELATION_UPDATED" ||
+ message.type === "COMMENT_UPDATED" ||
+ message.type === "PROJECT_UPDATED"
+ ) {
+ if (
+ message.type === "PROJECT_UPDATED" ||
+ message.type === "TASK_RELATION_UPDATED"
+ ) {
+ markBoardCacheChanged(queryClient, projectId);
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
});
- queryClient.invalidateQueries({
- queryKey: ["comments", message.taskId],
+ } else if (!message.taskId && message.type !== "COMMENT_UPDATED") {
+ markBoardCacheChanged(queryClient, projectId);
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
});
+ } else if (message.taskId && message.type !== "COMMENT_UPDATED") {
+ const taskId = message.taskId as string;
+ const sequence = ++requestSequence;
+ const version = (taskVersions.get(taskId) ?? 0) + 1;
+ taskVersions.set(taskId, version);
+ markBoardCacheChanged(queryClient, projectId, taskId);
+ const boardVersion = getBoardCacheVersion(
+ queryClient,
+ projectId,
+ taskId,
+ );
+ if (message.type === "TASK_DELETED") {
+ queryClient.setQueryData<ProjectWithTasks>(
+ ["tasks", projectId],
+ (board) =>
+ board ? (patchBoardTask(board, taskId) ?? board) : board,
+ );
+ } else if (!queryClient.getQueryData(["tasks", projectId])) {
+ // Calendar, backlog and detail-only views have no board to
+ // patch. Their active detail queries are invalidated below.
+ } else if (
+ refreshingTasks.size >= 4 ||
+ refreshingTasks.has(taskId) ||
+ burstReconcileTimer !== null
+ ) {
+ reconcileBurst();
+ } else {
+ refreshingTasks.add(taskId);
+ void Promise.all([
+ getTask(taskId, "board"),
+ getLabelsByTask({ taskId }),
+ getExternalLinks(taskId),
+ ])
+ .then(([task, labels, externalLinks]) => {
+ if (
+ disposed ||
+ activeSocket !== ws ||
+ taskVersions.get(taskId) !== version
+ )
+ return;
+ if (
+ getBoardCacheVersion(queryClient, projectId, taskId) !==
+ boardVersion
+ ) {
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
+ });
+ return;
+ }
+ const staleOwnCounts =
+ (parentCountVersions.get(taskId) ?? 0) > sequence;
+ const { subtaskCounts, ...taskFields } = task;
+ if (staleOwnCounts)
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
+ });
+ else parentCountVersions.set(taskId, sequence);
+ queryClient.setQueryData<ProjectWithTasks>(
+ ["tasks", projectId],
+ (board) =>
+ board
+ ? (patchBoardTask(board, taskId, {
+ ...taskFields,
+ ...(!staleOwnCounts ? { subtaskCounts } : {}),
+ labels,
+ externalLinks: externalLinks.map((link) => ({
+ ...link,
+ metadata:
+ link.metadata &&
+ typeof link.metadata === "object" &&
+ !Array.isArray(link.metadata)
+ ? link.metadata
+ : null,
+ })),
+ }) ?? board)
+ : board,
+ );
+ for (const progress of task.parentSubtaskCounts ?? []) {
+ if (
+ (parentCountVersions.get(progress.taskId) ?? 0) >
+ sequence
+ ) {
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
+ });
+ continue;
+ }
+ parentCountVersions.set(progress.taskId, sequence);
+ queryClient.setQueryData<ProjectWithTasks>(
+ ["tasks", projectId],
+ (board) =>
+ board
+ ? (patchBoardTask(board, progress.taskId, {
+ projectId,
+ subtaskCounts: {
+ completed: progress.completed,
+ total: progress.total,
+ },
+ }) ?? board)
+ : board,
+ );
+ }
+ })
+ .catch(() => {
+ if (
+ !disposed &&
+ activeSocket === ws &&
+ taskVersions.get(taskId) === version
+ )
+ void queryClient.invalidateQueries({
+ queryKey: ["tasks", projectId],
+ });
+ })
+ .finally(() => refreshingTasks.delete(taskId));
+ }
}
+
+ invalidateDetails(message);
}
} catch {
// Ignore malformed messages
diff --cc apps/web/src/lib/expanded-rows-storage.test.ts
index 2769ad017,000000000..848462c52
mode 100644,000000..100644
--- a/apps/web/src/lib/expanded-rows-storage.test.ts
+++ b/apps/web/src/lib/expanded-rows-storage.test.ts
@@@ -1,70 -1,0 +1,70 @@@
- import { afterEach, describe, expect, it, vi } from "vitest";
++import { afterEach, describe, expect, it, vi } from "vite-plus/test";
+import {
+ expandedRowsStorageKey,
+ readExpandedRows,
+ writeExpandedRows,
+} from "./expanded-rows-storage";
+
+afterEach(() => {
+ localStorage.clear();
+ vi.restoreAllMocks();
+});
+
+describe("readExpandedRows", () => {
+ it("returns an empty map when nothing is stored", () => {
+ expect(readExpandedRows("p1")).toEqual({});
+ });
+
+ it("round-trips what was written", () => {
+ writeExpandedRows("p1", { a: true, "a/b": true });
+
+ expect(readExpandedRows("p1")).toEqual({ a: true, "a/b": true });
+ });
+
+ it("keeps projects apart", () => {
+ writeExpandedRows("p1", { a: true });
+
+ expect(readExpandedRows("p2")).toEqual({});
+ });
+
+ // Each of these would previously have been cast straight to the map, and the
+ // first property read during render would throw and blank the list.
+ it.each([
+ ["null", "null"],
+ ["an array", "[1,2,3]"],
+ ["a string", '"hello"'],
+ ["a number", "42"],
+ ["malformed JSON", "{not json"],
+ ])("ignores %s", (_label, stored) => {
+ localStorage.setItem(expandedRowsStorageKey("p1"), stored);
+
+ expect(readExpandedRows("p1")).toEqual({});
+ });
+
+ it("drops non-true values rather than trusting the shape", () => {
+ localStorage.setItem(
+ expandedRowsStorageKey("p1"),
+ JSON.stringify({ a: true, b: false, c: "yes", d: null }),
+ );
+
+ expect(readExpandedRows("p1")).toEqual({ a: true });
+ });
+
+ it("survives storage that throws", () => {
+ vi.spyOn(Storage.prototype, "getItem").mockImplementation(() => {
+ throw new Error("blocked");
+ });
+
+ expect(readExpandedRows("p1")).toEqual({});
+ });
+});
+
+describe("writeExpandedRows", () => {
+ it("does not throw when storage refuses", () => {
+ vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
+ throw new Error("quota");
+ });
+
+ expect(() => writeExpandedRows("p1", { a: true })).not.toThrow();
+ });
+});
diff --cc apps/web/src/lib/relation-query-keys.test.ts
index 3e7c7714f,000000000..7949c17d9
mode 100644,000000..100644
--- a/apps/web/src/lib/relation-query-keys.test.ts
+++ b/apps/web/src/lib/relation-query-keys.test.ts
@@@ -1,21 -1,0 +1,21 @@@
- import { describe, expect, it } from "vitest";
++import { describe, expect, it } from "vite-plus/test";
+import { isPerTaskRelationQuery } from "./relation-query-keys";
+
+const q = (queryKey: readonly unknown[]) => ({ queryKey });
+
+describe("isPerTaskRelationQuery", () => {
+ it("matches a per-task relation query", () => {
+ expect(isPerTaskRelationQuery(q(["task-relations", "task-1"]))).toBe(true);
+ });
+
+ it("excludes the project-scoped query", () => {
+ expect(
+ isPerTaskRelationQuery(q(["task-relations", "project", "project-1"])),
+ ).toBe(false);
+ });
+
+ it("ignores unrelated queries", () => {
+ expect(isPerTaskRelationQuery(q(["tasks", "project-1"]))).toBe(false);
+ expect(isPerTaskRelationQuery(q([]))).toBe(false);
+ });
+});
diff --cc apps/web/src/lib/subtask-tree.test.ts
index 9ba98a11a,000000000..c39ff4066
mode 100644,000000..100644
--- a/apps/web/src/lib/subtask-tree.test.ts
+++ b/apps/web/src/lib/subtask-tree.test.ts
@@@ -1,291 -1,0 +1,291 @@@
- import { describe, expect, it } from "vitest";
++import { describe, expect, it } from "vite-plus/test";
+import {
+ buildSubtaskChildren,
+ flattenSubtaskRows,
+ type TaskRelationEdge,
+} from "./subtask-tree";
+
+type T = { id: string };
+
+const task = (id: string): T => ({ id });
+
+const subtask = (source: string, target: string): TaskRelationEdge => ({
+ sourceTaskId: source,
+ targetTaskId: target,
+ relationType: "subtask",
+});
+
+function flatten(
+ tasks: T[],
+ relations: TaskRelationEdge[],
+ {
+ all = tasks,
+ expanded = true,
+ }: { all?: T[]; expanded?: boolean | ((rowId: string) => boolean) } = {},
+) {
+ return flattenSubtaskRows({
+ tasks,
+ children: buildSubtaskChildren(relations),
+ tasksById: new Map(all.map((entry) => [entry.id, entry])),
+ isExpanded: typeof expanded === "function" ? expanded : () => expanded,
+ });
+}
+
+describe("buildSubtaskChildren", () => {
+ it("keeps only subtask edges", () => {
+ const children = buildSubtaskChildren([
+ subtask("a", "b"),
+ { sourceTaskId: "a", targetTaskId: "c", relationType: "blocks" },
+ { sourceTaskId: "a", targetTaskId: "d", relationType: "related" },
+ ]);
+
+ expect(children.get("a")).toEqual(["b"]);
+ });
+
+ it("ignores a self-referencing edge", () => {
+ expect(buildSubtaskChildren([subtask("a", "a")]).size).toBe(0);
+ });
+
+ it("does not repeat a duplicated edge", () => {
+ const children = buildSubtaskChildren([
+ subtask("a", "b"),
+ subtask("a", "b"),
+ ]);
+
+ expect(children.get("a")).toEqual(["b"]);
+ });
+});
+
+describe("flattenSubtaskRows", () => {
+ it("leaves a flat column untouched", () => {
+ const rows = flatten([task("a"), task("b")], []);
+
+ expect(rows.map((row) => [row.rowId, row.depth, row.childCount])).toEqual([
+ ["a", 0, 0],
+ ["b", 0, 0],
+ ]);
+ });
+
+ it("repeats a child under its parent without moving it", () => {
+ const tasks = [task("parent"), task("child")];
+ const rows = flatten(tasks, [subtask("parent", "child")]);
+
+ // The child keeps its own top-level row and appears again, indented.
+ expect(rows.map((row) => [row.rowId, row.depth])).toEqual([
+ ["parent", 0],
+ ["parent/child", 1],
+ ["child", 0],
+ ]);
+ });
+
+ it("reports a child count but no nested row while collapsed", () => {
+ const rows = flatten(
+ [task("parent"), task("child")],
+ [subtask("parent", "child")],
+ {
+ expanded: false,
+ },
+ );
+
+ expect(rows.map((row) => row.rowId)).toEqual(["parent", "child"]);
+ expect(rows[0].childCount).toBe(1);
+ });
+
+ it("nests to arbitrary depth", () => {
+ const tasks = [task("a"), task("b"), task("c")];
+ const rows = flatten(tasks, [subtask("a", "b"), subtask("b", "c")]);
+
+ expect(rows.filter((row) => row.depth > 0).map((row) => row.rowId)).toEqual(
+ ["a/b", "a/b/c", "b/c"],
+ );
+ });
+
+ it("terminates on a cycle instead of recursing forever", () => {
+ const tasks = [task("a"), task("b")];
+ const rows = flatten(tasks, [subtask("a", "b"), subtask("b", "a")]);
+
+ // Without the ancestor check this never returns and takes the tab with it.
+ expect(rows.map((row) => row.rowId)).toEqual(["a", "a/b", "b", "b/a"]);
+ });
+
+ it("terminates on a longer cycle", () => {
+ const tasks = [task("a"), task("b"), task("c")];
+ const rows = flatten(tasks, [
+ subtask("a", "b"),
+ subtask("b", "c"),
+ subtask("c", "a"),
+ ]);
+
+ expect(rows.every((row) => row.rowId.split("/").length <= 3)).toBe(true);
+ expect(rows.map((row) => row.rowId)).toContain("a/b/c");
+ });
+
+ it("renders a task under each of its parents", () => {
+ const tasks = [task("p1"), task("p2"), task("shared")];
+ const rows = flatten(tasks, [
+ subtask("p1", "shared"),
+ subtask("p2", "shared"),
+ ]);
+
+ expect(rows.map((row) => row.rowId)).toEqual([
+ "p1",
+ "p1/shared",
+ "p2",
+ "p2/shared",
+ "shared",
+ ]);
+ });
+
+ it("gives every row a unique id so rows can be keyed and dragged", () => {
+ const tasks = [task("p1"), task("p2"), task("shared")];
+ const rows = flatten(tasks, [
+ subtask("p1", "shared"),
+ subtask("p2", "shared"),
+ ]);
+ const ids = rows.map((row) => row.rowId);
+
+ expect(new Set(ids).size).toBe(ids.length);
+ });
+
+ it("caps nesting on a layered graph with shared descendants", () => {
+ // Every task on a level parents every task on the next. Expanding each
+ // occurrence would enumerate simple paths: this shape produced 16,356 rows
+ // before expansion was bounded, with no cycle anywhere in it.
+ const LEVELS = 12;
+ const WIDTH = 2;
+ const tasks: T[] = [];
+ const relations: TaskRelationEdge[] = [];
+
+ for (let level = 0; level < LEVELS; level += 1) {
+ for (let index = 0; index < WIDTH; index += 1) {
+ tasks.push(task(`l${level}n${index}`));
+ }
+ }
+ for (let level = 0; level < LEVELS - 1; level += 1) {
+ for (let from = 0; from < WIDTH; from += 1) {
+ for (let to = 0; to < WIDTH; to += 1) {
+ relations.push(subtask(`l${level}n${from}`, `l${level + 1}n${to}`));
+ }
+ }
+ }
+
+ const rows = flattenSubtaskRows({
+ tasks,
+ children: buildSubtaskChildren(relations),
+ tasksById: new Map(tasks.map((entry) => [entry.id, entry])),
+ isExpanded: () => true,
+ maxNestedRows: 200,
+ });
+
+ // Unbounded, this shape reaches 16,356 rows with no cycle in it. Reaching
+ // it in the app would need a viewer to expand that many rows by hand, but
+ // the walk itself has to terminate regardless of who calls it.
+ const nested = rows.filter((row) => row.depth > 0);
+ expect(nested.length).toBeLessThan(400);
+ expect(rows.filter((row) => row.depth === 0)).toHaveLength(tasks.length);
+ });
+
+ it("caps a single parent with more children than the budget", () => {
+ const parent = task("parent");
+ const children = Array.from({ length: 50 }, (_, index) =>
+ task(`child-${index}`),
+ );
+ const relations = children.map((child) => subtask("parent", child.id));
+
+ const rows = flattenSubtaskRows({
+ tasks: [parent],
+ children: buildSubtaskChildren(relations),
+ tasksById: new Map(
+ [parent, ...children].map((entry) => [entry.id, entry]),
+ ),
+ isExpanded: () => true,
+ maxNestedRows: 10,
+ });
+
+ // The budget used to be checked once per parent, so a wide parent emitted
+ // every child regardless of it.
+ expect(rows.filter((row) => row.depth > 0)).toHaveLength(10);
+ });
+
+ it("reports the expansion that was actually rendered", () => {
+ const tasks = [task("parent"), task("child")];
+ const relations = [subtask("parent", "child")];
+
+ const open = flatten(tasks, relations);
+ expect(open.find((row) => row.rowId === "parent")?.isExpanded).toBe(true);
+
+ // The stored preference is irrelevant once the flattener declines to
+ // expand — during a drag, say — and the chevron follows this, not the map.
+ const shut = flatten(tasks, relations, { expanded: false });
+ expect(shut.find((row) => row.rowId === "parent")?.isExpanded).toBe(false);
+ expect(shut.find((row) => row.rowId === "parent")?.childCount).toBe(1);
+ });
+
+ it("never reports a childless row as expanded", () => {
+ const rows = flatten([task("a")], []);
+
+ expect(rows[0].isExpanded).toBe(false);
+ });
+
+ it("reports no children once the budget is spent", () => {
+ const tasks = [task("a"), task("b")];
+ const rows = flattenSubtaskRows({
+ tasks,
+ children: buildSubtaskChildren([subtask("a", "b"), subtask("b", "c")]),
+ tasksById: new Map(
+ [...tasks, task("c")].map((entry) => [entry.id, entry]),
+ ),
+ isExpanded: () => true,
+ maxNestedRows: 1,
+ });
+
+ // The nested "a/b" is the row that spends the budget, so it must not
+ // advertise a chevron that can reveal nothing.
+ expect(rows.find((row) => row.rowId === "a/b")).toMatchObject({
+ childCount: 0,
+ });
+ expect(rows.map((row) => row.rowId)).not.toContain("a/b/c");
+ });
+
+ it("leaves every task a top-level row even when nesting is capped", () => {
+ const tasks = [task("a"), task("b"), task("c")];
+ const rows = flattenSubtaskRows({
+ tasks,
+ children: buildSubtaskChildren([subtask("a", "b"), subtask("b", "c")]),
+ tasksById: new Map(tasks.map((entry) => [entry.id, entry])),
+ isExpanded: () => true,
+ maxNestedRows: 0,
+ });
+
+ // Status grouping and the per-column counts depend on these rows, so the
+ // cap drops nesting and never a task's own row.
+ expect(rows.map((row) => row.rowId)).toEqual(["a", "b", "c"]);
+ });
+
+ it("ignores a child the view is not rendering", () => {
+ // A subtask in another project is not returned by the endpoint, so a
+ // chevron would open onto nothing.
+ const rows = flatten([task("parent")], [subtask("parent", "elsewhere")], {
+ all: [task("parent")],
+ });
+
+ expect(rows).toHaveLength(1);
+ expect(rows[0].childCount).toBe(0);
+ });
+
+ it("expands only the row that is open", () => {
+ const tasks = [task("p1"), task("p2"), task("shared")];
+ const rows = flatten(
+ tasks,
+ [subtask("p1", "shared"), subtask("p2", "shared")],
+ { expanded: (rowId) => rowId === "p1" },
+ );
+
+ expect(rows.map((row) => row.rowId)).toEqual([
+ "p1",
+ "p1/shared",
+ "p2",
+ "shared",
+ ]);
+ });
+});
diff --cc i18n/schema.json
index accb0166d,0f5f109d4..4d0abc1e2
--- a/i18n/schema.json
+++ b/i18n/schema.json
@@@ -7534,123 -10191,127 +10191,143 @@@
"type": "object",
"additionalProperties": false,
"properties": {
- "pageTitle": {
+ "success": {
"type": "string"
},
- "noTasksToMove": {
+ "success_zero": {
"type": "string"
},
- "moveAllConfirm": {
+ "success_one": {
"type": "string"
},
- "moveAllConfirm_zero": {
+ "success_two": {
"type": "string"
},
- "moveAllConfirm_one": {
+ "success_few": {
"type": "string"
},
- "moveAllConfirm_two": {
+ "success_many": {
"type": "string"
},
- "moveAllConfirm_few": {
+ "success_other": {
+ "type": "string"
+ }
+ },
+ "required": []
+ },
+ "listView": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "addTask": {
"type": "string"
},
- "moveAllConfirm_many": {
+ "archiveAllTooltip": {
"type": "string"
},
- "moveAllConfirm_other": {
+ "noTasks": {
"type": "string"
+ },
- "moveAllSuccess": {
++ "expandSubtasks": {
+ "type": "string"
+ },
- "moveAllSuccess_zero": {
++ "collapseSubtasks": {
+ "type": "string"
+ },
- "moveAllSuccess_one": {
++ "subtaskLevel": {
++ "type": "string"
+ }
+ },
- "required": ["addTask", "archiveAllTooltip", "noTasks"]
++ "required": [
++ "addTask",
++ "archiveAllTooltip",
++ "noTasks",
++ "expandSubtasks",
++ "collapseSubtasks",
++ "subtaskLevel"
++ ]
+ },
+ "kanban": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "addTask": {
+ "type": "string"
+ }
+ },
+ "required": ["addTask"]
+ },
+ "pr": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "merged": {
"type": "string"
},
- "moveAllSuccess_two": {
+ "draft": {
"type": "string"
},
- "moveAllSuccess_few": {
+ "open": {
"type": "string"
},
- "moveAllSuccess_many": {
+ "label": {
"type": "string"
},
- "moveAllSuccess_other": {
+ "count_one": {
"type": "string"
},
- "plan": {
+ "count_zero": {
"type": "string"
},
- "moveAllTooltip": {
+ "count_two": {
"type": "string"
},
- "moveAll": {
+ "count_few": {
"type": "string"
},
- "addTask": {
+ "count_many": {
"type": "string"
},
- "filter": {
+ "count_other": {
+ "type": "string"
+ }
+ },
+ "required": ["merged", "draft", "open", "label"]
+ },
+ "assignee": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "label": {
"type": "string"
},
- "addFilter": {
+ "unassigned": {
+ "type": "string"
+ }
+ },
+ "required": ["label", "unassigned"]
+ },
+ "dueDate": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "label": {
"type": "string"
},
- "sections": {
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "planned": {
- "type": "string"
- },
- "archived": {
- "type": "string"
- }
- },
- "required": ["planned", "archived"]
+ "clear": {
+ "type": "string"
},
- "noTasksInSection": {
+ "updateSuccess": {
"type": "string"
},
- "filters": {
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "priority": {
- "type": "string"
- },
- "assignee": {
- "type": "string"
- },
- "due": {
- "type": "string"
- },
- "label": {
- "type": "string"
- },
- "dueThisWeek": {
- "type": "string"
- },
- "dueNextWeek": {
- "type": "string"
- },
- "noDueDate": {
- "type": "string"
- }
- },
- "required": [
- "priority",
- "assignee",
- "due",
- "label",
- "dueThisWeek",
- "dueNextWeek",
- "noDueDate"
- ]
+ "updateError": {
+ "type": "string"
+ },
+ "clearSuccess": {
+ "type": "string"
+ },
+ "clearError": {
+ "type": "string"
}
},
"required": [
@@@ -8104,22 -10713,71 +10729,82 @@@
"type": "string"
}
},
- "required": ["merged", "draft", "open", "label"]
+ "required": ["ariaLabel"]
},
- "assignee": {
+ "descriptionSearchLoading": {
+ "type": "string"
+ },
+ "descriptionSearchError": {
+ "type": "string"
+ },
+ "descriptionRetry": {
+ "type": "string"
+ },
+ "descriptionLoading": {
+ "type": "string"
+ },
+ "descriptionLoadError": {
+ "type": "string"
++ },
++ "board": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
- "label": {
- "type": "string"
- },
- "unassigned": {
++ "reorderFailed": {
+ "type": "string"
+ }
+ },
- "required": ["label", "unassigned"]
- },
- "dueDate": {
++ "required": ["reorderFailed"]
+ }
+ },
+ "required": [
+ "checklistProgress",
+ "title",
+ "status",
+ "priority",
+ "boardSearchPlaceholder",
+ "view",
+ "common",
+ "detail",
+ "entity",
+ "relations",
+ "subtasks",
+ "properties",
+ "move",
+ "popover",
+ "backlog",
+ "sort",
+ "boardFilters",
+ "calendar",
+ "gantt",
+ "delete",
+ "duplicate",
+ "archive",
+ "listView",
+ "kanban",
+ "pr",
+ "assignee",
+ "dueDate",
+ "labels",
+ "update",
+ "contextMenu",
+ "actions",
+ "bulk",
+ "editor",
+ "customFields",
+ "descriptionSearchLoading",
+ "descriptionSearchError",
+ "descriptionRetry",
+ "descriptionLoading",
- "descriptionLoadError"
++ "descriptionLoadError",
++ "board"
+ ]
+ },
+ "invitations": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "email": {
"type": "object",
"additionalProperties": false,
"properties": {
diff --cc tests/api-integration/task-relation-project.test.ts
index b641e1523,000000000..137ba2556
mode 100644,000000..100644
--- a/tests/api-integration/task-relation-project.test.ts
+++ b/tests/api-integration/task-relation-project.test.ts
@@@ -1,185 -1,0 +1,185 @@@
- import { beforeEach, describe, expect, it } from "vitest";
++import { beforeEach, describe, expect, it } from "vite-plus/test";
+import db, { schema } from "../../apps/api/src/database";
+import { createApp } from "../../apps/api/src/index";
+import { mockAuthenticatedSession } from "./helpers/auth";
+import { resetTestDatabase } from "./helpers/database";
+import {
+ createProjectFixture,
+ createWorkspaceMember,
+} from "./helpers/fixtures";
+
+type RelationRow = typeof schema.taskRelationTable.$inferSelect;
+
+let taskCounter = 0;
+
+async function seedTask(
+ userId: string,
+ projectId: string,
+ title: string,
+ status = "to-do",
+) {
+ taskCounter += 1;
+ const [task] = await db
+ .insert(schema.taskTable)
+ .values({
+ projectId,
+ userId,
+ title,
+ status,
+ priority: "medium",
+ number: taskCounter,
+ position: taskCounter,
+ })
+ .returning();
+ return task;
+}
+
+async function relate(
+ sourceTaskId: string,
+ targetTaskId: string,
+ relationType = "subtask",
+) {
+ const [relation] = await db
+ .insert(schema.taskRelationTable)
+ .values({ sourceTaskId, targetTaskId, relationType })
+ .returning();
+ return relation;
+}
+
+async function fetchProjectRelations(projectId: string) {
+ const { app } = createApp();
+ return app.request(`/api/task-relation/project/${projectId}`);
+}
+
+describe("API integration: project task relations", () => {
+ beforeEach(async () => {
+ await resetTestDatabase();
+ taskCounter = 0;
+ });
+
+ it("returns the relations joining two tasks in the project", async () => {
+ const member = await createWorkspaceMember({ role: "owner" });
+ mockAuthenticatedSession(member.user);
+ const { project } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+
+ const parent = await seedTask(member.user.id, project.id, "Parent");
+ const child = await seedTask(member.user.id, project.id, "Child");
+ const blocker = await seedTask(member.user.id, project.id, "Blocker");
+
+ const subtask = await relate(parent.id, child.id, "subtask");
+ const blocks = await relate(blocker.id, parent.id, "blocks");
+
+ const response = await fetchProjectRelations(project.id);
+
+ expect(response.status).toBe(200);
+ const payload = (await response.json()) as RelationRow[];
+
+ // Every type is returned; narrowing to subtasks is the caller's business.
+ expect(payload.map((relation) => relation.id).sort()).toEqual(
+ [subtask.id, blocks.id].sort(),
+ );
+ expect(
+ payload.find((relation) => relation.id === subtask.id),
+ ).toMatchObject({
+ sourceTaskId: parent.id,
+ targetTaskId: child.id,
+ relationType: "subtask",
+ });
+ });
+
+ it("omits a relation whose other end is in a different project", async () => {
+ const member = await createWorkspaceMember({ role: "owner" });
+ mockAuthenticatedSession(member.user);
+ const { project } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+ const other = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ slug: "other-project",
+ });
+
+ const parent = await seedTask(member.user.id, project.id, "Parent");
+ const inside = await seedTask(member.user.id, project.id, "Inside");
+ const outside = await seedTask(member.user.id, other.project.id, "Outside");
+
+ const kept = await relate(parent.id, inside.id);
+ // Both directions: the endpoint requires each end to be in the project,
+ // so an outward and an inward edge exercise a different check each.
+ await relate(parent.id, outside.id);
+ await relate(outside.id, parent.id);
+
+ const response = await fetchProjectRelations(project.id);
+ const payload = (await response.json()) as RelationRow[];
+
+ expect(payload.map((relation) => relation.id)).toEqual([kept.id]);
+ });
+
+ it("returns an empty list for a project with no relations", async () => {
+ const member = await createWorkspaceMember({ role: "owner" });
+ mockAuthenticatedSession(member.user);
+ const { project } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+
+ const response = await fetchProjectRelations(project.id);
+
+ expect(response.status).toBe(200);
+ await expect(response.json()).resolves.toEqual([]);
+ });
+
+ it("refuses a member whose role does not grant task:read", async () => {
+ const member = await createWorkspaceMember({ role: "viewer" });
+ const { project } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+ await seedTask(member.user.id, project.id, "Parent");
+
+ // A workspace can redefine its roles, and the stored definition wins over
+ // the compiled-in one. This is the shape an API key restricted below
+ // task:read also takes.
+ await db.insert(schema.workspaceRoleTable).values({
+ workspaceId: member.workspace.id,
+ role: "viewer",
+ permission: JSON.stringify({ project: ["read"], workspace: ["read"] }),
+ });
+
+ mockAuthenticatedSession(member.user);
+ const response = await fetchProjectRelations(project.id);
+
+ expect(response.status).toBe(403);
+ });
+
+ it("allows a viewer, whose built-in role grants task:read", async () => {
+ const member = await createWorkspaceMember({ role: "viewer" });
+ mockAuthenticatedSession(member.user);
+ const { project } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+ const parent = await seedTask(member.user.id, project.id, "Parent");
+ const child = await seedTask(member.user.id, project.id, "Child");
+ const relation = await relate(parent.id, child.id);
+
+ const response = await fetchProjectRelations(project.id);
+
+ expect(response.status).toBe(200);
+ const payload = (await response.json()) as RelationRow[];
+ expect(payload.map((row) => row.id)).toEqual([relation.id]);
+ });
+
+ it("refuses a caller outside the project's workspace", async () => {
+ const owner = await createWorkspaceMember({ role: "owner" });
+ const { project } = await createProjectFixture({
+ workspaceId: owner.workspace.id,
+ });
+ await seedTask(owner.user.id, project.id, "Parent");
+
+ const outsider = await createWorkspaceMember({ role: "owner" });
+ mockAuthenticatedSession(outsider.user);
+
+ const response = await fetchProjectRelations(project.id);
+
+ expect(response.status).toBe(403);
+ });
+});