mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 04:44:28 +00:00
feat(agentic kanban): phase 1 not-agentic kanban board (#330)
* feat(kanban): implement AI-native kanban database models, services, and REST APIs * feat(webui): implement team kanban board and task management * style(webui): increase kanban dialog widths and form container * fix(webui): ensure kanban dialogs override sm:max-w-lg base class * style(webui): set edit task dialog max width to 5xl * chore: untrack kanban plan markdown files * feat(webui): update kanban page layout to 2 columns and refine task activity UI * fix(webui): constrain kanban column and board heights for vertical scrolling * feat(kanban): unify task status transition into updateTask API and allow unconstrained human task transitions * fix(webui): add optimistic updates to kanban drag-and-drop to eliminate flash * refactor(webui): remove client-side search box from kanban header * feat(kanban): redesign task dialog comments area and add attachment support * refactor(webui): remove top status action bar from task info dialog * fix(webui): narrow query cache predicate and add defensive guards for kanban drag optimistic update * feat(kanban): add drag-and-drop task reordering with fractional indexing (#331) * feat(kanban): add drag-and-drop task reordering with fractional indexing * fix(kanban): improve card drop zones, snap indicators, and column highlight * fix(kanban): enable card droppables only during active drag * fix(kanban): refine hover styles and drop indicators for column boundaries * fix(kanban): unify bottom drop indicator and fix top indicator clipping * fix(kanban): ensure full column highlight and full coverage drop target * minor change * feat(kanban): allow agent tasks free drag-and-drop and enforce status change permissions (#332) * refactor(kanban): rename task_type_agentic translation keys to task_type_agent * feat(kanban): refactor task type enum to isAgentTask boolean (#333) * refactor(kanban): remove phase 2 agent execution logic and streamline phase 1 kanban * feat(kanban): add notifications and audit logging for kanban (#334) * feat(kanban): redesign config area layout and add parent tasks multi-selector (#335) * feat(webui): redesign kanban task dialog config area * feat(kanban): simplify task dependencies with parent tasks multi-selector * refactor(kanban): remove unused links routes and legacy dependency methods * feat(kanban): connect assets and kanban tasks with many-to-many relationship (#336) * feat(kanban): connect assets and kanban tasks with many-to-many relationship * feat(kanban): improve asset picker layout, infinite scrolling, and breadcrumb icon styling * fix(kanban): ensure asset picker scrollarea is scrollable with min-h-0 and shrink-0 flex styling * fix(kanban): hide recently deleted in folder tree picker and adjust header padding * fix(kanban): use lucide files icon instead of paperclip for linked assets * feat(kanban): improve task deletion, goal sidebar interaction, and card styling (#337) * feat(kanban): improve task deletion, goal sidebar interaction, and card styling * feat(kanban): move agent task badge after priority and update to orange style * feat(kanban): add status Compare-And-Swap (CAS) to prevent drag-and-drop race conditions (#338) * feat(kanban): add status Compare-And-Swap (CAS) to prevent drag-and-drop race conditions * style(kanban): rotate kanban icon 180 degrees in sidebar and top nav * style(kanban): remove rotate-180 from SquareKanban icons * feat(kanban): add unassigned goal record and fix all tasks count (#339) * feat(kanban): add unassigned goal record and fix all tasks count * feat(kanban): toggle task count with three-dot action button on goal card hover * fix(ci): pin bun version to 1.3.14 across CI and Docker (#340) * fix(webui): truncate goal name to max 2 lines in kanban sidebar (#341)
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
import { useState } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||
import { toast } from 'sonner'
|
||||
import { Loader2, MessageSquare, X } from 'lucide-react'
|
||||
import { TaskCommentCard } from './task-comment-card'
|
||||
import { TaskCommentInput } from './task-comment-input'
|
||||
import type { KanbanAttachmentInfo, KanbanAttachmentPayload, KanbanCommentInfo } from '@shumai/dtos'
|
||||
|
||||
interface TaskCommentThreadProps {
|
||||
teamId: string
|
||||
taskId: string
|
||||
initialComments?: KanbanCommentInfo[]
|
||||
}
|
||||
|
||||
export function TaskCommentThread({ teamId, taskId, initialComments }: TaskCommentThreadProps) {
|
||||
const queryClient = useQueryClient()
|
||||
const [viewingAttachment, setViewingAttachment] = useState<KanbanAttachmentInfo | null>(null)
|
||||
|
||||
// Query Current User Info
|
||||
const { data: me } = useQuery({
|
||||
queryKey: ['teams', teamId, 'me'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].me.$get({
|
||||
param: { teamId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch me')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId,
|
||||
})
|
||||
|
||||
const isOwnerOrAdmin = me?.role?.toLowerCase() === 'owner' || me?.role?.toLowerCase() === 'editor'
|
||||
|
||||
// Query Comments
|
||||
const { data: commentsData, isLoading } = useQuery({
|
||||
queryKey: ['teams', teamId, 'kanban', 'tasks', taskId, 'comments'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].kanban.tasks[':taskId'].comments.$get({
|
||||
param: { teamId, taskId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch comments')
|
||||
return (await res.json()) as { data: KanbanCommentInfo[] }
|
||||
},
|
||||
initialData: initialComments ? { data: initialComments } : undefined,
|
||||
enabled: !!teamId && !!taskId,
|
||||
refetchInterval: 4000,
|
||||
})
|
||||
|
||||
const comments = commentsData?.data || []
|
||||
|
||||
// Add Comment Mutation
|
||||
const { mutateAsync: addComment, isPending: isAdding } = useMutation({
|
||||
mutationFn: async ({
|
||||
body,
|
||||
attachments,
|
||||
}: {
|
||||
body: string
|
||||
attachments?: KanbanAttachmentPayload[]
|
||||
}) => {
|
||||
const res = await client.api.teams[':teamId'].kanban.tasks[':taskId'].comments.$post({
|
||||
param: { teamId, taskId },
|
||||
json: { body, attachments },
|
||||
})
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({ message: m.error() }))
|
||||
throw new Error((err as { message?: string }).message || m.error())
|
||||
}
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'kanban', 'tasks', taskId, 'comments'],
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'kanban', 'task', taskId],
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'kanban', 'tasks'],
|
||||
})
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(err.message)
|
||||
},
|
||||
})
|
||||
|
||||
const handleSendMessage = async (text: string, attachments?: KanbanAttachmentPayload[]) => {
|
||||
await addComment({ body: text, attachments })
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full overflow-hidden bg-background">
|
||||
{/* Lightbox / Full-screen Attachment Viewer */}
|
||||
{viewingAttachment && (
|
||||
<div
|
||||
className="fixed inset-0 z-50 bg-black/90 flex flex-col items-center justify-center p-4 animate-in fade-in duration-150"
|
||||
onClick={() => setViewingAttachment(null)}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setViewingAttachment(null)}
|
||||
className="absolute top-4 right-4 text-white/80 hover:text-white bg-white/10 hover:bg-white/20 rounded-full p-2 transition-colors z-50 cursor-pointer"
|
||||
title="Close"
|
||||
>
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
|
||||
<div className="w-full h-full flex items-center justify-center p-2">
|
||||
<img
|
||||
src={viewingAttachment.url}
|
||||
alt={viewingAttachment.name}
|
||||
className="max-w-full max-h-[85vh] object-contain rounded-lg shadow-2xl"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Comments List */}
|
||||
<ScrollArea className="flex-1 p-3.5">
|
||||
<div className="space-y-3 pr-1 pb-2">
|
||||
{isLoading ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<Loader2 className="w-6 h-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
) : comments.length === 0 ? (
|
||||
<div className="flex flex-col items-center justify-center py-16 text-center text-xs text-muted-foreground/80 space-y-2">
|
||||
<div className="w-10 h-10 rounded-full bg-muted/60 flex items-center justify-center">
|
||||
<MessageSquare className="w-5 h-5 opacity-40" />
|
||||
</div>
|
||||
<p className="font-medium">{m.no_comments_yet()}</p>
|
||||
</div>
|
||||
) : (
|
||||
comments.map((comment) => (
|
||||
<TaskCommentCard
|
||||
key={comment.id}
|
||||
teamId={teamId}
|
||||
taskId={taskId}
|
||||
comment={comment}
|
||||
currentUserId={me?.id}
|
||||
isOwnerOrAdmin={isOwnerOrAdmin}
|
||||
onViewAttachment={(att) => setViewingAttachment(att)}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
|
||||
{/* Composer Input Box */}
|
||||
<div className="p-3 border-t border-border/60 bg-card/60 shrink-0">
|
||||
<TaskCommentInput
|
||||
teamId={teamId}
|
||||
onSendMessage={handleSendMessage}
|
||||
isSubmitting={isAdding}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user