feat(comment): add emoji reaction support for comments (#405)

* feat(comment): add emoji reaction support for comments

* fix(webui): adjust emoji picker trigger icon size to match mark-done icon

* fix(webui): prevent search icon and placeholder overlap in emoji picker

* fix(webui): use normal text color for reaction count

* feat(db): limit comment reaction code column to VarChar(32)
This commit is contained in:
Yiling-J
2026-09-14 15:01:36 +08:00
committed by GitHub
parent ede52e5009
commit def42cd000
29 changed files with 3084 additions and 41 deletions
+19
View File
@@ -251,6 +251,7 @@
"@dnd-kit/abstract": "0.5.0",
"@dnd-kit/dom": "0.5.0",
"@dnd-kit/react": "0.5.0",
"@ferrucc-io/emoji-picker": "0.1.2",
"@hookform/resolvers": "5.9.1",
"@lexical/code": "0.49.0",
"@lexical/link": "0.49.0",
@@ -578,6 +579,8 @@
"@eslint/plugin-kit": ["@eslint/plugin-kit@0.7.2", "", { "dependencies": { "@eslint/core": "^1.2.1", "levn": "^0.4.1" } }, "sha512-+CNAzxglkrpNf/kKywqQfk74QjtceuOE7Qm+AF8miRvPF/wmmK5+OJOgVh3AVTT3RP2mH3+FOaxlE5v72owk0A=="],
"@ferrucc-io/emoji-picker": ["@ferrucc-io/emoji-picker@0.1.2", "", { "dependencies": { "@tanstack/react-virtual": "^3.11.2", "clsx": "^2.1.1", "jotai": "^2.11.1", "node-emoji": "^2.1.3", "tailwind-merge": "^3.4.0", "unicode-emoji-json": "^0.8.0" }, "peerDependencies": { "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0", "tailwindcss": ">=3.0.0" } }, "sha512-P15x8qOOz3n12lkCWrnKbniy2otHTg0JLyK2LNsQzrj2UJwltSDcitqj10+FRf4dMEFuGKHPjiwqP/8Xz2e+YA=="],
"@floating-ui/core": ["@floating-ui/core@1.8.0", "", { "dependencies": { "@floating-ui/utils": "^0.2.12" } }, "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ=="],
"@floating-ui/dom": ["@floating-ui/dom@1.8.0", "", { "dependencies": { "@floating-ui/core": "^1.8.0", "@floating-ui/utils": "^0.2.12" } }, "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg=="],
@@ -1088,6 +1091,8 @@
"@sinclair/typebox": ["@sinclair/typebox@0.34.52", "", {}, "sha512-XiMQh7qqVlxZzcVD+kkGMNGMzcTrDMLWI7S4x7z1MkCkbDPrekpZXEUK0eZqZFMuHQg2a2DZOcDIh9o5v3Gonw=="],
"@sindresorhus/is": ["@sindresorhus/is@4.6.0", "", {}, "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw=="],
"@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
"@smithy/credential-provider-imds": ["@smithy/credential-provider-imds@4.5.2", "", { "dependencies": { "@smithy/core": "^3.33.2", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg=="],
@@ -1586,6 +1591,8 @@
"chai": ["chai@6.2.2", "", {}, "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg=="],
"char-regex": ["char-regex@1.0.2", "", {}, "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw=="],
"character-entities": ["character-entities@2.0.2", "", {}, "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ=="],
"character-entities-html4": ["character-entities-html4@2.1.0", "", {}, "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="],
@@ -1758,6 +1765,8 @@
"emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
"emojilib": ["emojilib@2.4.0", "", {}, "sha512-5U0rVMU5Y2n2+ykNLQqMoqklN9ICBT/KsvC1Gz6vqHbz2AXXGkG+Pm5rMWk/8Vjrr/mY9985Hi8DYzn1F09Nyw=="],
"empathic": ["empathic@2.0.0", "", {}, "sha512-i6UzDscO/XfAcNYD75CfICkmfLedpyPDdozrLMmQc5ORaQcdMoc21OnlEylMIqI7U8eniKrPMxxtj8k0vhmJhA=="],
"end-of-stream": ["end-of-stream@1.4.5", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg=="],
@@ -2106,6 +2115,8 @@
"jose": ["jose@6.2.10", "", {}, "sha512-iiW7J9qRFlGxvCOIBDBDxFePQSn7ZMAnrYGhrrOo6siO/MIqwfyilLR27pkfDgUk+raLuzADS8A3S/KLBisc0g=="],
"jotai": ["jotai@2.20.3", "", { "peerDependencies": { "@babel/core": ">=7.0.0", "@babel/template": ">=7.0.0", "@types/react": ">=17.0.0", "react": ">=17.0.0" }, "optionalPeers": ["@babel/core", "@babel/template", "@types/react", "react"] }, "sha512-N8L9FUbeGDP+0qNJw1FebOxt+5hk+jTOwUA2LlRE4C081jUcY6F1T/FSETp4DT2/INMtiSRZyNm2D+yZdzrSgA=="],
"joycon": ["joycon@3.1.1", "", {}, "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw=="],
"js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
@@ -2306,6 +2317,8 @@
"node-domexception": ["node-domexception@1.0.0", "", {}, "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="],
"node-emoji": ["node-emoji@2.2.0", "", { "dependencies": { "@sindresorhus/is": "^4.6.0", "char-regex": "^1.0.2", "emojilib": "^2.4.0", "skin-tone": "^2.0.0" } }, "sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw=="],
"node-exports-info": ["node-exports-info@1.6.2", "", { "dependencies": { "array.prototype.flatmap": "^1.3.3", "es-errors": "^1.3.0", "object.entries": "^1.1.9", "semver": "^6.3.1" } }, "sha512-kXs9Go0cah0qHVV2v389IXQLdLCeE1xfFtjOAF+iobu0OIoG1pje8At2vMHyaPMiPMnG/LWP50twML21eMcAag=="],
"node-fetch": ["node-fetch@3.3.2", "", { "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10" } }, "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA=="],
@@ -2608,6 +2621,8 @@
"signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="],
"skin-tone": ["skin-tone@2.0.0", "", { "dependencies": { "unicode-emoji-modifier-base": "^1.0.0" } }, "sha512-kUMbT1oBJCpgrnKoSr0o6wPtvRWT9W9UKvGLwfJYO2WuahZRHOpEyL1ckyMGgMWh0UdpmaoFqKKD29WTomNEGA=="],
"sonic-boom": ["sonic-boom@4.2.1", "", { "dependencies": { "atomic-sleep": "^1.0.0" } }, "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q=="],
"sonner": ["sonner@2.0.8", "", { "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-UM/ByIoFra8yzV75n1o0Puu0bw5U/9UNnDacrJNspekBewIfsQ3D6ez1nvlWpt7aTsO6rujQtifBpycwIivqlg=="],
@@ -2762,6 +2777,10 @@
"undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
"unicode-emoji-json": ["unicode-emoji-json@0.8.0", "", {}, "sha512-3wDXXvp6YGoKGhS2O2H7+V+bYduOBydN1lnI0uVfr1cIdY02uFFiEH1i3kE5CCE4l6UqbLKVmEFW9USxTAMD1g=="],
"unicode-emoji-modifier-base": ["unicode-emoji-modifier-base@1.0.0", "", {}, "sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g=="],
"unicode-properties": ["unicode-properties@1.4.1", "", { "dependencies": { "base64-js": "^1.3.0", "unicode-trie": "^2.0.0" } }, "sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg=="],
"unicode-trie": ["unicode-trie@2.0.0", "", { "dependencies": { "pako": "^0.2.5", "tiny-inflate": "^1.0.0" } }, "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ=="],
+58
View File
@@ -36,6 +36,7 @@ vi.mock('@shumai/core/src/authz/authz', () => ({
Asset: 'asset',
Team: 'team',
Project: 'project',
Comment: 'comment',
},
}))
@@ -65,6 +66,8 @@ describe('file api', () => {
vi.spyOn(assetService, 'createComment').mockImplementation(vi.fn())
vi.spyOn(assetService, 'completeComment').mockImplementation(vi.fn())
vi.spyOn(assetService, 'deleteComment').mockImplementation(vi.fn())
vi.spyOn(assetService, 'addCommentReaction').mockImplementation(vi.fn())
vi.spyOn(assetService, 'removeCommentReaction').mockImplementation(vi.fn())
vi.spyOn(assetService, 'getComment').mockResolvedValue({
id: 'comment1',
assetId: 'file1',
@@ -215,6 +218,7 @@ describe('file api', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
})
// Mock assetService.getAsset to return teamId for notification
@@ -274,6 +278,7 @@ describe('file api', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
})
// Mock assetService.getAsset to return teamId for notification
@@ -330,6 +335,7 @@ describe('file api', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
},
],
pageInfo: { cursor: 'cursor', total: 1 },
@@ -349,6 +355,7 @@ describe('file api', () => {
type: ResourceType.Asset,
id: 'test-id',
})
expect(assetService.listComments).toHaveBeenCalledWith('test-id', expect.anything(), 'user1')
})
it('POST /files/:fileId/comments/export - success', async () => {
@@ -472,6 +479,7 @@ describe('file api', () => {
sessionId: null,
isCompleted: true,
completionLastChangedBy: { id: 'user1', name: 'Test User' },
reactionCounts: [],
})
const app = new Hono().use('*', authMiddleware).route('/', fileRoute)
@@ -520,6 +528,56 @@ describe('file api', () => {
})
})
it('POST /comments/:commentId/reactions', async () => {
vi.mocked(assetService.addCommentReaction).mockResolvedValue(undefined)
const app = new Hono().use('*', authMiddleware).route('/', fileRoute)
const res = await app.request('/comments/comment-id/reactions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ code: '👍' }),
})
expect(res.status).toBe(200)
const json = await res.json()
expect(json.success).toBe(true)
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user1', name: 'Test User' },
permission: Permission.Read,
type: ResourceType.Comment,
id: 'comment-id',
})
expect(assetService.addCommentReaction).toHaveBeenCalledWith('comment-id', 'user1', '👍')
})
it('DELETE /comments/:commentId/reactions', async () => {
vi.mocked(assetService.removeCommentReaction).mockResolvedValue(undefined)
const app = new Hono().use('*', authMiddleware).route('/', fileRoute)
const res = await app.request('/comments/comment-id/reactions', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ code: '👍' }),
})
expect(res.status).toBe(200)
const json = await res.json()
expect(json.success).toBe(true)
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user1', name: 'Test User' },
permission: Permission.Read,
type: ResourceType.Comment,
id: 'comment-id',
})
expect(assetService.removeCommentReaction).toHaveBeenCalledWith('comment-id', 'user1', '👍')
})
it('POST /teams/:teamId/files - image with compression', async () => {
vi.mocked(s3Service.putObject).mockResolvedValue(undefined)
+43 -1
View File
@@ -18,6 +18,8 @@ import {
getDownloadLinksRequestSchema,
completeCommentRequestSchema,
exportCommentsRequestSchema,
addCommentReactionRequestSchema,
removeCommentReactionRequestSchema,
AuditAction,
} from '@shumai/dtos'
import { transcodeService, buildContentDisposition } from '@shumai/core'
@@ -225,7 +227,7 @@ const route = new Hono<{ Variables: { user: User } }>()
id: fileId,
})
const comments = await assetService.listComments(fileId, req)
const comments = await assetService.listComments(fileId, req, user.id)
return c.json(comments)
})
.post(
@@ -250,6 +252,46 @@ const route = new Hono<{ Variables: { user: User } }>()
return c.body(result.content)
},
)
.post(
'/comments/:commentId/reactions',
zValidator('json', addCommentReactionRequestSchema),
async (c) => {
const commentId = c.req.param('commentId')
const user = c.get('user')
const req = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Read,
type: ResourceType.Comment,
id: commentId,
})
await assetService.addCommentReaction(commentId, user.id, req.code)
return c.json({ success: true })
},
)
.delete(
'/comments/:commentId/reactions',
zValidator('json', removeCommentReactionRequestSchema),
async (c) => {
const commentId = c.req.param('commentId')
const user = c.get('user')
const req = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Read,
type: ResourceType.Comment,
id: commentId,
})
await assetService.removeCommentReaction(commentId, user.id, req.code)
return c.json({ success: true })
},
)
.post(
'/comments/:commentId/complete',
zValidator('json', completeCommentRequestSchema),
+8 -1
View File
@@ -282,7 +282,14 @@ const route = app
await shareService.verifyPublicAccess(fileId, password)
const targetFileId = await assetService.resolveTargetAssetId(fileId)
const res = await assetService.listComments(targetFileId, req)
let userId: string | undefined
const session = await auth.api.getSession({
headers: c.req.raw.headers,
})
if (session?.user) {
userId = session.user.id
}
const res = await assetService.listComments(targetFileId, req, userId)
return c.json(res)
} catch (err) {
return handlePublicShareError(c, err)
+98
View File
@@ -1117,6 +1117,104 @@ describe('AssetService', () => {
expect(incompleted.completionLastChangedBy?.id).toBe(user.id)
})
describe('Comment Reactions', () => {
it('adds, removes, and lists reactions chronologically with creatorNames', async () => {
const { user, assets } = await setupBasicAssets()
const user2 = await prisma.user.create({
data: {
name: 'Bob',
type: 'human',
email: `bob-${Date.now()}@example.com`,
},
})
const user3 = await prisma.user.create({
data: {
name: 'Charlie',
type: 'human',
email: `charlie-${Date.now()}@example.com`,
},
})
const comment = await assetService.createComment({
assetId: assets.fileA1.id,
userId: user.id,
message: 'A wonderful comment',
attachmentIds: [],
})
// Add reaction 1: Bob adds 👍
await assetService.addCommentReaction(comment.id, user2.id, '👍')
// Idempotency: Bob adds 👍 again
await assetService.addCommentReaction(comment.id, user2.id, '👍')
// Add reaction 2: Charlie adds ❤️
await assetService.addCommentReaction(comment.id, user3.id, '❤️')
// Add reaction 3: Alice (user) adds 👍
await assetService.addCommentReaction(comment.id, user.id, '👍')
// Fetch as user (Alice)
const commentAsAlice = await assetService.getComment(comment.id, user.id)
expect(commentAsAlice.reactionCounts).toHaveLength(2)
// First reaction added was 👍, then ❤️
expect(commentAsAlice.reactionCounts[0].code).toBe('👍')
expect(commentAsAlice.reactionCounts[0].count).toBe(2)
expect(commentAsAlice.reactionCounts[0].requestingUserReacted).toBe(true)
expect(commentAsAlice.reactionCounts[0].creatorNames).toEqual(['Bob'])
expect(commentAsAlice.reactionCounts[1].code).toBe('❤️')
expect(commentAsAlice.reactionCounts[1].count).toBe(1)
expect(commentAsAlice.reactionCounts[1].requestingUserReacted).toBe(false)
expect(commentAsAlice.reactionCounts[1].creatorNames).toEqual(['Charlie'])
// Fetch as Bob
const commentAsBob = await assetService.getComment(comment.id, user2.id)
expect(commentAsBob.reactionCounts[0].code).toBe('👍')
expect(commentAsBob.reactionCounts[0].requestingUserReacted).toBe(true)
expect(commentAsBob.reactionCounts[0].creatorNames).toEqual([user.name])
// Remove Alice's 👍
await assetService.removeCommentReaction(comment.id, user.id, '👍')
// Idempotency
await assetService.removeCommentReaction(comment.id, user.id, '👍')
const updatedAlice = await assetService.getComment(comment.id, user.id)
expect(updatedAlice.reactionCounts[0].code).toBe('👍')
expect(updatedAlice.reactionCounts[0].count).toBe(1)
expect(updatedAlice.reactionCounts[0].requestingUserReacted).toBe(false)
expect(updatedAlice.reactionCounts[0].creatorNames).toEqual(['Bob'])
// Verify listComments returns reactions for comments and replies
const reply = await assetService.createComment({
assetId: assets.fileA1.id,
userId: user2.id,
message: 'A nice reply',
replyToId: comment.id,
attachmentIds: [],
})
await assetService.addCommentReaction(reply.id, user.id, '🎉')
const listRes = await assetService.listComments(assets.fileA1.id, { first: 10 }, user.id)
const listedComment = listRes.data.find((c) => c.id === comment.id)
expect(listedComment).toBeDefined()
expect(listedComment?.reactionCounts[0].code).toBe('👍')
expect(listedComment?.replies).toHaveLength(1)
expect(listedComment?.replies[0].reactionCounts).toHaveLength(1)
expect(listedComment?.replies[0].reactionCounts[0].code).toBe('🎉')
expect(listedComment?.replies[0].reactionCounts[0].requestingUserReacted).toBe(true)
})
it('throws error when adding reaction to nonexistent comment', async () => {
const { user } = await setupBasicAssets()
await expect(
assetService.addCommentReaction('nonexistent-id', user.id, '👍'),
).rejects.toThrow('Comment not found')
})
})
it('can export comments in all supported NLE formats', async () => {
const { user, assets } = await setupBasicAssets()
+122 -6
View File
@@ -5,6 +5,7 @@ import {
AttachmentInfo,
ChildPreview,
CommentInfo,
CommentReactionCount,
CopyAssetsRequest,
CreateAssetRequest,
CreateCommentRequest,
@@ -86,11 +87,21 @@ type CommentWithIncludes = Prisma.AssetCommentGetPayload<{
creator: true
completionLastChangedBy: true
attachments: { include: { asset: { include: { storageKey: true } } } }
reactions: {
include: {
user: { select: { id: true; name: true } }
}
}
replies: {
include: {
creator: true
completionLastChangedBy: true
attachments: { include: { asset: { include: { storageKey: true } } } }
reactions: {
include: {
user: { select: { id: true; name: true } }
}
}
}
}
}
@@ -1707,10 +1718,10 @@ export class AssetService {
}
})
return this.getComment(commentId)
return this.getComment(commentId, req.userId)
}
async getComment(commentId: string): Promise<CommentInfo> {
async getComment(commentId: string, requestingUserId?: string): Promise<CommentInfo> {
const c = await this.prismaClient.assetComment.findUnique({
where: { id: commentId },
include: {
@@ -1718,18 +1729,65 @@ export class AssetService {
completionLastChangedBy: true,
asset: { include: { storageKey: true } },
attachments: { include: { asset: { include: { storageKey: true } } } },
reactions: {
include: {
user: { select: { id: true, name: true } },
},
orderBy: { createdAt: 'asc' },
},
replies: {
include: {
creator: true,
completionLastChangedBy: true,
attachments: { include: { asset: { include: { storageKey: true } } } },
reactions: {
include: {
user: { select: { id: true, name: true } },
},
orderBy: { createdAt: 'asc' },
},
},
orderBy: { id: 'asc' },
},
},
})
if (!c) throw new Error('Comment not found')
return this.toCommentInfo(c)
return this.toCommentInfo(c, requestingUserId)
}
async addCommentReaction(commentId: string, userId: string, code: string): Promise<void> {
const comment = await this.prismaClient.assetComment.findUnique({
where: { id: commentId },
select: { id: true },
})
if (!comment) throw new Error('Comment not found')
await this.prismaClient.assetCommentReaction.upsert({
where: {
// eslint-disable-next-line @typescript-eslint/naming-convention
commentId_userId_code: {
commentId,
userId,
code,
},
},
create: {
commentId,
userId,
code,
},
update: {},
})
}
async removeCommentReaction(commentId: string, userId: string, code: string): Promise<void> {
await this.prismaClient.assetCommentReaction.deleteMany({
where: {
commentId,
userId,
code,
},
})
}
async completeComment(
@@ -1744,7 +1802,7 @@ export class AssetService {
completionLastChangedById: userId,
},
})
return this.getComment(commentId)
return this.getComment(commentId, userId)
}
async deleteComment({ commentId, userId }: { commentId: string; userId: string }): Promise<void> {
@@ -1835,6 +1893,7 @@ export class AssetService {
async listComments(
assetId: string,
params: PaginationParams,
requestingUserId?: string,
): Promise<PaginatedData<CommentInfo[]>> {
const resolvedAssetId = await this.resolveLatestVersionId(assetId)
@@ -1847,11 +1906,23 @@ export class AssetService {
completionLastChangedBy: true,
asset: { include: { storageKey: true } },
attachments: { include: { asset: { include: { storageKey: true } } } },
reactions: {
include: {
user: { select: { id: true, name: true } },
},
orderBy: { createdAt: 'asc' },
},
replies: {
include: {
creator: true,
completionLastChangedBy: true,
attachments: { include: { asset: { include: { storageKey: true } } } },
reactions: {
include: {
user: { select: { id: true, name: true } },
},
orderBy: { createdAt: 'asc' },
},
},
orderBy: { id: 'asc' },
},
@@ -1865,7 +1936,7 @@ export class AssetService {
params,
)
const infos = await Promise.all(comments.map((c) => this.toCommentInfo(c)))
const infos = await Promise.all(comments.map((c) => this.toCommentInfo(c, requestingUserId)))
return { data: infos, pageInfo }
}
@@ -2575,11 +2646,12 @@ export class AssetService {
private async toCommentInfo(
c: CommentWithIncludes | CommentWithIncludes['replies'][0],
requestingUserId?: string,
): Promise<CommentInfo> {
const replies: CommentInfo[] = []
if ('replies' in c && c.replies) {
for (const r of c.replies) {
replies.push(await this.toCommentInfo(r))
replies.push(await this.toCommentInfo(r, requestingUserId))
}
}
@@ -2643,6 +2715,49 @@ export class AssetService {
}
: null
const reactionsMap = new Map<
string,
{
count: number
requestingUserReacted: boolean
creatorNames: string[]
firstCreatedAt: Date
}
>()
if ('reactions' in c && c.reactions) {
for (const reaction of c.reactions) {
let entry = reactionsMap.get(reaction.code)
if (!entry) {
entry = {
count: 0,
requestingUserReacted: false,
creatorNames: [],
firstCreatedAt: reaction.createdAt,
}
reactionsMap.set(reaction.code, entry)
}
entry.count++
if (requestingUserId && reaction.userId === requestingUserId) {
entry.requestingUserReacted = true
} else {
const userName = reaction.user?.name || 'User'
if (!entry.creatorNames.includes(userName)) {
entry.creatorNames.push(userName)
}
}
}
}
const reactionCounts: CommentReactionCount[] = Array.from(reactionsMap.entries())
.sort((a, b) => a[1].firstCreatedAt.getTime() - b[1].firstCreatedAt.getTime())
.map(([code, data]) => ({
code,
count: data.count,
requestingUserReacted: data.requestingUserReacted,
creatorNames: data.creatorNames,
}))
return {
id: c.id,
assetId: c.assetId,
@@ -2658,6 +2773,7 @@ export class AssetService {
sessionId: c.sessionId,
isCompleted: c.isCompleted,
completionLastChangedBy,
reactionCounts,
}
}
@@ -0,0 +1,22 @@
-- CreateTable
CREATE TABLE "asset_comment_reactions" (
"id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"comment_id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"code" TEXT NOT NULL,
CONSTRAINT "asset_comment_reactions_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "asset_comment_reactions_comment_id_idx" ON "asset_comment_reactions"("comment_id");
-- CreateIndex
CREATE UNIQUE INDEX "asset_comment_reactions_comment_id_user_id_code_key" ON "asset_comment_reactions"("comment_id", "user_id", "code");
-- AddForeignKey
ALTER TABLE "asset_comment_reactions" ADD CONSTRAINT "asset_comment_reactions_comment_id_fkey" FOREIGN KEY ("comment_id") REFERENCES "asset_comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "asset_comment_reactions" ADD CONSTRAINT "asset_comment_reactions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,8 @@
/*
Warnings:
- You are about to alter the column `code` on the `asset_comment_reactions` table. The data in that column could be lost. The data in that column will be cast from `Text` to `VarChar(32)`.
*/
-- AlterTable
ALTER TABLE "asset_comment_reactions" ALTER COLUMN "code" SET DATA TYPE VARCHAR(32);
+19
View File
@@ -218,6 +218,7 @@ model User {
teamMembers TeamMember[] @relation("UserToTeamMember")
comments AssetComment[] @relation("UserToAssetComment")
completionChangedComments AssetComment[] @relation("UserToAssetCommentCompletionChanged")
commentReactions AssetCommentReaction[] @relation("UserToAssetCommentReaction")
createdInvites Invite[] @relation("UserToInvite")
createdNotifications Notification[] @relation("UserToCreatedNotification")
notifications Notification[] @relation("UserToNotification")
@@ -656,6 +657,7 @@ model AssetComment {
replies AssetComment[] @relation("CommentReplies")
attachments AssetCommentAttachment[] @relation("CommentToAttachment")
reactions AssetCommentReaction[] @relation("CommentToReaction")
@@index([assetId])
@@map("asset_comments")
@@ -675,6 +677,23 @@ model AssetCommentAttachment {
@@map("asset_comment_attachments")
}
model AssetCommentReaction {
id String @id @default(ulid())
createdAt DateTime @default(now()) @map("created_at")
commentId String @map("comment_id")
comment AssetComment @relation("CommentToReaction", fields: [commentId], references: [id], onDelete: Cascade)
userId String @map("user_id")
user User @relation("UserToAssetCommentReaction", fields: [userId], references: [id], onDelete: Cascade)
code String @db.VarChar(32)
@@unique([commentId, userId, code])
@@index([commentId])
@@map("asset_comment_reactions")
}
model AssetEmbedding {
id String @id @default(ulid())
embedding Unsupported("vector(1536)")?
+5
View File
@@ -122,6 +122,11 @@ export type AssetComment = Prisma.AssetCommentModel
*
*/
export type AssetCommentAttachment = Prisma.AssetCommentAttachmentModel
/**
* Model AssetCommentReaction
*
*/
export type AssetCommentReaction = Prisma.AssetCommentReactionModel
/**
* Model AssetEmbedding
*
+5
View File
@@ -146,6 +146,11 @@ export type AssetComment = Prisma.AssetCommentModel
*
*/
export type AssetCommentAttachment = Prisma.AssetCommentAttachmentModel
/**
* Model AssetCommentReaction
*
*/
export type AssetCommentReaction = Prisma.AssetCommentReactionModel
/**
* Model AssetEmbedding
*
File diff suppressed because one or more lines are too long
+88 -1
View File
@@ -418,6 +418,7 @@ export const ModelName = {
AssetAgentMd: 'AssetAgentMd',
AssetComment: 'AssetComment',
AssetCommentAttachment: 'AssetCommentAttachment',
AssetCommentReaction: 'AssetCommentReaction',
AssetEmbedding: 'AssetEmbedding',
Invite: 'Invite',
MetadataField: 'MetadataField',
@@ -463,7 +464,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
omit: GlobalOmitOptions
}
meta: {
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent" | "recentFileItem"
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetCommentReaction" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent" | "recentFileItem"
txIsolationLevel: TransactionIsolationLevel
}
model: {
@@ -2021,6 +2022,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
}
}
}
AssetCommentReaction: {
payload: Prisma.$AssetCommentReactionPayload<ExtArgs>
fields: Prisma.AssetCommentReactionFieldRefs
operations: {
findUnique: {
args: Prisma.AssetCommentReactionFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload> | null
}
findUniqueOrThrow: {
args: Prisma.AssetCommentReactionFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>
}
findFirst: {
args: Prisma.AssetCommentReactionFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload> | null
}
findFirstOrThrow: {
args: Prisma.AssetCommentReactionFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>
}
findMany: {
args: Prisma.AssetCommentReactionFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>[]
}
create: {
args: Prisma.AssetCommentReactionCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>
}
createMany: {
args: Prisma.AssetCommentReactionCreateManyArgs<ExtArgs>
result: BatchPayload
}
createManyAndReturn: {
args: Prisma.AssetCommentReactionCreateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>[]
}
delete: {
args: Prisma.AssetCommentReactionDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>
}
update: {
args: Prisma.AssetCommentReactionUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>
}
deleteMany: {
args: Prisma.AssetCommentReactionDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.AssetCommentReactionUpdateManyArgs<ExtArgs>
result: BatchPayload
}
updateManyAndReturn: {
args: Prisma.AssetCommentReactionUpdateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>[]
}
upsert: {
args: Prisma.AssetCommentReactionUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetCommentReactionPayload>
}
aggregate: {
args: Prisma.AssetCommentReactionAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateAssetCommentReaction>
}
groupBy: {
args: Prisma.AssetCommentReactionGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AssetCommentReactionGroupByOutputType>[]
}
count: {
args: Prisma.AssetCommentReactionCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AssetCommentReactionCountAggregateOutputType> | number
}
}
}
AssetEmbedding: {
payload: Prisma.$AssetEmbeddingPayload<ExtArgs>
fields: Prisma.AssetEmbeddingFieldRefs
@@ -4584,6 +4659,17 @@ export const AssetCommentAttachmentScalarFieldEnum = {
export type AssetCommentAttachmentScalarFieldEnum = (typeof AssetCommentAttachmentScalarFieldEnum)[keyof typeof AssetCommentAttachmentScalarFieldEnum]
export const AssetCommentReactionScalarFieldEnum = {
id: 'id',
createdAt: 'createdAt',
commentId: 'commentId',
userId: 'userId',
code: 'code'
} as const
export type AssetCommentReactionScalarFieldEnum = (typeof AssetCommentReactionScalarFieldEnum)[keyof typeof AssetCommentReactionScalarFieldEnum]
export const AssetEmbeddingScalarFieldEnum = {
id: 'id',
startTime: 'startTime',
@@ -5686,6 +5772,7 @@ export type GlobalOmitConfig = {
assetAgentMd?: Prisma.AssetAgentMdOmit
assetComment?: Prisma.AssetCommentOmit
assetCommentAttachment?: Prisma.AssetCommentAttachmentOmit
assetCommentReaction?: Prisma.AssetCommentReactionOmit
assetEmbedding?: Prisma.AssetEmbeddingOmit
invite?: Prisma.InviteOmit
metadataField?: Prisma.MetadataFieldOmit
@@ -72,6 +72,7 @@ export const ModelName = {
AssetAgentMd: 'AssetAgentMd',
AssetComment: 'AssetComment',
AssetCommentAttachment: 'AssetCommentAttachment',
AssetCommentReaction: 'AssetCommentReaction',
AssetEmbedding: 'AssetEmbedding',
Invite: 'Invite',
MetadataField: 'MetadataField',
@@ -424,6 +425,17 @@ export const AssetCommentAttachmentScalarFieldEnum = {
export type AssetCommentAttachmentScalarFieldEnum = (typeof AssetCommentAttachmentScalarFieldEnum)[keyof typeof AssetCommentAttachmentScalarFieldEnum]
export const AssetCommentReactionScalarFieldEnum = {
id: 'id',
createdAt: 'createdAt',
commentId: 'commentId',
userId: 'userId',
code: 'code'
} as const
export type AssetCommentReactionScalarFieldEnum = (typeof AssetCommentReactionScalarFieldEnum)[keyof typeof AssetCommentReactionScalarFieldEnum]
export const AssetEmbeddingScalarFieldEnum = {
id: 'id',
startTime: 'startTime',
+1
View File
@@ -29,6 +29,7 @@ export type * from './models/AssetMetadataValue.ts'
export type * from './models/AssetAgentMd.ts'
export type * from './models/AssetComment.ts'
export type * from './models/AssetCommentAttachment.ts'
export type * from './models/AssetCommentReaction.ts'
export type * from './models/AssetEmbedding.ts'
export type * from './models/Invite.ts'
export type * from './models/MetadataField.ts'
+170
View File
@@ -277,6 +277,7 @@ export type AssetCommentWhereInput = {
replyTo?: Prisma.XOR<Prisma.AssetCommentNullableScalarRelationFilter, Prisma.AssetCommentWhereInput> | null
replies?: Prisma.AssetCommentListRelationFilter
attachments?: Prisma.AssetCommentAttachmentListRelationFilter
reactions?: Prisma.AssetCommentReactionListRelationFilter
}
export type AssetCommentOrderByWithRelationInput = {
@@ -299,6 +300,7 @@ export type AssetCommentOrderByWithRelationInput = {
replyTo?: Prisma.AssetCommentOrderByWithRelationInput
replies?: Prisma.AssetCommentOrderByRelationAggregateInput
attachments?: Prisma.AssetCommentAttachmentOrderByRelationAggregateInput
reactions?: Prisma.AssetCommentReactionOrderByRelationAggregateInput
}
export type AssetCommentWhereUniqueInput = Prisma.AtLeast<{
@@ -324,6 +326,7 @@ export type AssetCommentWhereUniqueInput = Prisma.AtLeast<{
replyTo?: Prisma.XOR<Prisma.AssetCommentNullableScalarRelationFilter, Prisma.AssetCommentWhereInput> | null
replies?: Prisma.AssetCommentListRelationFilter
attachments?: Prisma.AssetCommentAttachmentListRelationFilter
reactions?: Prisma.AssetCommentReactionListRelationFilter
}, "id">
export type AssetCommentOrderByWithAggregationInput = {
@@ -379,6 +382,7 @@ export type AssetCommentCreateInput = {
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateInput = {
@@ -396,6 +400,7 @@ export type AssetCommentUncheckedCreateInput = {
replyToId?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentUpdateInput = {
@@ -413,6 +418,7 @@ export type AssetCommentUpdateInput = {
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateInput = {
@@ -430,6 +436,7 @@ export type AssetCommentUncheckedUpdateInput = {
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentCreateManyInput = {
@@ -741,6 +748,20 @@ export type AssetCommentUpdateOneRequiredWithoutAttachmentsNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetCommentUpdateToOneWithWhereWithoutAttachmentsInput, Prisma.AssetCommentUpdateWithoutAttachmentsInput>, Prisma.AssetCommentUncheckedUpdateWithoutAttachmentsInput>
}
export type AssetCommentCreateNestedOneWithoutReactionsInput = {
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutReactionsInput, Prisma.AssetCommentUncheckedCreateWithoutReactionsInput>
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutReactionsInput
connect?: Prisma.AssetCommentWhereUniqueInput
}
export type AssetCommentUpdateOneRequiredWithoutReactionsNestedInput = {
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutReactionsInput, Prisma.AssetCommentUncheckedCreateWithoutReactionsInput>
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutReactionsInput
upsert?: Prisma.AssetCommentUpsertWithoutReactionsInput
connect?: Prisma.AssetCommentWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetCommentUpdateToOneWithWhereWithoutReactionsInput, Prisma.AssetCommentUpdateWithoutReactionsInput>, Prisma.AssetCommentUncheckedUpdateWithoutReactionsInput>
}
export type AssetCommentCreateNestedManyWithoutSessionInput = {
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutSessionInput, Prisma.AssetCommentUncheckedCreateWithoutSessionInput> | Prisma.AssetCommentCreateWithoutSessionInput[] | Prisma.AssetCommentUncheckedCreateWithoutSessionInput[]
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutSessionInput | Prisma.AssetCommentCreateOrConnectWithoutSessionInput[]
@@ -797,6 +818,7 @@ export type AssetCommentCreateWithoutCreatorInput = {
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutCreatorInput = {
@@ -813,6 +835,7 @@ export type AssetCommentUncheckedCreateWithoutCreatorInput = {
replyToId?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutCreatorInput = {
@@ -839,6 +862,7 @@ export type AssetCommentCreateWithoutCompletionLastChangedByInput = {
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutCompletionLastChangedByInput = {
@@ -855,6 +879,7 @@ export type AssetCommentUncheckedCreateWithoutCompletionLastChangedByInput = {
replyToId?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutCompletionLastChangedByInput = {
@@ -931,6 +956,7 @@ export type AssetCommentCreateWithoutAssetInput = {
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutAssetInput = {
@@ -947,6 +973,7 @@ export type AssetCommentUncheckedCreateWithoutAssetInput = {
replyToId?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutAssetInput = {
@@ -989,6 +1016,7 @@ export type AssetCommentCreateWithoutRepliesInput = {
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutRepliesInput = {
@@ -1005,6 +1033,7 @@ export type AssetCommentUncheckedCreateWithoutRepliesInput = {
completionLastChangedById?: string | null
replyToId?: string | null
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutRepliesInput = {
@@ -1026,6 +1055,7 @@ export type AssetCommentCreateWithoutReplyToInput = {
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutReplyToInput = {
@@ -1042,6 +1072,7 @@ export type AssetCommentUncheckedCreateWithoutReplyToInput = {
completionLastChangedById?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutReplyToInput = {
@@ -1079,6 +1110,7 @@ export type AssetCommentUpdateWithoutRepliesInput = {
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutRepliesInput = {
@@ -1095,6 +1127,7 @@ export type AssetCommentUncheckedUpdateWithoutRepliesInput = {
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUpsertWithWhereUniqueWithoutReplyToInput = {
@@ -1127,6 +1160,7 @@ export type AssetCommentCreateWithoutAttachmentsInput = {
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutAttachmentsInput = {
@@ -1143,6 +1177,7 @@ export type AssetCommentUncheckedCreateWithoutAttachmentsInput = {
completionLastChangedById?: string | null
replyToId?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutAttachmentsInput = {
@@ -1175,6 +1210,7 @@ export type AssetCommentUpdateWithoutAttachmentsInput = {
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutAttachmentsInput = {
@@ -1191,6 +1227,91 @@ export type AssetCommentUncheckedUpdateWithoutAttachmentsInput = {
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentCreateWithoutReactionsInput = {
id?: string
message?: string | null
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
second?: number | null
createdAt?: Date | string
updatedAt?: Date | string
isCompleted?: boolean
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutReactionsInput = {
id?: string
message?: string | null
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
second?: number | null
sessionId?: string | null
createdAt?: Date | string
updatedAt?: Date | string
assetId: string
creatorId?: string | null
isCompleted?: boolean
completionLastChangedById?: string | null
replyToId?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutReactionsInput = {
where: Prisma.AssetCommentWhereUniqueInput
create: Prisma.XOR<Prisma.AssetCommentCreateWithoutReactionsInput, Prisma.AssetCommentUncheckedCreateWithoutReactionsInput>
}
export type AssetCommentUpsertWithoutReactionsInput = {
update: Prisma.XOR<Prisma.AssetCommentUpdateWithoutReactionsInput, Prisma.AssetCommentUncheckedUpdateWithoutReactionsInput>
create: Prisma.XOR<Prisma.AssetCommentCreateWithoutReactionsInput, Prisma.AssetCommentUncheckedCreateWithoutReactionsInput>
where?: Prisma.AssetCommentWhereInput
}
export type AssetCommentUpdateToOneWithWhereWithoutReactionsInput = {
where?: Prisma.AssetCommentWhereInput
data: Prisma.XOR<Prisma.AssetCommentUpdateWithoutReactionsInput, Prisma.AssetCommentUncheckedUpdateWithoutReactionsInput>
}
export type AssetCommentUpdateWithoutReactionsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
message?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutReactionsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
message?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
assetId?: Prisma.StringFieldUpdateOperationsInput | string
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentCreateWithoutSessionInput = {
@@ -1207,6 +1328,7 @@ export type AssetCommentCreateWithoutSessionInput = {
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
}
export type AssetCommentUncheckedCreateWithoutSessionInput = {
@@ -1223,6 +1345,7 @@ export type AssetCommentUncheckedCreateWithoutSessionInput = {
replyToId?: string | null
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
}
export type AssetCommentCreateOrConnectWithoutSessionInput = {
@@ -1293,6 +1416,7 @@ export type AssetCommentUpdateWithoutCreatorInput = {
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutCreatorInput = {
@@ -1309,6 +1433,7 @@ export type AssetCommentUncheckedUpdateWithoutCreatorInput = {
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateManyWithoutCreatorInput = {
@@ -1339,6 +1464,7 @@ export type AssetCommentUpdateWithoutCompletionLastChangedByInput = {
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutCompletionLastChangedByInput = {
@@ -1355,6 +1481,7 @@ export type AssetCommentUncheckedUpdateWithoutCompletionLastChangedByInput = {
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateManyWithoutCompletionLastChangedByInput = {
@@ -1399,6 +1526,7 @@ export type AssetCommentUpdateWithoutAssetInput = {
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutAssetInput = {
@@ -1415,6 +1543,7 @@ export type AssetCommentUncheckedUpdateWithoutAssetInput = {
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateManyWithoutAssetInput = {
@@ -1459,6 +1588,7 @@ export type AssetCommentUpdateWithoutReplyToInput = {
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutReplyToInput = {
@@ -1475,6 +1605,7 @@ export type AssetCommentUncheckedUpdateWithoutReplyToInput = {
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateManyWithoutReplyToInput = {
@@ -1519,6 +1650,7 @@ export type AssetCommentUpdateWithoutSessionInput = {
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateWithoutSessionInput = {
@@ -1535,6 +1667,7 @@ export type AssetCommentUncheckedUpdateWithoutSessionInput = {
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
}
export type AssetCommentUncheckedUpdateManyWithoutSessionInput = {
@@ -1559,11 +1692,13 @@ export type AssetCommentUncheckedUpdateManyWithoutSessionInput = {
export type AssetCommentCountOutputType = {
replies: number
attachments: number
reactions: number
}
export type AssetCommentCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
replies?: boolean | AssetCommentCountOutputTypeCountRepliesArgs
attachments?: boolean | AssetCommentCountOutputTypeCountAttachmentsArgs
reactions?: boolean | AssetCommentCountOutputTypeCountReactionsArgs
}
/**
@@ -1590,6 +1725,13 @@ export type AssetCommentCountOutputTypeCountAttachmentsArgs<ExtArgs extends runt
where?: Prisma.AssetCommentAttachmentWhereInput
}
/**
* AssetCommentCountOutputType without action
*/
export type AssetCommentCountOutputTypeCountReactionsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
where?: Prisma.AssetCommentReactionWhereInput
}
export type AssetCommentSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
@@ -1611,6 +1753,7 @@ export type AssetCommentSelect<ExtArgs extends runtime.Types.Extensions.Internal
replyTo?: boolean | Prisma.AssetComment$replyToArgs<ExtArgs>
replies?: boolean | Prisma.AssetComment$repliesArgs<ExtArgs>
attachments?: boolean | Prisma.AssetComment$attachmentsArgs<ExtArgs>
reactions?: boolean | Prisma.AssetComment$reactionsArgs<ExtArgs>
_count?: boolean | Prisma.AssetCommentCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["assetComment"]>
@@ -1678,6 +1821,7 @@ export type AssetCommentInclude<ExtArgs extends runtime.Types.Extensions.Interna
replyTo?: boolean | Prisma.AssetComment$replyToArgs<ExtArgs>
replies?: boolean | Prisma.AssetComment$repliesArgs<ExtArgs>
attachments?: boolean | Prisma.AssetComment$attachmentsArgs<ExtArgs>
reactions?: boolean | Prisma.AssetComment$reactionsArgs<ExtArgs>
_count?: boolean | Prisma.AssetCommentCountOutputTypeDefaultArgs<ExtArgs>
}
export type AssetCommentIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -1705,6 +1849,7 @@ export type $AssetCommentPayload<ExtArgs extends runtime.Types.Extensions.Intern
replyTo: Prisma.$AssetCommentPayload<ExtArgs> | null
replies: Prisma.$AssetCommentPayload<ExtArgs>[]
attachments: Prisma.$AssetCommentAttachmentPayload<ExtArgs>[]
reactions: Prisma.$AssetCommentReactionPayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
@@ -2123,6 +2268,7 @@ export interface Prisma__AssetCommentClient<T, Null = never, ExtArgs extends run
replyTo<T extends Prisma.AssetComment$replyToArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$replyToArgs<ExtArgs>>): Prisma.Prisma__AssetCommentClient<runtime.Types.Result.GetResult<Prisma.$AssetCommentPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
replies<T extends Prisma.AssetComment$repliesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$repliesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AssetCommentPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
attachments<T extends Prisma.AssetComment$attachmentsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$attachmentsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AssetCommentAttachmentPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
reactions<T extends Prisma.AssetComment$reactionsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$reactionsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AssetCommentReactionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
@@ -2688,6 +2834,30 @@ export type AssetComment$attachmentsArgs<ExtArgs extends runtime.Types.Extension
distinct?: Prisma.AssetCommentAttachmentScalarFieldEnum | Prisma.AssetCommentAttachmentScalarFieldEnum[]
}
/**
* AssetComment.reactions
*/
export type AssetComment$reactionsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the AssetCommentReaction
*/
select?: Prisma.AssetCommentReactionSelect<ExtArgs> | null
/**
* Omit specific fields from the AssetCommentReaction
*/
omit?: Prisma.AssetCommentReactionOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.AssetCommentReactionInclude<ExtArgs> | null
where?: Prisma.AssetCommentReactionWhereInput
orderBy?: Prisma.AssetCommentReactionOrderByWithRelationInput | Prisma.AssetCommentReactionOrderByWithRelationInput[]
cursor?: Prisma.AssetCommentReactionWhereUniqueInput
take?: number
skip?: number
distinct?: Prisma.AssetCommentReactionScalarFieldEnum | Prisma.AssetCommentReactionScalarFieldEnum[]
}
/**
* AssetComment without action
*/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+20
View File
@@ -207,6 +207,24 @@ export const attachmentInfoSchema = z.object({
})
export type AttachmentInfo = z.infer<typeof attachmentInfoSchema>
export const commentReactionCountSchema = z.object({
code: z.string(),
count: z.number(),
requestingUserReacted: z.boolean(),
creatorNames: z.array(z.string()),
})
export type CommentReactionCount = z.infer<typeof commentReactionCountSchema>
export const addCommentReactionRequestSchema = z.object({
code: z.string().min(1),
})
export type AddCommentReactionRequest = z.infer<typeof addCommentReactionRequestSchema>
export const removeCommentReactionRequestSchema = z.object({
code: z.string().min(1),
})
export type RemoveCommentReactionRequest = z.infer<typeof removeCommentReactionRequestSchema>
export type CommentInfo = {
id: string
assetId: string
@@ -223,6 +241,7 @@ export type CommentInfo = {
sessionId: string | null
isCompleted: boolean
completionLastChangedBy: AssetUserInfo | null
reactionCounts: CommentReactionCount[]
}
export const commentInfoSchema: z.ZodType<CommentInfo> = z.object({
@@ -241,6 +260,7 @@ export const commentInfoSchema: z.ZodType<CommentInfo> = z.object({
sessionId: z.string().nullable(),
isCompleted: z.boolean(),
completionLastChangedBy: assetUserInfoSchema.nullable(),
reactionCounts: z.array(commentReactionCountSchema),
})
export const completeCommentRequestSchema = z.object({
@@ -1,11 +1,54 @@
// @vitest-environment happy-dom
import React from 'react'
import { cleanup, render, screen, fireEvent } from '@testing-library/react'
import { cleanup, render, screen, fireEvent, waitFor } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import type { CommentInfo } from '@shumai/dtos'
import { MessageCard } from './message-card'
import { client } from '@/ui/api/client'
vi.mock('@/ui/api/client', () => ({
client: {
api: {
teams: {
':teamId': {
me: {
$get: vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ id: 'u-1', name: 'Bob Reviewer', role: 'member' }),
}),
},
},
},
comments: {
':commentId': {
complete: {
$post: vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ isCompleted: true }),
}),
},
reactions: {
$post: vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ success: true }),
}),
$delete: vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ success: true }),
}),
},
$delete: vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ success: true }),
}),
},
},
},
},
}))
function createWrapper() {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
@@ -56,6 +99,7 @@ describe('MessageCard component', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
}
const onReply = vi.fn()
@@ -98,4 +142,124 @@ describe('MessageCard component', () => {
)
windowOpenSpy.mockRestore()
})
it('renders reaction badges with active and inactive styling and toggles on click', async () => {
const mockMessage: CommentInfo = {
id: 'msg-reactions',
assetId: 'asset-1',
message: 'Great work!',
annotations: null,
second: null,
creator: { id: 'u-2', name: 'Alice' },
replies: [],
attachments: [],
mentions: [],
createdAt: '2026-08-20T10:30:00.000Z',
updatedAt: '2026-08-20T10:30:00.000Z',
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [
{
code: '👍',
count: 2,
requestingUserReacted: true,
creatorNames: ['Bob'],
},
{
code: '❤️',
count: 1,
requestingUserReacted: false,
creatorNames: ['Charlie'],
},
],
}
const onReply = vi.fn()
const getUser = vi.fn().mockReturnValue({ id: 'u-2', name: 'Alice' })
render(<MessageCard message={mockMessage} getUser={getUser} onReply={onReply} />, {
wrapper: createWrapper(),
})
// Both emoji badges are rendered with their counts
const thumbsUpBadge = screen.getByText('👍').closest('button')
const heartBadge = screen.getByText('❤️').closest('button')
expect(thumbsUpBadge).toBeDefined()
expect(heartBadge).toBeDefined()
// Active badge (requestingUserReacted = true) has primary border/bg style
expect(thumbsUpBadge?.className).toContain('border-primary/40')
expect(thumbsUpBadge?.className).toContain('bg-primary/10')
// Inactive badge (requestingUserReacted = false) has border-border/60 style
expect(heartBadge?.className).toContain('border-border/60')
// Both badges display count with normal text color (text-foreground)
expect(screen.getByText('2').className).toContain('text-foreground')
expect(screen.getByText('1').className).toContain('text-foreground')
// Clicking thumbsUp badge (already reacted) calls DELETE reaction
fireEvent.click(thumbsUpBadge!)
await waitFor(() => {
expect(client.api.comments[':commentId'].reactions.$delete).toHaveBeenCalledWith({
param: { commentId: 'msg-reactions' },
json: { code: '👍' },
})
})
// Clicking heart badge (not yet reacted) calls POST reaction
fireEvent.click(heartBadge!)
await waitFor(() => {
expect(client.api.comments[':commentId'].reactions.$post).toHaveBeenCalledWith({
param: { commentId: 'msg-reactions' },
json: { code: '❤️' },
})
})
})
it('hides reaction picker and disables badges when readOnly is true', () => {
const mockMessage: CommentInfo = {
id: 'msg-readonly',
assetId: 'asset-1',
message: 'Read only message',
annotations: null,
second: null,
creator: { id: 'u-2', name: 'Alice' },
replies: [],
attachments: [],
mentions: [],
createdAt: '2026-08-20T10:30:00.000Z',
updatedAt: '2026-08-20T10:30:00.000Z',
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [
{
code: '🎉',
count: 1,
requestingUserReacted: false,
creatorNames: ['Bob'],
},
],
}
const onReply = vi.fn()
const getUser = vi.fn().mockReturnValue({ id: 'u-2', name: 'Alice' })
render(
<MessageCard message={mockMessage} getUser={getUser} onReply={onReply} readOnly={true} />,
{
wrapper: createWrapper(),
},
)
const partyBadge = screen.getByText('🎉').closest('button')
expect(partyBadge?.getAttribute('disabled')).not.toBeNull()
// Clicking does not call API
fireEvent.click(partyBadge!)
expect(client.api.comments[':commentId'].reactions.$post).not.toHaveBeenCalled()
})
})
+280 -25
View File
@@ -17,10 +17,10 @@ import {
AlertDialogTitle,
} from '@/ui/components/ui/alert-dialog'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/ui/components/ui/dialog'
import type { CommentInfo, UserInfo } from '@shumai/dtos'
import type { CommentInfo, CommentReactionCount, UserInfo } from '@shumai/dtos'
import type { MemberInfo } from '@/ui/stores/members'
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { Download, FileText, MoreHorizontal, Trash2 } from 'lucide-react'
import { Download, FileText, MoreHorizontal, Smile, Trash2 } from 'lucide-react'
import React from 'react'
import Markdown from 'react-markdown'
import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'
@@ -32,6 +32,7 @@ import { useUiStore } from '@/ui/stores/ui'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip'
import { AgentSessionLogsDialog } from '../agent/agent-session-logs-dialog'
import { isImageFileName } from '@/ui/lib/media'
import { EmojiPickerPopover } from '../ui/emoji-picker'
interface MessageCardProps {
teamId?: string
@@ -47,6 +48,8 @@ interface MessageCardProps {
startTimecode?: string
formatTimestamp?: (second: number) => string
rootParentId?: string
readOnly?: boolean
isPublic?: boolean
}
const UnfilledCircleCheck: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
@@ -93,6 +96,94 @@ const AI_PLACEHOLDERS: Record<string, string> = {
__RUNNING__: 'Generating...',
}
function formatReactionOthers(names: string[]): string {
if (names.length <= 3) return names.join(', ')
return `${names.slice(0, 3).join(', ')} and ${names.length - 3} more`
}
function getReactionTooltip(reaction: CommentReactionCount): string {
const hasOthers = reaction.creatorNames && reaction.creatorNames.length > 0
if (reaction.requestingUserReacted) {
if (!hasOthers) {
return m.reaction_you({ emoji: reaction.code })
}
return m.reaction_you_and_others({
others: formatReactionOthers(reaction.creatorNames),
emoji: reaction.code,
})
}
if (hasOthers) {
return m.reaction_others({
others: formatReactionOthers(reaction.creatorNames),
emoji: reaction.code,
})
}
return reaction.code
}
function updateCommentTreeReactions(
comments: CommentInfo[],
targetCommentId: string,
code: string,
isAdd: boolean,
): CommentInfo[] {
return comments.map((comment) => {
if (comment.id === targetCommentId) {
const existingReactions = comment.reactionCounts ? [...comment.reactionCounts] : []
const existingIndex = existingReactions.findIndex((r) => r.code === code)
if (isAdd) {
if (existingIndex >= 0) {
const existing = existingReactions[existingIndex]
if (!existing.requestingUserReacted) {
existingReactions[existingIndex] = {
...existing,
count: existing.count + 1,
requestingUserReacted: true,
}
}
} else {
existingReactions.push({
code,
count: 1,
requestingUserReacted: true,
creatorNames: [],
})
}
} else {
if (existingIndex >= 0) {
const existing = existingReactions[existingIndex]
if (existing.requestingUserReacted) {
if (existing.count <= 1) {
existingReactions.splice(existingIndex, 1)
} else {
existingReactions[existingIndex] = {
...existing,
count: existing.count - 1,
requestingUserReacted: false,
}
}
}
}
}
return {
...comment,
reactionCounts: existingReactions,
}
}
if (comment.replies && comment.replies.length > 0) {
return {
...comment,
replies: updateCommentTreeReactions(comment.replies, targetCommentId, code, isAdd),
}
}
return comment
})
}
export const MessageCard: React.FC<MessageCardProps> = ({
teamId,
message: initialMessage,
@@ -106,8 +197,11 @@ export const MessageCard: React.FC<MessageCardProps> = ({
frameRate,
startTimecode,
formatTimestamp,
readOnly,
isPublic,
}) => {
const message = initialMessage
const isReadOnly = Boolean(readOnly || isPublic)
const hasDrawInfo =
!!message.annotations && Array.isArray(message.annotations) && message.annotations.length > 0
const creator = message.creator
@@ -161,6 +255,110 @@ export const MessageCard: React.FC<MessageCardProps> = ({
},
})
const { mutate: addReaction } = useMutation({
mutationFn: async (code: string) => {
const res = await client.api.comments[':commentId'].reactions.$post({
param: { commentId: message.id },
json: { code },
})
if (!res.ok) throw new Error('Failed to add reaction')
return await res.json()
},
onMutate: async (code: string) => {
await queryClient.cancelQueries({
predicate: (query) => query.queryKey.includes('comments'),
})
const previousData = queryClient.getQueriesData({
predicate: (query) => query.queryKey.includes('comments'),
})
queryClient.setQueriesData(
{ predicate: (query) => query.queryKey.includes('comments') },
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TanStack Query cache structure is dynamic across infinite query pages
(old: any) => {
if (!old || !old.pages) return old
return {
...old,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TanStack Query page object
pages: old.pages.map((page: any) => ({
...page,
data: updateCommentTreeReactions(page.data || [], message.id, code, true),
})),
}
},
)
return { previousData }
},
onError: (_err, _code, context) => {
if (context?.previousData) {
for (const [queryKey, data] of context.previousData) {
queryClient.setQueryData(queryKey, data)
}
}
},
onSettled: () => {
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('comments'),
})
},
})
const { mutate: removeReaction } = useMutation({
mutationFn: async (code: string) => {
const res = await client.api.comments[':commentId'].reactions.$delete({
param: { commentId: message.id },
json: { code },
})
if (!res.ok) throw new Error('Failed to remove reaction')
return await res.json()
},
onMutate: async (code: string) => {
await queryClient.cancelQueries({
predicate: (query) => query.queryKey.includes('comments'),
})
const previousData = queryClient.getQueriesData({
predicate: (query) => query.queryKey.includes('comments'),
})
queryClient.setQueriesData(
{ predicate: (query) => query.queryKey.includes('comments') },
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TanStack Query cache structure is dynamic across infinite query pages
(old: any) => {
if (!old || !old.pages) return old
return {
...old,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TanStack Query page object
pages: old.pages.map((page: any) => ({
...page,
data: updateCommentTreeReactions(page.data || [], message.id, code, false),
})),
}
},
)
return { previousData }
},
onError: (_err, _code, context) => {
if (context?.previousData) {
for (const [queryKey, data] of context.previousData) {
queryClient.setQueryData(queryKey, data)
}
}
},
onSettled: () => {
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('comments'),
})
},
})
const handleToggleReaction = (code: string) => {
if (isReadOnly) return
const existing = message.reactionCounts?.find((r) => r.code === code)
if (existing?.requestingUserReacted) {
removeReaction(code)
} else {
addReaction(code)
}
}
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = React.useState(false)
const { mutate: deleteComment, isPending: isDeleting } = useMutation({
@@ -402,6 +600,44 @@ export const MessageCard: React.FC<MessageCardProps> = ({
</div>
)}
{/* Reactions */}
{message.reactionCounts && message.reactionCounts.length > 0 && (
<div className="flex flex-wrap items-center gap-1.5 mt-2">
{message.reactionCounts.map((reaction) => {
const tooltipText = getReactionTooltip(reaction)
return (
<TooltipProvider key={reaction.code}>
<Tooltip>
<TooltipTrigger asChild>
<button
type="button"
disabled={isReadOnly}
onClick={(e) => {
e.stopPropagation()
handleToggleReaction(reaction.code)
}}
className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs border transition-colors select-none ${
isReadOnly ? 'cursor-default' : 'cursor-pointer'
} ${
reaction.requestingUserReacted
? 'border-primary/40 bg-primary/10 font-medium'
: 'border-border/60 bg-muted/40 hover:bg-muted'
}`}
>
<span className="text-sm leading-none">{reaction.code}</span>
<span className="text-xs font-semibold text-foreground">
{reaction.count}
</span>
</button>
</TooltipTrigger>
<TooltipContent>{tooltipText}</TooltipContent>
</Tooltip>
</TooltipProvider>
)
})}
</div>
)}
{/* Actions */}
<div className="mt-2 flex items-center justify-between w-full">
<button
@@ -411,32 +647,51 @@ export const MessageCard: React.FC<MessageCardProps> = ({
{m.reply()}
</button>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<div className="flex items-center gap-1">
{!isReadOnly && (
<EmojiPickerPopover
onEmojiSelect={(emoji) => handleToggleReaction(emoji)}
align="end"
side="top"
>
<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'
}`}
type="button"
onClick={(e) => e.stopPropagation()}
className="flex items-center justify-center p-1 rounded-full text-gray-400 hover:text-foreground hover:bg-muted/80 transition-colors cursor-pointer"
title={m.add_reaction()}
>
{message.isCompleted ? (
<FilledCircleCheck className="w-5 h-5" />
) : (
<UnfilledCircleCheck className="w-5 h-5" />
)}
<Smile className="w-5 h-5" />
</button>
</TooltipTrigger>
<TooltipContent>
{message.isCompleted ? m.mark_as_incomplete() : m.mark_as_complete()}
</TooltipContent>
</Tooltip>
</TooltipProvider>
</EmojiPickerPopover>
)}
<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'
}`}
>
{message.isCompleted ? (
<FilledCircleCheck className="w-5 h-5" />
) : (
<UnfilledCircleCheck className="w-5 h-5" />
)}
</button>
</TooltipTrigger>
<TooltipContent>
{message.isCompleted ? m.mark_as_incomplete() : m.mark_as_complete()}
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
</div>
</div>
@@ -37,6 +37,7 @@ describe('ChatInput auto-mention on reply', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
}
const onSendMessage = vi.fn()
@@ -81,6 +82,7 @@ describe('ChatInput auto-mention on reply', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
}
const onSendMessage = vi.fn()
@@ -115,6 +117,7 @@ describe('ChatInput auto-mention on reply', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
}
const commentBob: CommentInfo = {
@@ -132,6 +135,7 @@ describe('ChatInput auto-mention on reply', () => {
sessionId: null,
isCompleted: false,
completionLastChangedBy: null,
reactionCounts: [],
}
const onSendMessage = vi.fn()
@@ -429,6 +429,8 @@ export function FileViewerRightSidebar({
onSelect={() => {
onCommentSelect?.(comment)
}}
readOnly={readOnly}
isPublic={isPublic}
/>
{comment.replies?.map((reply, index) => (
<div key={reply.id}>
@@ -455,6 +457,8 @@ export function FileViewerRightSidebar({
onSelect={() => {
onCommentSelect?.(reply)
}}
readOnly={readOnly}
isPublic={isPublic}
/>
</div>
))}
@@ -395,6 +395,8 @@ export function MobileFileBottomSheet({
onSelect={() => {
onCommentSelect?.(comment)
}}
readOnly={readOnly}
isPublic={isPublic}
/>
{comment.replies?.map((reply, index) => (
<div key={reply.id}>
@@ -421,6 +423,8 @@ export function MobileFileBottomSheet({
onSelect={() => {
onCommentSelect?.(reply)
}}
readOnly={readOnly}
isPublic={isPublic}
/>
</div>
))}
@@ -0,0 +1,80 @@
import * as React from 'react'
import { EmojiPicker } from '@ferrucc-io/emoji-picker'
import { Popover, PopoverContent, PopoverTrigger } from '@/ui/components/ui/popover'
import { m } from '@/ui/paraglide/messages.js'
import { cn } from '@/ui/lib/utils'
export interface EmojiPickerPopoverProps {
onEmojiSelect: (emoji: string) => void
children: React.ReactNode
align?: 'start' | 'center' | 'end'
side?: 'top' | 'right' | 'bottom' | 'left'
sideOffset?: number
className?: string
open?: boolean
onOpenChange?: (open: boolean) => void
}
export function EmojiPickerPopover({
onEmojiSelect,
children,
align = 'end',
side = 'top',
sideOffset = 4,
className,
open: controlledOpen,
onOpenChange: setControlledOpen,
}: EmojiPickerPopoverProps) {
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(false)
const isControlled = controlledOpen !== undefined
const open = isControlled ? controlledOpen : uncontrolledOpen
const handleOpenChange = React.useCallback(
(nextOpen: boolean) => {
if (!isControlled) {
setUncontrolledOpen(nextOpen)
}
setControlledOpen?.(nextOpen)
},
[isControlled, setControlledOpen],
)
const handleSelect = React.useCallback(
(emoji: string) => {
onEmojiSelect(emoji)
handleOpenChange(false)
},
[onEmojiSelect, handleOpenChange],
)
return (
<Popover open={open} onOpenChange={handleOpenChange}>
<PopoverTrigger asChild>{children}</PopoverTrigger>
<PopoverContent
align={align}
side={side}
sideOffset={sideOffset}
className={cn('w-auto p-0 border-border bg-popover shadow-lg overflow-hidden', className)}
onClick={(e) => e.stopPropagation()}
>
<EmojiPicker
onEmojiSelect={handleSelect}
emojisPerRow={9}
emojiSize={28}
className="border-none w-[320px] bg-popover"
>
<EmojiPicker.Header className="p-2 pb-1">
<EmojiPicker.Input
placeholder={m.search_emoji()}
autoFocus={true}
className="h-8 w-full rounded-md border border-input bg-background pl-8 pr-7 py-1 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"
/>
</EmojiPicker.Header>
<EmojiPicker.Group>
<EmojiPicker.List containerHeight={280} />
</EmojiPicker.Group>
</EmojiPicker>
</PopoverContent>
</Popover>
)
}
+2
View File
@@ -2,6 +2,8 @@
@import 'tailwindcss';
@import 'tw-animate-css';
@source "./node_modules/@ferrucc-io/emoji-picker";
@source "../../node_modules/@ferrucc-io/emoji-picker";
@import 'video.js/dist/video-js.css' layer(base);
+6 -1
View File
@@ -1424,5 +1424,10 @@
"provider_not_configured_warning": "This provider is not configured. Configure an API key in the API Key tab before using these models.",
"failed_to_update_provider": "Failed to update provider",
"manage_provider": "Manage",
"all_modalities": "All"
"all_modalities": "All",
"add_reaction": "Add reaction",
"search_emoji": "Search emoji",
"reaction_you": "You reacted with {emoji}",
"reaction_you_and_others": "You and {others} reacted with {emoji}",
"reaction_others": "{others} reacted with {emoji}"
}
+6 -1
View File
@@ -1424,5 +1424,10 @@
"provider_not_configured_warning": "此提供商尚未配置。在使用这些模型前,请在 API 密钥标签页中配置密钥。",
"failed_to_update_provider": "更新提供商失败",
"manage_provider": "管理",
"all_modalities": "全部"
"all_modalities": "全部",
"add_reaction": "添加回应",
"search_emoji": "搜索表情",
"reaction_you": "你回应了 {emoji}",
"reaction_you_and_others": "你和 {others} 回应了 {emoji}",
"reaction_others": "{others} 回应了 {emoji}"
}
+1
View File
@@ -9,6 +9,7 @@
"@dnd-kit/abstract": "0.5.0",
"@dnd-kit/dom": "0.5.0",
"@dnd-kit/react": "0.5.0",
"@ferrucc-io/emoji-picker": "0.1.2",
"@hookform/resolvers": "5.9.1",
"@lexical/code": "0.49.0",
"@lexical/link": "0.49.0",