mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
feat(comments): add internal comments and author comment editing (#552)
* feat(comments): add internal comments and author comment editing * chore(i18n): add Korean comment translations and update AGENTS.md i18n rule * style(comments): refine visibility selector corner radius and align send button height * fix(webui): avoid ResizeObserver loop when resizing file browser
This commit is contained in:
@@ -125,7 +125,7 @@ An **Operation** is defined once and exposed across built-in agent tools, the MC
|
||||
- **Route Code-Splitting**: Split all routes into `[route].tsx` (route definition and loaders) and `[route].lazy.tsx` (UI component and heavy imports).
|
||||
- **Radix / Shadcn UI**: Set `modal={false}` on `<DropdownMenu>` when triggering a `Dialog` or `AlertDialog` from inside it to prevent focus-trap UI freezes. Use `ScrollArea` (`@/ui/components/ui/scroll-area`) for scrollable containers.
|
||||
- **Pagination & Infinite Scroll**: Use `useInfiniteQuery` + `react-intersection-observer` with default `limit: 20` and the API's `total` field. Backend list APIs use `paginateQuery` from `packages/core/src/pagination.ts` (default `limit: 20`).
|
||||
- **Internationalization (i18n)**: Hardcoded UI text is strictly forbidden. Add `snake_case` keys to both `packages/webui/messages/en.json` and `packages/webui/messages/zh.json`, run `bun run i18n:compile` (or `bun run i18n:watch`), and import `m` from `@/ui/paraglide/messages.js`.
|
||||
- **Internationalization (i18n)**: Hardcoded UI text is strictly forbidden. Add `snake_case` keys to **all** locale files in `packages/webui/messages/*.json` (do not assume only `en.json` and `zh.json` exist; check the directory for all supported languages), run `bun run i18n:compile` (or `bun run i18n:watch`), and import `m` from `@/ui/paraglide/messages.js`.
|
||||
|
||||
## Database & Prisma (`packages/db`)
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
### Added
|
||||
|
||||
- **comments**: Add Internal Comments with a Public/Internal selector in the comment composer so team and project members can have private discussions (marked with a lock icon) that never appear on public share links.
|
||||
- **comments**: Allow comment authors to edit their comments inline from the comment menu, including updating text, switching between Public and Internal, removing timestamps, and adding or removing attachments.
|
||||
|
||||
- **comments**: Add a "Print Comments" option in the comments menu (available in both project file views and public share links) that opens a dedicated print-friendly page with asset metadata, comment thumbnails, visual markup overlays, replies, completion status, emoji reactions, and attachments.
|
||||
|
||||
- **share**: See view counts, last viewed times, and activity for public share links, including file and folder views, downloads, and comments.
|
||||
|
||||
@@ -118,6 +118,8 @@ apps/web/e2e/
|
||||
| Upload an image file, wait for transcode, and create a comment with draw | `tests/file/image-draw-comment.spec.ts` |
|
||||
| Upload a video file, wait for transcode, and create a comment with draw at a non-zero timestamp | `tests/file/video-draw-comment.spec.ts` |
|
||||
| Upload an audio file, wait for transcode, and create a comment at a non-zero timestamp | `tests/file/audio-timestamp-comment.spec.ts` |
|
||||
| Create internal and public comments, verify internal comments are hidden on public share links | `tests/file/internal-comment-and-edit.spec.ts` |
|
||||
| Author edits comment text, switches to internal, removes timestamp, and updates attachments | `tests/file/internal-comment-and-edit.spec.ts` |
|
||||
| Show a breathing poster preview and "Preparing..." while a video is still transcoding | `tests/file/processing-preview.spec.ts` |
|
||||
| Show a preparing circle before the poster is generated | `tests/file/processing-preview.spec.ts` |
|
||||
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
import { expect, test } from '../../fixtures'
|
||||
import { apiAddAssetsToShare, apiCreateShare, fileCard } from '../../helpers/files'
|
||||
|
||||
test('internal comments show lock icon in workspace and are hidden on public share pages', async ({
|
||||
browser,
|
||||
file,
|
||||
prisma,
|
||||
}) => {
|
||||
const { context, page, projectId, fileId, fileName } = file
|
||||
const publicText = `Public note ${Date.now()}`
|
||||
const internalText = `Internal secret ${Date.now()}`
|
||||
|
||||
await page.goto(`/projects/${projectId}/files/${fileId}`)
|
||||
|
||||
const editor = page.locator('[contenteditable="true"]').first()
|
||||
const sendBtn = page.locator('button:has(svg.lucide-arrow-up)').last()
|
||||
const visibilityTrigger = page.getByTestId('comment-visibility-trigger')
|
||||
|
||||
// Default visibility is Public
|
||||
await expect(visibilityTrigger).toBeVisible()
|
||||
await expect(visibilityTrigger).toContainText('Public')
|
||||
|
||||
// Post a public comment
|
||||
await editor.fill(publicText)
|
||||
await sendBtn.click()
|
||||
await expect(page.getByText(publicText)).toBeVisible()
|
||||
|
||||
// Switch to Internal and post an internal comment
|
||||
await visibilityTrigger.click()
|
||||
await page.getByTestId('comment-visibility-internal').click()
|
||||
await expect(visibilityTrigger).toContainText('Internal')
|
||||
|
||||
await editor.fill(internalText)
|
||||
await sendBtn.click()
|
||||
await expect(page.getByText(internalText)).toBeVisible()
|
||||
|
||||
// Visibility pill resets to Public after sending
|
||||
await expect(visibilityTrigger).toContainText('Public')
|
||||
|
||||
// Internal comment shows lock icon, public comment does not
|
||||
await expect(page.getByTestId('internal-comment-icon')).toHaveCount(1)
|
||||
|
||||
// Verify DB persisted isInternal flags
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const comments = await prisma.assetComment.findMany({
|
||||
where: { assetId: fileId },
|
||||
orderBy: { id: 'asc' },
|
||||
})
|
||||
return comments.map((c) => ({ message: c.message, isInternal: c.isInternal }))
|
||||
})
|
||||
.toEqual([
|
||||
{ message: publicText, isInternal: false },
|
||||
{ message: internalText, isInternal: true },
|
||||
])
|
||||
|
||||
// Create a public share link for this file
|
||||
const share = await apiCreateShare(context.request, projectId, 'External Review Share')
|
||||
await apiAddAssetsToShare(context.request, share.id, [fileId])
|
||||
|
||||
// Open public share page as an unauthenticated guest
|
||||
const guestContext = await browser.newContext()
|
||||
try {
|
||||
const guestPage = await guestContext.newPage()
|
||||
await guestPage.goto(`/share/${share.id}`)
|
||||
|
||||
// File card comment badge should only count the 1 public comment
|
||||
const card = fileCard(guestPage, fileName)
|
||||
await expect(card).toBeVisible()
|
||||
await expect(card).toContainText('1')
|
||||
|
||||
// Open the shared file
|
||||
await card.dblclick()
|
||||
await expect(guestPage.getByText(publicText)).toBeVisible()
|
||||
await expect(guestPage.getByText(internalText)).toHaveCount(0)
|
||||
await expect(guestPage.getByTestId('comment-visibility-trigger')).toHaveCount(0)
|
||||
} finally {
|
||||
await guestContext.close()
|
||||
}
|
||||
})
|
||||
|
||||
test.describe('author edits comment with timestamp and attachments', () => {
|
||||
test.use({ fileOptions: { mediaType: 'audio' } })
|
||||
|
||||
test('author edits comment text, switches to internal, removes timestamp, and updates attachments', async ({
|
||||
file,
|
||||
prisma,
|
||||
}) => {
|
||||
const { page, projectId, fileId } = file
|
||||
const originalText = `Initial audio note ${Date.now()}`
|
||||
const editedText = `Edited private note ${Date.now()}`
|
||||
|
||||
// Wait for audio transcode completion
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const asset = await prisma.asset.findUnique({ where: { id: fileId } })
|
||||
return asset?.status
|
||||
},
|
||||
{ timeout: 30_000 },
|
||||
)
|
||||
.toBe('processed')
|
||||
|
||||
await page.goto(`/projects/${projectId}/files/${fileId}`)
|
||||
|
||||
const mediaEl = page.locator('audio, video').first()
|
||||
await expect(mediaEl).toBeVisible({ timeout: 30_000 })
|
||||
|
||||
// Seek to non-zero timestamp
|
||||
await page.evaluate(() => {
|
||||
const el = document.querySelector('audio, video') as HTMLMediaElement | null
|
||||
if (el) el.currentTime = 1
|
||||
})
|
||||
await page.waitForTimeout(500)
|
||||
|
||||
// Attach initial file in composer
|
||||
const composerFileInput = page.locator('input[type="file"]').last()
|
||||
await composerFileInput.setInputFiles({
|
||||
name: 'old-attachment.txt',
|
||||
mimeType: 'text/plain',
|
||||
buffer: Buffer.from('old attachment content'),
|
||||
})
|
||||
await expect(page.getByText('old-attachment.txt')).toBeVisible()
|
||||
|
||||
// Submit public comment with timestamp and attachment
|
||||
const editor = page.locator('[contenteditable="true"]').first()
|
||||
await editor.fill(originalText)
|
||||
const sendBtn = page.locator('button:has(svg.lucide-arrow-up)').last()
|
||||
await expect(sendBtn).toBeEnabled()
|
||||
await sendBtn.click()
|
||||
|
||||
await expect(page.getByText(originalText)).toBeVisible()
|
||||
await expect(page.getByText('old-attachment.txt')).toBeVisible()
|
||||
|
||||
// Wait for DB persistence
|
||||
await expect
|
||||
.poll(async () => {
|
||||
return prisma.assetComment.findFirst({
|
||||
where: { assetId: fileId, message: originalText },
|
||||
})
|
||||
})
|
||||
.not.toBeNull()
|
||||
|
||||
// Open three-dot menu on comment card and click Edit
|
||||
const moreBtn = page.getByRole('button', { name: 'More options' }).last()
|
||||
await moreBtn.click({ force: true })
|
||||
await page.getByRole('menuitem', { name: 'Edit' }).click()
|
||||
|
||||
const editForm = page.getByTestId('comment-edit-form')
|
||||
await expect(editForm).toBeVisible()
|
||||
|
||||
// Remove timestamp
|
||||
await expect(editForm.getByTestId('edit-comment-timestamp')).toBeVisible()
|
||||
await editForm.getByTestId('edit-comment-remove-timestamp').click()
|
||||
await expect(editForm.getByTestId('edit-comment-timestamp')).toHaveCount(0)
|
||||
|
||||
// Remove existing attachment
|
||||
await editForm.getByTestId('edit-existing-attachment').locator('button').click()
|
||||
await expect(editForm.getByTestId('edit-existing-attachment')).toHaveCount(0)
|
||||
|
||||
// Add a new attachment
|
||||
await editForm.getByTestId('edit-comment-file-input').setInputFiles({
|
||||
name: 'new-attachment.txt',
|
||||
mimeType: 'text/plain',
|
||||
buffer: Buffer.from('new attachment content'),
|
||||
})
|
||||
await expect(editForm.getByText('new-attachment.txt')).toBeVisible()
|
||||
|
||||
// Switch Public -> Internal
|
||||
await editForm.getByTestId('comment-visibility-trigger').click()
|
||||
await page.getByTestId('comment-visibility-internal').click()
|
||||
await expect(editForm.getByTestId('comment-visibility-trigger')).toContainText('Internal')
|
||||
|
||||
// Change comment text
|
||||
const editInput = editForm.getByTestId('edit-comment-input')
|
||||
await editInput.click()
|
||||
await page.keyboard.press('ControlOrMeta+a')
|
||||
await page.keyboard.type(editedText)
|
||||
|
||||
// Save
|
||||
const saveBtn = editForm.getByTestId('edit-comment-save')
|
||||
await expect(saveBtn).toBeEnabled()
|
||||
await saveBtn.click()
|
||||
|
||||
await expect(editForm).toHaveCount(0)
|
||||
await expect(page.getByText(editedText)).toBeVisible()
|
||||
await expect(page.getByText('new-attachment.txt')).toBeVisible()
|
||||
await expect(page.getByText('old-attachment.txt')).toHaveCount(0)
|
||||
await expect(page.getByTestId('internal-comment-icon')).toHaveCount(1)
|
||||
|
||||
// Reload and verify persistence in UI and DB
|
||||
await page.reload()
|
||||
await expect(page.getByText(editedText)).toBeVisible()
|
||||
await expect(page.getByText('new-attachment.txt')).toBeVisible()
|
||||
await expect(page.getByTestId('internal-comment-icon')).toHaveCount(1)
|
||||
|
||||
const updated = await prisma.assetComment.findFirst({
|
||||
where: { assetId: fileId, message: editedText },
|
||||
include: { attachments: { include: { asset: true } } },
|
||||
})
|
||||
expect(updated).not.toBeNull()
|
||||
expect(updated?.isInternal).toBe(true)
|
||||
expect(updated?.second).toBeNull()
|
||||
expect(updated?.attachments.map((a) => a.asset.name)).toEqual(['new-attachment.txt'])
|
||||
})
|
||||
})
|
||||
@@ -601,6 +601,7 @@ export const createCommentActivity = defineStep(
|
||||
sessionId?: string | null
|
||||
agentId?: string | null
|
||||
replyToId?: string | null
|
||||
isInternal?: boolean
|
||||
}) {
|
||||
if (params.sessionId) {
|
||||
const agentId = params.agentId && params.agentId !== 'default' ? params.agentId : 'default'
|
||||
@@ -669,6 +670,7 @@ export const createCommentActivity = defineStep(
|
||||
sessionId: params.sessionId ?? null,
|
||||
creatorId: params.agentId && params.agentId !== 'default' ? params.agentId : null,
|
||||
replyToId: params.replyToId,
|
||||
isInternal: params.isInternal ?? false,
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
@@ -205,6 +205,43 @@ describe('Agent Chat Workflow', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('marks agent placeholder reply as internal when user comment is internal', async () => {
|
||||
mockActivities.getCommentActivity.mockResolvedValue({
|
||||
id: 'c-internal',
|
||||
message: 'hello agent privately',
|
||||
assetId: 'a1',
|
||||
creatorId: 'user-c1',
|
||||
second: null,
|
||||
annotation: null,
|
||||
replyToId: null,
|
||||
isInternal: true,
|
||||
attachments: [],
|
||||
})
|
||||
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'chat',
|
||||
status: 'pending',
|
||||
assetId: 'a1',
|
||||
payload: {
|
||||
projectId: 'p1',
|
||||
agent: { userCommentId: 'c-internal', agentId: 'b1' },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await agentChat(task)
|
||||
|
||||
expect(mockActivities.createCommentActivity).toHaveBeenCalledWith({
|
||||
assetId: 'a1',
|
||||
message: '__CHAT__',
|
||||
sessionId: 'pending',
|
||||
agentId: 'b1',
|
||||
replyToId: 'c-internal',
|
||||
isInternal: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('should skip session initialization if sessionId is already provided', async () => {
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
|
||||
@@ -85,6 +85,7 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
|
||||
sessionId: sessionId || 'pending',
|
||||
agentId: agentId,
|
||||
replyToId: userComment.replyToId ?? userComment.id,
|
||||
...(userComment.isInternal ? { isInternal: true } : {}),
|
||||
})
|
||||
placeholderCommentId = placeholder.id
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ describe('file api', () => {
|
||||
vi.spyOn(assetService, 'updateAssetName').mockImplementation(vi.fn())
|
||||
vi.spyOn(assetService, 'deleteAssets').mockImplementation(vi.fn())
|
||||
vi.spyOn(assetService, 'createComment').mockImplementation(vi.fn())
|
||||
vi.spyOn(assetService, 'updateComment').mockImplementation(vi.fn())
|
||||
vi.spyOn(assetService, 'completeComment').mockImplementation(vi.fn())
|
||||
vi.spyOn(assetService, 'deleteComment').mockImplementation(vi.fn())
|
||||
vi.spyOn(assetService, 'addCommentReaction').mockImplementation(vi.fn())
|
||||
@@ -291,6 +292,7 @@ describe('file api', () => {
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
})
|
||||
@@ -351,6 +353,7 @@ describe('file api', () => {
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
})
|
||||
@@ -408,6 +411,7 @@ describe('file api', () => {
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
},
|
||||
@@ -553,6 +557,7 @@ describe('file api', () => {
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: true,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: { id: 'user1', name: 'Test User' },
|
||||
reactionCounts: [],
|
||||
})
|
||||
@@ -579,6 +584,110 @@ describe('file api', () => {
|
||||
expect(assetService.getComment).toHaveBeenCalledWith('comment-id', 'user1')
|
||||
})
|
||||
|
||||
it('POST /files/:fileId/comments forwards isInternal', async () => {
|
||||
vi.mocked(assetService.createComment).mockResolvedValue({
|
||||
id: 'comment-internal-id',
|
||||
assetId: 'test-id',
|
||||
message: 'internal note',
|
||||
annotations: null,
|
||||
second: null,
|
||||
creator: { id: 'user1', name: 'Test User' },
|
||||
replies: [],
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: true,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
})
|
||||
|
||||
const app = new Hono().use('*', authMiddleware).route('/', fileRoute)
|
||||
const res = await app.request('/files/test-id/comments', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message: 'internal note', attachmentIds: [], isInternal: true }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(201)
|
||||
const json = await res.json()
|
||||
expect(json.isInternal).toBe(true)
|
||||
expect(assetService.createComment).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
assetId: 'test-id',
|
||||
userId: 'user1',
|
||||
message: 'internal note',
|
||||
isInternal: true,
|
||||
}),
|
||||
expect.anything(),
|
||||
)
|
||||
})
|
||||
|
||||
it('PATCH /comments/:commentId updates comment and logs comment_update audit entry', async () => {
|
||||
vi.mocked(assetService.updateComment).mockResolvedValue({
|
||||
id: 'comment-id',
|
||||
assetId: 'file-id',
|
||||
message: 'edited text',
|
||||
annotations: null,
|
||||
second: null,
|
||||
creator: { id: 'user1', name: 'Test User' },
|
||||
replies: [],
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: true,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
})
|
||||
vi.mocked(assetService.getAssetContext).mockResolvedValue({
|
||||
teamId: 'test-team',
|
||||
projectId: 'proj-1',
|
||||
})
|
||||
|
||||
const app = new Hono().use('*', authMiddleware).route('/', fileRoute)
|
||||
const res = await app.request('/comments/comment-id', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
message: 'edited text',
|
||||
isInternal: true,
|
||||
second: null,
|
||||
attachmentIds: ['att-1'],
|
||||
}),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const json = await res.json()
|
||||
expect(json.message).toBe('edited text')
|
||||
expect(json.isInternal).toBe(true)
|
||||
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
||||
user: { id: 'user1', name: 'Test User' },
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Comment,
|
||||
id: 'comment-id',
|
||||
})
|
||||
expect(assetService.updateComment).toHaveBeenCalledWith({
|
||||
commentId: 'comment-id',
|
||||
userId: 'user1',
|
||||
message: 'edited text',
|
||||
isInternal: true,
|
||||
second: null,
|
||||
attachmentIds: ['att-1'],
|
||||
})
|
||||
expect(auditLogService.logAction).toHaveBeenCalledWith({
|
||||
action: 'comment_update',
|
||||
teamId: 'test-team',
|
||||
userId: 'user1',
|
||||
projectId: 'proj-1',
|
||||
itemId: 'comment-id',
|
||||
})
|
||||
})
|
||||
|
||||
it('POST /comments/:commentId/complete reopens with isCompleted false', async () => {
|
||||
vi.mocked(runOperation).mockResolvedValue({ commentId: 'comment-id', resolved: false })
|
||||
vi.mocked(assetService.getComment).mockResolvedValue({
|
||||
@@ -1133,6 +1242,7 @@ describe('file api', () => {
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
},
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import {
|
||||
archiveAssetsRequestSchema,
|
||||
createCommentRequestSchema,
|
||||
updateCommentRequestSchema,
|
||||
deleteFilesRequestSchema,
|
||||
batchGetFilesRequestSchema,
|
||||
paginationParamsSchema,
|
||||
@@ -199,6 +200,7 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
annotations: req.annotations,
|
||||
second: req.second,
|
||||
attachmentIds: req.attachmentIds,
|
||||
isInternal: req.isInternal,
|
||||
})
|
||||
|
||||
const context = await assetService.getAssetContext(fileId)
|
||||
@@ -361,6 +363,38 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
return c.json(await assetService.getComment(commentId, user.id))
|
||||
},
|
||||
)
|
||||
.patch('/comments/:commentId', zValidator('json', updateCommentRequestSchema), 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,
|
||||
})
|
||||
|
||||
const updated = await assetService.updateComment({
|
||||
commentId,
|
||||
userId: user.id,
|
||||
message: req.message,
|
||||
isInternal: req.isInternal,
|
||||
second: req.second,
|
||||
attachmentIds: req.attachmentIds,
|
||||
})
|
||||
|
||||
const context = await assetService.getAssetContext(updated.assetId)
|
||||
await auditLogService.logAction({
|
||||
action: AuditAction.comment_update,
|
||||
teamId: context.teamId,
|
||||
userId: user.id,
|
||||
projectId: context.projectId,
|
||||
itemId: commentId,
|
||||
})
|
||||
|
||||
return c.json(updated)
|
||||
})
|
||||
.delete('/comments/:commentId', async (c) => {
|
||||
const commentId = c.req.param('commentId')
|
||||
const user = c.get('user')
|
||||
|
||||
@@ -65,6 +65,7 @@ describe('public share print comments and frame api', () => {
|
||||
updatedAt: new Date().toISOString(),
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
},
|
||||
@@ -76,6 +77,9 @@ describe('public share print comments and frame api', () => {
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(assetService.listAllComments).toHaveBeenCalledWith('file-1', undefined, {
|
||||
excludeInternal: true,
|
||||
})
|
||||
const body = await res.json()
|
||||
expect(body.breadcrumbs).toEqual(['Client Review', 'Inner Folder'])
|
||||
expect(body.asset.ancestorFolders).toEqual([{ id: 'inner', name: 'Inner Folder' }])
|
||||
@@ -127,4 +131,36 @@ describe('public share print comments and frame api', () => {
|
||||
signal: expect.any(AbortSignal),
|
||||
})
|
||||
})
|
||||
|
||||
it('GET /shares/:shareId/files/:fileId/comments excludes internal comments', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
id: 'share-1',
|
||||
rootFolderId: 'share-root',
|
||||
projectId: 'proj-1',
|
||||
} as never)
|
||||
vi.spyOn(assetService, 'resolveTargetAssetId').mockResolvedValue('file-1')
|
||||
const listSpy = vi.spyOn(assetService, 'listComments').mockResolvedValue({
|
||||
data: [],
|
||||
pageInfo: { cursor: undefined, total: 0 },
|
||||
})
|
||||
|
||||
const app = new Hono().route('/', publicShareRoute)
|
||||
const res = await app.request('/shares/share-1/files/file-1/comments')
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(listSpy).toHaveBeenCalledWith('file-1', expect.anything(), undefined, {
|
||||
excludeInternal: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('POST /shares/:shareId/files/:fileId/comments rejects isInternal=true with 400', async () => {
|
||||
const app = new Hono().route('/', publicShareRoute)
|
||||
const res = await app.request('/shares/share-1/files/file-1/comments', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message: 'secret', attachmentIds: [], isInternal: true }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(400)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -155,6 +155,9 @@ function toFieldInfo(
|
||||
}
|
||||
|
||||
export function handlePublicShareError(c: Context, err: unknown) {
|
||||
if (err instanceof HTTPException) {
|
||||
throw err
|
||||
}
|
||||
if (err instanceof ShareLinkPasswordInvalidError) {
|
||||
return c.json({ error: 'Unauthorized' }, 401)
|
||||
}
|
||||
@@ -273,13 +276,16 @@ const route = app
|
||||
order = parts[1]
|
||||
}
|
||||
|
||||
const res = await assetService.listChildren({
|
||||
...req,
|
||||
assetId: folderId,
|
||||
assetType: req.assetType || 'file',
|
||||
sort,
|
||||
order,
|
||||
})
|
||||
const res = await assetService.listChildren(
|
||||
{
|
||||
...req,
|
||||
assetId: folderId,
|
||||
assetType: req.assetType || 'file',
|
||||
sort,
|
||||
order,
|
||||
},
|
||||
{ excludeInternalComments: true },
|
||||
)
|
||||
|
||||
if (shareLink.watermarkConfigId && res.data.length > 0) {
|
||||
// Resolve symlink targets once and reuse for the media lookup, so each
|
||||
@@ -327,7 +333,10 @@ const route = app
|
||||
try {
|
||||
const shareLink = await shareService.verifyPublicAccess(shareId, fileId, password)
|
||||
|
||||
let asset = await assetService.getAsset({ assetId: fileId })
|
||||
let asset = await assetService.getAsset(
|
||||
{ assetId: fileId },
|
||||
{ excludeInternalComments: true },
|
||||
)
|
||||
|
||||
// Only video/image/3d assets are subject to watermark protection; skip the
|
||||
// watermark lookup entirely for other media types (pdf, audio, ...).
|
||||
@@ -412,7 +421,9 @@ const route = app
|
||||
|
||||
const targetFileId = await assetService.resolveTargetAssetId(fileId)
|
||||
const userId = await getPublicShareUserId(c, shareId)
|
||||
const res = await assetService.listComments(targetFileId, req, userId)
|
||||
const res = await assetService.listComments(targetFileId, req, userId, {
|
||||
excludeInternal: true,
|
||||
})
|
||||
return c.json(res)
|
||||
} catch (err) {
|
||||
return handlePublicShareError(c, err)
|
||||
@@ -426,7 +437,10 @@ const route = app
|
||||
|
||||
try {
|
||||
const shareLink = await shareService.verifyPublicAccess(shareId, fileId, password)
|
||||
let asset = await assetService.getAsset({ assetId: fileId })
|
||||
let asset = await assetService.getAsset(
|
||||
{ assetId: fileId },
|
||||
{ excludeInternalComments: true },
|
||||
)
|
||||
const targetAssetId = await assetService.resolveLatestVersionId(fileId)
|
||||
|
||||
if (
|
||||
@@ -447,7 +461,9 @@ const route = app
|
||||
|
||||
const targetFileId = await assetService.resolveTargetAssetId(fileId)
|
||||
const userId = await getPublicShareUserId(c, shareId)
|
||||
const comments = await assetService.listAllComments(targetFileId, userId)
|
||||
const comments = await assetService.listAllComments(targetFileId, userId, {
|
||||
excludeInternal: true,
|
||||
})
|
||||
|
||||
// Scope breadcrumbs strictly to folders inside the share link root so private
|
||||
// project and parent folder names are never leaked.
|
||||
@@ -518,6 +534,10 @@ const route = app
|
||||
return c.json({ error: 'Attachments are not allowed on public share comments' }, 400)
|
||||
}
|
||||
|
||||
if (req.isInternal) {
|
||||
return c.json({ error: 'Internal comments are not allowed on public share links' }, 400)
|
||||
}
|
||||
|
||||
try {
|
||||
const shareLink = await shareService.verifyPublicAccess(shareId, fileId, password)
|
||||
|
||||
@@ -540,6 +560,7 @@ const route = app
|
||||
annotations: req.annotations,
|
||||
second: req.second,
|
||||
attachmentIds: req.attachmentIds,
|
||||
isInternal: false,
|
||||
},
|
||||
{ shareLinkId: shareId },
|
||||
)
|
||||
|
||||
@@ -305,6 +305,7 @@ describe('Share API', () => {
|
||||
sort: 'name',
|
||||
order: 'asc',
|
||||
}),
|
||||
{ excludeInternalComments: true },
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -5964,4 +5964,367 @@ describe('AssetService — natural sort by name', () => {
|
||||
expect(variant).toContain('http://mock-s3-url')
|
||||
})
|
||||
})
|
||||
|
||||
describe('internal comments and comment editing', () => {
|
||||
async function setupCommentFixture() {
|
||||
const team = await prisma.team.create({ data: { name: 'Comment Team' } })
|
||||
const author = await prisma.user.create({
|
||||
data: { name: 'Author', email: `author-${Date.now()}-${Math.random()}@test.com` },
|
||||
})
|
||||
const owner = await prisma.user.create({
|
||||
data: { name: 'Owner', email: `owner-${Date.now()}-${Math.random()}@test.com` },
|
||||
})
|
||||
await prisma.teamMember.create({
|
||||
data: { teamId: team.id, userId: author.id, role: 'editor' },
|
||||
})
|
||||
await prisma.teamMember.create({
|
||||
data: { teamId: team.id, userId: owner.id, role: 'owner' },
|
||||
})
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'Comment Project', teamId: team.id },
|
||||
})
|
||||
const rootFolder = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'root',
|
||||
type: AssetType.folder,
|
||||
projectId: project.id,
|
||||
status: AssetStatus.uploaded,
|
||||
},
|
||||
})
|
||||
const file = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'clip.mp4',
|
||||
type: AssetType.file,
|
||||
projectId: project.id,
|
||||
parentId: rootFolder.id,
|
||||
creatorId: author.id,
|
||||
status: AssetStatus.uploaded,
|
||||
},
|
||||
})
|
||||
return { team, author, owner, project, rootFolder, file }
|
||||
}
|
||||
|
||||
async function createAttachmentAsset(projectId: string, creatorId: string, name: string) {
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: { key: `files/attachments/${Date.now()}-${Math.random()}-${name}` },
|
||||
})
|
||||
return prisma.asset.create({
|
||||
data: {
|
||||
name,
|
||||
type: AssetType.attachment,
|
||||
projectId,
|
||||
creatorId,
|
||||
status: AssetStatus.uploaded,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
it('creates public (default) and internal comments, and enforces internal replies on internal parents', async () => {
|
||||
const { author, owner, file } = await setupCommentFixture()
|
||||
|
||||
const pub = await assetService.createComment(
|
||||
{ assetId: file.id, userId: author.id, message: 'Public feedback', attachmentIds: [] },
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
expect(pub.isInternal).toBe(false)
|
||||
|
||||
const internal = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
message: 'Internal note',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
expect(internal.isInternal).toBe(true)
|
||||
|
||||
// Replying to an internal parent forces isInternal: true even if false is passed
|
||||
const replyToInternal = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: owner.id,
|
||||
replyToId: internal.id,
|
||||
message: 'Internal reply',
|
||||
attachmentIds: [],
|
||||
isInternal: false,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
expect(replyToInternal.isInternal).toBe(true)
|
||||
|
||||
// Replying internally to a public parent is allowed
|
||||
const internalReplyOnPublic = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: owner.id,
|
||||
replyToId: pub.id,
|
||||
message: 'Private side note',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
expect(internalReplyOnPublic.isInternal).toBe(true)
|
||||
|
||||
const publicReplyOnPublic = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
replyToId: pub.id,
|
||||
message: 'Public reply',
|
||||
attachmentIds: [],
|
||||
isInternal: false,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
expect(publicReplyOnPublic.isInternal).toBe(false)
|
||||
|
||||
// Authenticated list includes everything
|
||||
const allListed = await assetService.listComments(file.id, { first: 20 }, author.id)
|
||||
expect(allListed.data).toHaveLength(2)
|
||||
expect(allListed.data[0].replies).toHaveLength(2)
|
||||
expect(allListed.data[1].replies).toHaveLength(1)
|
||||
|
||||
// Public share list excludes internal comments and internal replies
|
||||
const publicListed = await assetService.listComments(file.id, { first: 20 }, undefined, {
|
||||
excludeInternal: true,
|
||||
})
|
||||
expect(publicListed.data).toHaveLength(1)
|
||||
expect(publicListed.data[0].id).toBe(pub.id)
|
||||
expect(publicListed.data[0].replies.map((r) => r.id)).toEqual([publicReplyOnPublic.id])
|
||||
|
||||
// listAllComments with excludeInternal matches
|
||||
const publicAll = await assetService.listAllComments(file.id, undefined, {
|
||||
excludeInternal: true,
|
||||
})
|
||||
expect(publicAll).toHaveLength(1)
|
||||
expect(publicAll[0].replies.map((r) => r.id)).toEqual([publicReplyOnPublic.id])
|
||||
})
|
||||
|
||||
it('excludes internal comments and replies under internal parents from public share commentsCount', async () => {
|
||||
const { author, rootFolder, file } = await setupCommentFixture()
|
||||
|
||||
const pub = await assetService.createComment(
|
||||
{ assetId: file.id, userId: author.id, message: 'Public', attachmentIds: [] },
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
replyToId: pub.id,
|
||||
message: 'Internal reply on public',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
const internal = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
message: 'Internal root',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
replyToId: internal.id,
|
||||
message: 'Reply on internal',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
|
||||
const allChildren = await assetService.listChildren({
|
||||
assetId: rootFolder.id,
|
||||
assetType: 'file',
|
||||
})
|
||||
expect(allChildren.data.find((a) => a.id === file.id)?.commentsCount).toBe(4)
|
||||
|
||||
const publicChildren = await assetService.listChildren(
|
||||
{ assetId: rootFolder.id, assetType: 'file' },
|
||||
{ excludeInternalComments: true },
|
||||
)
|
||||
expect(publicChildren.data.find((a) => a.id === file.id)?.commentsCount).toBe(1)
|
||||
|
||||
const publicFile = await assetService.getAsset(
|
||||
{ assetId: file.id },
|
||||
{ excludeInternalComments: true },
|
||||
)
|
||||
expect(publicFile.commentsCount).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects replying to an internal comment from a public share link', async () => {
|
||||
const { author, file } = await setupCommentFixture()
|
||||
const internal = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
message: 'Internal only',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
|
||||
await expect(
|
||||
assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
replyToId: internal.id,
|
||||
message: 'Guest reply attempt',
|
||||
attachmentIds: [],
|
||||
},
|
||||
{ triggerAgents: false, shareLinkId: 'share-1' },
|
||||
),
|
||||
).rejects.toMatchObject({ status: 404 })
|
||||
})
|
||||
|
||||
it('allows author to edit text, visibility, remove timestamp, and add/delete attachments', async () => {
|
||||
const { author, project, file } = await setupCommentFixture()
|
||||
const att1 = await createAttachmentAsset(project.id, author.id, 'old.png')
|
||||
const att2 = await createAttachmentAsset(project.id, author.id, 'keep.pdf')
|
||||
const att3 = await createAttachmentAsset(project.id, author.id, 'new.png')
|
||||
|
||||
const created = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
message: 'Original message',
|
||||
second: 12.5,
|
||||
attachmentIds: [att1.id, att2.id],
|
||||
isInternal: false,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
|
||||
const updated = await assetService.updateComment({
|
||||
commentId: created.id,
|
||||
userId: author.id,
|
||||
message: 'Updated message',
|
||||
isInternal: true,
|
||||
second: null,
|
||||
attachmentIds: [att2.id, att3.id],
|
||||
})
|
||||
|
||||
expect(updated.message).toBe('Updated message')
|
||||
expect(updated.isInternal).toBe(true)
|
||||
expect(updated.second).toBeNull()
|
||||
expect(updated.attachments.map((a) => a.assetId).sort()).toEqual([att2.id, att3.id].sort())
|
||||
|
||||
// Removed attachment asset should be cleaned up since no comment references it anymore
|
||||
expect(await prisma.asset.findUnique({ where: { id: att1.id } })).toBeNull()
|
||||
expect(await prisma.asset.findUnique({ where: { id: att2.id } })).not.toBeNull()
|
||||
expect(await prisma.asset.findUnique({ where: { id: att3.id } })).not.toBeNull()
|
||||
})
|
||||
|
||||
it('enforces author-only edit, parent-internal reply constraint, non-empty validation, and preserves reply flags', async () => {
|
||||
const { author, owner, file } = await setupCommentFixture()
|
||||
|
||||
const parent = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
message: 'Parent comment',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
const reply = await assetService.createComment(
|
||||
{
|
||||
assetId: file.id,
|
||||
userId: author.id,
|
||||
replyToId: parent.id,
|
||||
message: 'Internal reply',
|
||||
attachmentIds: [],
|
||||
isInternal: true,
|
||||
},
|
||||
{ triggerAgents: false },
|
||||
)
|
||||
|
||||
// Non-author (even team owner) cannot edit
|
||||
await expect(
|
||||
assetService.updateComment({
|
||||
commentId: parent.id,
|
||||
userId: owner.id,
|
||||
message: 'Owner edit attempt',
|
||||
}),
|
||||
).rejects.toMatchObject({ status: 403 })
|
||||
|
||||
// Reply cannot be made public while parent is internal
|
||||
await expect(
|
||||
assetService.updateComment({
|
||||
commentId: reply.id,
|
||||
userId: author.id,
|
||||
isInternal: false,
|
||||
}),
|
||||
).rejects.toMatchObject({ status: 400 })
|
||||
|
||||
// Empty comment without attachments or annotations is rejected
|
||||
await expect(
|
||||
assetService.updateComment({
|
||||
commentId: parent.id,
|
||||
userId: author.id,
|
||||
message: ' ',
|
||||
attachmentIds: [],
|
||||
}),
|
||||
).rejects.toMatchObject({ status: 400 })
|
||||
|
||||
// Toggling parent Internal -> Public keeps reply's own isInternal flag intact
|
||||
const toggledParent = await assetService.updateComment({
|
||||
commentId: parent.id,
|
||||
userId: author.id,
|
||||
isInternal: false,
|
||||
})
|
||||
expect(toggledParent.isInternal).toBe(false)
|
||||
expect(toggledParent.replies[0].isInternal).toBe(true)
|
||||
|
||||
// Agent comments cannot be edited
|
||||
const agentUser = await prisma.user.create({
|
||||
data: {
|
||||
name: 'Bot',
|
||||
email: `bot-${Date.now()}-${Math.random()}@test.com`,
|
||||
type: 'agent',
|
||||
},
|
||||
})
|
||||
const agent = await prisma.agent.create({
|
||||
data: {
|
||||
id: agentUser.id,
|
||||
teamId: (await prisma.project.findUniqueOrThrow({ where: { id: file.projectId! } }))
|
||||
.teamId,
|
||||
type: 'chat',
|
||||
config: { provider: 'openai', model: 'gpt-4' },
|
||||
},
|
||||
})
|
||||
const session = await prisma.agentSession.create({
|
||||
data: { agentId: agent.id, cwd: '/tmp' },
|
||||
})
|
||||
const agentComment = await prisma.assetComment.create({
|
||||
data: {
|
||||
assetId: file.id,
|
||||
creatorId: author.id,
|
||||
sessionId: session.id,
|
||||
message: 'Agent generated reply',
|
||||
},
|
||||
})
|
||||
await expect(
|
||||
assetService.updateComment({
|
||||
commentId: agentComment.id,
|
||||
userId: author.id,
|
||||
message: 'Try edit agent',
|
||||
}),
|
||||
).rejects.toMatchObject({ status: 403 })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -743,7 +743,10 @@ export class AssetService {
|
||||
}
|
||||
}
|
||||
|
||||
async listChildren(req: ListChildrenRequest): Promise<PaginatedData<AssetInfo[]>> {
|
||||
async listChildren(
|
||||
req: ListChildrenRequest,
|
||||
options?: { excludeInternalComments?: boolean },
|
||||
): Promise<PaginatedData<AssetInfo[]>> {
|
||||
let typesToQuery: AssetType[]
|
||||
if (req.assetType === 'file') {
|
||||
typesToQuery = [AssetType.file, AssetType.version_stack]
|
||||
@@ -831,6 +834,7 @@ export class AssetService {
|
||||
|
||||
const infos = await this.toAssetInfos(assets, undefined, {
|
||||
includeDeletedChildren: req.showDeleted,
|
||||
excludeInternalComments: options?.excludeInternalComments,
|
||||
})
|
||||
|
||||
return { data: infos, pageInfo }
|
||||
@@ -1107,7 +1111,10 @@ export class AssetService {
|
||||
return this.getAsset({ assetId: asset.id })
|
||||
}
|
||||
|
||||
async getAsset(req: GetAssetRequest): Promise<AssetInfo> {
|
||||
async getAsset(
|
||||
req: GetAssetRequest,
|
||||
options?: { excludeInternalComments?: boolean },
|
||||
): Promise<AssetInfo> {
|
||||
const a = await this.prismaClient.asset.findUnique({
|
||||
where: { id: req.assetId },
|
||||
include: assetInclude,
|
||||
@@ -1130,7 +1137,9 @@ export class AssetService {
|
||||
afs.push({ id: row.id, name: row.name })
|
||||
}
|
||||
|
||||
const infos = await this.toAssetInfos([a])
|
||||
const infos = await this.toAssetInfos([a], undefined, {
|
||||
excludeInternalComments: options?.excludeInternalComments,
|
||||
})
|
||||
const info = infos[0]
|
||||
info.ancestorFolders = afs
|
||||
|
||||
@@ -2001,16 +2010,39 @@ export class AssetService {
|
||||
|
||||
let actualReplyToId = req.replyToId
|
||||
let parentComment = null
|
||||
let parentIsInternal = false
|
||||
if (req.replyToId) {
|
||||
parentComment = await tx.assetComment.findUnique({
|
||||
where: { id: req.replyToId },
|
||||
include: { creator: true },
|
||||
include: {
|
||||
creator: true,
|
||||
replyTo: { select: { id: true, isInternal: true } },
|
||||
},
|
||||
})
|
||||
if (options.shareLinkId) {
|
||||
if (
|
||||
!parentComment ||
|
||||
parentComment.assetId !== a.id ||
|
||||
parentComment.isInternal ||
|
||||
parentComment.replyTo?.isInternal
|
||||
) {
|
||||
throw new HTTPException(404, { message: 'Comment not found' })
|
||||
}
|
||||
}
|
||||
if (parentComment?.replyToId) {
|
||||
actualReplyToId = parentComment.replyToId
|
||||
parentIsInternal = Boolean(parentComment.isInternal || parentComment.replyTo?.isInternal)
|
||||
} else if (parentComment) {
|
||||
parentIsInternal = parentComment.isInternal
|
||||
}
|
||||
}
|
||||
|
||||
const isInternal = options.shareLinkId
|
||||
? false
|
||||
: parentIsInternal
|
||||
? true
|
||||
: Boolean(req.isInternal)
|
||||
|
||||
const attachmentIds = await this.lockCommentAttachments(tx, req.attachmentIds, {
|
||||
projectId: a.projectId,
|
||||
userId: req.userId,
|
||||
@@ -2023,6 +2055,7 @@ export class AssetService {
|
||||
annotation: req.annotations,
|
||||
second: req.second,
|
||||
replyToId: actualReplyToId,
|
||||
isInternal,
|
||||
},
|
||||
})
|
||||
commentId = comment.id
|
||||
@@ -2221,6 +2254,145 @@ export class AssetService {
|
||||
return this.getComment(commentId, userId)
|
||||
}
|
||||
|
||||
async updateComment(params: {
|
||||
commentId: string
|
||||
userId: string
|
||||
message?: string
|
||||
isInternal?: boolean
|
||||
second?: number | null
|
||||
attachmentIds?: string[]
|
||||
}): Promise<CommentInfo> {
|
||||
await this.prismaClient.$transaction(async (tx) => {
|
||||
const comment = await tx.assetComment.findUnique({
|
||||
where: { id: params.commentId },
|
||||
select: {
|
||||
id: true,
|
||||
creatorId: true,
|
||||
sessionId: true,
|
||||
message: true,
|
||||
annotation: true,
|
||||
second: true,
|
||||
isInternal: true,
|
||||
attachments: { select: { assetId: true } },
|
||||
replyTo: { select: { isInternal: true } },
|
||||
asset: { select: { projectId: true } },
|
||||
},
|
||||
})
|
||||
|
||||
if (!comment) {
|
||||
throw new HTTPException(404, { message: 'Comment not found' })
|
||||
}
|
||||
|
||||
if (comment.sessionId !== null || comment.creatorId !== params.userId) {
|
||||
throw new HTTPException(403, { message: 'Only the comment author can edit this comment' })
|
||||
}
|
||||
|
||||
if (comment.replyTo?.isInternal && params.isInternal === false) {
|
||||
throw new HTTPException(400, {
|
||||
message: 'Cannot make a reply public when its parent comment is internal',
|
||||
})
|
||||
}
|
||||
|
||||
const existingAttachmentIds = comment.attachments.map(({ assetId }) => assetId)
|
||||
const existingSet = new Set(existingAttachmentIds)
|
||||
|
||||
let toAdd: string[] = []
|
||||
let toRemove: string[] = []
|
||||
let keptCount = existingAttachmentIds.length
|
||||
|
||||
if (params.attachmentIds !== undefined) {
|
||||
const desiredIds = Array.from(new Set(params.attachmentIds))
|
||||
const desiredSet = new Set(desiredIds)
|
||||
toAdd = desiredIds.filter((id) => !existingSet.has(id))
|
||||
toRemove = existingAttachmentIds.filter((id) => !desiredSet.has(id))
|
||||
keptCount = existingAttachmentIds.filter((id) => desiredSet.has(id)).length
|
||||
}
|
||||
|
||||
const idsToLock = Array.from(new Set([...toAdd, ...toRemove]))
|
||||
let claimedToAdd: string[] = []
|
||||
let lockedToRemove: string[] = []
|
||||
|
||||
if (idsToLock.length > 0) {
|
||||
const lockedRows = await tx.$queryRaw<
|
||||
{ id: string; projectId: string | null; creatorId: string | null }[]
|
||||
>`
|
||||
SELECT id, project_id AS "projectId", creator_id AS "creatorId" FROM assets
|
||||
WHERE id IN (${Prisma.join(idsToLock)}) AND type = 'attachment'
|
||||
ORDER BY id
|
||||
FOR NO KEY UPDATE
|
||||
`
|
||||
const toAddSet = new Set(toAdd)
|
||||
const toRemoveSet = new Set(toRemove)
|
||||
const ownedToAdd = lockedRows
|
||||
.filter(
|
||||
(row) =>
|
||||
toAddSet.has(row.id) &&
|
||||
row.projectId === comment.asset.projectId &&
|
||||
row.creatorId === params.userId,
|
||||
)
|
||||
.map((row) => row.id)
|
||||
|
||||
lockedToRemove = lockedRows.filter((row) => toRemoveSet.has(row.id)).map((row) => row.id)
|
||||
|
||||
if (ownedToAdd.length > 0) {
|
||||
const unclaimed = await tx.asset.findMany({
|
||||
where: { id: { in: ownedToAdd }, commentAttachments: { none: {} } },
|
||||
select: { id: true },
|
||||
})
|
||||
claimedToAdd = unclaimed.map(({ id }) => id)
|
||||
}
|
||||
}
|
||||
|
||||
const finalMessage = params.message !== undefined ? params.message : (comment.message ?? '')
|
||||
const hasAnnotations = Array.isArray(comment.annotation) && comment.annotation.length > 0
|
||||
const finalAttachmentCount = keptCount + claimedToAdd.length
|
||||
|
||||
if (!finalMessage.trim() && finalAttachmentCount === 0 && !hasAnnotations) {
|
||||
throw new HTTPException(400, { message: 'Comment cannot be empty' })
|
||||
}
|
||||
|
||||
if (toRemove.length > 0) {
|
||||
await tx.assetCommentAttachment.deleteMany({
|
||||
where: {
|
||||
commentId: params.commentId,
|
||||
assetId: { in: toRemove },
|
||||
},
|
||||
})
|
||||
if (lockedToRemove.length > 0) {
|
||||
await tx.asset.deleteMany({
|
||||
where: { id: { in: lockedToRemove }, commentAttachments: { none: {} } },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (claimedToAdd.length > 0) {
|
||||
await tx.assetCommentAttachment.createMany({
|
||||
data: claimedToAdd.map((assetId) => ({ assetId, commentId: params.commentId })),
|
||||
})
|
||||
}
|
||||
|
||||
const updateData: Prisma.AssetCommentUpdateInput = {}
|
||||
if (params.message !== undefined) {
|
||||
updateData.message = params.message
|
||||
}
|
||||
if (params.isInternal !== undefined) {
|
||||
updateData.isInternal = params.isInternal
|
||||
}
|
||||
if (params.second !== undefined) {
|
||||
updateData.second = params.second
|
||||
}
|
||||
|
||||
if (Object.keys(updateData).length > 0) {
|
||||
await tx.assetComment.update({
|
||||
where: { id: params.commentId },
|
||||
data: updateData,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return this.getComment(params.commentId, params.userId)
|
||||
}
|
||||
|
||||
async deleteComment({ commentId, userId }: { commentId: string; userId: string }): Promise<void> {
|
||||
const comment = await this.prismaClient.assetComment.findUnique({
|
||||
where: { id: commentId },
|
||||
@@ -2283,7 +2455,7 @@ export class AssetService {
|
||||
})
|
||||
}
|
||||
|
||||
private getCommentInclude() {
|
||||
private getCommentInclude(options?: { excludeInternal?: boolean }) {
|
||||
return {
|
||||
creator: true,
|
||||
completionLastChangedBy: true,
|
||||
@@ -2296,6 +2468,7 @@ export class AssetService {
|
||||
orderBy: { createdAt: 'asc' as const },
|
||||
},
|
||||
replies: {
|
||||
...(options?.excludeInternal ? { where: { isInternal: false } } : {}),
|
||||
include: {
|
||||
creator: true,
|
||||
completionLastChangedBy: true,
|
||||
@@ -2316,14 +2489,20 @@ export class AssetService {
|
||||
assetId: string,
|
||||
params: PaginationParams,
|
||||
requestingUserId?: string,
|
||||
options?: { excludeInternal?: boolean },
|
||||
): Promise<PaginatedData<CommentInfo[]>> {
|
||||
const resolvedAssetId = await this.resolveLatestVersionId(assetId)
|
||||
const where: Prisma.AssetCommentWhereInput = {
|
||||
assetId: resolvedAssetId,
|
||||
replyToId: null,
|
||||
...(options?.excludeInternal ? { isInternal: false } : {}),
|
||||
}
|
||||
|
||||
const { data: comments, pageInfo } = await paginateQuery(
|
||||
async (skip, take) => {
|
||||
return this.prismaClient.assetComment.findMany({
|
||||
where: { assetId: resolvedAssetId, replyToId: null },
|
||||
include: this.getCommentInclude(),
|
||||
where,
|
||||
include: this.getCommentInclude(options),
|
||||
skip,
|
||||
take,
|
||||
orderBy: { id: 'asc' },
|
||||
@@ -2331,7 +2510,7 @@ export class AssetService {
|
||||
},
|
||||
async () =>
|
||||
this.prismaClient.assetComment.count({
|
||||
where: { assetId: resolvedAssetId, replyToId: null },
|
||||
where,
|
||||
}),
|
||||
params,
|
||||
)
|
||||
@@ -2341,12 +2520,20 @@ export class AssetService {
|
||||
return { data: infos, pageInfo }
|
||||
}
|
||||
|
||||
async listAllComments(assetId: string, requestingUserId?: string): Promise<CommentInfo[]> {
|
||||
async listAllComments(
|
||||
assetId: string,
|
||||
requestingUserId?: string,
|
||||
options?: { excludeInternal?: boolean },
|
||||
): Promise<CommentInfo[]> {
|
||||
const resolvedAssetId = await this.resolveLatestVersionId(assetId)
|
||||
|
||||
const comments = await this.prismaClient.assetComment.findMany({
|
||||
where: { assetId: resolvedAssetId, replyToId: null },
|
||||
include: this.getCommentInclude(),
|
||||
where: {
|
||||
assetId: resolvedAssetId,
|
||||
replyToId: null,
|
||||
...(options?.excludeInternal ? { isInternal: false } : {}),
|
||||
},
|
||||
include: this.getCommentInclude(options),
|
||||
orderBy: { id: 'asc' },
|
||||
})
|
||||
|
||||
@@ -2461,9 +2648,10 @@ export class AssetService {
|
||||
async toAssetInfos(
|
||||
assets: AssetWithIncludes[],
|
||||
previewFormat?: PreviewFormat,
|
||||
options?: { includeDeletedChildren?: boolean },
|
||||
options?: { includeDeletedChildren?: boolean; excludeInternalComments?: boolean },
|
||||
): Promise<AssetInfo[]> {
|
||||
const includeDeletedChildren = options?.includeDeletedChildren ?? false
|
||||
const excludeInternalComments = options?.excludeInternalComments ?? false
|
||||
const stackIds = new Set<string>()
|
||||
|
||||
for (const a of assets) {
|
||||
@@ -2553,6 +2741,12 @@ export class AssetService {
|
||||
by: ['assetId'],
|
||||
where: {
|
||||
assetId: { in: Array.from(commentTargetIds) },
|
||||
...(excludeInternalComments
|
||||
? {
|
||||
isInternal: false,
|
||||
OR: [{ replyToId: null }, { replyTo: { isInternal: false } }],
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
_count: { _all: true },
|
||||
})
|
||||
@@ -3429,6 +3623,7 @@ export class AssetService {
|
||||
updatedAt: c.updatedAt.toISOString(),
|
||||
sessionId: c.sessionId,
|
||||
isCompleted: c.isCompleted,
|
||||
isInternal: c.isInternal,
|
||||
completionLastChangedBy,
|
||||
reactionCounts,
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ export interface PostCommentParams {
|
||||
/** Timecode in seconds (or the encoded viewing angle for 3D models). */
|
||||
second?: number
|
||||
attachmentIds?: string[]
|
||||
/** Whether the comment is internal and hidden from public share links (default false). */
|
||||
isInternal?: boolean
|
||||
/** Whether mentions of agents start a chat with them (default true). */
|
||||
triggerAgents?: boolean
|
||||
}
|
||||
@@ -31,6 +33,7 @@ export class CommentService {
|
||||
annotations: params.annotations,
|
||||
second: params.second,
|
||||
attachmentIds: params.attachmentIds ?? [],
|
||||
isInternal: params.isInternal,
|
||||
},
|
||||
{ triggerAgents: params.triggerAgents },
|
||||
)
|
||||
|
||||
@@ -240,7 +240,12 @@ describe('collaboration Operations', () => {
|
||||
message: 'Too dark at the start',
|
||||
second: 2.5,
|
||||
})
|
||||
expect(comment).toEqual({ id: expect.any(String), assetId: file, replyToId: null })
|
||||
expect(comment).toEqual({
|
||||
id: expect.any(String),
|
||||
assetId: file,
|
||||
replyToId: null,
|
||||
isInternal: false,
|
||||
})
|
||||
|
||||
const reply = await runOperation(createCommentOp, as(owner, 'agent', undefined), {
|
||||
assetId: file,
|
||||
@@ -248,9 +253,17 @@ describe('collaboration Operations', () => {
|
||||
replyToId: comment.id,
|
||||
})
|
||||
expect(reply.replyToId).toBe(comment.id)
|
||||
expect(reply.isInternal).toBe(false)
|
||||
|
||||
const internalComment = await runOperation(createCommentOp, as(reviewer), {
|
||||
assetId: file,
|
||||
message: 'Internal budget note',
|
||||
isInternal: true,
|
||||
})
|
||||
expect(internalComment.isInternal).toBe(true)
|
||||
|
||||
const listed = await runOperation(listCommentsOp, as(reviewer), { assetId: file })
|
||||
expect(listed.total).toBe(1)
|
||||
expect(listed.total).toBe(2)
|
||||
expect(listed.data).toEqual([
|
||||
expect.objectContaining({
|
||||
id: comment.id,
|
||||
@@ -258,14 +271,21 @@ describe('collaboration Operations', () => {
|
||||
author: { id: reviewer.id, name: 'Reviewer' },
|
||||
second: 2.5,
|
||||
resolved: false,
|
||||
isInternal: false,
|
||||
replies: [
|
||||
expect.objectContaining({
|
||||
id: reply.id,
|
||||
message: 'Brightened in v2',
|
||||
author: { id: owner.id, name: 'Owner' },
|
||||
isInternal: false,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: internalComment.id,
|
||||
message: 'Internal budget note',
|
||||
isInternal: true,
|
||||
}),
|
||||
])
|
||||
|
||||
await expect(
|
||||
@@ -276,7 +296,7 @@ describe('collaboration Operations', () => {
|
||||
).resolves.toEqual({ commentId: comment.id, resolved: false })
|
||||
|
||||
const created = await auditRows(AuditAction.comment_create)
|
||||
expect(created.map((r) => r.itemId)).toEqual([comment.id, reply.id])
|
||||
expect(created.map((r) => r.itemId)).toEqual([comment.id, reply.id, internalComment.id])
|
||||
expect(created.every((r) => r.teamId === teamId && r.projectId === projectId)).toBe(true)
|
||||
const completed = await auditRows(AuditAction.comment_complete)
|
||||
expect(completed).toHaveLength(2)
|
||||
|
||||
@@ -20,10 +20,16 @@ export const createCommentOp = implementOperation(createComment, {
|
||||
message: input.message,
|
||||
replyToId: input.replyToId,
|
||||
second: input.second,
|
||||
isInternal: input.isInternal,
|
||||
// Mentions in comments written by Shumai's own agent must not start more agent runs.
|
||||
triggerAgents: ctx.via !== 'agent',
|
||||
})
|
||||
return { id: comment.id, assetId: comment.assetId, replyToId: input.replyToId ?? null }
|
||||
return {
|
||||
id: comment.id,
|
||||
assetId: comment.assetId,
|
||||
replyToId: input.replyToId ?? null,
|
||||
isInternal: comment.isInternal,
|
||||
}
|
||||
},
|
||||
audit: (input, output) => [
|
||||
{ action: AuditAction.comment_create, itemId: output.id, contextAssetId: input.assetId },
|
||||
|
||||
@@ -15,6 +15,7 @@ function toCommentFields(comment: CommentInfo) {
|
||||
second: comment.second,
|
||||
hasMarkup: Array.isArray(comment.annotations) && comment.annotations.length > 0,
|
||||
attachmentCount: comment.attachments.length,
|
||||
isInternal: comment.isInternal,
|
||||
createdAt: comment.createdAt,
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "asset_comments" ADD COLUMN "is_internal" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -709,6 +709,7 @@ model AssetComment {
|
||||
creator User? @relation("UserToAssetComment", fields: [creatorId], references: [id])
|
||||
|
||||
isCompleted Boolean @default(false) @map("is_completed")
|
||||
isInternal Boolean @default(false) @map("is_internal")
|
||||
completionLastChangedById String? @map("completion_last_changed_by_id")
|
||||
completionLastChangedBy User? @relation("UserToAssetCommentCompletionChanged", fields: [completionLastChangedById], references: [id])
|
||||
|
||||
|
||||
+4
-4
File diff suppressed because one or more lines are too long
@@ -5412,6 +5412,7 @@ export const AssetCommentScalarFieldEnum = {
|
||||
assetId: 'assetId',
|
||||
creatorId: 'creatorId',
|
||||
isCompleted: 'isCompleted',
|
||||
isInternal: 'isInternal',
|
||||
completionLastChangedById: 'completionLastChangedById',
|
||||
replyToId: 'replyToId'
|
||||
} as const
|
||||
|
||||
@@ -438,6 +438,7 @@ export const AssetCommentScalarFieldEnum = {
|
||||
assetId: 'assetId',
|
||||
creatorId: 'creatorId',
|
||||
isCompleted: 'isCompleted',
|
||||
isInternal: 'isInternal',
|
||||
completionLastChangedById: 'completionLastChangedById',
|
||||
replyToId: 'replyToId'
|
||||
} as const
|
||||
|
||||
+72
-1
@@ -46,6 +46,7 @@ export type AssetCommentMinAggregateOutputType = {
|
||||
assetId: string | null
|
||||
creatorId: string | null
|
||||
isCompleted: boolean | null
|
||||
isInternal: boolean | null
|
||||
completionLastChangedById: string | null
|
||||
replyToId: string | null
|
||||
}
|
||||
@@ -60,6 +61,7 @@ export type AssetCommentMaxAggregateOutputType = {
|
||||
assetId: string | null
|
||||
creatorId: string | null
|
||||
isCompleted: boolean | null
|
||||
isInternal: boolean | null
|
||||
completionLastChangedById: string | null
|
||||
replyToId: string | null
|
||||
}
|
||||
@@ -75,6 +77,7 @@ export type AssetCommentCountAggregateOutputType = {
|
||||
assetId: number
|
||||
creatorId: number
|
||||
isCompleted: number
|
||||
isInternal: number
|
||||
completionLastChangedById: number
|
||||
replyToId: number
|
||||
_all: number
|
||||
@@ -99,6 +102,7 @@ export type AssetCommentMinAggregateInputType = {
|
||||
assetId?: true
|
||||
creatorId?: true
|
||||
isCompleted?: true
|
||||
isInternal?: true
|
||||
completionLastChangedById?: true
|
||||
replyToId?: true
|
||||
}
|
||||
@@ -113,6 +117,7 @@ export type AssetCommentMaxAggregateInputType = {
|
||||
assetId?: true
|
||||
creatorId?: true
|
||||
isCompleted?: true
|
||||
isInternal?: true
|
||||
completionLastChangedById?: true
|
||||
replyToId?: true
|
||||
}
|
||||
@@ -128,6 +133,7 @@ export type AssetCommentCountAggregateInputType = {
|
||||
assetId?: true
|
||||
creatorId?: true
|
||||
isCompleted?: true
|
||||
isInternal?: true
|
||||
completionLastChangedById?: true
|
||||
replyToId?: true
|
||||
_all?: true
|
||||
@@ -230,6 +236,7 @@ export type AssetCommentGroupByOutputType = {
|
||||
assetId: string
|
||||
creatorId: string | null
|
||||
isCompleted: boolean
|
||||
isInternal: boolean
|
||||
completionLastChangedById: string | null
|
||||
replyToId: string | null
|
||||
_count: AssetCommentCountAggregateOutputType | null
|
||||
@@ -268,6 +275,7 @@ export type AssetCommentWhereInput = {
|
||||
assetId?: Prisma.StringFilter<"AssetComment"> | string
|
||||
creatorId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
isCompleted?: Prisma.BoolFilter<"AssetComment"> | boolean
|
||||
isInternal?: Prisma.BoolFilter<"AssetComment"> | boolean
|
||||
completionLastChangedById?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
replyToId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
|
||||
@@ -291,6 +299,7 @@ export type AssetCommentOrderByWithRelationInput = {
|
||||
assetId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
isCompleted?: Prisma.SortOrder
|
||||
isInternal?: Prisma.SortOrder
|
||||
completionLastChangedById?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
replyToId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
session?: Prisma.AgentSessionOrderByWithRelationInput
|
||||
@@ -317,6 +326,7 @@ export type AssetCommentWhereUniqueInput = Prisma.AtLeast<{
|
||||
assetId?: Prisma.StringFilter<"AssetComment"> | string
|
||||
creatorId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
isCompleted?: Prisma.BoolFilter<"AssetComment"> | boolean
|
||||
isInternal?: Prisma.BoolFilter<"AssetComment"> | boolean
|
||||
completionLastChangedById?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
replyToId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
|
||||
@@ -340,6 +350,7 @@ export type AssetCommentOrderByWithAggregationInput = {
|
||||
assetId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
isCompleted?: Prisma.SortOrder
|
||||
isInternal?: Prisma.SortOrder
|
||||
completionLastChangedById?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
replyToId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
_count?: Prisma.AssetCommentCountOrderByAggregateInput
|
||||
@@ -363,6 +374,7 @@ export type AssetCommentScalarWhereWithAggregatesInput = {
|
||||
assetId?: Prisma.StringWithAggregatesFilter<"AssetComment"> | string
|
||||
creatorId?: Prisma.StringNullableWithAggregatesFilter<"AssetComment"> | string | null
|
||||
isCompleted?: Prisma.BoolWithAggregatesFilter<"AssetComment"> | boolean
|
||||
isInternal?: Prisma.BoolWithAggregatesFilter<"AssetComment"> | boolean
|
||||
completionLastChangedById?: Prisma.StringNullableWithAggregatesFilter<"AssetComment"> | string | null
|
||||
replyToId?: Prisma.StringNullableWithAggregatesFilter<"AssetComment"> | string | null
|
||||
}
|
||||
@@ -375,6 +387,7 @@ export type AssetCommentCreateInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
@@ -396,6 +409,7 @@ export type AssetCommentUncheckedCreateInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
@@ -411,6 +425,7 @@ export type AssetCommentUpdateInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
@@ -432,6 +447,7 @@ export type AssetCommentUncheckedUpdateInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
@@ -450,6 +466,7 @@ export type AssetCommentCreateManyInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
}
|
||||
@@ -462,6 +479,7 @@ export type AssetCommentUpdateManyMutationInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
}
|
||||
|
||||
export type AssetCommentUncheckedUpdateManyInput = {
|
||||
@@ -475,6 +493,7 @@ export type AssetCommentUncheckedUpdateManyInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
}
|
||||
@@ -505,6 +524,7 @@ export type AssetCommentCountOrderByAggregateInput = {
|
||||
assetId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrder
|
||||
isCompleted?: Prisma.SortOrder
|
||||
isInternal?: Prisma.SortOrder
|
||||
completionLastChangedById?: Prisma.SortOrder
|
||||
replyToId?: Prisma.SortOrder
|
||||
}
|
||||
@@ -523,6 +543,7 @@ export type AssetCommentMaxOrderByAggregateInput = {
|
||||
assetId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrder
|
||||
isCompleted?: Prisma.SortOrder
|
||||
isInternal?: Prisma.SortOrder
|
||||
completionLastChangedById?: Prisma.SortOrder
|
||||
replyToId?: Prisma.SortOrder
|
||||
}
|
||||
@@ -537,6 +558,7 @@ export type AssetCommentMinOrderByAggregateInput = {
|
||||
assetId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrder
|
||||
isCompleted?: Prisma.SortOrder
|
||||
isInternal?: Prisma.SortOrder
|
||||
completionLastChangedById?: Prisma.SortOrder
|
||||
replyToId?: Prisma.SortOrder
|
||||
}
|
||||
@@ -812,6 +834,7 @@ export type AssetCommentCreateWithoutCreatorInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -831,6 +854,7 @@ export type AssetCommentUncheckedCreateWithoutCreatorInput = {
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
@@ -856,6 +880,7 @@ export type AssetCommentCreateWithoutCompletionLastChangedByInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
@@ -876,6 +901,7 @@ export type AssetCommentUncheckedCreateWithoutCompletionLastChangedByInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
|
||||
@@ -922,6 +948,7 @@ export type AssetCommentScalarWhereInput = {
|
||||
assetId?: Prisma.StringFilter<"AssetComment"> | string
|
||||
creatorId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
isCompleted?: Prisma.BoolFilter<"AssetComment"> | boolean
|
||||
isInternal?: Prisma.BoolFilter<"AssetComment"> | boolean
|
||||
completionLastChangedById?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
replyToId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
}
|
||||
@@ -950,6 +977,7 @@ export type AssetCommentCreateWithoutAssetInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -969,6 +997,7 @@ export type AssetCommentUncheckedCreateWithoutAssetInput = {
|
||||
updatedAt?: Date | string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
@@ -1010,6 +1039,7 @@ export type AssetCommentCreateWithoutRepliesInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
@@ -1030,6 +1060,7 @@ export type AssetCommentUncheckedCreateWithoutRepliesInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
|
||||
@@ -1049,6 +1080,7 @@ export type AssetCommentCreateWithoutReplyToInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
@@ -1069,6 +1101,7 @@ export type AssetCommentUncheckedCreateWithoutReplyToInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
|
||||
@@ -1104,6 +1137,7 @@ export type AssetCommentUpdateWithoutRepliesInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
@@ -1124,6 +1158,7 @@ export type AssetCommentUncheckedUpdateWithoutRepliesInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
|
||||
@@ -1154,6 +1189,7 @@ export type AssetCommentCreateWithoutAttachmentsInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
@@ -1174,6 +1210,7 @@ export type AssetCommentUncheckedCreateWithoutAttachmentsInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
@@ -1204,6 +1241,7 @@ export type AssetCommentUpdateWithoutAttachmentsInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
@@ -1224,6 +1262,7 @@ export type AssetCommentUncheckedUpdateWithoutAttachmentsInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
@@ -1238,6 +1277,7 @@ export type AssetCommentCreateWithoutReactionsInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
@@ -1258,6 +1298,7 @@ export type AssetCommentUncheckedCreateWithoutReactionsInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
@@ -1288,6 +1329,7 @@ export type AssetCommentUpdateWithoutReactionsInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
@@ -1308,6 +1350,7 @@ export type AssetCommentUncheckedUpdateWithoutReactionsInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
@@ -1322,6 +1365,7 @@ export type AssetCommentCreateWithoutSessionInput = {
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -1341,6 +1385,7 @@ export type AssetCommentUncheckedCreateWithoutSessionInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
@@ -1384,6 +1429,7 @@ export type AssetCommentCreateManyCreatorInput = {
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
}
|
||||
@@ -1399,6 +1445,7 @@ export type AssetCommentCreateManyCompletionLastChangedByInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
replyToId?: string | null
|
||||
}
|
||||
|
||||
@@ -1410,6 +1457,7 @@ export type AssetCommentUpdateWithoutCreatorInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1429,6 +1477,7 @@ export type AssetCommentUncheckedUpdateWithoutCreatorInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
@@ -1446,6 +1495,7 @@ export type AssetCommentUncheckedUpdateManyWithoutCreatorInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
}
|
||||
@@ -1458,6 +1508,7 @@ export type AssetCommentUpdateWithoutCompletionLastChangedByInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
@@ -1478,6 +1529,7 @@ export type AssetCommentUncheckedUpdateWithoutCompletionLastChangedByInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
|
||||
@@ -1495,6 +1547,7 @@ export type AssetCommentUncheckedUpdateManyWithoutCompletionLastChangedByInput =
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
}
|
||||
|
||||
@@ -1508,6 +1561,7 @@ export type AssetCommentCreateManyAssetInput = {
|
||||
updatedAt?: Date | string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
}
|
||||
@@ -1520,6 +1574,7 @@ export type AssetCommentUpdateWithoutAssetInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1539,6 +1594,7 @@ export type AssetCommentUncheckedUpdateWithoutAssetInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
@@ -1556,6 +1612,7 @@ export type AssetCommentUncheckedUpdateManyWithoutAssetInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
}
|
||||
@@ -1571,6 +1628,7 @@ export type AssetCommentCreateManyReplyToInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
}
|
||||
|
||||
@@ -1582,6 +1640,7 @@ export type AssetCommentUpdateWithoutReplyToInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
@@ -1602,6 +1661,7 @@ export type AssetCommentUncheckedUpdateWithoutReplyToInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
|
||||
@@ -1619,6 +1679,7 @@ export type AssetCommentUncheckedUpdateManyWithoutReplyToInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
}
|
||||
|
||||
@@ -1632,6 +1693,7 @@ export type AssetCommentCreateManySessionInput = {
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
}
|
||||
@@ -1644,6 +1706,7 @@ export type AssetCommentUpdateWithoutSessionInput = {
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1663,6 +1726,7 @@ export type AssetCommentUncheckedUpdateWithoutSessionInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
@@ -1680,6 +1744,7 @@ export type AssetCommentUncheckedUpdateManyWithoutSessionInput = {
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
}
|
||||
@@ -1744,6 +1809,7 @@ export type AssetCommentSelect<ExtArgs extends runtime.Types.Extensions.Internal
|
||||
assetId?: boolean
|
||||
creatorId?: boolean
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: boolean
|
||||
replyToId?: boolean
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
@@ -1768,6 +1834,7 @@ export type AssetCommentSelectCreateManyAndReturn<ExtArgs extends runtime.Types.
|
||||
assetId?: boolean
|
||||
creatorId?: boolean
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: boolean
|
||||
replyToId?: boolean
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
@@ -1788,6 +1855,7 @@ export type AssetCommentSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.
|
||||
assetId?: boolean
|
||||
creatorId?: boolean
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: boolean
|
||||
replyToId?: boolean
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
@@ -1808,11 +1876,12 @@ export type AssetCommentSelectScalar = {
|
||||
assetId?: boolean
|
||||
creatorId?: boolean
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: boolean
|
||||
replyToId?: boolean
|
||||
}
|
||||
|
||||
export type AssetCommentOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "message" | "annotation" | "second" | "sessionId" | "createdAt" | "updatedAt" | "assetId" | "creatorId" | "isCompleted" | "completionLastChangedById" | "replyToId", ExtArgs["result"]["assetComment"]>
|
||||
export type AssetCommentOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "message" | "annotation" | "second" | "sessionId" | "createdAt" | "updatedAt" | "assetId" | "creatorId" | "isCompleted" | "isInternal" | "completionLastChangedById" | "replyToId", ExtArgs["result"]["assetComment"]>
|
||||
export type AssetCommentInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
asset?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
@@ -1865,6 +1934,7 @@ export type $AssetCommentPayload<ExtArgs extends runtime.Types.Extensions.Intern
|
||||
assetId: string
|
||||
creatorId: string | null
|
||||
isCompleted: boolean
|
||||
isInternal: boolean
|
||||
completionLastChangedById: string | null
|
||||
replyToId: string | null
|
||||
}, ExtArgs["result"]["assetComment"]>
|
||||
@@ -2308,6 +2378,7 @@ export interface AssetCommentFieldRefs {
|
||||
readonly assetId: Prisma.FieldRef<"AssetComment", 'String'>
|
||||
readonly creatorId: Prisma.FieldRef<"AssetComment", 'String'>
|
||||
readonly isCompleted: Prisma.FieldRef<"AssetComment", 'Boolean'>
|
||||
readonly isInternal: Prisma.FieldRef<"AssetComment", 'Boolean'>
|
||||
readonly completionLastChangedById: Prisma.FieldRef<"AssetComment", 'String'>
|
||||
readonly replyToId: Prisma.FieldRef<"AssetComment", 'String'>
|
||||
}
|
||||
|
||||
@@ -238,9 +238,18 @@ export const createCommentRequestSchema = z.object({
|
||||
annotations: z.any().optional(),
|
||||
second: z.number().optional(),
|
||||
attachmentIds: z.array(z.string()),
|
||||
isInternal: z.boolean().optional(),
|
||||
})
|
||||
export type CreateCommentRequest = z.infer<typeof createCommentRequestSchema>
|
||||
|
||||
export const updateCommentRequestSchema = z.object({
|
||||
message: z.string().optional(),
|
||||
isInternal: z.boolean().optional(),
|
||||
second: z.number().min(0).nullable().optional(),
|
||||
attachmentIds: z.array(z.string()).optional(),
|
||||
})
|
||||
export type UpdateCommentRequest = z.infer<typeof updateCommentRequestSchema>
|
||||
|
||||
export const attachmentInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
assetId: z.string(),
|
||||
@@ -282,6 +291,7 @@ export type CommentInfo = {
|
||||
updatedAt: string
|
||||
sessionId: string | null
|
||||
isCompleted: boolean
|
||||
isInternal: boolean
|
||||
completionLastChangedBy: AssetUserInfo | null
|
||||
reactionCounts: CommentReactionCount[]
|
||||
}
|
||||
@@ -301,6 +311,7 @@ export const commentInfoSchema: z.ZodType<CommentInfo> = z.object({
|
||||
updatedAt: z.string(),
|
||||
sessionId: z.string().nullable(),
|
||||
isCompleted: z.boolean(),
|
||||
isInternal: z.boolean(),
|
||||
completionLastChangedBy: assetUserInfoSchema.nullable(),
|
||||
reactionCounts: z.array(commentReactionCountSchema),
|
||||
})
|
||||
|
||||
@@ -22,11 +22,18 @@ export const createComment = defineOperation({
|
||||
.min(0)
|
||||
.optional()
|
||||
.describe('Timecode in seconds on a video or audio file. Omit for other files.'),
|
||||
isInternal: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
'Whether this is an internal comment hidden from public share links. Defaults to false.',
|
||||
),
|
||||
}),
|
||||
output: z.object({
|
||||
id: z.string().describe('The new comment ID.'),
|
||||
assetId: z.string().describe('The file the comment is on (the latest version for a stack).'),
|
||||
replyToId: z.string().nullable().describe('The thread it replies to, if any.'),
|
||||
isInternal: z.boolean().describe('Whether the created comment is internal.'),
|
||||
}),
|
||||
surfaces: ['agent', 'mcp', 'cli'],
|
||||
annotations: { readOnly: false, destructive: false },
|
||||
@@ -34,7 +41,7 @@ export const createComment = defineOperation({
|
||||
command: ['comment', 'add'],
|
||||
description: 'Comment on a file, or reply to a comment with --reply-to.',
|
||||
positional: ['assetId', 'message'],
|
||||
flags: { replyToId: ['--reply-to'], second: ['-t', '--at'] },
|
||||
flags: { replyToId: ['--reply-to'], second: ['-t', '--at'], isInternal: ['--internal'] },
|
||||
format: (output) => `Posted comment ${output.id}`,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -16,6 +16,9 @@ const commentFields = {
|
||||
/** Whether markup was drawn on the frame or page. */
|
||||
hasMarkup: z.boolean(),
|
||||
attachmentCount: z.number(),
|
||||
isInternal: z
|
||||
.boolean()
|
||||
.describe('Whether this comment is internal (hidden from public share links).'),
|
||||
createdAt: z.string(),
|
||||
}
|
||||
|
||||
@@ -68,9 +71,13 @@ export const listComments = defineOperation({
|
||||
for (const thread of output.data) {
|
||||
const at = thread.second !== null ? ` @${thread.second}s` : ''
|
||||
const status = thread.resolved ? ' [resolved]' : ''
|
||||
lines.push(`${thread.id}${at}${status} ${thread.author.name}: ${thread.message}`)
|
||||
const visibility = thread.isInternal ? ' [internal]' : ''
|
||||
lines.push(
|
||||
`${thread.id}${at}${status}${visibility} ${thread.author.name}: ${thread.message}`,
|
||||
)
|
||||
for (const reply of thread.replies) {
|
||||
lines.push(` ↳ ${reply.id} ${reply.author.name}: ${reply.message}`)
|
||||
const replyVisibility = reply.isInternal ? ' [internal]' : ''
|
||||
lines.push(` ↳ ${reply.id}${replyVisibility} ${reply.author.name}: ${reply.message}`)
|
||||
}
|
||||
}
|
||||
return lines.join('\n')
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
import React from 'react'
|
||||
import { Check, ChevronDown, Globe, Lock } from 'lucide-react'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '../ui/dropdown-menu'
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip'
|
||||
|
||||
export interface CommentVisibilitySelectorProps {
|
||||
isInternal: boolean
|
||||
onChange: (isInternal: boolean) => void
|
||||
disabled?: boolean
|
||||
disabledTooltip?: string
|
||||
align?: 'start' | 'center' | 'end'
|
||||
side?: 'top' | 'bottom'
|
||||
}
|
||||
|
||||
export const CommentVisibilitySelector: React.FC<CommentVisibilitySelectorProps> = ({
|
||||
isInternal,
|
||||
onChange,
|
||||
disabled = false,
|
||||
disabledTooltip,
|
||||
align = 'end',
|
||||
side = 'top',
|
||||
}) => {
|
||||
const pillClasses = `inline-flex h-7 items-center gap-1 rounded-md border px-2 text-xs font-medium transition-colors shrink-0 select-none ${
|
||||
isInternal
|
||||
? 'border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300'
|
||||
: 'border-border bg-muted/40 text-muted-foreground hover:text-foreground hover:bg-muted/80'
|
||||
} ${disabled ? 'opacity-70 cursor-not-allowed' : 'cursor-pointer'}`
|
||||
|
||||
const pillContent = (
|
||||
<>
|
||||
{isInternal ? <Lock className="w-3 h-3 shrink-0" /> : <Globe className="w-3 h-3 shrink-0" />}
|
||||
<span>{isInternal ? m.internal_comment_label() : m.public_comment_label()}</span>
|
||||
{!disabled && <ChevronDown className="w-3 h-3 shrink-0 opacity-70" />}
|
||||
</>
|
||||
)
|
||||
|
||||
if (disabled) {
|
||||
const button = (
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
data-testid="comment-visibility-trigger"
|
||||
className={pillClasses}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{pillContent}
|
||||
</button>
|
||||
)
|
||||
|
||||
if (!disabledTooltip) return button
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="inline-flex shrink-0">{button}</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">
|
||||
<p className="text-xs">{disabledTooltip}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="comment-visibility-trigger"
|
||||
className={pillClasses}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{pillContent}
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
align={align}
|
||||
side={side}
|
||||
className="w-60"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<DropdownMenuItem
|
||||
data-testid="comment-visibility-public"
|
||||
className="flex items-start gap-2.5 py-2 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onChange(false)
|
||||
}}
|
||||
>
|
||||
<Globe className="w-4 h-4 mt-0.5 shrink-0 text-muted-foreground" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-xs font-medium text-foreground">{m.public_comment()}</div>
|
||||
<div className="text-[11px] text-muted-foreground leading-snug">
|
||||
{m.public_comment_description()}
|
||||
</div>
|
||||
</div>
|
||||
{!isInternal && <Check className="w-4 h-4 mt-0.5 shrink-0 text-primary" />}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
data-testid="comment-visibility-internal"
|
||||
className="flex items-start gap-2.5 py-2 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onChange(true)
|
||||
}}
|
||||
>
|
||||
<Lock className="w-4 h-4 mt-0.5 shrink-0 text-amber-600 dark:text-amber-400" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-xs font-medium text-foreground">{m.internal_comment()}</div>
|
||||
<div className="text-[11px] text-muted-foreground leading-snug">
|
||||
{m.internal_comment_description()}
|
||||
</div>
|
||||
</div>
|
||||
{isInternal && <Check className="w-4 h-4 mt-0.5 shrink-0 text-primary" />}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
export const MENTION_CHIP_CLASS =
|
||||
'inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5'
|
||||
|
||||
export function createMentionNode(user: { id: string; name: string }): HTMLSpanElement {
|
||||
const mentionNode = document.createElement('span')
|
||||
mentionNode.contentEditable = 'false'
|
||||
mentionNode.dataset.type = 'mention'
|
||||
mentionNode.dataset.id = user.id
|
||||
mentionNode.className = MENTION_CHIP_CLASS
|
||||
mentionNode.innerText = `@${user.name}`
|
||||
return mentionNode
|
||||
}
|
||||
|
||||
function serializeChildNodes(parent: Node): string {
|
||||
let result = ''
|
||||
parent.childNodes.forEach((node) => {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
result += node.textContent ?? ''
|
||||
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
const el = node as HTMLElement
|
||||
if (el.dataset.type === 'mention') {
|
||||
result += `<@${el.dataset.id}>`
|
||||
} else if (el.tagName === 'BR') {
|
||||
result += '\n'
|
||||
} else if (el.tagName === 'DIV' || el.tagName === 'P') {
|
||||
result += '\n' + serializeChildNodes(el)
|
||||
} else {
|
||||
result += serializeChildNodes(el)
|
||||
}
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
export function serializeEditableContent(editor: HTMLElement): string {
|
||||
return serializeChildNodes(editor)
|
||||
.replace(/\u00A0/g, ' ')
|
||||
.trim()
|
||||
}
|
||||
|
||||
export function hydrateEditableWithMentions(
|
||||
editor: HTMLElement,
|
||||
text: string,
|
||||
resolveUserName: (userId: string) => string,
|
||||
): void {
|
||||
editor.innerHTML = ''
|
||||
if (!text) return
|
||||
|
||||
const parts = text.split(/(<@[a-zA-Z0-9_-]+>)/g)
|
||||
for (const part of parts) {
|
||||
if (!part) continue
|
||||
if (/^<@[a-zA-Z0-9_-]+>$/.test(part)) {
|
||||
const userId = part.slice(2, -1)
|
||||
editor.appendChild(createMentionNode({ id: userId, name: resolveUserName(userId) }))
|
||||
} else {
|
||||
editor.appendChild(document.createTextNode(part))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,19 @@ vi.mock('@/ui/api/client', () => ({
|
||||
},
|
||||
},
|
||||
},
|
||||
projects: {
|
||||
':projectId': {
|
||||
attachments: {
|
||||
$post: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
id: 'att-new-asset',
|
||||
uploadUrl: 'https://upload.example.com/new.txt',
|
||||
}),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
comments: {
|
||||
':commentId': {
|
||||
complete: {
|
||||
@@ -39,6 +52,10 @@ vi.mock('@/ui/api/client', () => ({
|
||||
json: async () => ({ success: true }),
|
||||
}),
|
||||
},
|
||||
$patch: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ id: 'msg-edit', message: 'Updated text', isInternal: true }),
|
||||
}),
|
||||
$delete: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ success: true }),
|
||||
@@ -98,6 +115,7 @@ describe('MessageCard component', () => {
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
@@ -158,6 +176,7 @@ describe('MessageCard component', () => {
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [
|
||||
{
|
||||
@@ -234,6 +253,7 @@ describe('MessageCard component', () => {
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [
|
||||
{
|
||||
@@ -262,4 +282,189 @@ describe('MessageCard component', () => {
|
||||
fireEvent.click(partyBadge!)
|
||||
expect(client.api.comments[':commentId'].reactions.$post).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('displays lock icon for internal comments and hides it for public comments', () => {
|
||||
const baseMessage: CommentInfo = {
|
||||
id: 'msg-internal',
|
||||
assetId: 'asset-1',
|
||||
message: 'Private review note',
|
||||
annotations: null,
|
||||
second: null,
|
||||
creator: { id: 'u-1', name: 'Bob Reviewer' },
|
||||
replies: [],
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
createdAt: '2026-08-20T10:30:00.000Z',
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: true,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
|
||||
const { rerender } = render(
|
||||
<MessageCard
|
||||
teamId="team-1"
|
||||
projectId="proj-1"
|
||||
message={baseMessage}
|
||||
getUser={() => ({ id: 'u-1', name: 'Bob Reviewer', role: 'reviewer' })}
|
||||
onReply={vi.fn()}
|
||||
/>,
|
||||
{ wrapper: createWrapper() },
|
||||
)
|
||||
|
||||
expect(screen.getByTestId('internal-comment-icon')).toBeDefined()
|
||||
|
||||
rerender(
|
||||
<MessageCard
|
||||
teamId="team-1"
|
||||
projectId="proj-1"
|
||||
message={{ ...baseMessage, isInternal: false }}
|
||||
getUser={() => ({ id: 'u-1', name: 'Bob Reviewer', role: 'reviewer' })}
|
||||
onReply={vi.fn()}
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.queryByTestId('internal-comment-icon')).toBeNull()
|
||||
})
|
||||
|
||||
it('allows author to edit text (preserving mentions), remove timestamp, remove attachment, toggle internal, and save', async () => {
|
||||
const mockMessage: CommentInfo = {
|
||||
id: 'msg-edit',
|
||||
assetId: 'asset-1',
|
||||
message: 'Hey <@u-2> check this frame',
|
||||
annotations: null,
|
||||
second: 5,
|
||||
creator: { id: 'u-1', name: 'Bob Reviewer' },
|
||||
replies: [],
|
||||
attachments: [
|
||||
{
|
||||
id: 'join-1',
|
||||
assetId: 'att-asset-1',
|
||||
url: 'https://example.com/spec.pdf',
|
||||
proxyType: null,
|
||||
},
|
||||
{
|
||||
id: 'join-2',
|
||||
assetId: 'att-asset-2',
|
||||
url: 'https://example.com/keep.png',
|
||||
proxyType: 'image',
|
||||
},
|
||||
],
|
||||
mentions: [{ id: 'u-2', name: 'Alice' }],
|
||||
createdAt: '2026-08-20T10:30:00.000Z',
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
|
||||
render(
|
||||
<MessageCard
|
||||
teamId="team-1"
|
||||
projectId="proj-1"
|
||||
message={mockMessage}
|
||||
frameRate={30}
|
||||
getUser={(id) =>
|
||||
id === 'u-2'
|
||||
? { id: 'u-2', name: 'Alice', role: 'editor' }
|
||||
: { id, name: 'Unknown', role: 'unknown' }
|
||||
}
|
||||
onReply={vi.fn()}
|
||||
/>,
|
||||
{ wrapper: createWrapper() },
|
||||
)
|
||||
|
||||
// Wait for team me query so author menu renders
|
||||
const moreBtn = await screen.findByRole('button', { name: /more options/i })
|
||||
fireEvent.pointerDown(moreBtn)
|
||||
fireEvent.click(moreBtn)
|
||||
|
||||
const editMenuItem = await screen.findByText('Edit')
|
||||
fireEvent.click(editMenuItem)
|
||||
|
||||
// Edit form should appear with hydrated mention chip, timestamp badge, and 2 attachments
|
||||
expect(screen.getByTestId('comment-edit-form')).toBeDefined()
|
||||
const mentionSpan = document.querySelector(
|
||||
'[data-testid="edit-comment-input"] span[data-type="mention"]',
|
||||
)
|
||||
expect(mentionSpan?.getAttribute('data-id')).toBe('u-2')
|
||||
expect(mentionSpan?.textContent).toBe('@Alice')
|
||||
|
||||
// Remove timestamp
|
||||
fireEvent.click(screen.getByTestId('edit-comment-remove-timestamp'))
|
||||
expect(screen.queryByTestId('edit-comment-timestamp')).toBeNull()
|
||||
|
||||
// Remove first attachment
|
||||
fireEvent.click(screen.getByTestId('edit-remove-attachment-att-asset-1'))
|
||||
expect(screen.getAllByTestId('edit-existing-attachment')).toHaveLength(1)
|
||||
|
||||
// Toggle Public -> Internal
|
||||
const visTrigger = screen.getByTestId('comment-visibility-trigger')
|
||||
fireEvent.pointerDown(visTrigger)
|
||||
fireEvent.click(visTrigger)
|
||||
fireEvent.click(await screen.findByTestId('comment-visibility-internal'))
|
||||
|
||||
// Save
|
||||
fireEvent.click(screen.getByTestId('edit-comment-save'))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(client.api.comments[':commentId'].$patch).toHaveBeenCalledWith({
|
||||
param: { commentId: 'msg-edit' },
|
||||
json: {
|
||||
message: 'Hey <@u-2> check this frame',
|
||||
isInternal: true,
|
||||
second: null,
|
||||
attachmentIds: ['att-asset-2'],
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('does not show Edit menu item to non-author even if they are team owner', async () => {
|
||||
vi.mocked(client.api.teams[':teamId'].me.$get).mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({ id: 'u-owner', name: 'Owner', role: 'owner' }),
|
||||
} as never)
|
||||
|
||||
const mockMessage: CommentInfo = {
|
||||
id: 'msg-other',
|
||||
assetId: 'asset-1',
|
||||
message: 'Another user comment',
|
||||
annotations: null,
|
||||
second: null,
|
||||
creator: { id: 'u-1', name: 'Bob Reviewer' },
|
||||
replies: [],
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
createdAt: '2026-08-20T10:30:00.000Z',
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
|
||||
render(
|
||||
<MessageCard
|
||||
teamId="team-1"
|
||||
projectId="proj-1"
|
||||
message={mockMessage}
|
||||
getUser={() => ({ id: 'u-1', name: 'Bob Reviewer', role: 'reviewer' })}
|
||||
onReply={vi.fn()}
|
||||
/>,
|
||||
{ wrapper: createWrapper() },
|
||||
)
|
||||
|
||||
const moreBtn = await screen.findByRole('button', { name: /more options/i })
|
||||
fireEvent.pointerDown(moreBtn)
|
||||
fireEvent.click(moreBtn)
|
||||
|
||||
await screen.findByText('Delete')
|
||||
expect(screen.queryByText('Edit')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/ui/component
|
||||
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, Smile, Trash2 } from 'lucide-react'
|
||||
import { Download, FileText, Lock, MoreHorizontal, Pencil, Smile, Trash2 } from 'lucide-react'
|
||||
import React from 'react'
|
||||
import Markdown from 'react-markdown'
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'
|
||||
@@ -33,11 +33,14 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/
|
||||
import { AgentSessionLogsDialog } from '../agent/agent-session-logs-dialog'
|
||||
import { isImageFileName } from '@/ui/lib/media'
|
||||
import { EmojiPickerPopover } from '../ui/emoji-picker'
|
||||
import { MessageEditForm } from './message-edit-form'
|
||||
|
||||
interface MessageCardProps {
|
||||
teamId?: string
|
||||
projectId?: string
|
||||
message: CommentInfo
|
||||
isReply?: boolean
|
||||
parentIsInternal?: boolean
|
||||
hasReplies?: boolean
|
||||
isLastReply?: boolean
|
||||
getUser: (id: string) => MemberInfo | UserInfo
|
||||
@@ -186,8 +189,10 @@ function updateCommentTreeReactions(
|
||||
|
||||
export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
teamId,
|
||||
projectId,
|
||||
message: initialMessage,
|
||||
isReply,
|
||||
parentIsInternal,
|
||||
hasReplies,
|
||||
isLastReply,
|
||||
getUser,
|
||||
@@ -210,6 +215,7 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
const loadingText = (message.message && AI_PLACEHOLDERS[message.message]) || 'Generating...'
|
||||
|
||||
const [isLogsOpen, setIsLogsOpen] = React.useState(false)
|
||||
const [isEditing, setIsEditing] = React.useState(false)
|
||||
const [previewImage, setPreviewImage] = React.useState<{ url: string; name: string } | null>(null)
|
||||
|
||||
const { videoTimeDisplayMode } = useUiStore()
|
||||
@@ -377,12 +383,17 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
},
|
||||
})
|
||||
|
||||
const canEdit = React.useMemo(() => {
|
||||
if (isReadOnly || !me || message.sessionId) return false
|
||||
return message.creator?.id === me.id
|
||||
}, [isReadOnly, me, message.creator?.id, message.sessionId])
|
||||
|
||||
const canDelete = React.useMemo(() => {
|
||||
if (!me) return false
|
||||
if (isReadOnly || !me) return false
|
||||
if (me.role === 'owner') return true
|
||||
if (message.creator?.id === me.id) return true
|
||||
return false
|
||||
}, [me, message.creator?.id])
|
||||
}, [isReadOnly, me, message.creator?.id])
|
||||
|
||||
const renderFormattedMessage = (text: string) => {
|
||||
const parts = text.split(/(<@[a-zA-Z0-9_-]+>)/g)
|
||||
@@ -410,7 +421,9 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={onSelect}
|
||||
onClick={() => {
|
||||
if (!isEditing) onSelect?.()
|
||||
}}
|
||||
className={`relative flex gap-4 ${isReply ? 'mt-[-1px]' : 'mt-3'} mr-3 group p-3 py-4 border transition-all duration-200 cursor-pointer ${
|
||||
isReply
|
||||
? isLastReply
|
||||
@@ -458,8 +471,26 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
minute: '2-digit',
|
||||
})}
|
||||
</span>
|
||||
{message.isInternal && (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span
|
||||
className="inline-flex items-center text-muted-foreground"
|
||||
data-testid="internal-comment-icon"
|
||||
aria-label={m.internal_comment_tooltip()}
|
||||
>
|
||||
<Lock className="w-3.5 h-3.5" />
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="text-xs">{m.internal_comment_tooltip()}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
</div>
|
||||
{canDelete && (
|
||||
{(canEdit || canDelete) && !isEditing && (
|
||||
<div className="opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
@@ -468,231 +499,262 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
variant="ghost"
|
||||
className="h-6 w-6 cursor-pointer"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
aria-label={m.more_options()}
|
||||
>
|
||||
<MoreHorizontal className="h-4 w-4 text-foreground/70" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" onClick={(e) => e.stopPropagation()}>
|
||||
<DropdownMenuItem
|
||||
className="text-destructive focus:text-destructive cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setIsDeleteDialogOpen(true)
|
||||
}}
|
||||
>
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
<span>{m.delete()}</span>
|
||||
</DropdownMenuItem>
|
||||
{canEdit && (
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setIsEditing(true)
|
||||
}}
|
||||
>
|
||||
<Pencil className="mr-2 h-4 w-4" />
|
||||
<span>{m.edit()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{canDelete && (
|
||||
<DropdownMenuItem
|
||||
className="text-destructive focus:text-destructive cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setIsDeleteDialogOpen(true)
|
||||
}}
|
||||
>
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
<span>{m.delete()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flow-root mt-1">
|
||||
{message.second !== null && message.second !== undefined && frameRate && (
|
||||
<div className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-1 mt-[2px] mr-2 rounded-sm text-xs leading-none font-mono font-bold flex items-center gap-1">
|
||||
{displayTime}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{hasDrawInfo && (
|
||||
<div
|
||||
className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-1 py-1 mt-[2px] mr-2 rounded-sm text-xs leading-none font-bold flex items-center gap-1"
|
||||
title="Contains drawing annotations"
|
||||
>
|
||||
<DrawAnnotation className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showSkeleton ? (
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-4 w-3/4" />
|
||||
<Skeleton className="h-4 w-1/2" />
|
||||
<span className="text-xs text-muted-foreground animate-pulse">{loadingText}</span>
|
||||
</div>
|
||||
) : message.sessionId ? (
|
||||
<div className="text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words">
|
||||
<Markdown>{preprocessMarkdown(message.message!)}</Markdown>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-sm leading-[1.8] whitespace-pre-wrap break-words text-wrap break-all">
|
||||
{renderFormattedMessage(message.message!)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Attachments */}
|
||||
{message.attachments && message.attachments.length > 0 && (
|
||||
<div className="flex flex-col gap-1.5 mt-3 w-full max-w-full overflow-hidden">
|
||||
{message.attachments.map((att) => {
|
||||
const rawName = att.url?.split('/').pop()?.split('?')[0] || 'file'
|
||||
const name = decodeURIComponent(rawName)
|
||||
const isImage = isImageFileName(name)
|
||||
return (
|
||||
<div
|
||||
key={att.id}
|
||||
className={`group relative flex items-center w-full max-w-full rounded-lg border border-border bg-card hover:bg-muted/40 transition-colors overflow-hidden ${
|
||||
isImage ? 'h-18 p-1.5 gap-2.5 cursor-pointer' : 'h-9 px-2.5 gap-2.5'
|
||||
}`}
|
||||
onClick={() => {
|
||||
if (isImage) {
|
||||
setPreviewImage({ url: att.url, name })
|
||||
} else {
|
||||
window.open(att.url, '_blank', 'noreferrer')
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isImage ? (
|
||||
<div className="h-full aspect-square rounded-md overflow-hidden bg-muted/40 shrink-0">
|
||||
<img
|
||||
src={att.url}
|
||||
alt={name}
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<FileText className="w-4 h-4 text-muted-foreground shrink-0" />
|
||||
)}
|
||||
|
||||
<div className="min-w-0 flex-1 overflow-hidden">
|
||||
<p
|
||||
className="text-xs font-medium text-foreground truncate block w-full"
|
||||
title={name}
|
||||
>
|
||||
{name}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<a
|
||||
href={att.url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
download={name}
|
||||
className="p-1 text-muted-foreground hover:text-foreground shrink-0 rounded-md hover:bg-muted transition-colors opacity-0 group-hover:opacity-100"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
title={m.download()}
|
||||
>
|
||||
<Download className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
{isEditing ? (
|
||||
<MessageEditForm
|
||||
projectId={projectId}
|
||||
teamId={teamId}
|
||||
message={message}
|
||||
parentIsInternal={parentIsInternal}
|
||||
getUser={getUser}
|
||||
displayTime={displayTime}
|
||||
hasDrawInfo={hasDrawInfo}
|
||||
onCancel={() => setIsEditing(false)}
|
||||
onSaved={() => setIsEditing(false)}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className="flow-root mt-1">
|
||||
{message.second !== null && message.second !== undefined && frameRate && (
|
||||
<div className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-1 mt-[2px] mr-2 rounded-sm text-xs leading-none font-mono font-bold flex items-center gap-1">
|
||||
{displayTime}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
|
||||
{/* Agent Footer */}
|
||||
{message.sessionId && (
|
||||
<div className="mt-3 pt-2 border-t border-foreground/5 flex items-center justify-between text-xs text-muted-foreground/60">
|
||||
<span className="flex items-center gap-1.5 font-medium text-muted-foreground/80">
|
||||
Created by Agent
|
||||
</span>
|
||||
{isAdmin && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
onClick={() => setIsLogsOpen(true)}
|
||||
className="cursor-pointer border-violet-500/20 text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 hover:text-violet-700 hover:border-violet-500/30 font-semibold"
|
||||
>
|
||||
Logs
|
||||
</Button>
|
||||
{hasDrawInfo && (
|
||||
<div
|
||||
className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-1 py-1 mt-[2px] mr-2 rounded-sm text-xs leading-none font-bold flex items-center gap-1"
|
||||
title="Contains drawing annotations"
|
||||
>
|
||||
<DrawAnnotation className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showSkeleton ? (
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-4 w-3/4" />
|
||||
<Skeleton className="h-4 w-1/2" />
|
||||
<span className="text-xs text-muted-foreground animate-pulse">{loadingText}</span>
|
||||
</div>
|
||||
) : message.sessionId ? (
|
||||
<div className="text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words">
|
||||
<Markdown>{preprocessMarkdown(message.message!)}</Markdown>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-sm leading-[1.8] whitespace-pre-wrap break-words text-wrap break-all">
|
||||
{renderFormattedMessage(message.message!)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Attachments */}
|
||||
{message.attachments && message.attachments.length > 0 && (
|
||||
<div className="flex flex-col gap-1.5 mt-3 w-full max-w-full overflow-hidden">
|
||||
{message.attachments.map((att) => {
|
||||
const rawName = att.url?.split('/').pop()?.split('?')[0] || 'file'
|
||||
const name = decodeURIComponent(rawName)
|
||||
const isImage = isImageFileName(name)
|
||||
return (
|
||||
<div
|
||||
key={att.id}
|
||||
className={`group relative flex items-center w-full max-w-full rounded-lg border border-border bg-card hover:bg-muted/40 transition-colors overflow-hidden ${
|
||||
isImage ? 'h-18 p-1.5 gap-2.5 cursor-pointer' : 'h-9 px-2.5 gap-2.5'
|
||||
}`}
|
||||
onClick={() => {
|
||||
if (isImage) {
|
||||
setPreviewImage({ url: att.url, name })
|
||||
} else {
|
||||
window.open(att.url, '_blank', 'noreferrer')
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isImage ? (
|
||||
<div className="h-full aspect-square rounded-md overflow-hidden bg-muted/40 shrink-0">
|
||||
<img
|
||||
src={att.url}
|
||||
alt={name}
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<FileText className="w-4 h-4 text-muted-foreground shrink-0" />
|
||||
)}
|
||||
|
||||
<div className="min-w-0 flex-1 overflow-hidden">
|
||||
<p
|
||||
className="text-xs font-medium text-foreground truncate block w-full"
|
||||
title={name}
|
||||
>
|
||||
{name}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<a
|
||||
href={att.url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
download={name}
|
||||
className="p-1 text-muted-foreground hover:text-foreground shrink-0 rounded-md hover:bg-muted transition-colors opacity-0 group-hover:opacity-100"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
title={m.download()}
|
||||
>
|
||||
<Download className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</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}>
|
||||
{/* Agent Footer */}
|
||||
{message.sessionId && (
|
||||
<div className="mt-3 pt-2 border-t border-foreground/5 flex items-center justify-between text-xs text-muted-foreground/60">
|
||||
<span className="flex items-center gap-1.5 font-medium text-muted-foreground/80">
|
||||
Created by Agent
|
||||
</span>
|
||||
{isAdmin && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
onClick={() => setIsLogsOpen(true)}
|
||||
className="cursor-pointer border-violet-500/20 text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 hover:text-violet-700 hover:border-violet-500/30 font-semibold"
|
||||
>
|
||||
Logs
|
||||
</Button>
|
||||
)}
|
||||
</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
|
||||
onClick={handleReply}
|
||||
className="text-xs font-medium text-gray-500 hover:text-blue-600 flex items-center gap-1 cursor-pointer"
|
||||
>
|
||||
{m.reply()}
|
||||
</button>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
{!isReadOnly && (
|
||||
<EmojiPickerPopover
|
||||
onEmojiSelect={(emoji) => handleToggleReaction(emoji)}
|
||||
align="end"
|
||||
side="top"
|
||||
>
|
||||
<button
|
||||
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()}
|
||||
>
|
||||
<Smile className="w-5 h-5" />
|
||||
</button>
|
||||
</EmojiPickerPopover>
|
||||
)}
|
||||
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
disabled={isReadOnly}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleToggleReaction(reaction.code)
|
||||
toggleComplete()
|
||||
}}
|
||||
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'
|
||||
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'
|
||||
}`}
|
||||
>
|
||||
<span className="text-sm leading-none">{reaction.code}</span>
|
||||
<span className="text-xs font-semibold text-foreground">
|
||||
{reaction.count}
|
||||
</span>
|
||||
{message.isCompleted ? (
|
||||
<FilledCircleCheck className="w-5 h-5" />
|
||||
) : (
|
||||
<UnfilledCircleCheck className="w-5 h-5" />
|
||||
)}
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{tooltipText}</TooltipContent>
|
||||
<TooltipContent>
|
||||
{message.isCompleted ? m.mark_as_incomplete() : m.mark_as_complete()}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Actions */}
|
||||
<div className="mt-2 flex items-center justify-between w-full">
|
||||
<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>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
{!isReadOnly && (
|
||||
<EmojiPickerPopover
|
||||
onEmojiSelect={(emoji) => handleToggleReaction(emoji)}
|
||||
align="end"
|
||||
side="top"
|
||||
>
|
||||
<button
|
||||
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()}
|
||||
>
|
||||
<Smile className="w-5 h-5" />
|
||||
</button>
|
||||
</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>
|
||||
|
||||
{/* Logs Dialog */}
|
||||
|
||||
@@ -0,0 +1,644 @@
|
||||
import React, { useCallback, useEffect, useRef, useState, type ChangeEvent } from 'react'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import type {
|
||||
AttachmentInfo,
|
||||
CommentInfo,
|
||||
PostAttachmentRequest,
|
||||
PostAttachmentResponse,
|
||||
UserInfo,
|
||||
} from '@shumai/dtos'
|
||||
import { FileIcon, FileText, Paperclip, XIcon } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { isImageFileName } from '@/ui/lib/media'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { useMemberStore, type MemberInfo } from '@/ui/stores/members'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'
|
||||
import { Button } from '../ui/button'
|
||||
import { DrawAnnotation } from '../ui/icons'
|
||||
import { ProgressCircle } from '../ui/progress-circle'
|
||||
import { Skeleton } from '../ui/skeleton'
|
||||
import { CommentVisibilitySelector } from './comment-visibility-selector'
|
||||
import {
|
||||
createMentionNode,
|
||||
hydrateEditableWithMentions,
|
||||
serializeEditableContent,
|
||||
} from './mention-utils'
|
||||
import type { UploadingFile } from './message-input'
|
||||
|
||||
export interface MessageEditFormProps {
|
||||
projectId?: string
|
||||
teamId?: string
|
||||
message: CommentInfo
|
||||
parentIsInternal?: boolean
|
||||
getUser: (id: string) => MemberInfo | UserInfo
|
||||
displayTime: string
|
||||
hasDrawInfo: boolean
|
||||
onCancel: () => void
|
||||
onSaved: () => void
|
||||
}
|
||||
|
||||
type MentionEntity = { type: 'user'; data: MemberInfo }
|
||||
|
||||
export const MessageEditForm: React.FC<MessageEditFormProps> = ({
|
||||
projectId,
|
||||
teamId: propTeamId,
|
||||
message,
|
||||
parentIsInternal = false,
|
||||
getUser,
|
||||
displayTime,
|
||||
hasDrawInfo,
|
||||
onCancel,
|
||||
onSaved,
|
||||
}) => {
|
||||
const queryClient = useQueryClient()
|
||||
const editorRef = useRef<HTMLDivElement>(null)
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
const mentionRangeRef = useRef<Range | null>(null)
|
||||
const mentionListRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
const [editedIsInternal, setEditedIsInternal] = useState<boolean>(
|
||||
parentIsInternal ? true : Boolean(message.isInternal),
|
||||
)
|
||||
const [editedSecond, setEditedSecond] = useState<number | null>(message.second ?? null)
|
||||
const [keptAttachments, setKeptAttachments] = useState<AttachmentInfo[]>(
|
||||
() => message.attachments ?? [],
|
||||
)
|
||||
const [uploadingFiles, setUploadingFiles] = useState<UploadingFile[]>([])
|
||||
const [hasText, setHasText] = useState<boolean>(() => Boolean((message.message ?? '').trim()))
|
||||
|
||||
const [showMentionList, setShowMentionList] = useState(false)
|
||||
const [mentionQuery, setMentionQuery] = useState('')
|
||||
const [highlightedIndex, setHighlightedIndex] = useState(0)
|
||||
|
||||
const { teamId: storeTeamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
const effectiveTeamId = propTeamId || storeTeamId
|
||||
const {
|
||||
members: storeMembers,
|
||||
loading: membersLoading,
|
||||
fetchMembers,
|
||||
fetchProjectMembers,
|
||||
} = useMemberStore()
|
||||
|
||||
useEffect(() => {
|
||||
if (projectId && !effectiveTeamId) {
|
||||
ensureTeamIdForProject(projectId)
|
||||
}
|
||||
}, [projectId, effectiveTeamId, ensureTeamIdForProject])
|
||||
|
||||
// Hydrate editor once on mount so background comment polling never overwrites draft edits.
|
||||
useEffect(() => {
|
||||
const editor = editorRef.current
|
||||
if (!editor) return
|
||||
|
||||
const resolveUserName = (userId: string) => {
|
||||
const fromMentions = message.mentions?.find((u) => u.id === userId)
|
||||
if (fromMentions?.name) return fromMentions.name
|
||||
const fromStore = getUser(userId)
|
||||
return fromStore?.name || 'Unknown'
|
||||
}
|
||||
|
||||
hydrateEditableWithMentions(editor, message.message ?? '', resolveUserName)
|
||||
setHasText(Boolean(serializeEditableContent(editor)))
|
||||
|
||||
editor.focus()
|
||||
const range = document.createRange()
|
||||
const sel = window.getSelection()
|
||||
range.selectNodeContents(editor)
|
||||
range.collapse(false)
|
||||
sel?.removeAllRanges()
|
||||
sel?.addRange(range)
|
||||
}, [])
|
||||
|
||||
const { mutateAsync: uploadAttachment } = useMutation({
|
||||
mutationFn: async ({
|
||||
targetProjectId,
|
||||
data,
|
||||
}: {
|
||||
targetProjectId: string
|
||||
data: PostAttachmentRequest
|
||||
}) => {
|
||||
const res = await client.api.projects[':projectId'].attachments.$post({
|
||||
param: { projectId: targetProjectId },
|
||||
json: data,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to create attachment')
|
||||
return (await res.json()) as PostAttachmentResponse
|
||||
},
|
||||
})
|
||||
|
||||
const { mutate: updateComment, isPending: isSaving } = useMutation({
|
||||
mutationFn: async (payload: {
|
||||
message: string
|
||||
isInternal: boolean
|
||||
second: number | null
|
||||
attachmentIds: string[]
|
||||
}) => {
|
||||
const res = await client.api.comments[':commentId'].$patch({
|
||||
param: { commentId: message.id },
|
||||
json: payload,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update comment')
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
predicate: (query) => query.queryKey.includes('comments'),
|
||||
})
|
||||
onSaved()
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(m.failed_to_update_comment())
|
||||
},
|
||||
})
|
||||
|
||||
const filteredEntities: MentionEntity[] = storeMembers
|
||||
.filter((u) => u.name?.toLowerCase().startsWith(mentionQuery.toLowerCase()))
|
||||
.map((u) => ({ type: 'user' as const, data: u }))
|
||||
|
||||
useEffect(() => {
|
||||
setHighlightedIndex(0)
|
||||
}, [mentionQuery, showMentionList])
|
||||
|
||||
useEffect(() => {
|
||||
mentionListRef.current
|
||||
?.querySelector<HTMLElement>(`[data-index="${highlightedIndex}"]`)
|
||||
?.scrollIntoView({ block: 'nearest' })
|
||||
}, [highlightedIndex])
|
||||
|
||||
const getInitials = (name: string) =>
|
||||
name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.slice(0, 2)
|
||||
.join('')
|
||||
.toUpperCase()
|
||||
|
||||
const handleInput = () => {
|
||||
if (!editorRef.current) return
|
||||
setHasText(Boolean(serializeEditableContent(editorRef.current)))
|
||||
|
||||
const sel = window.getSelection()
|
||||
if (!sel || sel.rangeCount === 0) return
|
||||
|
||||
const range = sel.getRangeAt(0)
|
||||
const node = range.startContainer
|
||||
const offset = range.startOffset
|
||||
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
const textContent = node.textContent || ''
|
||||
const textBeforeCursor = textContent.slice(0, offset)
|
||||
const lastAtPos = textBeforeCursor.lastIndexOf('@')
|
||||
|
||||
if (lastAtPos !== -1) {
|
||||
const isStartOfLine = lastAtPos === 0
|
||||
const charBeforeAt = textBeforeCursor[lastAtPos - 1]
|
||||
const hasSpaceBefore = isStartOfLine || /\s/.test(charBeforeAt)
|
||||
|
||||
if (hasSpaceBefore) {
|
||||
const query = textBeforeCursor.slice(lastAtPos + 1)
|
||||
if (!/\s/.test(query)) {
|
||||
setMentionQuery(query)
|
||||
setShowMentionList(true)
|
||||
|
||||
if (projectId) {
|
||||
fetchProjectMembers(projectId, true, true)
|
||||
} else if (effectiveTeamId) {
|
||||
fetchMembers(effectiveTeamId, true, true)
|
||||
}
|
||||
|
||||
const mentionRange = document.createRange()
|
||||
mentionRange.setStart(node, lastAtPos)
|
||||
mentionRange.setEnd(node, offset)
|
||||
mentionRangeRef.current = mentionRange
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setShowMentionList(false)
|
||||
mentionRangeRef.current = null
|
||||
}
|
||||
|
||||
const handleSelectEntity = (entity: MentionEntity) => {
|
||||
if (!mentionRangeRef.current || !editorRef.current) return
|
||||
|
||||
const range = mentionRangeRef.current
|
||||
range.deleteContents()
|
||||
|
||||
const mentionNode = createMentionNode({ id: entity.data.id, name: entity.data.name })
|
||||
range.insertNode(mentionNode)
|
||||
|
||||
const spaceNode = document.createTextNode('\u00A0')
|
||||
mentionNode.after(spaceNode)
|
||||
|
||||
const newRange = document.createRange()
|
||||
const sel = window.getSelection()
|
||||
newRange.setStartAfter(spaceNode)
|
||||
newRange.collapse(true)
|
||||
sel?.removeAllRanges()
|
||||
sel?.addRange(newRange)
|
||||
|
||||
setShowMentionList(false)
|
||||
mentionRangeRef.current = null
|
||||
setHasText(true)
|
||||
editorRef.current.focus()
|
||||
}
|
||||
|
||||
const handlePaste = (e: React.ClipboardEvent<HTMLDivElement>) => {
|
||||
e.preventDefault()
|
||||
const text = e.clipboardData.getData('text/plain')
|
||||
if (!text) return
|
||||
|
||||
const success =
|
||||
typeof document.execCommand === 'function' &&
|
||||
document.queryCommandSupported?.('insertText') &&
|
||||
document.execCommand('insertText', false, text)
|
||||
|
||||
if (!success) {
|
||||
const sel = window.getSelection()
|
||||
if (sel && sel.rangeCount > 0) {
|
||||
const range = sel.getRangeAt(0)
|
||||
range.deleteContents()
|
||||
const textNode = document.createTextNode(text)
|
||||
range.insertNode(textNode)
|
||||
range.setStartAfter(textNode)
|
||||
range.collapse(true)
|
||||
sel.removeAllRanges()
|
||||
sel.addRange(range)
|
||||
} else if (editorRef.current) {
|
||||
editorRef.current.innerText += text
|
||||
}
|
||||
}
|
||||
|
||||
handleInput()
|
||||
}
|
||||
|
||||
const handleFileSelect = useCallback(
|
||||
async (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (!e.target.files || !projectId) return
|
||||
const newFiles = Array.from(e.target.files)
|
||||
|
||||
for (const file of newFiles) {
|
||||
const tempId = `${Date.now()}-${Math.random()}-${file.name}`
|
||||
setUploadingFiles((prev) => [...prev, { id: tempId, file, progress: 0 }])
|
||||
|
||||
try {
|
||||
const data = await uploadAttachment({
|
||||
targetProjectId: projectId,
|
||||
data: {
|
||||
fileName: file.name,
|
||||
contentType: file.type,
|
||||
size: file.size,
|
||||
},
|
||||
})
|
||||
|
||||
if (data.uploadUrl && data.id) {
|
||||
await fetch(data.uploadUrl, {
|
||||
method: 'PUT',
|
||||
body: file,
|
||||
headers: {
|
||||
'Content-Type': file.type,
|
||||
},
|
||||
})
|
||||
|
||||
setUploadingFiles((prev) =>
|
||||
prev.map((uf) =>
|
||||
uf.id === tempId ? { ...uf, progress: 100, attachmentId: data.id } : uf,
|
||||
),
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
setUploadingFiles((prev) =>
|
||||
prev.map((uf) =>
|
||||
uf.id === tempId
|
||||
? {
|
||||
...uf,
|
||||
error: error instanceof Error ? error.message : 'Upload failed',
|
||||
}
|
||||
: uf,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.value = ''
|
||||
}
|
||||
},
|
||||
[projectId, uploadAttachment],
|
||||
)
|
||||
|
||||
const isUploading = uploadingFiles.some((f) => !f.attachmentId && !f.error)
|
||||
const uploadedAttachmentIds = uploadingFiles
|
||||
.map((f) => f.attachmentId)
|
||||
.filter((id): id is string => Boolean(id))
|
||||
|
||||
const effectiveIsInternal = parentIsInternal ? true : editedIsInternal
|
||||
const canSave =
|
||||
!isSaving &&
|
||||
!isUploading &&
|
||||
(hasText || keptAttachments.length > 0 || uploadedAttachmentIds.length > 0 || hasDrawInfo)
|
||||
|
||||
const handleSave = () => {
|
||||
if (!editorRef.current || !canSave) return
|
||||
const serialized = serializeEditableContent(editorRef.current)
|
||||
const attachmentIds = [...keptAttachments.map((att) => att.assetId), ...uploadedAttachmentIds]
|
||||
|
||||
if (!serialized && attachmentIds.length === 0 && !hasDrawInfo) return
|
||||
|
||||
updateComment({
|
||||
message: serialized,
|
||||
isInternal: effectiveIsInternal,
|
||||
second: editedSecond,
|
||||
attachmentIds,
|
||||
})
|
||||
}
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if (e.nativeEvent.isComposing) return
|
||||
|
||||
if (showMentionList && filteredEntities.length > 0) {
|
||||
if (e.key === 'ArrowUp') {
|
||||
e.preventDefault()
|
||||
setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : filteredEntities.length - 1))
|
||||
return
|
||||
}
|
||||
if (e.key === 'ArrowDown') {
|
||||
e.preventDefault()
|
||||
setHighlightedIndex((prev) => (prev < filteredEntities.length - 1 ? prev + 1 : 0))
|
||||
return
|
||||
}
|
||||
if (e.key === 'Enter' || e.key === 'Tab') {
|
||||
e.preventDefault()
|
||||
handleSelectEntity(filteredEntities[highlightedIndex])
|
||||
return
|
||||
}
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault()
|
||||
setShowMentionList(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault()
|
||||
onCancel()
|
||||
return
|
||||
}
|
||||
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault()
|
||||
handleSave()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="relative mt-1.5 flex flex-col gap-2"
|
||||
data-testid="comment-edit-form"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* Mention dropdown */}
|
||||
{showMentionList && (membersLoading || filteredEntities.length > 0) && (
|
||||
<div
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
className="absolute bottom-full left-0 mb-2 w-60 rounded-xl shadow-lg border border-border overflow-hidden z-30 bg-popover text-popover-foreground"
|
||||
>
|
||||
<div ref={mentionListRef} className="max-h-48 overflow-y-auto">
|
||||
{membersLoading ? (
|
||||
<div className="p-2 space-y-2 animate-pulse">
|
||||
<div className="flex items-center gap-2 px-2 py-1">
|
||||
<Skeleton className="w-6 h-6 rounded-full" />
|
||||
<Skeleton className="h-4 w-28" />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
filteredEntities.map((item, index) => (
|
||||
<button
|
||||
type="button"
|
||||
key={item.data.id}
|
||||
data-index={index}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => handleSelectEntity(item)}
|
||||
onMouseEnter={() => setHighlightedIndex(index)}
|
||||
className={`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left cursor-pointer ${
|
||||
index === highlightedIndex
|
||||
? 'bg-accent text-accent-foreground'
|
||||
: 'hover:bg-accent/50'
|
||||
}`}
|
||||
>
|
||||
<Avatar className="w-6 h-6">
|
||||
{item.data.image && (
|
||||
<AvatarImage
|
||||
src={item.data.image}
|
||||
alt={item.data.name}
|
||||
className="object-cover"
|
||||
/>
|
||||
)}
|
||||
<AvatarFallback className="text-[10px] bg-purple-400 text-black font-semibold">
|
||||
{getInitials(item.data.name)}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="text-sm truncate">{item.data.name}</span>
|
||||
</button>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Timestamp & Draw badges */}
|
||||
{((editedSecond !== null && displayTime) || hasDrawInfo) && (
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{editedSecond !== null && displayTime && (
|
||||
<div
|
||||
data-testid="edit-comment-timestamp"
|
||||
className="inline-flex items-center gap-1 select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 pl-2 pr-1 py-0.5 rounded-sm text-xs leading-none font-mono font-bold"
|
||||
>
|
||||
<span>{displayTime}</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setEditedSecond(null)}
|
||||
className="p-0.5 rounded hover:bg-blue-200/70 dark:hover:bg-blue-800/70 cursor-pointer"
|
||||
title={m.remove_timestamp()}
|
||||
aria-label={m.remove_timestamp()}
|
||||
data-testid="edit-comment-remove-timestamp"
|
||||
>
|
||||
<XIcon className="w-3 h-3" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{hasDrawInfo && (
|
||||
<div
|
||||
className="inline-flex items-center bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-1 py-0.5 rounded-sm text-xs leading-none font-bold"
|
||||
title={m.contains_drawing_annotations()}
|
||||
>
|
||||
<DrawAnnotation className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Editable text box */}
|
||||
<div
|
||||
ref={editorRef}
|
||||
contentEditable={!isSaving}
|
||||
suppressContentEditableWarning
|
||||
onInput={handleInput}
|
||||
onKeyDown={handleKeyDown}
|
||||
onPaste={handlePaste}
|
||||
data-testid="edit-comment-input"
|
||||
className="w-full min-h-[56px] max-h-48 overflow-y-auto rounded-lg border border-border bg-background px-2.5 py-2 text-sm leading-relaxed focus:outline-none focus:ring-1 focus:ring-ring whitespace-pre-wrap break-words"
|
||||
/>
|
||||
|
||||
{/* Existing & Newly Uploaded Attachments */}
|
||||
{(keptAttachments.length > 0 || uploadingFiles.length > 0) && (
|
||||
<div className="flex flex-col gap-1.5 w-full max-w-full overflow-hidden">
|
||||
{keptAttachments.map((att) => {
|
||||
const rawName = att.url?.split('/').pop()?.split('?')[0] || 'file'
|
||||
const name = decodeURIComponent(rawName)
|
||||
const isImage = isImageFileName(name)
|
||||
return (
|
||||
<div
|
||||
key={att.id}
|
||||
data-testid="edit-existing-attachment"
|
||||
className="flex items-center gap-2 rounded-lg border border-border bg-card px-2 py-1.5"
|
||||
>
|
||||
{isImage ? (
|
||||
<img
|
||||
src={att.url}
|
||||
alt={name}
|
||||
className="w-8 h-8 rounded object-cover shrink-0 bg-muted/40"
|
||||
/>
|
||||
) : (
|
||||
<FileText className="w-4 h-4 text-muted-foreground shrink-0" />
|
||||
)}
|
||||
<span className="text-xs font-medium text-foreground truncate flex-1 min-w-0">
|
||||
{name}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
setKeptAttachments((prev) => prev.filter((item) => item.id !== att.id))
|
||||
}
|
||||
className="p-1 text-muted-foreground hover:text-destructive rounded hover:bg-muted transition-colors cursor-pointer shrink-0"
|
||||
aria-label={`${m.delete()} ${name}`}
|
||||
data-testid={`edit-remove-attachment-${att.assetId}`}
|
||||
>
|
||||
<XIcon className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
||||
{uploadingFiles.map((upload) => (
|
||||
<div
|
||||
key={upload.id}
|
||||
data-testid="edit-new-attachment"
|
||||
className="flex items-center gap-2 rounded-lg border border-border bg-card px-2 py-1.5"
|
||||
>
|
||||
{upload.file.type.startsWith('image/') ? (
|
||||
<div className="relative w-8 h-8 rounded overflow-hidden shrink-0 bg-muted/40">
|
||||
<img
|
||||
src={URL.createObjectURL(upload.file)}
|
||||
alt={upload.file.name}
|
||||
className={`w-full h-full object-cover ${!upload.attachmentId ? 'opacity-50' : ''}`}
|
||||
/>
|
||||
{!upload.attachmentId && !upload.error && (
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-black/40">
|
||||
<ProgressCircle progress={upload.progress} className="w-5 h-5" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<FileIcon className="w-4 h-4 text-muted-foreground shrink-0" />
|
||||
)}
|
||||
<div className="flex-1 min-w-0">
|
||||
<span className="text-xs font-medium text-foreground truncate block">
|
||||
{upload.file.name}
|
||||
</span>
|
||||
{upload.error && (
|
||||
<span className="text-[10px] text-destructive block truncate">
|
||||
{upload.error}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
setUploadingFiles((prev) => prev.filter((item) => item.id !== upload.id))
|
||||
}
|
||||
className="p-1 text-muted-foreground hover:text-destructive rounded hover:bg-muted transition-colors cursor-pointer shrink-0"
|
||||
aria-label={`${m.delete()} ${upload.file.name}`}
|
||||
>
|
||||
<XIcon className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Action bar: attach + visibility on left, cancel + save on right */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 pt-1">
|
||||
<div className="flex items-center gap-1.5">
|
||||
{projectId && (
|
||||
<>
|
||||
<input
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
className="hidden"
|
||||
multiple
|
||||
onChange={handleFileSelect}
|
||||
data-testid="edit-comment-file-input"
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
className="h-7 w-7 rounded-full cursor-pointer"
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
title={m.attach_files()}
|
||||
aria-label={m.attach_files()}
|
||||
>
|
||||
<Paperclip className="w-3.5 h-3.5" />
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<CommentVisibilitySelector
|
||||
isInternal={effectiveIsInternal}
|
||||
onChange={setEditedIsInternal}
|
||||
disabled={parentIsInternal}
|
||||
disabledTooltip={m.internal_reply_locked_tooltip()}
|
||||
align="start"
|
||||
side="bottom"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="xs"
|
||||
disabled={isSaving}
|
||||
onClick={onCancel}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
{m.cancel()}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
disabled={!canSave}
|
||||
onClick={handleSave}
|
||||
className="cursor-pointer"
|
||||
data-testid="edit-comment-save"
|
||||
>
|
||||
{m.save()}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -44,6 +44,7 @@ describe('ChatInput auto-mention on reply', () => {
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
@@ -89,6 +90,7 @@ describe('ChatInput auto-mention on reply', () => {
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
@@ -124,6 +126,7 @@ describe('ChatInput auto-mention on reply', () => {
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
@@ -142,6 +145,7 @@ describe('ChatInput auto-mention on reply', () => {
|
||||
updatedAt: '2026-08-20T10:31:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
@@ -164,4 +168,110 @@ describe('ChatInput auto-mention on reply', () => {
|
||||
expect(mentionSpans).toHaveLength(2)
|
||||
expect(mentionSpans[1].getAttribute('data-id')).toBe('user-bob')
|
||||
})
|
||||
|
||||
it('hides visibility selector when allowInternalComments is false', () => {
|
||||
const onSendMessage = vi.fn()
|
||||
render(<ChatInput projectId="proj-1" onSendMessage={onSendMessage} />, {
|
||||
wrapper: createWrapper(),
|
||||
})
|
||||
|
||||
expect(document.querySelector('[data-testid="comment-visibility-trigger"]')).toBeNull()
|
||||
})
|
||||
|
||||
it('defaults to Public, switches to Internal via dropdown pill, and resets after send', () => {
|
||||
const onSendMessage = vi.fn()
|
||||
render(
|
||||
<ChatInput projectId="proj-1" onSendMessage={onSendMessage} allowInternalComments={true} />,
|
||||
{ wrapper: createWrapper() },
|
||||
)
|
||||
|
||||
const trigger = document.querySelector(
|
||||
'[data-testid="comment-visibility-trigger"]',
|
||||
) as HTMLButtonElement
|
||||
expect(trigger).not.toBeNull()
|
||||
expect(trigger.textContent).toContain('Public')
|
||||
|
||||
// Open dropdown and choose Internal
|
||||
fireEvent.pointerDown(trigger)
|
||||
fireEvent.click(trigger)
|
||||
const internalOption = document.querySelector(
|
||||
'[data-testid="comment-visibility-internal"]',
|
||||
) as HTMLElement
|
||||
expect(internalOption).not.toBeNull()
|
||||
fireEvent.click(internalOption)
|
||||
|
||||
expect(trigger.textContent).toContain('Internal')
|
||||
|
||||
// Type message and send
|
||||
const editor = document.querySelector('[contenteditable="true"]') as HTMLDivElement
|
||||
editor.innerText = 'Internal discussion'
|
||||
fireEvent.input(editor)
|
||||
|
||||
const sendButton = document.querySelector('button .lucide-arrow-up')?.closest('button')
|
||||
fireEvent.click(sendButton as HTMLButtonElement)
|
||||
|
||||
expect(onSendMessage).toHaveBeenCalledWith(
|
||||
'Internal discussion',
|
||||
[],
|
||||
[],
|
||||
undefined,
|
||||
undefined,
|
||||
[],
|
||||
true,
|
||||
)
|
||||
// Resets back to Public default after send
|
||||
expect(trigger.textContent).toContain('Public')
|
||||
})
|
||||
|
||||
it('locks visibility to Internal when replying to an internal comment', () => {
|
||||
const internalComment: CommentInfo = {
|
||||
id: 'comment-int',
|
||||
assetId: 'asset-1',
|
||||
message: 'Private thread',
|
||||
annotations: null,
|
||||
second: null,
|
||||
creator: { id: 'user-alice', name: 'Alice Smith' },
|
||||
replies: [],
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
createdAt: '2026-08-20T10:30:00.000Z',
|
||||
updatedAt: '2026-08-20T10:30:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: true,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
}
|
||||
|
||||
const onSendMessage = vi.fn()
|
||||
render(
|
||||
<ChatInput
|
||||
projectId="proj-1"
|
||||
onSendMessage={onSendMessage}
|
||||
replyingTo={internalComment}
|
||||
allowInternalComments={true}
|
||||
/>,
|
||||
{ wrapper: createWrapper() },
|
||||
)
|
||||
|
||||
const trigger = document.querySelector(
|
||||
'[data-testid="comment-visibility-trigger"]',
|
||||
) as HTMLButtonElement
|
||||
expect(trigger).not.toBeNull()
|
||||
expect(trigger.textContent).toContain('Internal')
|
||||
expect(trigger.disabled).toBe(true)
|
||||
|
||||
const sendButton = document.querySelector('button .lucide-arrow-up')?.closest('button')
|
||||
fireEvent.click(sendButton as HTMLButtonElement)
|
||||
|
||||
expect(onSendMessage).toHaveBeenCalledWith(
|
||||
'<@user-alice>',
|
||||
[],
|
||||
[],
|
||||
'comment-int',
|
||||
undefined,
|
||||
[],
|
||||
true,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -32,6 +32,8 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/
|
||||
import { formatTimecode } from '../viewers/video/utils'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import { isImageFileName } from '@/ui/lib/media'
|
||||
import { CommentVisibilitySelector } from './comment-visibility-selector'
|
||||
import { createMentionNode, serializeEditableContent } from './mention-utils'
|
||||
|
||||
export type UploadingFile = {
|
||||
id: string // A unique ID for the file, e.g., timestamp + name
|
||||
@@ -59,6 +61,7 @@ export interface ChatInputProps {
|
||||
replyToId?: string | null,
|
||||
second?: number | null,
|
||||
attachedFilesMeta?: AttachedFileMeta[],
|
||||
isInternal?: boolean,
|
||||
) => void
|
||||
|
||||
placeholder?: string
|
||||
@@ -95,6 +98,9 @@ export interface ChatInputProps {
|
||||
replyingTo?: CommentInfo | null
|
||||
onCancelReply?: () => void
|
||||
|
||||
// Internal Comments (hidden from public share links)
|
||||
allowInternalComments?: boolean
|
||||
|
||||
// Bottom action bar extras (e.g. Agent Selector)
|
||||
bottomLeftExtra?: React.ReactNode
|
||||
|
||||
@@ -127,6 +133,7 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
onSendMessage,
|
||||
replyingTo,
|
||||
onCancelReply,
|
||||
allowInternalComments = false,
|
||||
placeholder,
|
||||
initialText = '',
|
||||
value,
|
||||
@@ -156,6 +163,14 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
const [uploadingFiles, setUploadingFiles] = useState<UploadingFile[]>([])
|
||||
const [viewingFile, setViewingFile] = useState<File | null>(null)
|
||||
const [isTimestampEnabled, setIsTimestampEnabled] = useState(true)
|
||||
const [isInternal, setIsInternal] = useState(false)
|
||||
|
||||
const isReplyLockedInternal = Boolean(allowInternalComments && replyingTo?.isInternal)
|
||||
const effectiveIsInternal = allowInternalComments
|
||||
? isReplyLockedInternal
|
||||
? true
|
||||
: isInternal
|
||||
: false
|
||||
|
||||
const effectiveAllowMentions = allowMentions ?? !disableMentions
|
||||
const effectiveAllowMarkup = allowMarkup ?? !hideAnnotationControl
|
||||
@@ -285,14 +300,7 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
(user: { id: string; name: string }) => {
|
||||
if (!editorRef.current) return
|
||||
|
||||
const mentionNode = document.createElement('span')
|
||||
mentionNode.contentEditable = 'false'
|
||||
mentionNode.dataset.type = 'mention'
|
||||
mentionNode.dataset.id = user.id
|
||||
mentionNode.className =
|
||||
'inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5'
|
||||
mentionNode.innerText = `@${user.name}`
|
||||
|
||||
const mentionNode = createMentionNode(user)
|
||||
const spaceNode = document.createTextNode('\u00A0')
|
||||
|
||||
editorRef.current.appendChild(mentionNode)
|
||||
@@ -457,13 +465,7 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
const range = mentionRangeRef.current
|
||||
range.deleteContents()
|
||||
|
||||
const mentionNode = document.createElement('span')
|
||||
mentionNode.contentEditable = 'false'
|
||||
mentionNode.dataset.type = 'mention'
|
||||
mentionNode.dataset.id = entity.data.id
|
||||
mentionNode.className =
|
||||
'inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5'
|
||||
mentionNode.innerText = `@${entity.data.name}`
|
||||
const mentionNode = createMentionNode({ id: entity.data.id, name: entity.data.name })
|
||||
|
||||
range.insertNode(mentionNode)
|
||||
|
||||
@@ -652,26 +654,7 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
}))
|
||||
|
||||
// Serialize content
|
||||
let processedText = ''
|
||||
editorRef.current.childNodes.forEach((node) => {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
processedText += node.textContent
|
||||
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
const el = node as HTMLElement
|
||||
if (el.dataset.type === 'mention') {
|
||||
processedText += `<@${el.dataset.id}>`
|
||||
} else if (el.tagName === 'BR') {
|
||||
processedText += '\n'
|
||||
} else if (el.tagName === 'DIV' || el.tagName === 'P') {
|
||||
// contentEditable often uses div/p for new lines
|
||||
processedText += '\n' + el.innerText
|
||||
} else {
|
||||
processedText += el.innerText
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
processedText = processedText.trim()
|
||||
const processedText = serializeEditableContent(editorRef.current)
|
||||
|
||||
const hasWorkspaceAssets = (workspaceAssets?.length ?? 0) > 0
|
||||
|
||||
@@ -684,14 +667,26 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
)
|
||||
return
|
||||
|
||||
onSendMessage(
|
||||
processedText,
|
||||
successfulAttachmentIds,
|
||||
annotations,
|
||||
replyingTo?.id,
|
||||
effectiveAllowTimestamp && isTimestampEnabled ? currentTime : undefined,
|
||||
successfulAttachedFilesMeta,
|
||||
)
|
||||
if (allowInternalComments) {
|
||||
onSendMessage(
|
||||
processedText,
|
||||
successfulAttachmentIds,
|
||||
annotations,
|
||||
replyingTo?.id,
|
||||
effectiveAllowTimestamp && isTimestampEnabled ? currentTime : undefined,
|
||||
successfulAttachedFilesMeta,
|
||||
effectiveIsInternal,
|
||||
)
|
||||
} else {
|
||||
onSendMessage(
|
||||
processedText,
|
||||
successfulAttachmentIds,
|
||||
annotations,
|
||||
replyingTo?.id,
|
||||
effectiveAllowTimestamp && isTimestampEnabled ? currentTime : undefined,
|
||||
successfulAttachedFilesMeta,
|
||||
)
|
||||
}
|
||||
|
||||
// Reset editor
|
||||
editorRef.current.innerHTML = ''
|
||||
@@ -703,6 +698,7 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
setIsDrawing(false)
|
||||
resetAnnotations()
|
||||
setShowMentionList(false)
|
||||
setIsInternal(false)
|
||||
if (onCancelReply) onCancelReply()
|
||||
}
|
||||
|
||||
@@ -1177,17 +1173,27 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
</div>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={handleSend}
|
||||
disabled={!canSend || isUploading}
|
||||
className={`p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 ${
|
||||
canSend && !isUploading
|
||||
? 'bg-blue-600 text-white shadow-md hover:bg-blue-700 hover:shadow-lg transform hover:-translate-y-0.5 cursor-pointer'
|
||||
: 'bg-gray-400 cursor-not-allowed opacity-50'
|
||||
}`}
|
||||
>
|
||||
<ArrowUp className="w-4 h-4" />
|
||||
</button>
|
||||
<div className="flex items-center gap-1.5 shrink-0">
|
||||
{allowInternalComments && !isDrawing && (
|
||||
<CommentVisibilitySelector
|
||||
isInternal={effectiveIsInternal}
|
||||
onChange={setIsInternal}
|
||||
disabled={isReplyLockedInternal}
|
||||
disabledTooltip={m.internal_reply_locked_tooltip()}
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
onClick={handleSend}
|
||||
disabled={!canSend || isUploading}
|
||||
className={`h-7 w-7 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 ${
|
||||
canSend && !isUploading
|
||||
? 'bg-blue-600 text-white shadow-md hover:bg-blue-700 hover:shadow-lg transform hover:-translate-y-0.5 cursor-pointer'
|
||||
: 'bg-gray-400 cursor-not-allowed opacity-50'
|
||||
}`}
|
||||
>
|
||||
<ArrowUp className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -118,9 +118,10 @@ export function FileBrowserGridView({
|
||||
|
||||
useEffect(() => {
|
||||
let resizeFrame = 0
|
||||
const observeTarget = scrollContainerRef.current ?? containerRef.current
|
||||
const updateCols = () => {
|
||||
if (!containerRef.current) return
|
||||
const width = containerRef.current.offsetWidth
|
||||
const width = containerRef.current?.offsetWidth ?? scrollContainerRef.current?.clientWidth
|
||||
if (!width) return
|
||||
if (width < 640) setCols(2)
|
||||
else if (width < 768) setCols(2)
|
||||
else if (width < 1024) setCols(3)
|
||||
@@ -134,12 +135,12 @@ export function FileBrowserGridView({
|
||||
cancelAnimationFrame(resizeFrame)
|
||||
resizeFrame = requestAnimationFrame(updateCols)
|
||||
})
|
||||
if (containerRef.current) observer.observe(containerRef.current)
|
||||
if (observeTarget) observer.observe(observeTarget)
|
||||
return () => {
|
||||
observer.disconnect()
|
||||
cancelAnimationFrame(resizeFrame)
|
||||
}
|
||||
}, [])
|
||||
}, [scrollContainerRef])
|
||||
|
||||
const rows = useMemo(() => {
|
||||
const list: (
|
||||
@@ -191,6 +192,7 @@ export function FileBrowserGridView({
|
||||
),
|
||||
overscan: 5,
|
||||
paddingEnd: 240,
|
||||
useFlushSync: false,
|
||||
})
|
||||
|
||||
const virtualItems = rowVirtualizer.getVirtualItems()
|
||||
|
||||
@@ -333,6 +333,7 @@ export function FileBrowserListView({
|
||||
),
|
||||
overscan: 10,
|
||||
paddingEnd: 240,
|
||||
useFlushSync: false,
|
||||
})
|
||||
|
||||
const virtualItems = rowVirtualizer.getVirtualItems()
|
||||
|
||||
@@ -209,12 +209,14 @@ export function FileViewerRightSidebar({
|
||||
annotations,
|
||||
replyToId,
|
||||
second,
|
||||
isInternal,
|
||||
}: {
|
||||
text: string
|
||||
attachmentIds: string[]
|
||||
annotations?: Annotation[]
|
||||
replyToId?: string | null
|
||||
second?: number | null
|
||||
isInternal?: boolean
|
||||
}) => {
|
||||
if (isPublic) {
|
||||
const password = localStorage.getItem(`share_pwd_${shareId}`) || ''
|
||||
@@ -246,6 +248,7 @@ export function FileViewerRightSidebar({
|
||||
replyToId: replyToId ?? undefined,
|
||||
annotations: annotations,
|
||||
second: second ?? undefined,
|
||||
isInternal: isInternal ?? false,
|
||||
},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to create comment')
|
||||
@@ -297,6 +300,8 @@ export function FileViewerRightSidebar({
|
||||
annotations?: Annotation[],
|
||||
replyToId?: string | null,
|
||||
second?: number | null,
|
||||
_attachedFilesMeta?: unknown,
|
||||
isInternal?: boolean,
|
||||
) => {
|
||||
if (!file?.id) return
|
||||
|
||||
@@ -321,7 +326,7 @@ export function FileViewerRightSidebar({
|
||||
createComment({ text, attachmentIds, annotations, replyToId, second })
|
||||
}
|
||||
} else {
|
||||
createComment({ text, attachmentIds, annotations, replyToId, second })
|
||||
createComment({ text, attachmentIds, annotations, replyToId, second, isInternal })
|
||||
}
|
||||
setReplyingTo(null)
|
||||
}
|
||||
@@ -418,6 +423,7 @@ export function FileViewerRightSidebar({
|
||||
<div key={comment.id}>
|
||||
<MessageCard
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
message={comment}
|
||||
getUser={getUser}
|
||||
onReply={setReplyingTo}
|
||||
@@ -444,7 +450,9 @@ export function FileViewerRightSidebar({
|
||||
<div key={reply.id}>
|
||||
<MessageCard
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
isReply={true}
|
||||
parentIsInternal={comment.isInternal}
|
||||
message={reply}
|
||||
getUser={getUser}
|
||||
onReply={setReplyingTo}
|
||||
@@ -488,6 +496,7 @@ export function FileViewerRightSidebar({
|
||||
onSendMessage={handleSendMessage}
|
||||
replyingTo={replyingTo}
|
||||
onCancelReply={() => setReplyingTo(null)}
|
||||
allowInternalComments={!isPublic}
|
||||
hideAnnotationControl={hideAnnotationControl}
|
||||
disableMentions={isPublic}
|
||||
currentTime={viewerDef?.commentsConfig?.hasTimestamp ? currentTime : undefined}
|
||||
|
||||
@@ -171,12 +171,14 @@ export function MobileFileBottomSheet({
|
||||
annotations,
|
||||
replyToId,
|
||||
second,
|
||||
isInternal,
|
||||
}: {
|
||||
text: string
|
||||
attachmentIds: string[]
|
||||
annotations?: Annotation[]
|
||||
replyToId?: string | null
|
||||
second?: number | null
|
||||
isInternal?: boolean
|
||||
}) => {
|
||||
if (isPublic) {
|
||||
const password = localStorage.getItem(`share_pwd_${shareId}`) || ''
|
||||
@@ -208,6 +210,7 @@ export function MobileFileBottomSheet({
|
||||
replyToId: replyToId ?? undefined,
|
||||
annotations: annotations,
|
||||
second: second ?? undefined,
|
||||
isInternal: isInternal ?? false,
|
||||
},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to create comment')
|
||||
@@ -267,6 +270,8 @@ export function MobileFileBottomSheet({
|
||||
annotations: Annotation[] = [],
|
||||
replyToId?: string | null,
|
||||
second?: number | null,
|
||||
_attachedFilesMeta?: unknown,
|
||||
isInternal?: boolean,
|
||||
) => {
|
||||
if (!text.trim() && attachmentIds.length === 0 && annotations.length === 0) return
|
||||
|
||||
@@ -286,7 +291,14 @@ export function MobileFileBottomSheet({
|
||||
})
|
||||
}
|
||||
} else {
|
||||
createComment({ text, attachmentIds, annotations, replyToId: actualReplyToId, second })
|
||||
createComment({
|
||||
text,
|
||||
attachmentIds,
|
||||
annotations,
|
||||
replyToId: actualReplyToId,
|
||||
second,
|
||||
isInternal,
|
||||
})
|
||||
}
|
||||
setReplyingTo(null)
|
||||
}
|
||||
@@ -372,6 +384,7 @@ export function MobileFileBottomSheet({
|
||||
<div key={comment.id}>
|
||||
<MessageCard
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
message={comment}
|
||||
getUser={getUser}
|
||||
onReply={setReplyingTo}
|
||||
@@ -398,7 +411,9 @@ export function MobileFileBottomSheet({
|
||||
<div key={reply.id}>
|
||||
<MessageCard
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
isReply={true}
|
||||
parentIsInternal={comment.isInternal}
|
||||
message={reply}
|
||||
getUser={getUser}
|
||||
onReply={setReplyingTo}
|
||||
@@ -445,6 +460,7 @@ export function MobileFileBottomSheet({
|
||||
onSendMessage={handleSendMessage}
|
||||
replyingTo={replyingTo}
|
||||
onCancelReply={() => setReplyingTo(null)}
|
||||
allowInternalComments={!isPublic}
|
||||
hideAnnotationControl={hideAnnotationControl}
|
||||
disableMentions={isPublic}
|
||||
currentTime={viewerDef?.commentsConfig?.hasTimestamp ? currentTime : undefined}
|
||||
|
||||
@@ -25,6 +25,7 @@ function makeComment(overrides: Partial<CommentInfo> = {}): CommentInfo {
|
||||
updatedAt: '2026-11-25T14:53:00.000Z',
|
||||
sessionId: null,
|
||||
isCompleted: false,
|
||||
isInternal: false,
|
||||
completionLastChangedBy: null,
|
||||
reactionCounts: [],
|
||||
...overrides,
|
||||
@@ -498,4 +499,29 @@ describe('PrintCommentsView', () => {
|
||||
'0 0 200 267',
|
||||
)
|
||||
})
|
||||
|
||||
it('renders a lock indicator for internal comments', () => {
|
||||
render(
|
||||
<PrintCommentsView
|
||||
asset={{
|
||||
id: 'asset-1',
|
||||
name: 'video.mp4',
|
||||
sizeByte: 100,
|
||||
fileCount: 1,
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
proxyType: 'video',
|
||||
createdAt: '2026-11-25T14:53:00.000Z',
|
||||
updatedAt: '2026-11-25T14:53:00.000Z',
|
||||
}}
|
||||
breadcrumbs={['Project']}
|
||||
comments={[
|
||||
makeComment({ id: 'c-pub', isInternal: false }),
|
||||
makeComment({ id: 'c-int', isInternal: true }),
|
||||
]}
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getAllByTestId('print-comment-internal')).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
FileIcon,
|
||||
FileText,
|
||||
Loader2,
|
||||
Lock,
|
||||
Printer,
|
||||
} from 'lucide-react'
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
@@ -399,6 +400,16 @@ export const PrintCommentsView: React.FC<PrintCommentsViewProps> = ({
|
||||
<span className="whitespace-nowrap text-xs text-muted-foreground">
|
||||
{formatCommentDateTime(comment.createdAt)}
|
||||
</span>
|
||||
{comment.isInternal && (
|
||||
<span
|
||||
className="inline-flex items-center text-muted-foreground"
|
||||
title={m.internal_comment_tooltip()}
|
||||
aria-label={m.internal_comment_tooltip()}
|
||||
data-testid="print-comment-internal"
|
||||
>
|
||||
<Lock className="h-3.5 w-3.5" />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
{comment.isCompleted && (
|
||||
|
||||
@@ -1793,5 +1793,15 @@
|
||||
"print_comments_error": "Failed to load printable comments.",
|
||||
"print_comments_count": "{count} comments",
|
||||
"print_comments_count_one": "1 comment",
|
||||
"print_comments_has_annotations": "Comment has annotations"
|
||||
"print_comments_has_annotations": "Comment has annotations",
|
||||
"public_comment": "Public Comment",
|
||||
"internal_comment": "Internal Comment",
|
||||
"public_comment_label": "Public",
|
||||
"internal_comment_label": "Internal",
|
||||
"public_comment_description": "Visible to team members and share links",
|
||||
"internal_comment_description": "Only visible to team members",
|
||||
"internal_comment_tooltip": "Internal comment — hidden from public share links",
|
||||
"internal_reply_locked_tooltip": "Replies to internal comments are always internal",
|
||||
"remove_timestamp": "Remove timestamp",
|
||||
"failed_to_update_comment": "Failed to update comment"
|
||||
}
|
||||
|
||||
@@ -1723,5 +1723,15 @@
|
||||
"print_comments_error": "인쇄용 댓글을 불러오지 못했습니다.",
|
||||
"print_comments_count": "댓글 {count}개",
|
||||
"print_comments_count_one": "댓글 1개",
|
||||
"print_comments_has_annotations": "주석이 포함된 댓글"
|
||||
"print_comments_has_annotations": "주석이 포함된 댓글",
|
||||
"public_comment": "공개 댓글",
|
||||
"internal_comment": "내부 댓글",
|
||||
"public_comment_label": "공개",
|
||||
"internal_comment_label": "내부",
|
||||
"public_comment_description": "팀 멤버와 공유 링크에서 모두 볼 수 있음",
|
||||
"internal_comment_description": "팀 멤버만 볼 수 있음",
|
||||
"internal_comment_tooltip": "내부 댓글 — 공개 공유 링크에는 표시되지 않음",
|
||||
"internal_reply_locked_tooltip": "내부 댓글에 대한 답글은 항상 내부 댓글로 작성됩니다",
|
||||
"remove_timestamp": "타임스탬프 제거",
|
||||
"failed_to_update_comment": "댓글을 수정하지 못했습니다"
|
||||
}
|
||||
|
||||
@@ -1793,5 +1793,15 @@
|
||||
"print_comments_error": "加载可打印评论失败。",
|
||||
"print_comments_count": "{count} 条评论",
|
||||
"print_comments_count_one": "1 条评论",
|
||||
"print_comments_has_annotations": "评论包含标注"
|
||||
"print_comments_has_annotations": "评论包含标注",
|
||||
"public_comment": "公开评论",
|
||||
"internal_comment": "内部评论",
|
||||
"public_comment_label": "公开",
|
||||
"internal_comment_label": "内部",
|
||||
"public_comment_description": "团队成员和公开分享链接均可见",
|
||||
"internal_comment_description": "仅团队成员可见",
|
||||
"internal_comment_tooltip": "内部评论 — 不会在公开分享链接中显示",
|
||||
"internal_reply_locked_tooltip": "回复内部评论时只能发送内部评论",
|
||||
"remove_timestamp": "移除时间戳",
|
||||
"failed_to_update_comment": "更新评论失败"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user