feat(comments): allow marking comments as complete or incomplete

This commit is contained in:
yiling
2026-07-06 12:24:40 +08:00
parent af7d636f31
commit e1d3dd46db
22 changed files with 878 additions and 18 deletions
@@ -10,8 +10,8 @@ import {
import { Separator } from '@/ui/components/ui/separator'
import { formatTimeAgo } from '@/ui/lib/time'
import type { AttachmentInfo, CommentInfo, UserInfo } from '@shumai/dtos'
import { useQuery } from '@tanstack/react-query'
import { Download, File, Terminal } from 'lucide-react'
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { Download, File, Terminal, CircleCheck } from 'lucide-react'
import React from 'react'
import Markdown from 'react-markdown'
import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'
@@ -20,6 +20,7 @@ import { Skeleton } from '../ui/skeleton'
import { formatTimecode } from '../viewers/video/utils'
import { m } from '@/ui/paraglide/messages.js'
import { useUiStore } from '@/ui/stores/ui'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip'
interface MessageCardProps {
teamId?: string
@@ -91,6 +92,22 @@ export const MessageCard: React.FC<MessageCardProps> = ({
const isAdmin = me?.role === 'owner'
const queryClient = useQueryClient()
const { mutate: toggleComplete } = useMutation({
mutationFn: async () => {
const res = await client.api.comments[':commentId'].complete.$post({
param: { commentId: message.id },
json: { isCompleted: !message.isCompleted },
})
if (!res.ok) throw new Error('Failed to update comment completion status')
return await res.json()
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['files'] })
queryClient.invalidateQueries({ queryKey: ['shares'] })
},
})
const { data: logs, isLoading: isLogsLoading } = useQuery({
queryKey: ['agent-sessions', message.sessionId, 'entries'],
queryFn: async () => {
@@ -273,13 +290,40 @@ export const MessageCard: React.FC<MessageCardProps> = ({
)}
{/* Actions */}
<div className="mt-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 flex items-center gap-4">
<div
className={`mt-2 transition-opacity duration-200 flex items-center justify-between w-full ${
message.isCompleted ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
}`}
>
<button
onClick={handleReply}
className="text-xs font-medium text-gray-500 hover:text-blue-600 flex items-center gap-1 cursor-pointer"
>
{m.reply()}
</button>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<button
onClick={(e) => {
e.stopPropagation()
toggleComplete()
}}
className={`flex items-center justify-center p-1 rounded-full transition-colors cursor-pointer ${
message.isCompleted
? 'text-green-500 hover:text-green-600 hover:bg-green-500/10'
: 'text-gray-400 hover:text-green-500 hover:bg-green-500/10'
}`}
>
<CircleCheck className="w-4 h-4" />
</button>
</TooltipTrigger>
<TooltipContent>
{message.isCompleted ? m.mark_as_incomplete() : m.mark_as_complete()}
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
</div>
+2
View File
@@ -646,6 +646,8 @@
"all": "All",
"unread": "Unread",
"mark_all_as_read": "Mark all as read",
"mark_as_complete": "Mark as complete",
"mark_as_incomplete": "Mark as incomplete",
"no_notifications": "No notifications",
"unknown_date": "Unknown Date",
+2
View File
@@ -646,6 +646,8 @@
"all": "全部",
"unread": "未读",
"mark_all_as_read": "全部标记为已读",
"mark_as_complete": "标记为已完成",
"mark_as_incomplete": "标记为未完成",
"no_notifications": "暂无通知",
"unknown_date": "未知日期",
+2
View File
@@ -606,6 +606,8 @@ export * from "./notification_generic.js";
export * from "./all.js";
export * from "./unread.js";
export * from "./mark_all_as_read.js";
export * from "./mark_as_complete.js";
export * from "./mark_as_incomplete.js";
export * from "./no_notifications.js";
export * from "./unknown_date.js";
export * from "./today.js";
+2
View File
@@ -608,6 +608,8 @@ export * from './notification_generic.js'
export * from './all.js'
export * from './unread.js'
export * from './mark_all_as_read.js'
export * from './mark_as_complete.js'
export * from './mark_as_incomplete.js'
export * from './no_notifications.js'
export * from './unknown_date.js'
export * from './today.js'
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Mark as complete" |
*
* @param {Mark_As_CompleteInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const mark_as_complete: ((inputs?: Mark_As_CompleteInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Mark_As_CompleteInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Mark_As_CompleteInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Mark_As_CompleteInputs */
const en_mark_as_complete = /** @type {(inputs: Mark_As_CompleteInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Mark as complete`)
};
const zh_mark_as_complete = /** @type {(inputs: Mark_As_CompleteInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`标记为已完成`)
};
/**
* | output |
* | --- |
* | "Mark as complete" |
*
* @param {Mark_As_CompleteInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const mark_as_complete = /** @type {((inputs?: Mark_As_CompleteInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Mark_As_CompleteInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_mark_as_complete(inputs)
return zh_mark_as_complete(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Mark as incomplete" |
*
* @param {Mark_As_IncompleteInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const mark_as_incomplete: ((inputs?: Mark_As_IncompleteInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Mark_As_IncompleteInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Mark_As_IncompleteInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Mark_As_IncompleteInputs */
const en_mark_as_incomplete = /** @type {(inputs: Mark_As_IncompleteInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Mark as incomplete`)
};
const zh_mark_as_incomplete = /** @type {(inputs: Mark_As_IncompleteInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`标记为未完成`)
};
/**
* | output |
* | --- |
* | "Mark as incomplete" |
*
* @param {Mark_As_IncompleteInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const mark_as_incomplete = /** @type {((inputs?: Mark_As_IncompleteInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Mark_As_IncompleteInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_mark_as_incomplete(inputs)
return zh_mark_as_incomplete(inputs)
});