Compare commits

...
6 Commits
Author SHA1 Message Date
yiling 6d4f62d6f6 Release v0.3.8 2026-08-15 20:35:30 +08:00
Yiling-J 43808216e6 fix(core): rename latest version child record on version stack rename (#312) 2026-08-15 16:18:11 +08:00
Yiling-J f66bb7af73 feat(version-stack): add manage versions dialog and version removal (#311)
* feat(version-stack): add manage versions dialog and version removal

* fix(webui): remove ellipsis and add pointer cursor to manage versions button

* fix(version-stack): handle symlink deduplication and name sync for share links

* refactor(version-stack): extract shared symlink dedup helper

The 'repoint first symlink per share folder, delete duplicates with
fileCount decrement' logic was triplicated across createVersionStack,
reparentAssets, and reparentFileToFile with subtle variations. Extract
it into dedupeSymlinksToTarget() in packages/core/src/asset/symlink.ts
and call it from all three sites (behavior unchanged), with a dedicated
test suite covering the edge cases.
2026-08-15 15:37:17 +08:00
Yiling-J ae86d56a7d feat(webui): improve AGENTS.md editor placeholder and read-only notice (#310)
* feat(webui): improve AGENTS.md editor placeholder and read-only notice

* docs: add AGENTS.md documentation under Shumai Agent Settings
2026-08-15 11:00:30 +08:00
Yiling-J 1cee103b1c feat(agent): add nested agents.md support across backend and webui (#309)
* feat(agent): add nested agents.md support across backend and webui

* fix(webui): update agentsmd route paths and unnest folder agentsmd route

* fix(agent): flush agents.md autosave on close and address review feedback

- Flush pending debounced AGENTS.md autosave on close/unmount so edits
  made within 750ms of navigating away are no longer silently lost
- Serialize autosaves through a promise chain so an older in-flight
  request can never overwrite newer content on the server
- Internationalize the hardcoded "Failed to save" and
  "Loading AGENTS.md..." strings (en + zh)
- Validate that AGENTS.md is only stored on folder/root assets in
  AssetService, preventing bogus virtual paths for file assets
- Cap updateAgentsMd content at 100k chars via Zod validation
- Remove unused getAgentsMd/updateAgentsMd response DTO schemas
- Drop unused teamId prop from AgentsMdEditor
- Add tests: non-folder asset rejection, oversized content 400,
  and agent-chat workflow assetId passthrough

* refactor(db): isolate AGENTS.md content in dedicated 1:1 AssetAgentMd table

* style(webui): unify top bar button hover styles and add wand icon to agentsmd button

* style(webui): update agentsmd button state colors and remove presence dot

* fix(webui): fix close button overflow and stabilize debounced autosave in agentsmd editor

* fix(webui): update debounce to 1s and await pending save before closing agentsmd editor

* feat(webui): add terminal AGENTS.md breadcrumb on agentsmd editor page

* fix(webui): use ScrollArea for markdown editor scrolling
2026-08-15 10:25:46 +08:00
Yiling-J 3c3b6880e4 feat(webui): replace legacy markdown editor with new lexical wysiwyg editor (#308)
* feat(webui): replace legacy markdown editor with new lexical wysiwyg editor

* refactor(webui): organize markdown editor files into components/markdown-editor folder
2026-08-14 16:27:14 +08:00
109 changed files with 6797 additions and 781 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent-app",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"bin": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/cli",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"bin": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/transcode-app",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"bin": {
+4
View File
@@ -80,6 +80,10 @@ apps/web/e2e/
| Owner drags a file into a folder and a folder into another folder | `tests/project/move-folder-file.spec.ts` |
| Owner drags a file onto a file to create a version stack | `tests/project/version-stack-create.spec.ts` |
| Owner drags a file onto a version stack to add a new version | `tests/project/version-stack-add-version.spec.ts` |
| Owner manages version stack: removes version from 3-version stack | `tests/project/version-stack-manage.spec.ts` |
| Owner removes version from 2-version stack which dissolves into standalone files | `tests/project/version-stack-manage.spec.ts` |
| Dissolving a shared version stack renders the remaining standalone file name on the share page | `tests/project/version-stack-manage.spec.ts` |
| Moving a shared file into a shared version stack leaves only 1 stack card on the share page | `tests/project/version-stack-manage.spec.ts` |
| Owner searches the file list by an English name keyword | `tests/project/search-file-list.spec.ts` |
| Owner searches the file list by Chinese, Japanese, and Korean name keywords | `tests/project/search-file-list.spec.ts` |
| Owner searches the file list with a keyword and a filter condition | `tests/project/search-file-list.spec.ts` |
@@ -0,0 +1,233 @@
import { expect, test } from '../../fixtures'
import { seedFile } from '../../helpers/assets'
import { dragCard } from '../../helpers/dnd'
import { apiAddAssetsToShare, apiCreateShare, fileCard } from '../../helpers/files'
test('owner manages versions: removes a version from a 3-version stack', async ({
project,
prisma,
}) => {
const { page, projectId, rootFolderId } = project
const fileA = await seedFile(prisma, projectId, rootFolderId, `e2e-mng-a-${Date.now()}`)
const fileB = await seedFile(prisma, projectId, rootFolderId, `e2e-mng-b-${Date.now()}`)
const fileC = await seedFile(prisma, projectId, rootFolderId, `e2e-mng-c-${Date.now()}`)
await page.goto(`/projects/${projectId}`)
await expect(fileCard(page, fileA.name)).toBeVisible()
await expect(fileCard(page, fileB.name)).toBeVisible()
await expect(fileCard(page, fileC.name)).toBeVisible()
// 1. Create a 3-version stack: B on A -> stack (v2), then C on stack -> stack (v3)
await dragCard(page, fileCard(page, fileB.name), fileCard(page, fileA.name))
await expect(page.getByText('v2', { exact: true })).toBeVisible()
await dragCard(page, fileCard(page, fileC.name), fileCard(page, fileB.name))
await expect(page.getByText('v3', { exact: true })).toBeVisible()
const stack = await prisma.asset.findFirstOrThrow({
where: { projectId, parentId: rootFolderId, type: 'version_stack' },
})
expect(stack.fileCount).toBe(3)
// 2. Navigate to file viewer for the stack
await page.goto(`/projects/${projectId}/files/${stack.id}`)
// 3. Open breadcrumb menu and click "Manage versions..."
// Click on the asset name / badge dropdown trigger
await page.getByRole('button', { name: new RegExp(fileC.name) }).click()
// Hover or click on Versions sub-menu trigger
await page.getByRole('menuitem', { name: 'Versions', exact: true }).hover()
// Click "Manage versions..."
await page.getByRole('button', { name: /manage versions$/i }).click()
// 4. Verify Manage versions dialog is visible with all 3 versions
const dialog = page.getByRole('dialog')
await expect(dialog).toBeVisible()
await expect(dialog.getByText('Manage versions')).toBeVisible()
await expect(dialog.getByText(fileA.name)).toBeVisible()
await expect(dialog.getByText(fileB.name)).toBeVisible()
await expect(dialog.getByText(fileC.name)).toBeVisible()
// 5. Remove fileB from stack: hover its row and click Remove from stack
const rowB = dialog.locator('div.group', { hasText: fileB.name })
await rowB.hover()
const moreButton = rowB.getByRole('button', { name: 'More options' })
await moreButton.click()
await page.getByRole('menuitem', { name: /remove from stack/i }).click()
// 6. Verify toast and that fileB is removed from dialog
await expect(page.getByText(/version removed from stack/i)).toBeVisible()
await expect(dialog.getByText(fileB.name)).not.toBeVisible()
await expect(dialog.getByText(fileA.name)).toBeVisible()
await expect(dialog.getByText(fileC.name)).toBeVisible()
// DB: stack now has 2 versions (fileA and fileC), and fileB is standalone in root folder
await expect
.poll(async () => {
const s = await prisma.asset.findUnique({ where: { id: stack.id } })
return s?.fileCount
})
.toBe(2)
const updatedFileB = await prisma.asset.findUnique({ where: { id: fileB.id } })
expect(updatedFileB?.parentId).toBe(rootFolderId)
})
test('owner removes version from 2-version stack dissolving the stack into standalone files', async ({
project,
prisma,
}) => {
const { page, projectId, rootFolderId } = project
const fileA = await seedFile(prisma, projectId, rootFolderId, `e2e-dis-a-${Date.now()}`)
const fileB = await seedFile(prisma, projectId, rootFolderId, `e2e-dis-b-${Date.now()}`)
await page.goto(`/projects/${projectId}`)
await dragCard(page, fileCard(page, fileB.name), fileCard(page, fileA.name))
await expect(page.getByText('v2', { exact: true })).toBeVisible()
const stack = await prisma.asset.findFirstOrThrow({
where: { projectId, parentId: rootFolderId, type: 'version_stack' },
})
// Open file view
await page.goto(`/projects/${projectId}/files/${stack.id}`)
// Open breadcrumb menu and click "Manage versions..."
await page.getByRole('button', { name: new RegExp(fileB.name) }).click()
await page.getByRole('menuitem', { name: 'Versions', exact: true }).hover()
await page.getByRole('button', { name: /manage versions$/i }).click()
const dialog = page.getByRole('dialog')
await expect(dialog).toBeVisible()
// Remove fileB -> stack dissolves -> only fileA remains
const rowB = dialog.locator('div.group', { hasText: fileB.name })
await rowB.hover()
const moreButton = rowB.getByRole('button', { name: 'More options' })
await moreButton.click()
await page.getByRole('menuitem', { name: /remove from stack/i }).click()
// Dialog should close automatically when stack dissolves
await expect(dialog).not.toBeVisible()
// DB: stack asset is deleted
await expect
.poll(async () => {
const s = await prisma.asset.findUnique({ where: { id: stack.id } })
return s === null
})
.toBe(true)
// Both fileA and fileB are now standalone files in rootFolder
const updatedFileA = await prisma.asset.findUnique({ where: { id: fileA.id } })
const updatedFileB = await prisma.asset.findUnique({ where: { id: fileB.id } })
expect(updatedFileA?.parentId).toBe(rootFolderId)
expect(updatedFileB?.parentId).toBe(rootFolderId)
})
test('dissolving a shared version stack renders the remaining standalone file name on the share page', async ({
project,
prisma,
}) => {
const { page, projectId, rootFolderId } = project
const fileA = await seedFile(prisma, projectId, rootFolderId, `e2e-shd-a-${Date.now()}`)
const fileB = await seedFile(prisma, projectId, rootFolderId, `e2e-shd-b-${Date.now()}`)
await page.goto(`/projects/${projectId}`)
await dragCard(page, fileCard(page, fileB.name), fileCard(page, fileA.name))
await expect(page.getByText('v2', { exact: true })).toBeVisible()
const stack = await prisma.asset.findFirstOrThrow({
where: { projectId, parentId: rootFolderId, type: 'version_stack' },
})
// Share the version stack
await fileCard(page, fileB.name).click({ button: 'right' })
await page.getByRole('menuitem', { name: 'Create Share Link' }).click()
const toast = page.locator('[data-sonner-toast]').filter({ hasText: 'Share link created' })
await expect(toast).toBeVisible()
const share = await prisma.shareLink.findFirstOrThrow({
where: { projectId },
orderBy: { createdAt: 'desc' },
})
// Open file viewer for the stack
await page.goto(`/projects/${projectId}/files/${stack.id}`)
// Open breadcrumb menu and click "Manage versions"
await page.getByRole('button', { name: new RegExp(fileB.name) }).click()
await page.getByRole('menuitem', { name: 'Versions', exact: true }).hover()
await page.getByRole('button', { name: /manage versions$/i }).click()
const dialog = page.getByRole('dialog')
await expect(dialog).toBeVisible()
// Remove fileB -> stack dissolves -> only fileA remains
const rowB = dialog.locator('div.group', { hasText: fileB.name })
await rowB.hover()
const moreButton = rowB.getByRole('button', { name: 'More options' })
await moreButton.click()
await page.getByRole('menuitem', { name: /remove from stack/i }).click()
await expect(dialog).not.toBeVisible()
// Navigate to public share page: verify fileA is displayed with its non-empty name
await page.goto(`/share/${share.id}`)
await expect(fileCard(page, fileA.name)).toBeVisible()
await expect(fileCard(page, fileB.name)).not.toBeVisible()
})
test('moving a shared file into a shared version stack leaves only 1 stack card on the share page', async ({
project,
prisma,
}) => {
const { page, projectId, rootFolderId } = project
const fileA = await seedFile(prisma, projectId, rootFolderId, `e2e-mvsh-a-${Date.now()}`)
const fileB = await seedFile(prisma, projectId, rootFolderId, `e2e-mvsh-b-${Date.now()}`)
const fileC = await seedFile(prisma, projectId, rootFolderId, `e2e-mvsh-c-${Date.now()}`)
await page.goto(`/projects/${projectId}`)
// 1. Create a version stack from file B and file A (stack has v2, displays file B)
await dragCard(page, fileCard(page, fileB.name), fileCard(page, fileA.name))
await expect(page.getByText('v2', { exact: true })).toBeVisible()
const stack = await prisma.asset.findFirstOrThrow({
where: { projectId, parentId: rootFolderId, type: 'version_stack' },
})
// 2. Create a share link and add both stack AB and file C to it
const share = await apiCreateShare(project.context.request, projectId, `Test Share ${Date.now()}`)
await apiAddAssetsToShare(project.context.request, share.id, [stack.id, fileC.id])
// Verify initial share page has both stack and file C
await page.goto(`/share/${share.id}`)
await expect(fileCard(page, fileB.name)).toBeVisible()
await expect(fileCard(page, fileC.name)).toBeVisible()
// 3. In project page, drop file C onto stack card (displays file B)
await page.goto(`/projects/${projectId}`)
await dragCard(page, fileCard(page, fileC.name), fileCard(page, fileB.name))
await expect(page.getByText('v3', { exact: true })).toBeVisible()
// 4. Return to public share page: now only 1 card exists (the stack showing file C with v3)
await page.goto(`/share/${share.id}`)
await expect(page.getByText('v3', { exact: true })).toBeVisible()
await expect(fileCard(page, fileC.name)).toBeVisible()
await expect(fileCard(page, fileB.name)).not.toBeVisible()
// DB: share rootFolder fileCount is 1 and exactly 1 symlink exists
const symlinks = await prisma.asset.findMany({
where: { parentId: share.rootFolderId, type: 'symlink' },
})
expect(symlinks).toHaveLength(1)
expect(symlinks[0].targetId).toBe(stack.id)
const updatedShareRoot = await prisma.asset.findUnique({ where: { id: share.rootFolderId } })
expect(updatedShareRoot?.fileCount).toBe(1)
})
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/web-app",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"dependencies": {
+14 -14
View File
@@ -33,7 +33,7 @@
},
"apps/agent": {
"name": "@shumai/agent-app",
"version": "0.3.6",
"version": "0.3.7",
"bin": {
"shumai-agent": "./src/index.ts",
},
@@ -45,7 +45,7 @@
},
"apps/cli": {
"name": "@shumai/cli",
"version": "0.3.6",
"version": "0.3.7",
"bin": {
"shumai-cli": "./src/index.ts",
},
@@ -60,7 +60,7 @@
},
"apps/transcode": {
"name": "@shumai/transcode-app",
"version": "0.3.6",
"version": "0.3.7",
"bin": {
"shumai-transcode": "./src/index.ts",
},
@@ -72,7 +72,7 @@
},
"apps/web": {
"name": "@shumai/web-app",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@shumai/agent": "workspace:*",
"@shumai/api": "workspace:*",
@@ -92,7 +92,7 @@
},
"packages/agent": {
"name": "@shumai/agent",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@anthropic-ai/sandbox-runtime": "0.0.66",
"@earendil-works/pi-agent-core": "0.82.1",
@@ -117,7 +117,7 @@
},
"packages/api": {
"name": "@shumai/api",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@hono/zod-validator": "0.7.6",
"@shumai/core": "workspace:*",
@@ -131,7 +131,7 @@
},
"packages/core": {
"name": "@shumai/core",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
@@ -166,7 +166,7 @@
},
"packages/db": {
"name": "@shumai/db",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@earendil-works/pi-agent-core": "0.82.1",
"@prisma/adapter-pg": "7.8.0",
@@ -182,7 +182,7 @@
},
"packages/dtos": {
"name": "@shumai/dtos",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@earendil-works/pi-agent-core": "0.82.1",
"zod": "4.4.3",
@@ -190,7 +190,7 @@
},
"packages/e2e": {
"name": "@shumai/e2e",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@earendil-works/pi-agent-core": "0.82.1",
"@google/genai": "1.52.0",
@@ -205,11 +205,11 @@
},
"packages/tableprinter": {
"name": "@shumai/tableprinter",
"version": "0.3.6",
"version": "0.3.7",
},
"packages/transcode": {
"name": "@shumai/transcode",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
@@ -223,7 +223,7 @@
},
"packages/webui": {
"name": "@shumai/webui",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@base-ui/react": "1.5.0",
"@dnd-kit/abstract": "0.4.0",
@@ -321,7 +321,7 @@
},
"packages/workflow-core": {
"name": "@shumai/workflow-core",
"version": "0.3.6",
"version": "0.3.7",
"dependencies": {
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
+1
View File
@@ -43,6 +43,7 @@
"pages": [
"using-shumai/agent-providers",
"using-shumai/agents",
"using-shumai/agents-md",
"using-shumai/agent-skills",
"using-shumai/agent-tools",
"using-shumai/mcp-servers",
+53
View File
@@ -0,0 +1,53 @@
---
title: AGENTS.md Context & Instructions
description: Provide hierarchical, folder-specific instructions and context to AI agents.
---
In addition to global agent system prompts and skills, Shumai allows you to define project-level and folder-level instructions using **`AGENTS.md`**.
When an AI agent (such as a Chat Agent or Autofill Agent) operates within a project or folder, Shumai automatically loads the corresponding `AGENTS.md` files to provide context, operational rules, and project-specific knowledge.
---
## Hierarchical Traversal & Inheritance
Shumai uses a hierarchical context model for `AGENTS.md`:
- **Upward Traversal**: When an agent works on a file or folder, Shumai traverses the folder tree upwards from the current folder all the way to the **project root level**.
- **Combined Context**: All `AGENTS.md` files found along this path are loaded into the agent's context in order (from the project root down to the current folder).
- **Layered Rules**: This lets you define broad, project-wide rules and guidelines at the project root `AGENTS.md`, while adding specific rules, vocabulary, or autofill hints in nested subfolder `AGENTS.md` files.
---
## What to Include in AGENTS.md
You can use `AGENTS.md` to define any instructions you want the agent to follow when working in that folder or project:
- **Project & Folder Overview**: Describe what assets are stored in the folder and how they relate to the broader project.
- **Agent Behavioral Rules**: Specify guardrails, tone, required formats, or things the agent should and shouldn't do when answering queries or leaving comments.
- **Terminology & Domain Knowledge**: Define specialized vocabulary, acronyms, brand naming conventions, or project-specific jargon.
- **Metadata & Autofill Instructions**: Guide the **Autofill Agent** on how to summarize assets, generate tags, or populate specific custom metadata fields for files in this folder.
---
## Accessing and Editing AGENTS.md
### Opening the Editor
To view or edit `AGENTS.md`:
1. Open any project or folder in the Shumai web application.
2. Click the **`AGENTS.md`** button in the top navigation toolbar, or right-click any folder in the file browser and choose **AGENTS.md**.
3. A dedicated WYSIWYG Markdown editor opens with full formatting support (headings, lists, code blocks, bold/italics, and links).
### Auto-Save
As you make changes in the editor, Shumai automatically saves your edits in the background with visual save status indicators (`Saving...`, `Saved`).
---
## Permissions & Read-Only Mode
- **Viewing**: All team members who have read access to the project can view `AGENTS.md`.
- **Editing**: **Only Team Owners** are permitted to create, edit, or delete `AGENTS.md` files.
- **Read-Only State**: Non-owner members will see a clear read-only indicator in the toolbar explaining that only team owners can edit instructions for the file.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "shumai",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"repository": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./src/index.ts",
+110
View File
@@ -18,6 +18,7 @@ import {
generateSessionNameActivity,
type GenerateSessionNameParams,
getUserTeamInfoActivity,
formatProjectContextPrompt,
} from './agent'
import * as piAgent from '../index'
import { type AgentHarness, type Session } from '@earendil-works/pi-agent-core'
@@ -2041,4 +2042,113 @@ describe('Agent Database Activities Integration', () => {
expect(piAgent.createAgentSession).not.toHaveBeenCalled()
})
})
describe('Nested AGENTS.md prompt injection', () => {
it('formatProjectContextPrompt formats context files into XML project_context block', () => {
expect(formatProjectContextPrompt([])).toBe('')
const formatted = formatProjectContextPrompt([
{ path: '/AGENTS.md', content: 'Root rules' },
{ path: '/subfolder/AGENTS.md', content: 'Subfolder rules' },
])
expect(formatted).toBe(
'\n\n<project_context>\n\nProject-specific instructions and guidelines:\n\n<project_instructions path="/AGENTS.md">\nRoot rules\n</project_instructions>\n\n<project_instructions path="/subfolder/AGENTS.md">\nSubfolder rules\n</project_instructions>\n\n</project_context>',
)
})
it('agentChatActivity injects nested AGENTS.md instructions into systemPrompt', async () => {
const user = await prisma.user.create({
data: { name: 'User_Chat_Md', email: `chat-md-${Date.now()}@example.com` },
})
const team = await prisma.team.create({
data: { name: 'Team_Chat_Md_' + Date.now() },
})
const project = await prisma.project.create({
data: { name: 'Project_Chat_Md', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.root,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await prisma.assetAgentMd.create({
data: {
assetId: rootFolder.id,
content: '# Root Policy',
},
})
const subfolder = await prisma.asset.create({
data: {
name: 'subfolder',
type: AssetType.folder,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await prisma.assetAgentMd.create({
data: {
assetId: subfolder.id,
content: '# Subfolder Policy',
},
})
const mockHarness = {
subscribe: vi.fn(),
prompt: vi.fn().mockResolvedValue({
content: [{ type: 'text', text: 'Chat reply' }],
usage: { input: 10, output: 20 },
}),
}
const mockSession = {
getEntries: vi.fn().mockResolvedValue([]),
getStorage: vi.fn().mockReturnValue({ sessionId: 'mock-session-id' }),
}
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Mock AgentHarness instance for activity test
harness: mockHarness as unknown as AgentHarness<any, any, any, any>,
})
const context = {
agent: { id: 'agent-1', provider: { name: 'google' }, modelRef: { modelId: 'gemini' } },
dbProviders: [],
teamSkills: [],
allowedDomains: [],
} as unknown as AgentExecutionContext
await agentChatActivity({
teamId: team.id,
agentId: 'agent-1',
message: 'Hello',
imageUrls: [],
projectId: project.id,
folderId: subfolder.id,
assetId: subfolder.id,
sessionId: 'mock-session-id',
userId: user.id,
context,
})
expect(piAgent.createAgentSession).toHaveBeenCalledWith(
expect.objectContaining({
systemPrompt: expect.stringContaining('<project_context>'),
}),
)
const lastCall = vi.mocked(piAgent.createAgentSession).mock.calls.at(-1)
const systemPromptArg = lastCall?.[0].systemPrompt as string
expect(systemPromptArg).toContain(
'<project_instructions path="/AGENTS.md">\n# Root Policy\n</project_instructions>',
)
expect(systemPromptArg).toContain(
'<project_instructions path="/subfolder/AGENTS.md">\n# Subfolder Policy\n</project_instructions>',
)
})
})
})
+55 -7
View File
@@ -65,6 +65,18 @@ export interface AgentExecutionContext {
allowedDomains: string[]
}
export function formatProjectContextPrompt(
contextFiles: Array<{ path: string; content: string }>,
): string {
if (contextFiles.length === 0) return ''
let prompt = '\n\n<project_context>\n\nProject-specific instructions and guidelines:\n\n'
for (const { path: filePath, content } of contextFiles) {
prompt += `<project_instructions path="${filePath}">\n${content}\n</project_instructions>\n\n`
}
prompt += '</project_context>'
return prompt
}
async function executeAgentPrompt(params: {
taskId?: string
teamId: string
@@ -75,6 +87,7 @@ async function executeAgentPrompt(params: {
sessionId?: string
userId?: string
projectId?: string
assetId?: string
userCommentId?: string | null
tools?: AgentTool[]
context: AgentExecutionContext
@@ -114,6 +127,40 @@ When creating a file or version, you may attach metadata (for example, the AI mo
// Note: params.agentsInstruction is no longer appended to systemPrompt here.
// Instead, it is persisted as a custom message session entry in the conversation history below.
let targetAssetId = params.assetId
if (!targetAssetId) {
if (params.userCommentId) {
const comment = await prisma.assetComment.findUnique({
where: { id: params.userCommentId },
select: { assetId: true },
})
if (comment?.assetId) {
targetAssetId = comment.assetId
}
} else if (params.taskId) {
const task = await prisma.workflowTask.findUnique({
where: { id: params.taskId },
select: { assetId: true },
})
if (task?.assetId) {
targetAssetId = task.assetId
}
} else if (params.projectId) {
const project = await prisma.project.findUnique({
where: { id: params.projectId },
select: { rootFolderId: true },
})
if (project?.rootFolderId) {
targetAssetId = project.rootFolderId
}
}
}
const contextFiles = targetAssetId ? await assetService.getNestedAgentsMd(targetAssetId) : []
if (contextFiles.length > 0) {
systemPrompt += formatProjectContextPrompt(contextFiles)
}
const modelConfig = agent.modelRef?.config
if (modelConfig?.input) {
systemPrompt += `\n\nYour current model supports the following input types: ${modelConfig.input.join(', ')}.`
@@ -349,6 +396,7 @@ export interface AgentChatParams {
imageUrls: string[]
projectId: string
folderId: string
assetId?: string
agentsInstruction?: string
sessionId: string
userId?: string
@@ -414,6 +462,7 @@ export async function agentChatActivity(params: AgentChatParams) {
sessionId,
userId: params.userId,
projectId: params.projectId,
assetId: params.assetId || params.folderId,
userCommentId: params.userCommentId,
context: params.context,
attachedAssets: params.attachedAssets,
@@ -425,6 +474,8 @@ export interface AutofillAiParams {
images: string[]
fields: AutofillField[]
context: AgentExecutionContext
assetId?: string
projectId?: string
}
export async function autofillAiActivity(params: AutofillAiParams) {
@@ -458,6 +509,8 @@ export async function autofillAiActivity(params: AutofillAiParams) {
agentsInstruction: '',
sessionId: undefined,
userId: undefined,
projectId: params.projectId,
assetId: params.assetId,
tools: [autofillTool],
context: params.context,
})
@@ -1192,9 +1245,7 @@ export async function executeAgentToolActivity(params: ExecuteAgentToolParams):
{ first: limit, after },
)
const stackIds = assets
.filter((a) => a.type === AssetType.version_stack && (!a.name || a.name === ''))
.map((a) => a.id)
const stackIds = assets.filter((a) => a.type === AssetType.version_stack).map((a) => a.id)
const latestVersionsMap = new Map<string, Prisma.AssetGetPayload<Record<string, never>>>()
@@ -1215,10 +1266,7 @@ export async function executeAgentToolActivity(params: ExecuteAgentToolParams):
const latestVersion = latestVersionsMap.get(a.id)
return {
id: a.id,
name:
a.type === AssetType.version_stack && (!a.name || a.name === '')
? (latestVersion?.name ?? a.name)
: a.name,
name: a.type === AssetType.version_stack ? (latestVersion?.name ?? a.name) : a.name,
type: a.type,
size:
a.type === AssetType.version_stack && latestVersion
@@ -64,6 +64,7 @@ describe('Agent Autofill Workflow', () => {
mockActivities.createCommentActivity.mockResolvedValue({ id: 'comment-placeholder-id' })
mockActivities.getAssetActivity.mockResolvedValue({
id: 'a1',
projectId: 'p1',
storageKey: { key: 'asset-key' },
project: { id: 'p1', teamId: 't1' },
mediaType: 'image/png',
@@ -117,6 +118,9 @@ describe('Agent Autofill Workflow', () => {
status: 'processing',
})
// Verify asset fetched
expect(mockActivities.getAssetActivity).toHaveBeenCalledWith('a1')
// Verify placeholder comment created
expect(mockActivities.createCommentActivity).toHaveBeenCalledWith({
assetId: 'a1',
@@ -143,6 +147,8 @@ describe('Agent Autofill Workflow', () => {
// Verify AI autofill called with mapped fields
expect(mockActivities.autofillAiActivity).toHaveBeenCalledWith({
teamId: 't1',
assetId: 'a1',
projectId: 'p1',
images: ['/tmp/test-dir/1.webp'],
fields: [
{
@@ -135,6 +135,8 @@ export async function agentAutofillMedia(task: WorkflowTask): Promise<void> {
const aiResult = await executeActivity(agentWorkerQueue, autofillAiActivity, {
teamId,
images: generatedFiles,
assetId: asset.id,
projectId: asset.projectId ?? undefined,
fields: fields.map(
(f: { key: string; config: Record<string, unknown>; description?: string | null }) => ({
id: f.key,
@@ -150,6 +150,7 @@ describe('Agent Chat Workflow', () => {
agentsInstruction: expectedInstruction1,
sessionId: 'session-123',
folderId: 'parent-folder-id',
assetId: 'a1',
}),
)
@@ -202,6 +202,7 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
imageUrls: attachmentImageUrls,
projectId: payload.projectId,
folderId,
assetId: asset.id,
agentsInstruction: instruction,
sessionId,
userId: payload.agent?.userId,
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/api",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./src/index.ts",
+55
View File
@@ -310,4 +310,59 @@ describe('folder api', () => {
beforeIndex: 'index-1',
})
})
it('GET /folders/:folderId/agentsmd', async () => {
vi.spyOn(assetService, 'getAgentsMd').mockResolvedValue('# Folder Guidelines')
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
const res = await app.request('/folders/test-id/agentsmd')
expect(res.status).toBe(200)
const json = await res.json()
expect(json.content).toBe('# Folder Guidelines')
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user1', name: 'Test User' },
permission: Permission.Read,
type: ResourceType.Asset,
id: 'test-id',
})
expect(assetService.getAgentsMd).toHaveBeenCalledWith('test-id')
})
it('PATCH /folders/:folderId/agentsmd', async () => {
vi.spyOn(assetService, 'updateAgentsMd').mockResolvedValue({ content: '# Updated Guidelines' })
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
const res = await app.request('/folders/test-id/agentsmd', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content: '# Updated Guidelines' }),
})
expect(res.status).toBe(200)
const json = await res.json()
expect(json.content).toBe('# Updated Guidelines')
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user1', name: 'Test User' },
permission: Permission.Admin,
type: ResourceType.Asset,
id: 'test-id',
})
expect(assetService.updateAgentsMd).toHaveBeenCalledWith('test-id', '# Updated Guidelines')
})
it('PATCH /folders/:folderId/agentsmd rejects oversized content', async () => {
const mockUpdate = vi.spyOn(assetService, 'updateAgentsMd').mockResolvedValue({ content: '' })
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
const res = await app.request('/folders/test-id/agentsmd', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content: 'x'.repeat(100_001) }),
})
expect(res.status).toBe(400)
expect(mockUpdate).not.toHaveBeenCalled()
})
})
+44
View File
@@ -8,6 +8,7 @@ import {
updateFolderRequestSchema,
deleteFoldersRequestSchema,
restoreFoldersRequestSchema,
updateAgentsMdRequestSchema,
} from '@shumai/dtos'
import { listChildrenRequestSchema, updateAssetOrderRequestSchema, AuditAction } from '@shumai/dtos'
import { searchRequestSchema } from '@shumai/dtos'
@@ -189,5 +190,48 @@ const route = new Hono<{ Variables: { user: User } }>()
const result = await searchService.search(folderId, req)
return c.json(result)
})
.get('/folders/:folderId/agentsmd', async (c) => {
const folderId = c.req.param('folderId')
const user = c.get('user')
await authzService.hasPermission({
user,
permission: Permission.Read,
type: ResourceType.Asset,
id: folderId,
})
const content = await assetService.getAgentsMd(folderId)
return c.json({ content })
})
.patch(
'/folders/:folderId/agentsmd',
zValidator('json', updateAgentsMdRequestSchema),
async (c) => {
const folderId = c.req.param('folderId')
const user = c.get('user')
const req = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Asset,
id: folderId,
})
const res = await assetService.updateAgentsMd(folderId, req.content)
const ctx = await assetService.getAssetContext(folderId)
await auditLogService.logAction({
action: AuditAction.folder_update,
teamId: ctx.teamId,
userId: user.id,
projectId: ctx.projectId,
itemId: folderId,
})
return c.json(res)
},
)
export default route
+28
View File
@@ -32,12 +32,14 @@ vi.mock('./middleware/auth', () => ({
describe('versionStack api', () => {
let mockCreateVersionStack: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockChangeStackFileVersion: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockRemoveVersionFromStack: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockGetAsset: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockGetStackVersions: any // eslint-disable-line @typescript-eslint/no-explicit-any
beforeEach(() => {
mockCreateVersionStack = vi.spyOn(versionStackService, 'createVersionStack')
mockChangeStackFileVersion = vi.spyOn(versionStackService, 'changeStackFileVersion')
mockRemoveVersionFromStack = vi.spyOn(versionStackService, 'removeVersionFromStack')
mockGetAsset = vi.spyOn(assetService, 'getAsset')
mockGetStackVersions = vi.spyOn(assetService, 'getStackVersions')
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
@@ -146,4 +148,30 @@ describe('versionStack api', () => {
expect(mockGetStackVersions).toHaveBeenCalledWith('stack1')
})
})
describe('DELETE /version_stacks/:stackId/versions/:versionId', () => {
it('should remove version from stack and return 200', async () => {
mockRemoveVersionFromStack.mockResolvedValue()
const app = new Hono().use('*', authMiddleware).route('/', versionStackRoute)
const res = await app.request('/version_stacks/stack1/versions/v1', {
method: 'DELETE',
})
expect(res.status).toBe(200)
expect(authzService.hasPermission).toHaveBeenCalledWith(
expect.objectContaining({
type: ResourceType.Asset,
id: 'stack1',
permission: Permission.Edit,
}),
)
expect(mockRemoveVersionFromStack).toHaveBeenCalledWith({
stackId: 'stack1',
fileId: 'v1',
})
})
})
})
+19
View File
@@ -75,5 +75,24 @@ const route = app
const versions = await assetService.getStackVersions(stackId)
return c.json(versions)
})
.delete('/version_stacks/:stackId/versions/:versionId', async (c) => {
const stackId = c.req.param('stackId')
const versionId = c.req.param('versionId')
const user = c.get('user')
await authzService.hasPermission({
user,
permission: Permission.Edit,
type: ResourceType.Asset,
id: stackId,
})
await versionStackService.removeVersionFromStack({
stackId,
fileId: versionId,
})
return new Response(null, { status: 200 })
})
export default route
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/core",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./src/index.ts",
+611
View File
@@ -2830,4 +2830,615 @@ describe('AssetService — natural sort by name', () => {
)
})
})
describe('AGENTS.md methods', () => {
it('getAgentsMd returns null when no agentmd is set', async () => {
const team = await prisma.team.create({
data: { name: 'Team_AgentsMd_' + Date.now() },
})
const project = await prisma.project.create({
data: { name: 'Project_AgentsMd', teamId: team.id },
})
const folder = await prisma.asset.create({
data: {
name: 'Folder_No_Md',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const content = await assetService.getAgentsMd(folder.id)
expect(content).toBeNull()
})
it('updateAgentsMd updates and getAgentsMd retrieves agentmd, and empty deletes', async () => {
const team = await prisma.team.create({
data: { name: 'Team_AgentsMd2_' + Date.now() },
})
const project = await prisma.project.create({
data: { name: 'Project_AgentsMd2', teamId: team.id },
})
const folder = await prisma.asset.create({
data: {
name: 'Folder_With_Md',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const updateResult = await assetService.updateAgentsMd(folder.id, '# Custom Guidelines')
expect(updateResult).toEqual({ content: '# Custom Guidelines' })
const content = await assetService.getAgentsMd(folder.id)
expect(content).toBe('# Custom Guidelines')
let folderInfo = await assetService.getAsset({ assetId: folder.id })
expect(folderInfo?.hasAgentsMd).toBe(true)
// Empty string deletes the record
const clearResult = await assetService.updateAgentsMd(folder.id, ' ')
expect(clearResult).toEqual({ content: '' })
const emptyContent = await assetService.getAgentsMd(folder.id)
expect(emptyContent).toBeNull()
folderInfo = await assetService.getAsset({ assetId: folder.id })
expect(folderInfo?.hasAgentsMd).toBe(false)
})
it('getNestedAgentsMd traverses hierarchy from root to leaf and formats virtual paths', async () => {
const team = await prisma.team.create({
data: { name: 'Team_NestedMd_' + Date.now() },
})
const project = await prisma.project.create({
data: { name: 'Project_NestedMd', teamId: team.id },
})
// 1. Root folder
const rootFolder = await prisma.asset.create({
data: {
name: 'Root Folder',
type: AssetType.root,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await prisma.assetAgentMd.create({
data: {
assetId: rootFolder.id,
content: '# Root Instructions\nFollow global rules.',
},
})
// 2. Subfolder 1: marketing (has agentmd)
const marketingFolder = await prisma.asset.create({
data: {
name: 'marketing',
type: AssetType.folder,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await prisma.assetAgentMd.create({
data: {
assetId: marketingFolder.id,
content: '# Marketing Instructions\nTone must be upbeat.',
},
})
// 3. Subfolder 2: campaigns (no agentmd)
const campaignsFolder = await prisma.asset.create({
data: {
name: 'campaigns',
type: AssetType.folder,
parentId: marketingFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
// 4. Subfolder 3: video-ads (has agentmd)
const videoAdsFolder = await prisma.asset.create({
data: {
name: 'video-ads',
type: AssetType.folder,
parentId: campaignsFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await prisma.assetAgentMd.create({
data: {
assetId: videoAdsFolder.id,
content: '# Video Ads Instructions\nInclude resolution tags.',
},
})
// 5. File inside video-ads
const fileAsset = await prisma.asset.create({
data: {
name: 'ad_clip.mp4',
type: AssetType.file,
parentId: videoAdsFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const nestedFromLeaf = await assetService.getNestedAgentsMd(fileAsset.id)
expect(nestedFromLeaf).toEqual([
{
path: '/AGENTS.md',
content: '# Root Instructions\nFollow global rules.',
},
{
path: '/marketing/AGENTS.md',
content: '# Marketing Instructions\nTone must be upbeat.',
},
{
path: '/marketing/campaigns/video-ads/AGENTS.md',
content: '# Video Ads Instructions\nInclude resolution tags.',
},
])
const nestedFromMarketing = await assetService.getNestedAgentsMd(marketingFolder.id)
expect(nestedFromMarketing).toEqual([
{
path: '/AGENTS.md',
content: '# Root Instructions\nFollow global rules.',
},
{
path: '/marketing/AGENTS.md',
content: '# Marketing Instructions\nTone must be upbeat.',
},
])
})
it('rejects get/update agentsmd on non-folder assets', async () => {
const team = await prisma.team.create({
data: { name: 'Team_AgentsMd_Type_' + Date.now() },
})
const project = await prisma.project.create({
data: { name: 'Project_AgentsMd_Type', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.root,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const fileAsset = await prisma.asset.create({
data: {
name: 'doc.pdf',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await expect(assetService.getAgentsMd(fileAsset.id)).rejects.toThrow(
'AGENTS.md can only be stored on folders',
)
await expect(assetService.updateAgentsMd(fileAsset.id, '# Nope')).rejects.toThrow(
'AGENTS.md can only be stored on folders',
)
})
})
describe('reparentAssets into version_stack with sharelink symlinks', () => {
it('deduplicates symlinks when both Stack A and File B are in the sharelink and File B is moved into Stack A', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const user = await prisma.user.create({
data: { name: 'Test User', email: `test-${Date.now()}@example.com` },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const shareRoot = await prisma.asset.create({
data: {
name: 'ShareRoot',
type: AssetType.share_root,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 2,
},
})
const fileA1 = await prisma.asset.create({
data: {
name: 'fileA1.txt',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 100,
sortIndex: 'a0',
},
})
const fileA2 = await prisma.asset.create({
data: {
name: 'fileA2.txt',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 100,
sortIndex: 'a1',
},
})
const fileB = await prisma.asset.create({
data: {
name: 'fileB.txt',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 200,
sortIndex: 'a2',
},
})
// Create Stack A from fileA1 and fileA2
const stackA = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 2,
sizeByte: 200,
},
})
await prisma.asset.update({ where: { id: fileA1.id }, data: { parentId: stackA.id } })
await prisma.asset.update({ where: { id: fileA2.id }, data: { parentId: stackA.id } })
// Create symlinks in shareRoot for both Stack A and File B
const symlinkStackA = await prisma.asset.create({
data: {
name: '',
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: stackA.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const symlinkFileB = await prisma.asset.create({
data: {
name: fileB.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: fileB.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
// Move File B into Stack A
await assetService.reparentAssets({
newParentId: stackA.id,
assetIds: [fileB.id],
creatorId: user.id,
})
// Verify: File B's symlink was deleted, only Stack A's symlink remains
expect(await prisma.asset.findUnique({ where: { id: symlinkFileB.id } })).toBeNull()
const remainingSymlinks = await prisma.asset.findMany({
where: { parentId: shareRoot.id, type: AssetType.symlink },
})
expect(remainingSymlinks).toHaveLength(1)
expect(remainingSymlinks[0].id).toBe(symlinkStackA.id)
expect(remainingSymlinks[0].targetId).toBe(stackA.id)
// ShareRoot fileCount was decremented from 2 to 1
const updatedShareRoot = await prisma.asset.findUnique({ where: { id: shareRoot.id } })
expect(updatedShareRoot?.fileCount).toBe(1)
})
it('repoints symlink to Stack A when only File B is in sharelink and File B is moved into Stack A', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const user = await prisma.user.create({
data: { name: 'Test User', email: `test-${Date.now()}@example.com` },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const shareRoot = await prisma.asset.create({
data: {
name: 'ShareRoot',
type: AssetType.share_root,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 1,
},
})
const fileA1 = await prisma.asset.create({
data: {
name: 'fileA1.txt',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 100,
sortIndex: 'a0',
},
})
const stackA = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 1,
sizeByte: 100,
},
})
await prisma.asset.update({ where: { id: fileA1.id }, data: { parentId: stackA.id } })
const fileB = await prisma.asset.create({
data: {
name: 'fileB.txt',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 200,
sortIndex: 'a1',
},
})
// Create symlink for File B only
const symlinkFileB = await prisma.asset.create({
data: {
name: fileB.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: fileB.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
// Move File B into Stack A
await assetService.reparentAssets({
newParentId: stackA.id,
assetIds: [fileB.id],
creatorId: user.id,
})
// Verify: symlinkFileB now points to stackA.id
const updatedSymlink = await prisma.asset.findUnique({ where: { id: symlinkFileB.id } })
expect(updatedSymlink?.targetId).toBe(stackA.id)
// Listing assets for shareRoot returns Stack A with latest version name
const result = await assetService.listChildren({
assetId: shareRoot.id,
assetType: AssetType.file,
})
expect(result.data).toHaveLength(1)
expect(result.data[0].name).toBe(fileB.name) // fileB is the latest version
})
})
describe('updateAssetName', () => {
it('renames the latest version child file and returns updated AssetInfo when given a version stack ID', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const stack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 2,
sizeByte: 300,
},
})
const fileV1 = await prisma.asset.create({
data: {
name: 'v1.mp4',
type: AssetType.file,
parentId: stack.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 100,
sortIndex: 'b0',
},
})
const fileV2 = await prisma.asset.create({
data: {
name: 'v2.mp4',
type: AssetType.file,
parentId: stack.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 200,
sortIndex: 'a0', // latest version
},
})
const updated = await assetService.updateAssetName({
id: stack.id,
name: 'v2-renamed.mp4',
})
expect(updated.id).toBe(stack.id)
expect(updated.name).toBe('v2-renamed.mp4')
expect(updated.versionStack?.versions[0]?.name).toBe('v2-renamed.mp4')
const dbFileV2 = await prisma.asset.findUnique({ where: { id: fileV2.id } })
expect(dbFileV2?.name).toBe('v2-renamed.mp4')
const dbFileV1 = await prisma.asset.findUnique({ where: { id: fileV1.id } })
expect(dbFileV1?.name).toBe('v1.mp4')
const dbStack = await prisma.asset.findUnique({ where: { id: stack.id } })
expect(dbStack?.name).toBe('')
})
it('preserves the renamed filename when a version stack dissolves', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const stack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 2,
sizeByte: 300,
sortIndex: 's0',
},
})
const fileV1 = await prisma.asset.create({
data: {
name: 'v1.mp4',
type: AssetType.file,
parentId: stack.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 100,
sortIndex: 'b0',
},
})
const fileV2 = await prisma.asset.create({
data: {
name: 'v2.mp4',
type: AssetType.file,
parentId: stack.id,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 200,
sortIndex: 'a0',
},
})
await assetService.updateAssetName({
id: stack.id,
name: 'v2-renamed.mp4',
})
// Remove v1 from stack -> stack dissolves and v2 becomes standalone file
const { versionStackService } = await import('../versionStack/versionStack')
await versionStackService.removeVersionFromStack({
stackId: stack.id,
fileId: fileV1.id,
})
const remainingFile = await prisma.asset.findUnique({ where: { id: fileV2.id } })
expect(remainingFile?.parentId).toBe(rootFolder.id)
expect(remainingFile?.name).toBe('v2-renamed.mp4')
})
it('throws an error if version stack has no active versions to rename', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const emptyStack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await expect(
assetService.updateAssetName({
id: emptyStack.id,
name: 'new-name.mp4',
}),
).rejects.toThrow('No active version found in stack to rename')
})
it('renames a regular file and folder correctly', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const folder = await prisma.asset.create({
data: {
name: 'Original Folder',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const file = await prisma.asset.create({
data: {
name: 'original.png',
type: AssetType.file,
parentId: folder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const updatedFolder = await assetService.updateAssetName({
id: folder.id,
name: 'Renamed Folder',
})
expect(updatedFolder.name).toBe('Renamed Folder')
const updatedFile = await assetService.updateAssetName({
id: file.id,
name: 'renamed.png',
})
expect(updatedFile.name).toBe('renamed.png')
})
})
})
+182 -6
View File
@@ -22,6 +22,7 @@ import { HTTPException } from 'hono/http-exception'
import { logger } from '@shumai/core/src/logger'
import { PaginatedData, paginateQuery, PaginationParams } from '@shumai/core/src/pagination'
import { s3Service } from '@shumai/core/src/s3/s3'
import { dedupeSymlinksToTarget } from './symlink'
import { watermarkService } from '@shumai/core/src/watermark/watermark'
import { generateKeyBetween } from 'jittered-fractional-indexing'
import { getAvatarUrl } from '@shumai/core/src/user/avatar'
@@ -160,6 +161,9 @@ export class AssetService {
const count = await tx.asset.count({ where: { parentId: stack.id } })
if (count === 0) {
await tx.asset.deleteMany({
where: { targetId: stack.id, type: AssetType.symlink },
})
if (stack.parentId) {
await tx.asset.update({
where: { id: stack.parentId },
@@ -174,9 +178,14 @@ export class AssetService {
if (!lastChild) return
if (!stack.parentId) throw new Error('Stack has no parent')
await tx.asset.updateMany({
where: { targetId: stack.id, type: AssetType.symlink },
data: { targetId: lastChild.id, name: lastChild.name },
})
await tx.asset.update({
where: { id: lastChild.id },
data: { parentId: stack.parentId, sortIndex: null },
data: { parentId: stack.parentId, sortIndex: stack.sortIndex },
})
await tx.asset.delete({ where: { id: stack.id } })
}
@@ -273,6 +282,14 @@ export class AssetService {
firstSortIndex = newSortIndex
}
if (newParent.type === AssetType.version_stack) {
await dedupeSymlinksToTarget(tx, {
targetIds: req.assetIds,
newTargetId: newParent.id,
name: '',
})
}
const oldParent = await tx.asset.findUnique({
where: { id: oldParentId },
})
@@ -579,6 +596,12 @@ export class AssetService {
},
})
// Update existing symlinks pointing to destFile or sourceAsset
await dedupeSymlinksToTarget(tx, {
targetIds: [destFile.id, sourceAsset.id],
newTargetId: stack.id,
})
const oldParent = await tx.asset.findUnique({ where: { id: oldParentId } })
if (oldParent) {
await this.dissolveStackIfEmpty(tx, oldParent)
@@ -932,9 +955,42 @@ export class AssetService {
}
async updateAssetName(req: UpdateAssetNameRequest): Promise<AssetInfo> {
const asset = await this.prismaClient.asset.update({
const existing = await this.prismaClient.asset.findUnique({
where: { id: req.id },
include: { target: true },
})
if (!existing) throw new Error('Asset not found')
let targetType = existing.type
let targetId = existing.id
if (existing.type === AssetType.symlink && existing.target) {
targetType = existing.target.type
targetId = existing.target.id
}
if (targetType === AssetType.version_stack) {
const latestChild = await this.prismaClient.asset.findFirst({
where: { parentId: targetId, isDeleted: false },
orderBy: { sortIndex: 'asc' },
select: { id: true },
})
if (!latestChild) {
throw new Error('No active version found in stack to rename')
}
await this.prismaClient.asset.update({
where: { id: latestChild.id },
data: { name: req.name },
})
} else {
await this.prismaClient.asset.update({
where: { id: req.id },
data: { name: req.name },
})
}
const asset = await this.prismaClient.asset.findUnique({
where: { id: req.id },
data: { name: req.name },
include: {
creator: true,
metadataValues: true,
@@ -960,6 +1016,8 @@ export class AssetService {
storageKey: true,
},
})
if (!asset) throw new Error('Asset not found')
const infos = await this.toAssetInfos([asset as unknown as AssetWithIncludes])
return infos[0]
}
@@ -1592,6 +1650,15 @@ export class AssetService {
}
}
const agentMdRecords =
assets.length > 0
? await this.prismaClient.assetAgentMd.findMany({
where: { assetId: { in: assets.map((a) => a.id) } },
select: { assetId: true },
})
: []
const hasAgentMdSet = new Set(agentMdRecords.map((r) => r.assetId))
const result: AssetInfo[] = []
for (const a of assets) {
let latestVersion:
@@ -1620,6 +1687,7 @@ export class AssetService {
id: v.id,
name: v.name,
previewUrl: preview?.thumbnailUrl || null,
createdAt: v.createdAt.toISOString(),
creator: v.creator
? {
id: v.creator.id,
@@ -1735,9 +1803,12 @@ export class AssetService {
result.push({
id: a.id,
name:
a.type === AssetType.version_stack && (a.name === '' || !a.name)
a.type === AssetType.version_stack ||
(a.type === AssetType.symlink && a.target?.type === AssetType.version_stack)
? latestVersion.name
: a.name,
: a.type === AssetType.symlink
? a.name || latestVersion.name || a.target?.name || ''
: a.name,
sizeByte: Number(latestVersion.sizeByte),
fileCount: latestVersion.fileCount,
type: a.type,
@@ -1753,6 +1824,7 @@ export class AssetService {
creator,
fieldValues,
sortIndex: a.sortIndex,
hasAgentsMd: hasAgentMdSet.has(a.id),
media: media as unknown as AssetInfo['media'],
versionStack,
})
@@ -1766,7 +1838,8 @@ export class AssetService {
version: number
name: string
previewUrl: string | null
creator: { id: string; name: string | null } | null
createdAt: string
creator: { id: string; name: string | null; image?: string | null } | null
}>
> {
const versions = await this.prismaClient.asset.findMany({
@@ -1787,6 +1860,7 @@ export class AssetService {
version: versions.length - i,
name: v.name,
previewUrl: preview?.thumbnailUrl || null,
createdAt: v.createdAt.toISOString(),
creator: v.creator
? {
id: v.creator.id,
@@ -2164,6 +2238,108 @@ export class AssetService {
completionLastChangedBy,
}
}
async getAgentsMd(assetId: string): Promise<string | null> {
const asset = await this.prismaClient.asset.findUnique({
where: { id: assetId },
select: { type: true },
})
if (!asset) throw new Error('Asset not found')
if (asset.type !== AssetType.folder && asset.type !== AssetType.root) {
throw new Error('AGENTS.md can only be stored on folders')
}
const record = await this.prismaClient.assetAgentMd.findUnique({
where: { assetId },
select: { content: true },
})
return record?.content ?? null
}
async updateAgentsMd(assetId: string, content: string): Promise<{ content: string }> {
const asset = await this.prismaClient.asset.findUnique({
where: { id: assetId },
select: { id: true, type: true },
})
if (!asset) throw new Error('Asset not found')
if (asset.type !== AssetType.folder && asset.type !== AssetType.root) {
throw new Error('AGENTS.md can only be stored on folders')
}
const trimmed = content.trim()
if (trimmed.length === 0) {
await this.prismaClient.assetAgentMd.deleteMany({
where: { assetId },
})
return { content: '' }
}
const record = await this.prismaClient.assetAgentMd.upsert({
where: { assetId },
create: { assetId, content },
update: { content },
select: { content: true },
})
return { content: record.content }
}
async getNestedAgentsMd(assetId: string): Promise<Array<{ path: string; content: string }>> {
let currentId: string | null = assetId
const nodes: Array<{
id: string
name: string
type: AssetType
parentId: string | null
}> = []
while (currentId) {
const node: {
id: string
name: string
type: AssetType
parentId: string | null
} | null = await this.prismaClient.asset.findUnique({
where: { id: currentId },
select: { id: true, name: true, type: true, parentId: true },
})
if (!node) break
nodes.unshift(node)
currentId = node.parentId
}
if (nodes.length === 0) return []
const agentMds = await this.prismaClient.assetAgentMd.findMany({
where: { assetId: { in: nodes.map((n) => n.id) } },
select: { assetId: true, content: true },
})
const agentMdMap = new Map(agentMds.map((m) => [m.assetId, m.content]))
const results: Array<{ path: string; content: string }> = []
let currentFolderPath = ''
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i]
let virtualPath: string
if (node.type === AssetType.root || i === 0) {
currentFolderPath = ''
virtualPath = '/AGENTS.md'
} else {
currentFolderPath = currentFolderPath
? `${currentFolderPath}/${node.name}`
: `/${node.name}`
virtualPath = `${currentFolderPath}/AGENTS.md`
}
const content = agentMdMap.get(node.id)
if (content && content.trim().length > 0) {
results.push({
path: virtualPath,
content: content.trim(),
})
}
}
return results
}
}
export const assetService = new AssetService()
+249
View File
@@ -0,0 +1,249 @@
import { describe, it, expect } from 'vitest'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { AssetType } from '@shumai/db'
import { dedupeSymlinksToTarget } from './symlink'
async function setupShareFolder(projectId: string, fileCount: number) {
const shareRoot = await prisma.asset.create({
data: {
name: 'share-root',
type: AssetType.share_root,
projectId,
status: 'uploaded',
fileCount,
},
})
return shareRoot
}
describe('dedupeSymlinksToTarget', () => {
setupTestDbHooks()
async function setupProject() {
const team = await prisma.team.create({ data: { name: 'Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Project ' + Date.now(), teamId: team.id },
})
const root = await prisma.asset.create({
data: {
name: 'root',
type: AssetType.folder,
projectId: project.id,
status: 'uploaded',
},
})
const fileA = await prisma.asset.create({
data: {
name: 'a.txt',
type: AssetType.file,
parentId: root.id,
projectId: project.id,
status: 'uploaded',
sizeByte: 10,
},
})
const fileB = await prisma.asset.create({
data: {
name: 'b.txt',
type: AssetType.file,
parentId: root.id,
projectId: project.id,
status: 'uploaded',
sizeByte: 20,
},
})
return { project, root, fileA, fileB }
}
it('repoints one symlink per parent and deletes duplicates, decrementing fileCount once', async () => {
const { project, root, fileA, fileB } = await setupProject()
const shareRoot = await setupShareFolder(project.id, 2)
const symA = await prisma.asset.create({
data: {
name: fileA.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: fileA.id,
projectId: project.id,
status: 'uploaded',
},
})
const symB = await prisma.asset.create({
data: {
name: fileB.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: fileB.id,
projectId: project.id,
status: 'uploaded',
},
})
const stack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: root.id,
projectId: project.id,
status: 'uploaded',
fileCount: 2,
sizeByte: 30,
},
})
await prisma.$transaction((tx) =>
dedupeSymlinksToTarget(tx, { targetIds: [fileA.id, fileB.id], newTargetId: stack.id }),
)
// First symlink repointed to the stack, second deleted
const repointed = await prisma.asset.findUnique({ where: { id: symA.id } })
expect(repointed?.targetId).toBe(stack.id)
expect(await prisma.asset.findUnique({ where: { id: symB.id } })).toBeNull()
// fileCount decremented exactly once (2 -> 1)
const updatedShareRoot = await prisma.asset.findUnique({ where: { id: shareRoot.id } })
expect(updatedShareRoot?.fileCount).toBe(1)
})
it('deletes a file symlink when the parent already shows the stack', async () => {
const { project, root, fileA } = await setupProject()
const shareRoot = await setupShareFolder(project.id, 2)
const stack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: root.id,
projectId: project.id,
status: 'uploaded',
fileCount: 1,
sizeByte: 10,
},
})
// Share already contains a symlink to the stack
const stackSymlink = await prisma.asset.create({
data: {
name: '',
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: stack.id,
projectId: project.id,
status: 'uploaded',
},
})
// And a symlink to the file being moved into the stack
const fileSymlink = await prisma.asset.create({
data: {
name: fileA.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: fileA.id,
projectId: project.id,
status: 'uploaded',
},
})
await prisma.$transaction((tx) =>
dedupeSymlinksToTarget(tx, { targetIds: [fileA.id], newTargetId: stack.id }),
)
// File symlink deleted, stack symlink untouched
expect(await prisma.asset.findUnique({ where: { id: fileSymlink.id } })).toBeNull()
const updatedStackSymlink = await prisma.asset.findUnique({ where: { id: stackSymlink.id } })
expect(updatedStackSymlink?.targetId).toBe(stack.id)
// fileCount decremented once (2 -> 1)
const updatedShareRoot = await prisma.asset.findUnique({ where: { id: shareRoot.id } })
expect(updatedShareRoot?.fileCount).toBe(1)
})
it('repoints symlinks in different share folders without changing fileCounts', async () => {
const { project, root, fileA, fileB } = await setupProject()
const share1 = await setupShareFolder(project.id, 1)
const share2 = await setupShareFolder(project.id, 1)
const sym1 = await prisma.asset.create({
data: {
name: fileA.name,
type: AssetType.symlink,
parentId: share1.id,
targetId: fileA.id,
projectId: project.id,
status: 'uploaded',
},
})
const sym2 = await prisma.asset.create({
data: {
name: fileB.name,
type: AssetType.symlink,
parentId: share2.id,
targetId: fileB.id,
projectId: project.id,
status: 'uploaded',
},
})
const stack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: root.id,
projectId: project.id,
status: 'uploaded',
fileCount: 2,
sizeByte: 30,
},
})
await prisma.$transaction((tx) =>
dedupeSymlinksToTarget(tx, { targetIds: [fileA.id, fileB.id], newTargetId: stack.id }),
)
expect((await prisma.asset.findUnique({ where: { id: sym1.id } }))?.targetId).toBe(stack.id)
expect((await prisma.asset.findUnique({ where: { id: sym2.id } }))?.targetId).toBe(stack.id)
expect((await prisma.asset.findUnique({ where: { id: share1.id } }))?.fileCount).toBe(1)
expect((await prisma.asset.findUnique({ where: { id: share2.id } }))?.fileCount).toBe(1)
})
it('sets the provided name on repointed symlinks', async () => {
const { project, root, fileA } = await setupProject()
const shareRoot = await setupShareFolder(project.id, 1)
const sym = await prisma.asset.create({
data: {
name: fileA.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: fileA.id,
projectId: project.id,
status: 'uploaded',
},
})
const stack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
parentId: root.id,
projectId: project.id,
status: 'uploaded',
fileCount: 1,
sizeByte: 10,
},
})
await prisma.$transaction((tx) =>
dedupeSymlinksToTarget(tx, {
targetIds: [fileA.id],
newTargetId: stack.id,
name: '',
}),
)
const updatedSym = await prisma.asset.findUnique({ where: { id: sym.id } })
expect(updatedSym?.targetId).toBe(stack.id)
expect(updatedSym?.name).toBe('')
})
})
+58
View File
@@ -0,0 +1,58 @@
import { Prisma } from '@shumai/db'
import { AssetType } from '@shumai/db'
interface DedupeSymlinksParams {
/** Files being merged into a version stack — symlinks pointing at them are the candidates. */
targetIds: string[]
/** The version stack the files are moving into. */
newTargetId: string
/** Optional name to set on repointed symlinks ('' for stacks — display name comes from the latest version). */
name?: string
}
/**
* When files are merged into a version stack, symlinks in share folders that
* pointed at those files must either be repointed to the stack (one per parent)
* or deleted as duplicates. Per parent folder: if the parent already shows the
* stack (either before this call or after the first repoint), delete the
* incoming symlink and decrement the parent's fileCount; otherwise repoint the
* first symlink to the stack.
*/
export async function dedupeSymlinksToTarget(
tx: Prisma.TransactionClient,
{ targetIds, newTargetId, name }: DedupeSymlinksParams,
): Promise<void> {
const existingSymlinks = await tx.asset.findMany({
where: { targetId: { in: targetIds }, type: AssetType.symlink },
})
if (existingSymlinks.length === 0) return
// Parents that already display the stack (or will after the first repoint).
const stackSymlinkParents = new Set(
(
await tx.asset.findMany({
where: { targetId: newTargetId, type: AssetType.symlink },
select: { parentId: true },
})
)
.map((s) => s.parentId)
.filter((id): id is string => !!id),
)
for (const symlink of existingSymlinks) {
if (!symlink.parentId) continue
if (stackSymlinkParents.has(symlink.parentId)) {
await tx.asset.delete({ where: { id: symlink.id } })
await tx.asset.update({
where: { id: symlink.parentId },
data: { fileCount: { decrement: 1 } },
})
} else {
stackSymlinkParents.add(symlink.parentId)
await tx.asset.update({
where: { id: symlink.id },
data: { targetId: newTargetId, ...(name !== undefined ? { name } : {}) },
})
}
}
}
@@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach } from 'vitest'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { VersionStackService } from './versionStack'
import { assetService } from '../asset/asset'
import { AssetType } from '@shumai/db'
describe('VersionStackService', () => {
@@ -207,4 +208,299 @@ describe('VersionStackService', () => {
expect(children.map((c) => c.id).includes(file3.id)).toBe(true)
})
})
describe('removeVersionFromStack', () => {
it('removes a version from a 3-version stack and turns it into a standalone file adjacent to the stack', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team' } })
const proj = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const user = await prisma.user.create({
data: { name: 'Test User', email: `test-${Date.now()}@example.com` },
})
const root = await prisma.asset.create({
data: {
name: 'root',
type: AssetType.folder,
status: 'uploaded',
projectId: proj.id,
creatorId: user.id,
},
})
const parent = await prisma.asset.create({
data: {
name: 'Parent Folder',
type: AssetType.folder,
projectId: proj.id,
parentId: root.id,
creatorId: user.id,
status: 'uploaded',
fileCount: 3,
},
})
const file1 = await prisma.asset.create({
data: {
name: 'file1.txt',
type: AssetType.file,
parentId: parent.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
sizeByte: 100,
sortIndex: 'a0',
},
})
const file2 = await prisma.asset.create({
data: {
name: 'file2.txt',
type: AssetType.file,
parentId: parent.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
sizeByte: 200,
},
})
const file3 = await prisma.asset.create({
data: {
name: 'file3.txt',
type: AssetType.file,
parentId: parent.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
sizeByte: 300,
},
})
const stack = await service.createVersionStack({
fileIds: [file1.id, file2.id, file3.id],
projectId: proj.id,
creatorId: user.id,
})
// Stack should have 3 versions
expect(stack.fileCount).toBe(3)
expect(Number(stack.sizeByte)).toBe(600)
// Parent fileCount should be 1 (the stack)
const parentBefore = await prisma.asset.findUnique({ where: { id: parent.id } })
expect(parentBefore?.fileCount).toBe(1)
// Remove file2 from stack
await service.removeVersionFromStack({
stackId: stack.id,
fileId: file2.id,
})
// File2 should now be in parent folder
const updatedFile2 = await prisma.asset.findUnique({ where: { id: file2.id } })
expect(updatedFile2?.parentId).toBe(parent.id)
expect(updatedFile2?.sortIndex).toBeDefined()
expect(updatedFile2!.sortIndex! > stack.sortIndex!).toBe(true)
// Parent fileCount should be 2 (stack + file2)
const updatedParent = await prisma.asset.findUnique({ where: { id: parent.id } })
expect(updatedParent?.fileCount).toBe(2)
// Stack should still exist with 2 versions (file1 and file3)
const updatedStack = await prisma.asset.findUnique({ where: { id: stack.id } })
expect(updatedStack).toBeDefined()
expect(updatedStack?.fileCount).toBe(2)
expect(Number(updatedStack?.sizeByte)).toBe(400)
const remainingChildren = await prisma.asset.findMany({
where: { parentId: stack.id },
})
expect(remainingChildren).toHaveLength(2)
expect(remainingChildren.map((c) => c.id).sort()).toEqual([file1.id, file3.id].sort())
})
it('dissolves the version stack when removing down to 1 remaining version', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team' } })
const proj = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const user = await prisma.user.create({
data: { name: 'Test User', email: `test-${Date.now()}@example.com` },
})
const root = await prisma.asset.create({
data: {
name: 'root',
type: AssetType.folder,
status: 'uploaded',
projectId: proj.id,
creatorId: user.id,
},
})
const parent = await prisma.asset.create({
data: {
name: 'Parent Folder',
type: AssetType.folder,
projectId: proj.id,
parentId: root.id,
creatorId: user.id,
status: 'uploaded',
fileCount: 2,
},
})
const file1 = await prisma.asset.create({
data: {
name: 'file1.txt',
type: AssetType.file,
parentId: parent.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
sizeByte: 100,
sortIndex: 'a0',
},
})
const file2 = await prisma.asset.create({
data: {
name: 'file2.txt',
type: AssetType.file,
parentId: parent.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
sizeByte: 200,
},
})
const stack = await service.createVersionStack({
fileIds: [file1.id, file2.id],
projectId: proj.id,
creatorId: user.id,
})
// Remove file2 from stack
await service.removeVersionFromStack({
stackId: stack.id,
fileId: file2.id,
})
// Stack asset should be deleted
const deletedStack = await prisma.asset.findUnique({ where: { id: stack.id } })
expect(deletedStack).toBeNull()
// File1 should now be in parent folder and inherited stack's sortIndex
const updatedFile1 = await prisma.asset.findUnique({ where: { id: file1.id } })
expect(updatedFile1?.parentId).toBe(parent.id)
expect(updatedFile1?.sortIndex).toBe('a0')
// File2 should also be in parent folder
const updatedFile2 = await prisma.asset.findUnique({ where: { id: file2.id } })
expect(updatedFile2?.parentId).toBe(parent.id)
// Parent fileCount should be 2
const updatedParent = await prisma.asset.findUnique({ where: { id: parent.id } })
expect(updatedParent?.fileCount).toBe(2)
})
it('updates share link symlinks when normal asset becomes version stack and when stack dissolves back to normal asset', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team' } })
const proj = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const user = await prisma.user.create({
data: { name: 'Test User', email: `test-${Date.now()}@example.com` },
})
const root = await prisma.asset.create({
data: {
name: 'root',
type: AssetType.folder,
status: 'uploaded',
projectId: proj.id,
creatorId: user.id,
},
})
const shareRoot = await prisma.asset.create({
data: {
name: 'share-root',
type: AssetType.share_root,
status: 'uploaded',
projectId: proj.id,
creatorId: user.id,
fileCount: 0,
},
})
const shareLink = await prisma.shareLink.create({
data: {
name: 'My Share',
projectId: proj.id,
rootFolderId: shareRoot.id,
creatorId: user.id,
},
})
const file1 = await prisma.asset.create({
data: {
name: 'file1.txt',
type: AssetType.file,
parentId: root.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
sizeByte: 100,
},
})
const file2 = await prisma.asset.create({
data: {
name: 'file2.txt',
type: AssetType.file,
parentId: root.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
sizeByte: 200,
},
})
// Add file1 to share link (create symlink)
const symlink = await prisma.asset.create({
data: {
name: file1.name,
type: AssetType.symlink,
parentId: shareLink.rootFolderId,
targetId: file1.id,
projectId: proj.id,
creatorId: user.id,
status: 'uploaded',
},
})
// 1. Group file1 and file2 into a version stack
const stack = await service.createVersionStack({
fileIds: [file1.id, file2.id],
projectId: proj.id,
creatorId: user.id,
})
// Symlink in share link should now point to stack.id
const symlinkAfterStack = await prisma.asset.findUnique({ where: { id: symlink.id } })
expect(symlinkAfterStack?.targetId).toBe(stack.id)
// 2. Remove file2 from stack -> stack dissolves -> only file1 remains
await service.removeVersionFromStack({
stackId: stack.id,
fileId: file2.id,
})
// Symlink in share link should now point directly to file1.id and have file1's name
const symlinkAfterDissolve = await prisma.asset.findUnique({ where: { id: symlink.id } })
expect(symlinkAfterDissolve?.targetId).toBe(file1.id)
expect(symlinkAfterDissolve?.name).toBe(file1.name)
// Listing share link files returns file1 with correct name
const shareFiles = await assetService.listChildren({
assetId: shareLink.rootFolderId,
assetType: AssetType.file,
})
expect(shareFiles.data).toHaveLength(1)
expect(shareFiles.data[0].name).toBe(file1.name)
})
})
})
+128 -2
View File
@@ -1,7 +1,12 @@
import { generateKeyBetween } from 'jittered-fractional-indexing'
import { prisma } from '@shumai/db'
import { type Asset, AssetType } from '@shumai/db'
import { ChangeStackFileVersionParams, CreateVersionStackParams } from '@shumai/dtos'
import {
ChangeStackFileVersionParams,
CreateVersionStackParams,
RemoveStackVersionParams,
} from '@shumai/dtos'
import { dedupeSymlinksToTarget } from '../asset/symlink'
function generateSortIndex(previous?: string | null): string {
if (!previous) return generateKeyBetween(null, null)
@@ -95,6 +100,9 @@ export class VersionStackService {
},
})
// Update existing symlinks pointing to any of the stacked files
await dedupeSymlinksToTarget(tx, { targetIds: fileIds, newTargetId: stack.id })
return stack
})
}
@@ -127,7 +135,7 @@ export class VersionStackService {
if (beforeId === '-1') {
const lastFile = await tx.asset.findFirst({
where: { parentId: stackId },
where: { parentId: stackId, id: { not: fileId } },
orderBy: { sortIndex: 'desc' },
})
newSortIndex = generateKeyBetween(lastFile?.sortIndex || null, null)
@@ -145,6 +153,7 @@ export class VersionStackService {
const prevFile = await tx.asset.findFirst({
where: {
parentId: stackId,
id: { not: fileId },
sortIndex: {
lt: beforeFile.sortIndex!,
},
@@ -168,6 +177,123 @@ export class VersionStackService {
})
})
}
async removeVersionFromStack(params: RemoveStackVersionParams): Promise<void> {
const { stackId, fileId } = params
await this.prismaClient.$transaction(async (tx) => {
const stack = await tx.asset.findUnique({
where: { id: stackId },
})
if (!stack) {
throw new Error('stack not found')
}
if (stack.type !== AssetType.version_stack) {
throw new Error('asset is not a version stack')
}
if (!stack.parentId) {
throw new Error('stack has no parent')
}
const fileToRemove = await tx.asset.findUnique({
where: { id: fileId },
})
if (!fileToRemove) {
throw new Error('file not found')
}
if (fileToRemove.parentId !== stackId) {
throw new Error('file is not in the stack')
}
// Find next sibling in parent folder after the stack to insert the removed file adjacent to the stack
const nextSibling = await tx.asset.findFirst({
where: {
parentId: stack.parentId,
id: { not: stack.id },
sortIndex: {
gt: stack.sortIndex || '',
},
},
orderBy: { sortIndex: 'asc' },
})
let newSortIndex: string
try {
newSortIndex = generateKeyBetween(stack.sortIndex || null, nextSibling?.sortIndex || null)
} catch {
newSortIndex = generateKeyBetween(null, null)
}
await tx.asset.update({
where: { id: fileId },
data: {
parentId: stack.parentId,
sortIndex: newSortIndex,
},
})
// Increment parent folder fileCount for the newly standalone file
await tx.asset.update({
where: { id: stack.parentId },
data: {
fileCount: { increment: 1 },
},
})
// Remaining files in stack
const remainingFiles = await tx.asset.findMany({
where: { parentId: stackId, isDeleted: false, id: { not: fileId } },
orderBy: { sortIndex: 'asc' },
})
if (remainingFiles.length > 1) {
let totalSize = 0
for (const f of remainingFiles) {
totalSize += Number(f.sizeByte)
}
await tx.asset.update({
where: { id: stack.id },
data: {
fileCount: remainingFiles.length,
sizeByte: totalSize,
},
})
} else if (remainingFiles.length === 1) {
const lastChild = remainingFiles[0]
// Update symlinks pointing to stack.id to point to the single remaining child
await tx.asset.updateMany({
where: { targetId: stack.id, type: AssetType.symlink },
data: { targetId: lastChild.id, name: lastChild.name },
})
// Reparent the single remaining child to stack.parentId, keeping stack's sortIndex
await tx.asset.update({
where: { id: lastChild.id },
data: {
parentId: stack.parentId,
sortIndex: stack.sortIndex,
},
})
// Delete the stack asset (parent folder file count is unchanged: -1 stack, +1 remaining child)
await tx.asset.delete({
where: { id: stack.id },
})
} else {
await tx.asset.deleteMany({
where: { targetId: stack.id, type: AssetType.symlink },
})
await tx.asset.delete({
where: { id: stack.id },
})
await tx.asset.update({
where: { id: stack.parentId },
data: { fileCount: { decrement: 1 } },
})
}
})
}
}
export const versionStackService = new VersionStackService()
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/db",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./src/index.ts",
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "assets" ADD COLUMN "agentmd" TEXT;
@@ -0,0 +1,21 @@
/*
Warnings:
- You are about to drop the column `agentmd` on the `assets` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "assets" DROP COLUMN "agentmd";
-- CreateTable
CREATE TABLE "asset_agentmd" (
"asset_id" TEXT NOT NULL,
"content" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "asset_agentmd_pkey" PRIMARY KEY ("asset_id")
);
-- AddForeignKey
ALTER TABLE "asset_agentmd" ADD CONSTRAINT "asset_agentmd_asset_id_fkey" FOREIGN KEY ("asset_id") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+12
View File
@@ -490,6 +490,7 @@ model Asset {
shareLinkRootFolder ShareLink? @relation("ShareLinkToRootFolder")
agentSessions AgentSession[] @relation("AssetToAgentSession")
watermarkFiles WatermarkFile[] @relation("AssetToWatermarkFile")
agentMd AssetAgentMd? @relation("AssetToAgentMd")
@@map("assets")
@@index([type])
@@ -537,6 +538,17 @@ model AssetMetadataValue {
@@map("asset_metadata_values")
}
model AssetAgentMd {
assetId String @id @map("asset_id")
content String @db.Text
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
asset Asset @relation("AssetToAgentMd", fields: [assetId], references: [id], onDelete: Cascade)
@@map("asset_agentmd")
}
model AssetComment {
id String @id @default(ulid())
message String?
+5
View File
@@ -107,6 +107,11 @@ export type StorageKey = Prisma.StorageKeyModel
*
*/
export type AssetMetadataValue = Prisma.AssetMetadataValueModel
/**
* Model AssetAgentMd
*
*/
export type AssetAgentMd = Prisma.AssetAgentMdModel
/**
* Model AssetComment
*
+5
View File
@@ -131,6 +131,11 @@ export type StorageKey = Prisma.StorageKeyModel
*
*/
export type AssetMetadataValue = Prisma.AssetMetadataValueModel
/**
* Model AssetAgentMd
*
*/
export type AssetAgentMd = Prisma.AssetAgentMdModel
/**
* Model AssetComment
*
File diff suppressed because one or more lines are too long
+87 -1
View File
@@ -402,6 +402,7 @@ export const ModelName = {
Asset: 'Asset',
StorageKey: 'StorageKey',
AssetMetadataValue: 'AssetMetadataValue',
AssetAgentMd: 'AssetAgentMd',
AssetComment: 'AssetComment',
AssetCommentAttachment: 'AssetCommentAttachment',
AssetEmbedding: 'AssetEmbedding',
@@ -440,7 +441,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
omit: GlobalOmitOptions
}
meta: {
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog"
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog"
txIsolationLevel: TransactionIsolationLevel
}
model: {
@@ -1776,6 +1777,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
}
}
}
AssetAgentMd: {
payload: Prisma.$AssetAgentMdPayload<ExtArgs>
fields: Prisma.AssetAgentMdFieldRefs
operations: {
findUnique: {
args: Prisma.AssetAgentMdFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload> | null
}
findUniqueOrThrow: {
args: Prisma.AssetAgentMdFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>
}
findFirst: {
args: Prisma.AssetAgentMdFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload> | null
}
findFirstOrThrow: {
args: Prisma.AssetAgentMdFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>
}
findMany: {
args: Prisma.AssetAgentMdFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>[]
}
create: {
args: Prisma.AssetAgentMdCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>
}
createMany: {
args: Prisma.AssetAgentMdCreateManyArgs<ExtArgs>
result: BatchPayload
}
createManyAndReturn: {
args: Prisma.AssetAgentMdCreateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>[]
}
delete: {
args: Prisma.AssetAgentMdDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>
}
update: {
args: Prisma.AssetAgentMdUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>
}
deleteMany: {
args: Prisma.AssetAgentMdDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.AssetAgentMdUpdateManyArgs<ExtArgs>
result: BatchPayload
}
updateManyAndReturn: {
args: Prisma.AssetAgentMdUpdateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>[]
}
upsert: {
args: Prisma.AssetAgentMdUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetAgentMdPayload>
}
aggregate: {
args: Prisma.AssetAgentMdAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateAssetAgentMd>
}
groupBy: {
args: Prisma.AssetAgentMdGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AssetAgentMdGroupByOutputType>[]
}
count: {
args: Prisma.AssetAgentMdCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AssetAgentMdCountAggregateOutputType> | number
}
}
}
AssetComment: {
payload: Prisma.$AssetCommentPayload<ExtArgs>
fields: Prisma.AssetCommentFieldRefs
@@ -3780,6 +3855,16 @@ export const AssetMetadataValueScalarFieldEnum = {
export type AssetMetadataValueScalarFieldEnum = (typeof AssetMetadataValueScalarFieldEnum)[keyof typeof AssetMetadataValueScalarFieldEnum]
export const AssetAgentMdScalarFieldEnum = {
assetId: 'assetId',
content: 'content',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
export type AssetAgentMdScalarFieldEnum = (typeof AssetAgentMdScalarFieldEnum)[keyof typeof AssetAgentMdScalarFieldEnum]
export const AssetCommentScalarFieldEnum = {
id: 'id',
message: 'message',
@@ -4652,6 +4737,7 @@ export type GlobalOmitConfig = {
asset?: Prisma.AssetOmit
storageKey?: Prisma.StorageKeyOmit
assetMetadataValue?: Prisma.AssetMetadataValueOmit
assetAgentMd?: Prisma.AssetAgentMdOmit
assetComment?: Prisma.AssetCommentOmit
assetCommentAttachment?: Prisma.AssetCommentAttachmentOmit
assetEmbedding?: Prisma.AssetEmbeddingOmit
@@ -69,6 +69,7 @@ export const ModelName = {
Asset: 'Asset',
StorageKey: 'StorageKey',
AssetMetadataValue: 'AssetMetadataValue',
AssetAgentMd: 'AssetAgentMd',
AssetComment: 'AssetComment',
AssetCommentAttachment: 'AssetCommentAttachment',
AssetEmbedding: 'AssetEmbedding',
@@ -373,6 +374,16 @@ export const AssetMetadataValueScalarFieldEnum = {
export type AssetMetadataValueScalarFieldEnum = (typeof AssetMetadataValueScalarFieldEnum)[keyof typeof AssetMetadataValueScalarFieldEnum]
export const AssetAgentMdScalarFieldEnum = {
assetId: 'assetId',
content: 'content',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
export type AssetAgentMdScalarFieldEnum = (typeof AssetAgentMdScalarFieldEnum)[keyof typeof AssetAgentMdScalarFieldEnum]
export const AssetCommentScalarFieldEnum = {
id: 'id',
message: 'message',
+1
View File
@@ -26,6 +26,7 @@ export type * from './models/WatermarkFile.ts'
export type * from './models/Asset.ts'
export type * from './models/StorageKey.ts'
export type * from './models/AssetMetadataValue.ts'
export type * from './models/AssetAgentMd.ts'
export type * from './models/AssetComment.ts'
export type * from './models/AssetCommentAttachment.ts'
export type * from './models/AssetEmbedding.ts'
+284
View File
@@ -361,6 +361,7 @@ export type AssetWhereInput = {
shareLinkRootFolder?: Prisma.XOR<Prisma.ShareLinkNullableScalarRelationFilter, Prisma.ShareLinkWhereInput> | null
agentSessions?: Prisma.AgentSessionListRelationFilter
watermarkFiles?: Prisma.WatermarkFileListRelationFilter
agentMd?: Prisma.XOR<Prisma.AssetAgentMdNullableScalarRelationFilter, Prisma.AssetAgentMdWhereInput> | null
}
export type AssetOrderByWithRelationInput = {
@@ -404,6 +405,7 @@ export type AssetOrderByWithRelationInput = {
shareLinkRootFolder?: Prisma.ShareLinkOrderByWithRelationInput
agentSessions?: Prisma.AgentSessionOrderByRelationAggregateInput
watermarkFiles?: Prisma.WatermarkFileOrderByRelationAggregateInput
agentMd?: Prisma.AssetAgentMdOrderByWithRelationInput
}
export type AssetWhereUniqueInput = Prisma.AtLeast<{
@@ -451,6 +453,7 @@ export type AssetWhereUniqueInput = Prisma.AtLeast<{
shareLinkRootFolder?: Prisma.XOR<Prisma.ShareLinkNullableScalarRelationFilter, Prisma.ShareLinkWhereInput> | null
agentSessions?: Prisma.AgentSessionListRelationFilter
watermarkFiles?: Prisma.WatermarkFileListRelationFilter
agentMd?: Prisma.XOR<Prisma.AssetAgentMdNullableScalarRelationFilter, Prisma.AssetAgentMdWhereInput> | null
}, "id" | "parentIdTargetId">
export type AssetOrderByWithAggregationInput = {
@@ -544,6 +547,7 @@ export type AssetCreateInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateInput = {
@@ -581,6 +585,7 @@ export type AssetUncheckedCreateInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetUpdateInput = {
@@ -618,6 +623,7 @@ export type AssetUpdateInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateInput = {
@@ -655,6 +661,7 @@ export type AssetUncheckedUpdateInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateManyInput = {
@@ -1191,6 +1198,20 @@ export type AssetUpdateOneRequiredWithoutMetadataValuesNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetUpdateToOneWithWhereWithoutMetadataValuesInput, Prisma.AssetUpdateWithoutMetadataValuesInput>, Prisma.AssetUncheckedUpdateWithoutMetadataValuesInput>
}
export type AssetCreateNestedOneWithoutAgentMdInput = {
create?: Prisma.XOR<Prisma.AssetCreateWithoutAgentMdInput, Prisma.AssetUncheckedCreateWithoutAgentMdInput>
connectOrCreate?: Prisma.AssetCreateOrConnectWithoutAgentMdInput
connect?: Prisma.AssetWhereUniqueInput
}
export type AssetUpdateOneRequiredWithoutAgentMdNestedInput = {
create?: Prisma.XOR<Prisma.AssetCreateWithoutAgentMdInput, Prisma.AssetUncheckedCreateWithoutAgentMdInput>
connectOrCreate?: Prisma.AssetCreateOrConnectWithoutAgentMdInput
upsert?: Prisma.AssetUpsertWithoutAgentMdInput
connect?: Prisma.AssetWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetUpdateToOneWithWhereWithoutAgentMdInput, Prisma.AssetUpdateWithoutAgentMdInput>, Prisma.AssetUncheckedUpdateWithoutAgentMdInput>
}
export type AssetCreateNestedOneWithoutCommentsInput = {
create?: Prisma.XOR<Prisma.AssetCreateWithoutCommentsInput, Prisma.AssetUncheckedCreateWithoutCommentsInput>
connectOrCreate?: Prisma.AssetCreateOrConnectWithoutCommentsInput
@@ -1341,6 +1362,7 @@ export type AssetCreateWithoutCreatorInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutCreatorInput = {
@@ -1377,6 +1399,7 @@ export type AssetUncheckedCreateWithoutCreatorInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutCreatorInput = {
@@ -1466,6 +1489,7 @@ export type AssetCreateWithoutTeamRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutTeamRootFolderInput = {
@@ -1502,6 +1526,7 @@ export type AssetUncheckedCreateWithoutTeamRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutTeamRootFolderInput = {
@@ -1554,6 +1579,7 @@ export type AssetUpdateWithoutTeamRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutTeamRootFolderInput = {
@@ -1590,6 +1616,7 @@ export type AssetUncheckedUpdateWithoutTeamRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutProjectRootFolderInput = {
@@ -1626,6 +1653,7 @@ export type AssetCreateWithoutProjectRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutProjectRootFolderInput = {
@@ -1662,6 +1690,7 @@ export type AssetUncheckedCreateWithoutProjectRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutProjectRootFolderInput = {
@@ -1703,6 +1732,7 @@ export type AssetCreateWithoutProjectShareRootInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutProjectShareRootInput = {
@@ -1739,6 +1769,7 @@ export type AssetUncheckedCreateWithoutProjectShareRootInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutProjectShareRootInput = {
@@ -1780,6 +1811,7 @@ export type AssetCreateWithoutProjectInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutProjectInput = {
@@ -1816,6 +1848,7 @@ export type AssetUncheckedCreateWithoutProjectInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutProjectInput = {
@@ -1873,6 +1906,7 @@ export type AssetUpdateWithoutProjectRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutProjectRootFolderInput = {
@@ -1909,6 +1943,7 @@ export type AssetUncheckedUpdateWithoutProjectRootFolderInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUpsertWithoutProjectShareRootInput = {
@@ -1956,6 +1991,7 @@ export type AssetUpdateWithoutProjectShareRootInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutProjectShareRootInput = {
@@ -1992,6 +2028,7 @@ export type AssetUncheckedUpdateWithoutProjectShareRootInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUpsertWithWhereUniqueWithoutProjectInput = {
@@ -2044,6 +2081,7 @@ export type AssetCreateWithoutShareLinkRootFolderInput = {
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutShareLinkRootFolderInput = {
@@ -2080,6 +2118,7 @@ export type AssetUncheckedCreateWithoutShareLinkRootFolderInput = {
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutShareLinkRootFolderInput = {
@@ -2132,6 +2171,7 @@ export type AssetUpdateWithoutShareLinkRootFolderInput = {
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutShareLinkRootFolderInput = {
@@ -2168,6 +2208,7 @@ export type AssetUncheckedUpdateWithoutShareLinkRootFolderInput = {
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutWatermarkFilesInput = {
@@ -2204,6 +2245,7 @@ export type AssetCreateWithoutWatermarkFilesInput = {
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutWatermarkFilesInput = {
@@ -2240,6 +2282,7 @@ export type AssetUncheckedCreateWithoutWatermarkFilesInput = {
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutWatermarkFilesInput = {
@@ -2292,6 +2335,7 @@ export type AssetUpdateWithoutWatermarkFilesInput = {
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutWatermarkFilesInput = {
@@ -2328,6 +2372,7 @@ export type AssetUncheckedUpdateWithoutWatermarkFilesInput = {
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutChildrenInput = {
@@ -2364,6 +2409,7 @@ export type AssetCreateWithoutChildrenInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutChildrenInput = {
@@ -2400,6 +2446,7 @@ export type AssetUncheckedCreateWithoutChildrenInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutChildrenInput = {
@@ -2441,6 +2488,7 @@ export type AssetCreateWithoutParentInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutParentInput = {
@@ -2477,6 +2525,7 @@ export type AssetUncheckedCreateWithoutParentInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutParentInput = {
@@ -2523,6 +2572,7 @@ export type AssetCreateWithoutSymlinksInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutSymlinksInput = {
@@ -2559,6 +2609,7 @@ export type AssetUncheckedCreateWithoutSymlinksInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutSymlinksInput = {
@@ -2600,6 +2651,7 @@ export type AssetCreateWithoutTargetInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutTargetInput = {
@@ -2636,6 +2688,7 @@ export type AssetUncheckedCreateWithoutTargetInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutTargetInput = {
@@ -2693,6 +2746,7 @@ export type AssetUpdateWithoutChildrenInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutChildrenInput = {
@@ -2729,6 +2783,7 @@ export type AssetUncheckedUpdateWithoutChildrenInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUpsertWithWhereUniqueWithoutParentInput = {
@@ -2792,6 +2847,7 @@ export type AssetUpdateWithoutSymlinksInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutSymlinksInput = {
@@ -2828,6 +2884,7 @@ export type AssetUncheckedUpdateWithoutSymlinksInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUpsertWithWhereUniqueWithoutTargetInput = {
@@ -2880,6 +2937,7 @@ export type AssetCreateWithoutStorageKeyInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutStorageKeyInput = {
@@ -2916,6 +2974,7 @@ export type AssetUncheckedCreateWithoutStorageKeyInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutStorageKeyInput = {
@@ -2978,6 +3037,7 @@ export type AssetCreateWithoutMetadataValuesInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutMetadataValuesInput = {
@@ -3014,6 +3074,7 @@ export type AssetUncheckedCreateWithoutMetadataValuesInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutMetadataValuesInput = {
@@ -3066,6 +3127,7 @@ export type AssetUpdateWithoutMetadataValuesInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutMetadataValuesInput = {
@@ -3102,6 +3164,171 @@ export type AssetUncheckedUpdateWithoutMetadataValuesInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutAgentMdInput = {
id?: string
name?: string
nameNgram?: Prisma.AssetCreatenameNgramInput | string[]
type: $Enums.AssetType
mediaType?: string | null
fileCount?: number
sizeByte?: bigint | number
status: $Enums.AssetStatus
transcodeTaskId?: string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: boolean
deletedAt?: Date | string | null
sortIndex?: string | null
createdAt?: Date | string
updatedAt?: Date | string
parent?: Prisma.AssetCreateNestedOneWithoutChildrenInput
children?: Prisma.AssetCreateNestedManyWithoutParentInput
target?: Prisma.AssetCreateNestedOneWithoutSymlinksInput
symlinks?: Prisma.AssetCreateNestedManyWithoutTargetInput
storageKey?: Prisma.StorageKeyCreateNestedOneWithoutAssetsInput
metadataValues?: Prisma.AssetMetadataValueCreateNestedManyWithoutAssetInput
creator?: Prisma.UserCreateNestedOneWithoutAssetsInput
task?: Prisma.TaskCreateNestedOneWithoutAssetsInput
project?: Prisma.ProjectCreateNestedOneWithoutAssetsInput
comments?: Prisma.AssetCommentCreateNestedManyWithoutAssetInput
commentAttachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutAssetInput
notifications?: Prisma.NotificationCreateNestedManyWithoutAssetInput
embeddings?: Prisma.AssetEmbeddingCreateNestedManyWithoutAssetInput
teamRootFolder?: Prisma.TeamCreateNestedOneWithoutRootFolderInput
projectRootFolder?: Prisma.ProjectCreateNestedOneWithoutRootFolderInput
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutAgentMdInput = {
id?: string
name?: string
nameNgram?: Prisma.AssetCreatenameNgramInput | string[]
type: $Enums.AssetType
mediaType?: string | null
fileCount?: number
sizeByte?: bigint | number
status: $Enums.AssetStatus
transcodeTaskId?: string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: boolean
deletedAt?: Date | string | null
sortIndex?: string | null
createdAt?: Date | string
updatedAt?: Date | string
parentId?: string | null
targetId?: string | null
storageKeyId?: string | null
creatorId?: string | null
taskId?: string | null
projectId?: string | null
children?: Prisma.AssetUncheckedCreateNestedManyWithoutParentInput
symlinks?: Prisma.AssetUncheckedCreateNestedManyWithoutTargetInput
metadataValues?: Prisma.AssetMetadataValueUncheckedCreateNestedManyWithoutAssetInput
comments?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutAssetInput
commentAttachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutAssetInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutAssetInput
embeddings?: Prisma.AssetEmbeddingUncheckedCreateNestedManyWithoutAssetInput
teamRootFolder?: Prisma.TeamUncheckedCreateNestedOneWithoutRootFolderInput
projectRootFolder?: Prisma.ProjectUncheckedCreateNestedOneWithoutRootFolderInput
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutAgentMdInput = {
where: Prisma.AssetWhereUniqueInput
create: Prisma.XOR<Prisma.AssetCreateWithoutAgentMdInput, Prisma.AssetUncheckedCreateWithoutAgentMdInput>
}
export type AssetUpsertWithoutAgentMdInput = {
update: Prisma.XOR<Prisma.AssetUpdateWithoutAgentMdInput, Prisma.AssetUncheckedUpdateWithoutAgentMdInput>
create: Prisma.XOR<Prisma.AssetCreateWithoutAgentMdInput, Prisma.AssetUncheckedCreateWithoutAgentMdInput>
where?: Prisma.AssetWhereInput
}
export type AssetUpdateToOneWithWhereWithoutAgentMdInput = {
where?: Prisma.AssetWhereInput
data: Prisma.XOR<Prisma.AssetUpdateWithoutAgentMdInput, Prisma.AssetUncheckedUpdateWithoutAgentMdInput>
}
export type AssetUpdateWithoutAgentMdInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
nameNgram?: Prisma.AssetUpdatenameNgramInput | string[]
type?: Prisma.EnumAssetTypeFieldUpdateOperationsInput | $Enums.AssetType
mediaType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
fileCount?: Prisma.IntFieldUpdateOperationsInput | number
sizeByte?: Prisma.BigIntFieldUpdateOperationsInput | bigint | number
status?: Prisma.EnumAssetStatusFieldUpdateOperationsInput | $Enums.AssetStatus
transcodeTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
sortIndex?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
parent?: Prisma.AssetUpdateOneWithoutChildrenNestedInput
children?: Prisma.AssetUpdateManyWithoutParentNestedInput
target?: Prisma.AssetUpdateOneWithoutSymlinksNestedInput
symlinks?: Prisma.AssetUpdateManyWithoutTargetNestedInput
storageKey?: Prisma.StorageKeyUpdateOneWithoutAssetsNestedInput
metadataValues?: Prisma.AssetMetadataValueUpdateManyWithoutAssetNestedInput
creator?: Prisma.UserUpdateOneWithoutAssetsNestedInput
task?: Prisma.TaskUpdateOneWithoutAssetsNestedInput
project?: Prisma.ProjectUpdateOneWithoutAssetsNestedInput
comments?: Prisma.AssetCommentUpdateManyWithoutAssetNestedInput
commentAttachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutAssetNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutAssetNestedInput
embeddings?: Prisma.AssetEmbeddingUpdateManyWithoutAssetNestedInput
teamRootFolder?: Prisma.TeamUpdateOneWithoutRootFolderNestedInput
projectRootFolder?: Prisma.ProjectUpdateOneWithoutRootFolderNestedInput
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutAgentMdInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
nameNgram?: Prisma.AssetUpdatenameNgramInput | string[]
type?: Prisma.EnumAssetTypeFieldUpdateOperationsInput | $Enums.AssetType
mediaType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
fileCount?: Prisma.IntFieldUpdateOperationsInput | number
sizeByte?: Prisma.BigIntFieldUpdateOperationsInput | bigint | number
status?: Prisma.EnumAssetStatusFieldUpdateOperationsInput | $Enums.AssetStatus
transcodeTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
sortIndex?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
targetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
storageKeyId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
taskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
projectId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
children?: Prisma.AssetUncheckedUpdateManyWithoutParentNestedInput
symlinks?: Prisma.AssetUncheckedUpdateManyWithoutTargetNestedInput
metadataValues?: Prisma.AssetMetadataValueUncheckedUpdateManyWithoutAssetNestedInput
comments?: Prisma.AssetCommentUncheckedUpdateManyWithoutAssetNestedInput
commentAttachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutAssetNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutAssetNestedInput
embeddings?: Prisma.AssetEmbeddingUncheckedUpdateManyWithoutAssetNestedInput
teamRootFolder?: Prisma.TeamUncheckedUpdateOneWithoutRootFolderNestedInput
projectRootFolder?: Prisma.ProjectUncheckedUpdateOneWithoutRootFolderNestedInput
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutCommentsInput = {
@@ -3138,6 +3365,7 @@ export type AssetCreateWithoutCommentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutCommentsInput = {
@@ -3174,6 +3402,7 @@ export type AssetUncheckedCreateWithoutCommentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutCommentsInput = {
@@ -3226,6 +3455,7 @@ export type AssetUpdateWithoutCommentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutCommentsInput = {
@@ -3262,6 +3492,7 @@ export type AssetUncheckedUpdateWithoutCommentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutCommentAttachmentsInput = {
@@ -3298,6 +3529,7 @@ export type AssetCreateWithoutCommentAttachmentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutCommentAttachmentsInput = {
@@ -3334,6 +3566,7 @@ export type AssetUncheckedCreateWithoutCommentAttachmentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutCommentAttachmentsInput = {
@@ -3386,6 +3619,7 @@ export type AssetUpdateWithoutCommentAttachmentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutCommentAttachmentsInput = {
@@ -3422,6 +3656,7 @@ export type AssetUncheckedUpdateWithoutCommentAttachmentsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutEmbeddingsInput = {
@@ -3458,6 +3693,7 @@ export type AssetCreateWithoutEmbeddingsInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutEmbeddingsInput = {
@@ -3494,6 +3730,7 @@ export type AssetUncheckedCreateWithoutEmbeddingsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutEmbeddingsInput = {
@@ -3546,6 +3783,7 @@ export type AssetUpdateWithoutEmbeddingsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutEmbeddingsInput = {
@@ -3582,6 +3820,7 @@ export type AssetUncheckedUpdateWithoutEmbeddingsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutNotificationsInput = {
@@ -3618,6 +3857,7 @@ export type AssetCreateWithoutNotificationsInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutNotificationsInput = {
@@ -3654,6 +3894,7 @@ export type AssetUncheckedCreateWithoutNotificationsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutNotificationsInput = {
@@ -3706,6 +3947,7 @@ export type AssetUpdateWithoutNotificationsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutNotificationsInput = {
@@ -3742,6 +3984,7 @@ export type AssetUncheckedUpdateWithoutNotificationsInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateWithoutTaskInput = {
@@ -3778,6 +4021,7 @@ export type AssetCreateWithoutTaskInput = {
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutTaskInput = {
@@ -3814,6 +4058,7 @@ export type AssetUncheckedCreateWithoutTaskInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutTaskInput = {
@@ -3876,6 +4121,7 @@ export type AssetCreateWithoutAgentSessionsInput = {
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
}
export type AssetUncheckedCreateWithoutAgentSessionsInput = {
@@ -3912,6 +4158,7 @@ export type AssetUncheckedCreateWithoutAgentSessionsInput = {
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
}
export type AssetCreateOrConnectWithoutAgentSessionsInput = {
@@ -3964,6 +4211,7 @@ export type AssetUpdateWithoutAgentSessionsInput = {
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutAgentSessionsInput = {
@@ -4000,6 +4248,7 @@ export type AssetUncheckedUpdateWithoutAgentSessionsInput = {
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetCreateManyCreatorInput = {
@@ -4059,6 +4308,7 @@ export type AssetUpdateWithoutCreatorInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutCreatorInput = {
@@ -4095,6 +4345,7 @@ export type AssetUncheckedUpdateWithoutCreatorInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutCreatorInput = {
@@ -4177,6 +4428,7 @@ export type AssetUpdateWithoutProjectInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutProjectInput = {
@@ -4213,6 +4465,7 @@ export type AssetUncheckedUpdateWithoutProjectInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutProjectInput = {
@@ -4318,6 +4571,7 @@ export type AssetUpdateWithoutParentInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutParentInput = {
@@ -4354,6 +4608,7 @@ export type AssetUncheckedUpdateWithoutParentInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutParentInput = {
@@ -4413,6 +4668,7 @@ export type AssetUpdateWithoutTargetInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutTargetInput = {
@@ -4449,6 +4705,7 @@ export type AssetUncheckedUpdateWithoutTargetInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutTargetInput = {
@@ -4531,6 +4788,7 @@ export type AssetUpdateWithoutStorageKeyInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutStorageKeyInput = {
@@ -4567,6 +4825,7 @@ export type AssetUncheckedUpdateWithoutStorageKeyInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutStorageKeyInput = {
@@ -4649,6 +4908,7 @@ export type AssetUpdateWithoutTaskInput = {
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutTaskInput = {
@@ -4685,6 +4945,7 @@ export type AssetUncheckedUpdateWithoutTaskInput = {
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutTaskInput = {
@@ -4854,6 +5115,7 @@ export type AssetSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs =
shareLinkRootFolder?: boolean | Prisma.Asset$shareLinkRootFolderArgs<ExtArgs>
agentSessions?: boolean | Prisma.Asset$agentSessionsArgs<ExtArgs>
watermarkFiles?: boolean | Prisma.Asset$watermarkFilesArgs<ExtArgs>
agentMd?: boolean | Prisma.Asset$agentMdArgs<ExtArgs>
_count?: boolean | Prisma.AssetCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["asset"]>
@@ -4962,6 +5224,7 @@ export type AssetInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
shareLinkRootFolder?: boolean | Prisma.Asset$shareLinkRootFolderArgs<ExtArgs>
agentSessions?: boolean | Prisma.Asset$agentSessionsArgs<ExtArgs>
watermarkFiles?: boolean | Prisma.Asset$watermarkFilesArgs<ExtArgs>
agentMd?: boolean | Prisma.Asset$agentMdArgs<ExtArgs>
_count?: boolean | Prisma.AssetCountOutputTypeDefaultArgs<ExtArgs>
}
export type AssetIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -5003,6 +5266,7 @@ export type $AssetPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs
shareLinkRootFolder: Prisma.$ShareLinkPayload<ExtArgs> | null
agentSessions: Prisma.$AgentSessionPayload<ExtArgs>[]
watermarkFiles: Prisma.$WatermarkFilePayload<ExtArgs>[]
agentMd: Prisma.$AssetAgentMdPayload<ExtArgs> | null
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
@@ -5442,6 +5706,7 @@ export interface Prisma__AssetClient<T, Null = never, ExtArgs extends runtime.Ty
shareLinkRootFolder<T extends Prisma.Asset$shareLinkRootFolderArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$shareLinkRootFolderArgs<ExtArgs>>): Prisma.Prisma__ShareLinkClient<runtime.Types.Result.GetResult<Prisma.$ShareLinkPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
agentSessions<T extends Prisma.Asset$agentSessionsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$agentSessionsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AgentSessionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
watermarkFiles<T extends Prisma.Asset$watermarkFilesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$watermarkFilesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$WatermarkFilePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
agentMd<T extends Prisma.Asset$agentMdArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$agentMdArgs<ExtArgs>>): Prisma.Prisma__AssetAgentMdClient<runtime.Types.Result.GetResult<Prisma.$AssetAgentMdPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
@@ -6298,6 +6563,25 @@ export type Asset$watermarkFilesArgs<ExtArgs extends runtime.Types.Extensions.In
distinct?: Prisma.WatermarkFileScalarFieldEnum | Prisma.WatermarkFileScalarFieldEnum[]
}
/**
* Asset.agentMd
*/
export type Asset$agentMdArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the AssetAgentMd
*/
select?: Prisma.AssetAgentMdSelect<ExtArgs> | null
/**
* Omit specific fields from the AssetAgentMd
*/
omit?: Prisma.AssetAgentMdOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.AssetAgentMdInclude<ExtArgs> | null
where?: Prisma.AssetAgentMdWhereInput
}
/**
* Asset without action
*/
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/dtos",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./src/index.ts",
+3
View File
@@ -74,6 +74,7 @@ export const assetInfoSchema = z.object({
sortIndex: z.string().optional().nullable(),
startTime: z.number().optional().nullable(),
endTime: z.number().optional().nullable(),
hasAgentsMd: z.boolean().optional(),
media: z
.object({
@@ -119,10 +120,12 @@ export const assetInfoSchema = z.object({
id: z.string(),
name: z.string().optional().nullable(),
previewUrl: z.string().optional().nullable(),
createdAt: z.string().optional().nullable(),
creator: z
.object({
id: z.string(),
name: z.string().nullable(),
image: z.string().optional().nullable(),
})
.nullable()
.optional(),
+5
View File
@@ -20,3 +20,8 @@ export const restoreFoldersRequestSchema = z.object({
ids: z.array(z.string()),
})
export type RestoreFoldersRequest = z.infer<typeof restoreFoldersRequestSchema>
export const updateAgentsMdRequestSchema = z.object({
content: z.string().max(100_000),
})
export type UpdateAgentsMdRequest = z.infer<typeof updateAgentsMdRequestSchema>
+22
View File
@@ -22,3 +22,25 @@ export interface ChangeStackFileVersionParams {
fileId: string
beforeId: string
}
export interface RemoveStackVersionParams {
stackId: string
fileId: string
}
export const stackVersionInfoSchema = z.object({
id: z.string(),
version: z.number(),
name: z.string().optional().nullable(),
previewUrl: z.string().optional().nullable(),
createdAt: z.string().optional().nullable(),
creator: z
.object({
id: z.string(),
name: z.string().nullable(),
image: z.string().optional().nullable(),
})
.nullable()
.optional(),
})
export type StackVersionInfo = z.infer<typeof stackVersionInfoSchema>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/e2e",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/tableprinter",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/transcode",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./src/index.ts",
@@ -0,0 +1,147 @@
// @vitest-environment happy-dom
import { cleanup, render, screen, waitFor } from '@testing-library/react'
import React from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AgentsMdEditor } from './agents-md-editor'
import { m } from '@/ui/paraglide/messages.js'
// Mock API client
vi.mock('@/ui/api/client', () => ({
client: {
api: {
folders: {
':folderId': {
agentsmd: {
$get: vi.fn(),
$patch: vi.fn(),
},
},
},
},
},
}))
// Mock usePermissions
const mockUsePermissions = vi.fn()
vi.mock('@/ui/hooks/use-permissions', () => ({
usePermissions: () => mockUsePermissions(),
}))
// Mock useNavigate
const mockNavigate = vi.fn()
vi.mock('@tanstack/react-router', () => ({
useNavigate: () => mockNavigate,
}))
describe('AgentsMdEditor Component', () => {
let queryClient: QueryClient
beforeEach(() => {
queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false,
},
},
})
mockUsePermissions.mockReturnValue({
role: 'owner',
canEdit: true,
canAdmin: true,
})
})
afterEach(() => {
cleanup()
vi.clearAllMocks()
})
it('renders loading state initially', async () => {
const { client } = await import('@/ui/api/client')
const getMock = client.api.folders[':folderId'].agentsmd.$get as unknown as ReturnType<
typeof vi.fn
>
getMock.mockImplementation(() => new Promise(() => {}))
render(
<QueryClientProvider client={queryClient}>
<AgentsMdEditor projectId="proj-1" assetId="folder-1" rootFolderId="folder-1" isRoot />
</QueryClientProvider>,
)
expect(screen.getByText(m.agents_md_loading())).toBeDefined()
})
it('renders editable editor for team owner', async () => {
const { client } = await import('@/ui/api/client')
const getMock = client.api.folders[':folderId'].agentsmd.$get as unknown as ReturnType<
typeof vi.fn
>
getMock.mockResolvedValue({
ok: true,
json: async () => ({ content: '# Instructions' }),
})
render(
<QueryClientProvider client={queryClient}>
<AgentsMdEditor projectId="proj-1" assetId="folder-1" rootFolderId="folder-1" isRoot />
</QueryClientProvider>,
)
await waitFor(() => {
expect(screen.getByRole('textbox')).toBeDefined()
})
expect(screen.queryByText(m.agents_md_readonly_hint())).toBeNull()
})
it('renders read-only notice and restricts editing for non-owner', async () => {
mockUsePermissions.mockReturnValue({
role: 'editor',
canEdit: true,
canAdmin: false,
})
const { client } = await import('@/ui/api/client')
const getMock = client.api.folders[':folderId'].agentsmd.$get as unknown as ReturnType<
typeof vi.fn
>
getMock.mockResolvedValue({
ok: true,
json: async () => ({ content: '# Instructions' }),
})
const { container } = render(
<QueryClientProvider client={queryClient}>
<AgentsMdEditor projectId="proj-1" assetId="folder-1" rootFolderId="folder-1" isRoot />
</QueryClientProvider>,
)
await waitFor(() => {
expect(screen.getByText(m.agents_md_readonly_hint())).toBeDefined()
})
expect(container.querySelector('.read-only')).toBeDefined()
})
it('displays the friendly multiline placeholder when content is empty', async () => {
const { client } = await import('@/ui/api/client')
const getMock = client.api.folders[':folderId'].agentsmd.$get as unknown as ReturnType<
typeof vi.fn
>
getMock.mockResolvedValue({
ok: true,
json: async () => ({ content: null }),
})
render(
<QueryClientProvider client={queryClient}>
<AgentsMdEditor projectId="proj-1" assetId="folder-1" rootFolderId="folder-1" isRoot />
</QueryClientProvider>,
)
await waitFor(() => {
expect(screen.getByText(/parent folders up to the project level/)).toBeDefined()
})
})
})
@@ -0,0 +1,242 @@
import { client } from '@/ui/api/client'
import { usePermissions } from '@/ui/hooks/use-permissions'
import { m } from '@/ui/paraglide/messages.js'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import { AlertCircle, Check, Lock, Save, X } from 'lucide-react'
import { useCallback, useEffect, useRef, useState } from 'react'
import { MarkdownEditor } from '../markdown-editor/markdown-editor'
import { Button } from '../ui/button'
import { Separator } from '../ui/separator'
export interface AgentsMdEditorProps {
projectId: string
assetId: string
rootFolderId: string
isRoot?: boolean
}
export function AgentsMdEditor({ projectId, assetId, rootFolderId, isRoot }: AgentsMdEditorProps) {
const navigate = useNavigate()
const queryClient = useQueryClient()
const { canAdmin } = usePermissions(projectId)
const { data, isLoading } = useQuery({
queryKey: ['folders', assetId, 'agentsmd'],
queryFn: async () => {
const res = await client.api.folders[':folderId'].agentsmd.$get({
param: { folderId: assetId },
})
if (!res.ok) throw new Error('Failed to fetch agents.md')
return await res.json()
},
})
const [content, setContent] = useState<string>('')
const [isInitialized, setIsInitialized] = useState(false)
const [saveStatus, setSaveStatus] = useState<'idle' | 'saving' | 'saved' | 'error'>('idle')
const saveTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
const clearSavedTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
const latestContentRef = useRef<string>('')
const lastSavedContentRef = useRef<string | null>(null)
// Serializes autosaves so a newer write can never be overwritten by an older
// in-flight request completing out of order.
const saveChainRef = useRef<Promise<unknown>>(Promise.resolve())
useEffect(() => {
if (!isInitialized && data !== undefined) {
const initial = data.content ?? ''
setContent(initial)
latestContentRef.current = initial
lastSavedContentRef.current = initial
setIsInitialized(true)
}
}, [data, isInitialized])
const [isClosing, setIsClosing] = useState(false)
const saveMutation = useMutation({
mutationFn: async (newContent: string) => {
const res = await client.api.folders[':folderId'].agentsmd.$patch({
param: { folderId: assetId },
json: { content: newContent },
})
if (!res.ok) throw new Error('Failed to save agents.md')
return await res.json()
},
onSuccess: (_, newContent) => {
setSaveStatus('saved')
lastSavedContentRef.current = newContent
queryClient.setQueryData(['folders', assetId, 'agentsmd'], { content: newContent })
queryClient.invalidateQueries({ queryKey: ['folders', assetId] })
if (clearSavedTimeoutRef.current) {
clearTimeout(clearSavedTimeoutRef.current)
}
clearSavedTimeoutRef.current = setTimeout(() => {
setSaveStatus('idle')
}, 2500)
},
onError: () => {
setSaveStatus('error')
},
})
const saveMutationRef = useRef(saveMutation.mutateAsync)
saveMutationRef.current = saveMutation.mutateAsync
const enqueueSave = useCallback(
(textToSave: string) => {
if (!canAdmin) return Promise.resolve()
if (lastSavedContentRef.current === textToSave) {
setSaveStatus('saved')
return Promise.resolve()
}
setSaveStatus('saving')
const p = saveChainRef.current
.then(async () => {
await saveMutationRef.current(textToSave)
})
.catch(() => {
// Swallow so a failed save does not break the chain for later saves.
// The mutation's onError handler already surfaces the failure.
})
saveChainRef.current = p
return p
},
[canAdmin],
)
const handleContentChange = useCallback(
(newMarkdown: string) => {
if (!canAdmin) return
setContent(newMarkdown)
latestContentRef.current = newMarkdown
if (saveTimeoutRef.current) {
clearTimeout(saveTimeoutRef.current)
}
setSaveStatus('saving')
saveTimeoutRef.current = setTimeout(() => {
saveTimeoutRef.current = null
enqueueSave(newMarkdown)
}, 1000)
},
[canAdmin, enqueueSave],
)
// Flushes any pending debounced edits so they are not lost when the editor
// unmounts (close button, folder-tree navigation, or route change).
const flushPendingSave = useCallback(() => {
if (saveTimeoutRef.current) {
clearTimeout(saveTimeoutRef.current)
saveTimeoutRef.current = null
return enqueueSave(latestContentRef.current)
}
return saveChainRef.current
}, [enqueueSave])
useEffect(() => {
return () => {
flushPendingSave()
if (clearSavedTimeoutRef.current) {
clearTimeout(clearSavedTimeoutRef.current)
}
}
}, [flushPendingSave])
const handleClose = async () => {
setIsClosing(true)
try {
flushPendingSave()
await saveChainRef.current
} catch {
// Proceed with navigation even if error occurs
} finally {
if (isRoot || assetId === rootFolderId) {
navigate({
to: '/projects/$projectId',
params: { projectId },
})
} else {
navigate({
to: '/projects/$projectId/folders/$folderId',
params: { projectId, folderId: assetId },
})
}
}
}
const rightToolbarContent = (
<div className="flex items-center justify-between w-full gap-2 shrink-0">
{canAdmin ? (
<div className="flex items-center gap-1.5 text-xs shrink-0">
{(saveStatus === 'saving' || isClosing) && (
<span className="inline-flex items-center gap-1 text-muted-foreground animate-pulse whitespace-nowrap">
<Save className="h-3.5 w-3.5 shrink-0" />
<span>{m.saving_ellipsis()}</span>
</span>
)}
{saveStatus === 'saved' && !isClosing && (
<span className="inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400 font-medium whitespace-nowrap">
<Check className="h-3.5 w-3.5 shrink-0" />
<span>{m.saved()}</span>
</span>
)}
{saveStatus === 'error' && !isClosing && (
<span className="inline-flex items-center gap-1 text-destructive font-medium whitespace-nowrap">
<AlertCircle className="h-3.5 w-3.5 shrink-0" />
<span>{m.agents_md_save_failed()}</span>
</span>
)}
</div>
) : (
<div
className="inline-flex items-center gap-1.5 text-xs text-muted-foreground bg-muted/60 px-2.5 py-1 rounded-md shrink-0"
title={m.agents_md_readonly_hint()}
>
<Lock className="h-3.5 w-3.5 shrink-0" />
<span>{m.agents_md_readonly_hint()}</span>
</div>
)}
<div className="flex items-center gap-2 shrink-0">
{canAdmin && <Separator orientation="vertical" className="h-4 shrink-0" />}
<Button
variant="ghost"
size="sm"
onClick={handleClose}
disabled={isClosing}
className="h-7 px-2.5 hover:bg-muted text-muted-foreground hover:text-foreground shrink-0"
title={m.close()}
>
<X className="h-4 w-4 mr-1 shrink-0" />
<span>{m.close()}</span>
</Button>
</div>
</div>
)
if (isLoading || !isInitialized) {
return (
<div className="flex-1 flex items-center justify-center p-8 text-sm text-muted-foreground">
<Save className="h-4 w-4 animate-pulse mr-2" />
<span>{m.agents_md_loading()}</span>
</div>
)
}
return (
<div className="flex-1 flex flex-col h-full min-h-0 overflow-hidden">
<MarkdownEditor
value={content}
onChange={handleContentChange}
placeholder={m.agents_md_placeholder()}
readOnly={!canAdmin}
rightToolbarContent={rightToolbarContent}
className="flex-1 flex flex-col h-full min-h-0 border rounded-lg shadow-sm"
/>
</div>
)
}
@@ -0,0 +1,158 @@
import { client } from '@/ui/api/client'
import { ChatbotSidebar } from '@/ui/components/chatbot-sidebar'
import { FolderTree } from '@/ui/components/folder-tree'
import { ResizeHandle } from '@/ui/components/resize-handle'
import { useChatbotStore } from '@/ui/stores/chatbot'
import { useTopNavStore } from '@/ui/stores/top-nav'
import { useUiStore } from '@/ui/stores/ui'
import type { AncestorFolder, AssetInfo } from '@shumai/dtos'
import { useQuery } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import { useEffect, useState } from 'react'
import { AgentsMdEditor } from './agents-md-editor'
export interface AgentsMdManagerProps {
teamId: string
projectId: string
projectName: string
assetId: string
rootFolderId: string
isRoot?: boolean
}
export default function AgentsMdManager({
teamId,
projectId,
projectName,
assetId,
rootFolderId,
isRoot,
}: AgentsMdManagerProps) {
const navigate = useNavigate()
const [leftSidebarWidth, setLeftSidebarWidth] = useState(240)
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
const {
fileListLeftSidebarCollapsed: isLeftSidebarCollapsed,
setFileListLeftSidebarCollapsed: setIsLeftSidebarCollapsed,
} = useUiStore()
const { isChatbotOpen, setIsChatbotOpen } = useChatbotStore()
const { data: folderInfo } = useQuery({
queryKey: ['folders', assetId],
queryFn: async () => {
const res = await client.api.folders[':folderId'].$get({
param: { folderId: assetId },
})
if (!res.ok) throw new Error('failed to fetch folder')
return (await res.json()) as unknown as AssetInfo
},
enabled: !!assetId,
})
const { setProjectState, clearProjectState } = useTopNavStore()
useEffect(() => {
const isRootFolder = isRoot || assetId === rootFolderId
const ancestors: AncestorFolder[] = isRootFolder
? []
: folderInfo?.name
? [{ id: assetId, name: folderInfo.name }, ...(folderInfo?.ancestorFolders ?? [])]
: (folderInfo?.ancestorFolders ?? [])
setProjectState({
teamId,
projectId,
projectName,
ancestorFolders: ancestors,
currentAsset: { name: folderInfo?.name, type: 'folder' },
isRootFolder: true,
customTerminalBreadcrumb: 'AGENTS.md',
onFolderClick: (id: string) => {
navigate({
to: '/projects/$projectId/folders/$folderId',
params: { projectId, folderId: id },
})
},
})
return () => clearProjectState()
}, [
teamId,
projectId,
projectName,
folderInfo?.ancestorFolders,
folderInfo?.name,
isRoot,
assetId,
rootFolderId,
setProjectState,
clearProjectState,
navigate,
])
return (
<div className="flex-1 flex flex-col h-full overflow-hidden bg-background">
<div className="flex-1 flex overflow-hidden relative">
{!isLeftSidebarCollapsed && (
<div
className="md:hidden fixed inset-0 bg-black/50 z-40"
onClick={() => setIsLeftSidebarCollapsed(true)}
/>
)}
{isChatbotOpen && (
<div
className="md:hidden fixed inset-0 bg-black/50 z-40"
onClick={() => setIsChatbotOpen(false)}
/>
)}
{!isLeftSidebarCollapsed && (
<>
<div className="bg-background flex-shrink-0" style={{ width: leftSidebarWidth }}>
<FolderTree
teamId={teamId}
projectId={projectId}
projectName={projectName}
rootFolderId={rootFolderId}
selectedFolderId={assetId}
ancestorFolders={folderInfo?.ancestorFolders ?? []}
/>
</div>
<ResizeHandle
onResize={(delta) => {
setLeftSidebarWidth((prev) => Math.max(180, Math.min(400, prev + delta)))
}}
className="hidden md:block"
/>
</>
)}
<div className="flex-1 flex flex-col min-w-0 min-h-0 bg-background overflow-hidden p-3">
<AgentsMdEditor
projectId={projectId}
assetId={assetId}
rootFolderId={rootFolderId}
isRoot={isRoot}
/>
</div>
{isChatbotOpen && (
<>
<ResizeHandle
onResize={(delta) => {
setRightSidebarWidth((prev) => Math.max(240, Math.min(600, prev - delta)))
}}
className="hidden md:block"
/>
<div
style={{ width: rightSidebarWidth }}
className="bg-background flex flex-col flex-shrink-0"
>
<ChatbotSidebar projectId={projectId} contextAssetId={assetId} />
</div>
</>
)}
</div>
</div>
)
}
+51 -5
View File
@@ -40,6 +40,8 @@ import {
LayoutGrid,
List,
} from 'lucide-react'
import { useState } from 'react'
import { ManageVersionsDialog } from './manage-versions-dialog'
interface BreadcrumbNavProps {
teamId: string
@@ -53,6 +55,7 @@ interface BreadcrumbNavProps {
proxyType?: 'image' | 'video' | 'audio' | 'pdf' | null
}
isRootFolder: boolean
customTerminalBreadcrumb?: string
displayStyle?: 'card' | 'list'
onDisplayStyleChange?: (style: 'card' | 'list') => void
isLeftSidebarCollapsed?: boolean
@@ -95,6 +98,7 @@ export function BreadcrumbNav({
ancestorFolders,
currentAsset,
isRootFolder,
customTerminalBreadcrumb,
displayStyle,
onDisplayStyleChange,
isLeftSidebarCollapsed,
@@ -118,6 +122,7 @@ export function BreadcrumbNav({
}: BreadcrumbNavProps) {
const navigate = useNavigate()
const { canEdit } = usePermissions(projectId)
const [isManageVersionsOpen, setIsManageVersionsOpen] = useState(false)
const isChatbotDisabled = false
@@ -219,7 +224,14 @@ export function BreadcrumbNav({
)}
</div>
))}
{!isRootFolder && !compareMode && (
{customTerminalBreadcrumb ? (
<div className="flex items-center gap-1">
<span className="text-muted-foreground">/</span>
<span className="truncate rounded px-2 py-1 text-sm font-medium text-foreground">
{customTerminalBreadcrumb}
</span>
</div>
) : !isRootFolder && !compareMode ? (
<div className="flex items-center gap-1">
<span className="text-muted-foreground">/</span>
{currentAsset.type === 'folder' ? (
@@ -227,7 +239,7 @@ export function BreadcrumbNav({
{currentAsset.name}
</span>
) : (
<DropdownMenu>
<DropdownMenu modal={false}>
<DropdownMenuTrigger className="flex items-center gap-1 truncate rounded px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground">
<span>{currentAsset.name}</span>
{currentAsset.version !== undefined && (
@@ -370,10 +382,10 @@ export function BreadcrumbNav({
<DropdownMenuSeparator />
<div className="p-1">
<button
className="w-full text-center text-xs font-medium py-2 px-3 rounded-md bg-muted/80 hover:bg-muted text-foreground transition-colors"
onClick={() => console.log('Manage versions')}
className="w-full text-center text-xs font-medium py-2 px-3 rounded-md bg-muted/80 hover:bg-muted text-foreground transition-colors cursor-pointer"
onClick={() => setIsManageVersionsOpen(true)}
>
Manage versions...
{m.manage_versions()}
</button>
</div>
</DropdownMenuSubContent>
@@ -385,6 +397,40 @@ export function BreadcrumbNav({
</DropdownMenu>
)}
</div>
) : null}
{fileId && versions && versions.length > 0 && (
<ManageVersionsDialog
open={isManageVersionsOpen}
onOpenChange={setIsManageVersionsOpen}
stackId={fileId}
canEdit={canEdit}
onStackDissolved={(remainingFileId) => {
setIsManageVersionsOpen(false)
navigate({
to: '/projects/$projectId/files/$fileId',
params: { projectId, fileId: remainingFileId },
})
}}
onVersionRemoved={(removedVersionId, remainingVersions) => {
const currentVersionId = currentAsset.version
? versions.find((v) => v.version === currentAsset.version)?.id
: undefined
if (currentVersionId === removedVersionId) {
const topVersion = remainingVersions[0]
if (topVersion) {
navigate({
to: '/projects/$projectId/files/$fileId',
params: { projectId, fileId },
search: (prev: Record<string, unknown>) => ({
...prev,
version: topVersion.id,
}),
})
}
}
}}
/>
)}
</div>
@@ -4,6 +4,7 @@ import { m } from '@/ui/paraglide/messages.js'
import type { AssetInfo, CollectionInfo, SearchCondition, SearchSort } from '@shumai/dtos'
import { type FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import type { InferRequestType, InferResponseType } from 'hono/client'
import { useState } from 'react'
import { FieldsManager } from '../fields-manager'
@@ -17,6 +18,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'
import { Button } from '../ui/button'
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
import { Separator } from '../ui/separator'
import { cn } from '@/ui/lib/utils'
type FileBrowserToolbarProps = {
teamId: string
@@ -55,6 +57,7 @@ export function FileBrowserToolbar({
const [isMembersDialogOpen, setIsMembersDialogOpen] = useState(false)
const [isFolderSelectorOpen, setIsFolderSelectorOpen] = useState(false)
const navigate = useNavigate()
const activeFiltersCount = filterConditions.length
const isCollection = !!collection
const queryClient = useQueryClient()
@@ -68,9 +71,23 @@ export function FileBrowserToolbar({
if (!res.ok) throw new Error('failed to fetch folder')
return (await res.json()) as unknown as AssetInfo
},
enabled: isCollection && !!assetId,
enabled: !!assetId && !isRecentlyDeleted,
})
const handleOpenAgentsMd = () => {
if (assetId === rootFolderId) {
navigate({
to: '/projects/$projectId/agentsmd',
params: { projectId },
})
} else {
navigate({
to: '/projects/$projectId/folders/$folderId/agentsmd',
params: { projectId, folderId: assetId },
})
}
}
const { data: members, refetch: refetchProjectMembers } = useQuery({
queryKey: ['projects', projectId, 'members'],
queryFn: async () => {
@@ -225,11 +242,9 @@ export function FileBrowserToolbar({
<div className="flex items-center gap-2 h-full">
<Popover open={popoverOpen} onOpenChange={setPopoverOpen}>
<PopoverTrigger asChild>
<div>
<Button variant="ghost" size="sm">
{m.field()}
</Button>
</div>
<Button variant="ghost" size="sm">
{m.field()}
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<FieldsManager
@@ -254,11 +269,7 @@ export function FileBrowserToolbar({
<>
<Popover open={isFolderSelectorOpen} onOpenChange={setIsFolderSelectorOpen}>
<PopoverTrigger asChild>
<Button
variant="ghost"
size="sm"
className="inline-flex items-center gap-2 px-3 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8 text-muted-foreground"
>
<Button variant="ghost" size="sm" className="text-muted-foreground">
<span className="truncate max-w-[150px]">{folderInfo?.name || 'Loading...'}</span>
</Button>
</PopoverTrigger>
@@ -295,11 +306,7 @@ export function FileBrowserToolbar({
<Popover>
<PopoverTrigger asChild>
<Button
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
size="sm"
className="inline-flex items-center gap-2 px-4 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8"
>
<Button variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'} size="sm">
<span>Filter</span>
{activeFiltersCount > 0 && (
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
@@ -333,20 +340,49 @@ export function FileBrowserToolbar({
</Popover>
</>
) : (
<Button
onClick={() => setSearchDialogOpen(true)}
disabled={isRecentlyDeleted}
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
size="sm"
className="inline-flex items-center gap-2 px-4 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8"
>
<span>{m.search()}</span>
{activeFiltersCount > 0 && (
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
{activeFiltersCount}
</span>
<>
<Button
onClick={() => setSearchDialogOpen(true)}
disabled={isRecentlyDeleted}
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
size="sm"
>
<span>{m.search()}</span>
{activeFiltersCount > 0 && (
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
{activeFiltersCount}
</span>
)}
</Button>
{!isRecentlyDeleted && (
<>
<Separator orientation="vertical" />
<Button
onClick={handleOpenAgentsMd}
variant="ghost"
size="sm"
title="AGENTS.md"
className={cn(
folderInfo?.hasAgentsMd ? 'text-foreground' : 'text-muted-foreground',
)}
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 -960 960 960"
className={cn(
'size-4',
folderInfo?.hasAgentsMd ? 'text-primary' : 'text-muted-foreground',
)}
fill="currentColor"
>
<path d="m176-120-56-56 301-302-181-45 198-123-17-234 179 151 216-88-87 217 151 178-234-16-124 198-45-181-301 301Zm24-520-80-80 80-80 80 80-80 80Zm520 520-80-80 80-80 80 80-80 80Z" />
</svg>
<span>{m.agents_md()}</span>
</Button>
</>
)}
</Button>
</>
)}
</div>
@@ -1,324 +0,0 @@
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import { useCallback, useEffect, useState } from 'react'
import {
SELECTION_CHANGE_COMMAND,
FORMAT_TEXT_COMMAND,
$getSelection,
$isRangeSelection,
COMMAND_PRIORITY_CRITICAL,
$createParagraphNode,
} from 'lexical'
import {
$isListNode,
ListNode,
INSERT_ORDERED_LIST_COMMAND,
INSERT_UNORDERED_LIST_COMMAND,
REMOVE_LIST_COMMAND,
} from '@lexical/list'
import {
$createHeadingNode,
$createQuoteNode,
$isHeadingNode,
type HeadingTagType,
} from '@lexical/rich-text'
import { $createCodeNode } from '@lexical/code'
import { $setBlocksType } from '@lexical/selection'
import { $getNearestNodeOfType } from '@lexical/utils'
import {
Bold,
Italic,
Underline,
Strikethrough,
Code,
Quote,
List,
ListOrdered,
Type,
Heading1,
Heading2,
Heading3,
} from 'lucide-react'
import { Toggle } from '@/ui/components/ui/toggle'
import { Separator } from '@/ui/components/ui/separator'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/ui/components/ui/select'
const blockTypeToBlockName = {
paragraph: 'Normal',
h1: 'Heading 1',
h2: 'Heading 2',
h3: 'Heading 3',
bullet: 'Bullet List',
number: 'Numbered List',
quote: 'Quote',
code: 'Code Block',
}
export function ToolbarPlugin() {
const [editor] = useLexicalComposerContext()
const [activeEditor, setActiveEditor] = useState(editor)
const [isBold, setIsBold] = useState(false)
const [isItalic, setIsItalic] = useState(false)
const [isUnderline, setIsUnderline] = useState(false)
const [isStrikethrough, setIsStrikethrough] = useState(false)
const [isCode, setIsCode] = useState(false)
const [blockType, setBlockType] = useState<keyof typeof blockTypeToBlockName>('paragraph')
const $updateToolbar = useCallback(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
setIsBold(selection.hasFormat('bold'))
setIsItalic(selection.hasFormat('italic'))
setIsUnderline(selection.hasFormat('underline'))
setIsStrikethrough(selection.hasFormat('strikethrough'))
setIsCode(selection.hasFormat('code'))
const anchorNode = selection.anchor.getNode()
const element =
anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow()
const elementKey = element.getKey()
const elementDom = activeEditor.getElementByKey(elementKey)
if (elementDom !== null) {
if ($isListNode(element)) {
const parentList = $getNearestNodeOfType(anchorNode, ListNode)
const type = parentList ? parentList.getListType() : element.getListType()
setBlockType(type as keyof typeof blockTypeToBlockName)
} else {
const type = $isHeadingNode(element) ? element.getTag() : element.getType()
if (type in blockTypeToBlockName) {
setBlockType(type as keyof typeof blockTypeToBlockName)
}
}
}
}
}, [activeEditor])
useEffect(() => {
return editor.registerCommand(
SELECTION_CHANGE_COMMAND,
(_payload, newEditor) => {
$updateToolbar()
setActiveEditor(newEditor)
return false
},
COMMAND_PRIORITY_CRITICAL,
)
}, [editor, $updateToolbar])
useEffect(() => {
return editor.registerUpdateListener(({ editorState }) => {
editorState.read(() => {
$updateToolbar()
})
})
}, [editor, $updateToolbar])
const formatParagraph = () => {
if (blockType !== 'paragraph') {
activeEditor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createParagraphNode())
}
})
}
}
const formatHeading = (headingSize: HeadingTagType) => {
if (blockType !== headingSize) {
activeEditor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createHeadingNode(headingSize))
}
})
}
}
const formatBulletList = () => {
if (blockType !== 'bullet') {
activeEditor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)
} else {
activeEditor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
}
}
const formatNumberedList = () => {
if (blockType !== 'number') {
activeEditor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)
} else {
activeEditor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
}
}
const formatQuote = () => {
if (blockType !== 'quote') {
activeEditor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createQuoteNode())
}
})
} else {
formatParagraph()
}
}
const formatCode = () => {
if (blockType !== 'code') {
activeEditor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createCodeNode())
}
})
} else {
formatParagraph()
}
}
const handleBlockTypeChange = (value: string) => {
switch (value) {
case 'paragraph':
formatParagraph()
break
case 'h1':
formatHeading('h1')
break
case 'h2':
formatHeading('h2')
break
case 'h3':
formatHeading('h3')
break
case 'bullet':
formatBulletList()
break
case 'number':
formatNumberedList()
break
case 'quote':
formatQuote()
break
case 'code':
formatCode()
break
}
}
return (
<div className="toolbar bg-background border-b border-border flex items-center p-1 gap-1 sticky top-0 z-10 flex-wrap">
<Select value={blockType} onValueChange={handleBlockTypeChange}>
<SelectTrigger className="h-8 w-[140px] border-none shadow-none focus:ring-0">
<SelectValue placeholder="Normal" />
</SelectTrigger>
<SelectContent
onCloseAutoFocus={(e) => {
e.preventDefault()
activeEditor.focus()
}}
>
<SelectItem value="paragraph">
<div className="flex items-center gap-2">
<Type className="h-4 w-4" /> Normal
</div>
</SelectItem>
<SelectItem value="h1">
<div className="flex items-center gap-2">
<Heading1 className="h-4 w-4" /> Heading 1
</div>
</SelectItem>
<SelectItem value="h2">
<div className="flex items-center gap-2">
<Heading2 className="h-4 w-4" /> Heading 2
</div>
</SelectItem>
<SelectItem value="h3">
<div className="flex items-center gap-2">
<Heading3 className="h-4 w-4" /> Heading 3
</div>
</SelectItem>
<SelectItem value="number">
<div className="flex items-center gap-2">
<ListOrdered className="h-4 w-4" /> Numbered List
</div>
</SelectItem>
<SelectItem value="bullet">
<div className="flex items-center gap-2">
<List className="h-4 w-4" /> Bullet List
</div>
</SelectItem>
<SelectItem value="quote">
<div className="flex items-center gap-2">
<Quote className="h-4 w-4" /> Quote
</div>
</SelectItem>
<SelectItem value="code">
<div className="flex items-center gap-2">
<Code className="h-4 w-4" /> Code Block
</div>
</SelectItem>
</SelectContent>
</Select>
<Separator orientation="vertical" className="h-6 mx-1" />
<Toggle
size="sm"
pressed={isBold}
onPressedChange={() => {
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')
}}
aria-label="Format Bold"
>
<Bold className="h-4 w-4" />
</Toggle>
<Toggle
size="sm"
pressed={isItalic}
onPressedChange={() => {
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')
}}
aria-label="Format Italic"
>
<Italic className="h-4 w-4" />
</Toggle>
<Toggle
size="sm"
pressed={isUnderline}
onPressedChange={() => {
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')
}}
aria-label="Format Underline"
>
<Underline className="h-4 w-4" />
</Toggle>
<Toggle
size="sm"
pressed={isStrikethrough}
onPressedChange={() => {
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')
}}
aria-label="Format Strikethrough"
>
<Strikethrough className="h-4 w-4" />
</Toggle>
<Toggle
size="sm"
pressed={isCode}
onPressedChange={() => {
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code')
}}
aria-label="Insert Code"
>
<Code className="h-4 w-4" />
</Toggle>
</div>
)
}
@@ -0,0 +1,313 @@
import { client } from '@/ui/api/client'
import { Button } from '@/ui/components/ui/button'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/ui/components/ui/dialog'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/ui/components/ui/dropdown-menu'
import { ScrollArea } from '@/ui/components/ui/scroll-area'
import { cn } from '@/ui/lib/utils'
import { m } from '@/ui/paraglide/messages.js'
import { PointerActivationConstraints } from '@dnd-kit/dom'
import { DragDropProvider, KeyboardSensor, PointerSensor, type DragEndEvent } from '@dnd-kit/react'
import { isSortable, useSortable } from '@dnd-kit/react/sortable'
import type { StackVersionInfo } from '@shumai/dtos'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { format, parseISO } from 'date-fns'
import { FileIcon, GripVertical, MoreVertical, Trash2 } from 'lucide-react'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
interface ManageVersionsDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
stackId: string
canEdit?: boolean
onVersionRemoved?: (removedVersionId: string, remainingVersions: StackVersionInfo[]) => void
onStackDissolved?: (remainingFileId: string) => void
}
interface SortableVersionRowProps {
version: StackVersionInfo
displayVersionNumber: number
index: number
canEdit: boolean
onRemove: (versionId: string) => void
}
function formatVersionDate(dateString?: string | null): string | null {
if (!dateString) return null
try {
const date = parseISO(dateString)
if (isNaN(date.getTime())) return null
return format(date, 'MMM d, yyyy')
} catch {
return null
}
}
function SortableVersionRow({
version,
displayVersionNumber,
index,
canEdit,
onRemove,
}: SortableVersionRowProps) {
const [dropdownOpen, setDropdownOpen] = useState(false)
const { ref, handleRef } = useSortable({
id: version.id,
index,
disabled: !canEdit,
})
const formattedDate = formatVersionDate(version.createdAt)
return (
<div
ref={ref}
className="group flex items-center gap-3 p-2.5 rounded-lg border border-border bg-card hover:bg-accent/40 transition-colors"
>
{/* 1. Version Label */}
<div className="flex-shrink-0 flex items-center justify-center bg-muted text-muted-foreground rounded-full px-2.5 py-0.5 text-xs font-semibold select-none min-w-[2.25rem]">
v{displayVersionNumber}
</div>
{/* 2. Drag Handler */}
{canEdit ? (
<div
ref={handleRef}
className="cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground p-1 -m-1 rounded touch-none flex items-center justify-center"
>
<GripVertical className="h-4 w-4" />
</div>
) : (
<div className="w-4" />
)}
{/* 3. Thumbnail Preview */}
<div className="h-12 w-20 flex-shrink-0 overflow-hidden rounded-md border border-border bg-muted flex items-center justify-center">
{version.previewUrl ? (
<img
src={version.previewUrl}
alt={version.name || ''}
className="h-full w-full object-cover"
/>
) : (
<FileIcon className="h-5 w-5 text-muted-foreground" />
)}
</div>
{/* 4. Name / Creator / Create Date (2 rows) */}
<div className="flex flex-col flex-1 min-w-0 text-left">
{/* Row 1: Name */}
<span className="truncate text-sm font-medium text-foreground" title={version.name || ''}>
{version.name || 'Untitled'}
</span>
{/* Row 2: Creator & Create Date */}
<div className="flex items-center gap-1.5 text-xs text-muted-foreground truncate">
<span>{version.creator?.name || m.unknown()}</span>
{formattedDate && (
<>
<span>•</span>
<span>{formattedDate}</span>
</>
)}
</div>
</div>
{/* 5. Three-dot button (only shows on card hover or dropdown open) */}
{canEdit && (
<DropdownMenu modal={false} open={dropdownOpen} onOpenChange={setDropdownOpen}>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
aria-label="More options"
className={cn(
'h-8 w-8 text-muted-foreground hover:text-foreground transition-opacity flex-shrink-0',
dropdownOpen
? 'opacity-100'
: 'opacity-0 group-hover:opacity-100 focus:opacity-100',
)}
>
<MoreVertical className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem
onClick={() => onRemove(version.id)}
className="text-destructive focus:text-destructive cursor-pointer"
>
<Trash2 className="h-4 w-4 mr-2" />
<span>{m.remove_from_stack()}</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
</div>
)
}
export function ManageVersionsDialog({
open,
onOpenChange,
stackId,
canEdit = true,
onVersionRemoved,
onStackDissolved,
}: ManageVersionsDialogProps) {
const queryClient = useQueryClient()
const [localVersions, setLocalVersions] = useState<StackVersionInfo[]>([])
const { data: fetchedVersions, isLoading } = useQuery({
queryKey: ['version_stacks', stackId, 'versions'],
queryFn: async () => {
const res = await client.api.version_stacks[':stackId'].versions.$get({
param: { stackId },
})
if (!res.ok) throw new Error('Failed to fetch versions')
return (await res.json()) as StackVersionInfo[]
},
enabled: open && !!stackId,
})
useEffect(() => {
if (fetchedVersions) {
setLocalVersions(fetchedVersions)
}
}, [fetchedVersions])
// Reorder mutation
const { mutate: reorderVersion } = useMutation({
mutationFn: async ({ fileId, beforeId }: { fileId: string; beforeId: string }) => {
const res = await client.api.version_stacks[':stackId'].order.$post({
param: { stackId },
json: { fileId, beforeId },
})
if (!res.ok) throw new Error('Failed to reorder versions')
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['version_stacks'] })
queryClient.invalidateQueries({ queryKey: ['files'] })
queryClient.invalidateQueries({ queryKey: ['projects'] })
toast.success(m.version_reordered_successfully())
},
onError: () => {
toast.error(m.failed_to_reorder_versions())
if (fetchedVersions) {
setLocalVersions(fetchedVersions)
}
},
})
// Remove version mutation
const { mutate: removeVersion, isPending: isRemoving } = useMutation({
mutationFn: async (versionId: string) => {
const res = await client.api.version_stacks[':stackId'].versions[':versionId'].$delete({
param: { stackId, versionId },
})
if (!res.ok) throw new Error('Failed to remove version from stack')
return versionId
},
onSuccess: (removedVersionId) => {
toast.success(m.version_removed_successfully())
const remaining = localVersions.filter((v) => v.id !== removedVersionId)
setLocalVersions(remaining)
queryClient.invalidateQueries({ queryKey: ['version_stacks'] })
queryClient.invalidateQueries({ queryKey: ['files'] })
queryClient.invalidateQueries({ queryKey: ['projects'] })
if (remaining.length <= 1) {
const singleRemaining = remaining[0]
onOpenChange(false)
if (singleRemaining) {
onStackDissolved?.(singleRemaining.id)
}
} else {
onVersionRemoved?.(removedVersionId, remaining)
}
},
onError: () => {
toast.error(m.failed_to_remove_version())
},
})
const handleDragEnd = (event: DragEndEvent) => {
if (event.canceled) return
const { source } = event.operation
if (!isSortable(source)) return
const { initialIndex, index } = source
if (initialIndex === index) return
const updated = [...localVersions]
const [movedItem] = updated.splice(initialIndex, 1)
updated.splice(index, 0, movedItem)
setLocalVersions(updated)
// Calculate beforeId for the API:
// When moved to index `index` in a list ordered from newest to oldest:
// If index is at the very bottom (index === updated.length - 1), beforeId = '-1' (places after all others).
// Otherwise, beforeId is the ID of the item currently at index + 1 (the next item below it in the list).
const beforeId = index === updated.length - 1 ? '-1' : updated[index + 1].id
reorderVersion({
fileId: movedItem.id,
beforeId,
})
}
const handleRemove = (versionId: string) => {
if (isRemoving) return
removeVersion(versionId)
}
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-lg p-0 gap-0 overflow-hidden">
<DialogHeader className="p-4 pb-3 border-b border-border">
<DialogTitle className="text-base font-semibold">{m.manage_versions_title()}</DialogTitle>
</DialogHeader>
<ScrollArea className="max-h-[60vh] p-4">
{isLoading ? (
<div className="py-8 text-center text-sm text-muted-foreground">
{m.loading?.() || 'Loading...'}
</div>
) : localVersions.length === 0 ? (
<div className="py-8 text-center text-sm text-muted-foreground">
{m.no_versions_found()}
</div>
) : (
<div className="space-y-2">
<DragDropProvider
sensors={[
PointerSensor.configure({
activationConstraints: [
new PointerActivationConstraints.Distance({ value: 6 }),
],
}),
KeyboardSensor,
]}
onDragEnd={handleDragEnd}
>
{localVersions.map((version, index) => (
<SortableVersionRow
key={version.id}
version={version}
displayVersionNumber={localVersions.length - index}
index={index}
canEdit={canEdit}
onRemove={handleRemove}
/>
))}
</DragDropProvider>
</div>
)}
</ScrollArea>
</DialogContent>
</Dialog>
)
}
@@ -1,176 +0,0 @@
.editor-container {
border-radius: 8px;
background: transparent;
color: inherit;
position: relative;
line-height: 1.5;
font-weight: 400;
text-align: left;
height: 100%;
}
.editor-inner {
background: transparent;
position: relative;
height: 100%;
}
.editor-input {
height: 100%;
min-height: 150px;
resize: none;
font-size: 15px;
caret-color: inherit;
position: relative;
tab-size: 1;
outline: 0;
padding: 15px 10px;
overflow-y: auto;
}
.editor-placeholder {
color: #999;
overflow: hidden;
position: absolute;
text-overflow: ellipsis;
top: 15px;
left: 10px;
font-size: 15px;
user-select: none;
display: inline-block;
pointer-events: none;
}
.editor-paragraph {
margin: 0 0 15px 0;
position: relative;
}
.editor-paragraph:last-child {
margin-bottom: 0;
}
.editor-heading-h1 {
font-size: 24px;
color: inherit;
font-weight: 400;
margin: 0;
padding: 0;
}
.editor-heading-h2 {
font-size: 15px;
color: inherit;
font-weight: 700;
margin: 0;
padding: 0;
text-transform: uppercase;
}
.editor-quote {
margin: 0;
margin-left: 20px;
font-size: 15px;
color: inherit;
border-left-color: #cecece;
border-left-width: 4px;
border-left-style: solid;
padding-left: 16px;
}
.editor-list-ol {
padding: 0;
margin: 0;
margin-left: 16px;
}
.editor-list-ul {
padding: 0;
margin: 0;
margin-left: 16px;
}
.editor-listitem {
margin: 8px 32px 8px 32px;
}
.editor-nested-listitem {
list-style-type: none;
}
pre {
line-height: 1.5;
}
.editor-code {
background-color: rgba(0, 0, 0, 0.05);
font-family: Menlo, Consolas, Monaco, monospace;
display: block;
padding: 8px 8px 8px 52px;
line-height: 1.53;
font-size: 13px;
margin: 0;
margin-top: 8px;
margin-bottom: 8px;
tab-size: 2;
overflow-x: auto;
position: relative;
}
.dark .editor-code {
background-color: rgba(255, 255, 255, 0.05);
}
.editor-code:before {
content: attr(data-gutter);
position: absolute;
background-color: transparent;
left: 0;
top: 0;
border-right: 1px solid transparent;
padding: 8px;
color: #777;
white-space: pre-wrap;
text-align: right;
min-width: 25px;
}
.editor-text-bold {
font-weight: bold;
}
.editor-text-italic {
font-style: italic;
}
.editor-text-underline {
text-decoration: underline;
}
.editor-text-strikethrough {
text-decoration: line-through;
}
.editor-text-underlineStrikethrough {
text-decoration: underline line-through;
}
.editor-text-code {
background-color: rgba(0, 0, 0, 0.05);
padding: 1px 0.25rem;
font-family: Menlo, Consolas, Monaco, monospace;
font-size: 94%;
}
.dark .editor-text-code {
background-color: rgba(255, 255, 255, 0.05);
}
.editor-link {
color: rgb(33, 111, 219);
text-decoration: none;
}
.editor-link:hover {
text-decoration: underline;
cursor: pointer;
}
@@ -1,180 +0,0 @@
import { CodeHighlightNode, CodeNode } from '@lexical/code'
import { AutoLinkNode, LinkNode } from '@lexical/link'
import { ListItemNode, ListNode } from '@lexical/list'
import {
$convertFromMarkdownString,
$convertToMarkdownString,
TRANSFORMERS,
} from '@lexical/markdown'
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin'
import { LexicalComposer } from '@lexical/react/LexicalComposer'
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import { ContentEditable } from '@lexical/react/LexicalContentEditable'
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary'
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin'
import { MarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin'
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin'
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin'
import { HeadingNode, QuoteNode } from '@lexical/rich-text'
import { TableCellNode, TableNode, TableRowNode } from '@lexical/table'
import { useEffect, useRef } from 'react'
import { ToolbarPlugin } from './lexical/plugins/ToolbarPlugin'
import './markdown-editor.css'
const theme = {
ltr: 'ltr',
rtl: 'rtl',
placeholder: 'editor-placeholder',
paragraph: 'editor-paragraph',
quote: 'editor-quote',
heading: {
h1: 'editor-heading-h1',
h2: 'editor-heading-h2',
h3: 'editor-heading-h3',
h4: 'editor-heading-h4',
h5: 'editor-heading-h5',
h6: 'editor-heading-h6',
},
list: {
nested: {
listitem: 'editor-nested-listitem',
},
ol: 'editor-list-ol',
ul: 'editor-list-ul',
listitem: 'editor-listitem',
},
image: 'editor-image',
link: 'editor-link',
text: {
bold: 'editor-text-bold',
italic: 'editor-text-italic',
overflowed: 'editor-text-overflowed',
hashtag: 'editor-text-hashtag',
underline: 'editor-text-underline',
strikethrough: 'editor-text-strikethrough',
underlineStrikethrough: 'editor-text-underlineStrikethrough',
code: 'editor-text-code',
},
code: 'editor-code',
codeHighlight: {
atrule: 'editor-tokenAttr',
attr: 'editor-tokenAttr',
boolean: 'editor-tokenProperty',
builtin: 'editor-tokenSelector',
cdata: 'editor-tokenComment',
char: 'editor-tokenSelector',
class: 'editor-tokenFunction',
'class-name': 'editor-tokenFunction',
comment: 'editor-tokenComment',
constant: 'editor-tokenProperty',
deleted: 'editor-tokenProperty',
doctype: 'editor-tokenComment',
entity: 'editor-tokenOperator',
function: 'editor-tokenFunction',
important: 'editor-tokenVariable',
inserted: 'editor-tokenSelector',
keyword: 'editor-tokenAttr',
namespace: 'editor-tokenVariable',
number: 'editor-tokenProperty',
operator: 'editor-tokenOperator',
prolog: 'editor-tokenComment',
property: 'editor-tokenProperty',
punctuation: 'editor-tokenPunctuation',
regex: 'editor-tokenVariable',
selector: 'editor-tokenSelector',
string: 'editor-tokenSelector',
symbol: 'editor-tokenProperty',
tag: 'editor-tokenProperty',
url: 'editor-tokenOperator',
variable: 'editor-tokenVariable',
},
}
function OnChangeMarkdownPlugin({ onChange }: { onChange: (markdown: string) => void }) {
const [editor] = useLexicalComposerContext()
return (
<OnChangePlugin
ignoreSelectionChange
onChange={() => {
editor.getEditorState().read(() => {
const markdown = $convertToMarkdownString(TRANSFORMERS)
onChange(markdown)
})
}}
/>
)
}
function InitialContentPlugin({ content }: { content: string }) {
const [editor] = useLexicalComposerContext()
const isFirstRender = useRef(true)
useEffect(() => {
if (isFirstRender.current) {
isFirstRender.current = false
editor.update(() => {
$convertFromMarkdownString(content, TRANSFORMERS)
})
}
}, [editor, content])
return null
}
export interface MarkdownEditorProps {
initialContent?: string
onChange?: (content: string) => void
readOnly?: boolean
}
export function MarkdownEditor({
initialContent = '',
onChange,
readOnly = false,
}: MarkdownEditorProps) {
const initialConfig = {
namespace: 'MarkdownEditor',
theme,
editable: !readOnly,
onError: (error: Error) => {
console.error(error)
},
nodes: [
HeadingNode,
ListNode,
ListItemNode,
QuoteNode,
CodeNode,
CodeHighlightNode,
TableNode,
TableCellNode,
TableRowNode,
AutoLinkNode,
LinkNode,
],
}
return (
<LexicalComposer initialConfig={initialConfig}>
<div className={`editor-container ${readOnly ? 'read-only' : ''}`}>
{!readOnly && <ToolbarPlugin />}
<div className="editor-inner">
<RichTextPlugin
contentEditable={<ContentEditable className="editor-input" />}
placeholder={
<div className="editor-placeholder">
{readOnly ? 'No content.' : 'Enter some text...'}
</div>
}
ErrorBoundary={LexicalErrorBoundary}
/>
<HistoryPlugin />
<AutoFocusPlugin />
<MarkdownShortcutPlugin transformers={TRANSFORMERS} />
{onChange && <OnChangeMarkdownPlugin onChange={onChange} />}
<InitialContentPlugin content={initialContent} />
</div>
</div>
</LexicalComposer>
)
}
@@ -0,0 +1,2 @@
export { MarkdownEditor, type MarkdownEditorProps } from './markdown-editor'
export { default } from './markdown-editor'
@@ -0,0 +1,280 @@
.shumai-editor-wrapper {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
border: 1px solid var(--border, #e2e8f0);
border-radius: 8px;
background-color: var(--background, #ffffff);
color: var(--foreground, #0f172a);
position: relative;
width: 100%;
box-sizing: border-box;
overflow: hidden;
font-family: inherit;
}
.shumai-editor-toolbar {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 4px;
padding: 6px 8px;
border-bottom: 1px solid var(--border, #e2e8f0);
background-color: var(--muted, #f8fafc);
user-select: none;
}
.shumai-editor-toolbar-left button {
display: inline-flex;
align-items: center;
justify-content: center;
width: 30px;
height: 30px;
border-radius: 6px;
border: none;
background: transparent;
color: var(--muted-foreground, #64748b);
cursor: pointer;
transition: all 0.15s ease;
padding: 0;
}
.shumai-editor-toolbar-left button:hover:not(:disabled) {
background-color: var(--accent, #e2e8f0);
color: var(--accent-foreground, #0f172a);
}
.shumai-editor-toolbar-left button:disabled {
opacity: 0.35;
cursor: not-allowed;
}
.shumai-editor-toolbar-left button.active {
background-color: var(--primary, #0f172a);
color: var(--primary-foreground, #ffffff);
}
.shumai-editor-toolbar select {
height: 30px;
padding: 0 8px;
border-radius: 6px;
border: 1px solid var(--border, #e2e8f0);
background-color: var(--background, #ffffff);
color: var(--foreground, #0f172a);
font-size: 13px;
cursor: pointer;
outline: none;
}
.shumai-editor-toolbar .toolbar-divider {
width: 1px;
height: 20px;
background-color: var(--border, #e2e8f0);
margin: 0 4px;
}
.shumai-editor-content-area {
position: relative;
min-height: 0;
flex: 1;
width: 100%;
box-sizing: border-box;
}
.editor-input {
min-height: 100%;
padding: 16px;
outline: none;
font-size: 15px;
line-height: 1.7;
color: inherit;
width: 100%;
box-sizing: border-box;
}
.editor-placeholder {
position: absolute;
top: 16px;
left: 16px;
right: 16px;
color: var(--muted-foreground, #94a3b8);
pointer-events: none;
user-select: none;
font-size: 15px;
line-height: 1.7;
white-space: pre-wrap;
}
/* Typography styles in WYSIWYG mode */
.editor-paragraph {
margin: 0 0 12px 0;
position: relative;
}
.editor-heading-h1 {
display: block;
font-size: 26px;
font-weight: 700;
margin: 20px 0 12px 0;
line-height: 1.3;
color: inherit;
}
.editor-heading-h2 {
display: block;
font-size: 20px;
font-weight: 600;
margin: 18px 0 10px 0;
line-height: 1.35;
color: inherit;
}
.editor-heading-h3 {
display: block;
font-size: 17px;
font-weight: 600;
margin: 14px 0 8px 0;
line-height: 1.4;
color: inherit;
}
.editor-quote {
display: block;
margin: 12px 0;
padding: 8px 16px;
border-left: 4px solid var(--primary, #3b82f6);
background-color: var(--muted, rgba(0, 0, 0, 0.03));
border-radius: 0 6px 6px 0;
color: var(--muted-foreground, #64748b);
font-style: italic;
}
.editor-list-ul {
padding: 0 0 0 24px;
margin: 8px 0 12px 0;
list-style-type: disc;
}
.editor-list-ol {
padding: 0 0 0 24px;
margin: 8px 0 12px 0;
list-style-type: decimal;
}
.editor-listitem {
margin: 4px 0;
}
.editor-nested-listitem {
list-style-type: none;
margin: 0;
}
/* Checklist / Task list */
.editor-checklist {
list-style-type: none;
padding-left: 0;
margin: 8px 0 12px 0;
}
.editor-listitem-checked,
.editor-listitem-unchecked {
position: relative;
list-style-type: none;
padding-left: 28px;
margin: 6px 0;
outline: none;
cursor: default;
}
.editor-listitem-checked:before,
.editor-listitem-unchecked:before {
content: '';
position: absolute;
left: 4px;
top: 4px;
width: 16px;
height: 16px;
border: 1.5px solid var(--border, #cbd5e1);
border-radius: 4px;
background-color: var(--background, #ffffff);
cursor: pointer;
box-sizing: border-box;
}
.editor-listitem-checked:before {
background-color: var(--primary, #2563eb);
border-color: var(--primary, #2563eb);
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
background-size: 12px;
background-position: center;
background-repeat: no-repeat;
}
.editor-listitem-checked {
text-decoration: line-through;
opacity: 0.75;
}
/* Inline text formats */
.editor-text-bold {
font-weight: 600;
}
.editor-text-italic {
font-style: italic;
}
.editor-text-underline {
text-decoration: underline;
}
.editor-text-strikethrough {
text-decoration: line-through;
}
.editor-text-code {
font-family:
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
monospace;
font-size: 0.9em;
padding: 2px 6px;
border-radius: 4px;
background-color: var(--muted, #f1f5f9);
border: 1px solid var(--border, #e2e8f0);
}
/* Code block (full-row block display) */
code.editor-code-block,
.editor-code-block {
display: block !important;
width: 100% !important;
box-sizing: border-box !important;
font-family:
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
monospace;
font-size: 13.5px;
line-height: 1.6;
background-color: var(--muted, #f1f5f9);
color: var(--foreground, #0f172a);
border: 1px solid var(--border, #e2e8f0);
padding: 12px 16px;
border-radius: 6px;
margin: 12px 0;
overflow-x: auto;
white-space: pre-wrap;
word-break: break-all;
tab-size: 2;
position: relative;
}
.editor-link {
color: var(--primary, #2563eb);
text-decoration: underline;
cursor: pointer;
}
.editor-link:hover {
opacity: 0.8;
}
@@ -0,0 +1,23 @@
// @vitest-environment happy-dom
import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import React from 'react'
import { MarkdownEditor } from './markdown-editor'
describe('MarkdownEditor', () => {
it('renders toolbar buttons and content editable area', () => {
render(<MarkdownEditor placeholder="Type here..." initialContent="# Hello World" />)
expect(screen.getByRole('textbox')).toBeDefined()
expect(screen.getByRole('button', { name: /bold/i })).toBeDefined()
expect(screen.getByRole('button', { name: /italic/i })).toBeDefined()
expect(screen.getByRole('button', { name: /undo/i })).toBeDefined()
})
it('renders in readOnly mode without toolbar', () => {
const { container } = render(<MarkdownEditor readOnly initialContent="Read only text" />)
expect(container.querySelector('.shumai-editor-toolbar')).toBeNull()
expect(container.querySelector('.read-only')).toBeDefined()
})
})
@@ -0,0 +1,161 @@
import React, { useEffect, useRef } from 'react'
import { LexicalComposer, type InitialConfigType } from '@lexical/react/LexicalComposer'
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin'
import { ContentEditable } from '@lexical/react/LexicalContentEditable'
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin'
import { ListPlugin } from '@lexical/react/LexicalListPlugin'
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin'
import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin'
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin'
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin'
import { MarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin'
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin'
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary'
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown'
import { HeadingNode, QuoteNode } from '@lexical/rich-text'
import { ListNode, ListItemNode } from '@lexical/list'
import { CodeNode } from '@lexical/code'
import { TableNode, TableCellNode, TableRowNode } from '@lexical/table'
import { AutoLinkNode, LinkNode } from '@lexical/link'
import { ToolbarPlugin } from './toolbar'
import { editorTheme } from './theme'
import { EDITOR_TRANSFORMERS } from './transformers'
import { ScrollArea } from '@/ui/components/ui/scroll-area'
import './markdown-editor.css'
function MarkdownSyncPlugin({
value,
initialContent = '',
onChange,
}: {
value?: string
initialContent?: string
onChange?: (markdown: string) => void
}) {
const [editor] = useLexicalComposerContext()
const isInitializedRef = useRef(false)
const lastEmittedMarkdownRef = useRef<string>('')
useEffect(() => {
if (!isInitializedRef.current) {
isInitializedRef.current = true
const startingContent = value !== undefined ? value : initialContent
if (startingContent) {
editor.update(() => {
$convertFromMarkdownString(startingContent, EDITOR_TRANSFORMERS)
})
lastEmittedMarkdownRef.current = startingContent
}
}
}, [editor, initialContent, value])
useEffect(() => {
if (
isInitializedRef.current &&
value !== undefined &&
value !== lastEmittedMarkdownRef.current
) {
editor.update(() => {
$convertFromMarkdownString(value, EDITOR_TRANSFORMERS)
})
lastEmittedMarkdownRef.current = value
}
}, [editor, value])
return (
<OnChangePlugin
ignoreSelectionChange
onChange={(editorState) => {
editorState.read(() => {
const markdown = $convertToMarkdownString(EDITOR_TRANSFORMERS)
if (markdown !== lastEmittedMarkdownRef.current) {
lastEmittedMarkdownRef.current = markdown
onChange?.(markdown)
}
})
}}
/>
)
}
export interface MarkdownEditorProps {
initialContent?: string
value?: string
onChange?: (markdown: string) => void
placeholder?: string
readOnly?: boolean
autoFocus?: boolean
className?: string
hideToolbar?: boolean
rightToolbarContent?: React.ReactNode
}
export function MarkdownEditor({
initialContent = '',
value,
onChange,
placeholder = 'Write your markdown content here...',
readOnly = false,
autoFocus = false,
className = '',
hideToolbar = false,
rightToolbarContent,
}: MarkdownEditorProps) {
const initialConfig: InitialConfigType = {
namespace: 'ShumaiWysiwygMarkdownEditor',
theme: editorTheme,
editable: !readOnly,
onError: (error: Error) => {
console.error('[MarkdownEditor] Error:', error)
},
nodes: [
HeadingNode,
QuoteNode,
ListNode,
ListItemNode,
CodeNode,
TableNode,
TableCellNode,
TableRowNode,
AutoLinkNode,
LinkNode,
],
}
return (
<div className={`shumai-editor-wrapper ${readOnly ? 'read-only' : ''} ${className}`}>
<LexicalComposer initialConfig={initialConfig}>
{!readOnly && !hideToolbar ? (
<ToolbarPlugin rightContent={rightToolbarContent} />
) : rightToolbarContent ? (
<div className="shumai-editor-toolbar flex items-center justify-between px-3 py-1.5 border-b">
{rightToolbarContent}
</div>
) : null}
<ScrollArea className="shumai-editor-content-area flex-1 min-h-0 w-full">
<div className="relative min-h-full">
<RichTextPlugin
contentEditable={<ContentEditable className="editor-input" />}
placeholder={<div className="editor-placeholder">{placeholder}</div>}
ErrorBoundary={LexicalErrorBoundary}
/>
</div>
<HistoryPlugin />
<ListPlugin />
<CheckListPlugin />
<TabIndentationPlugin />
<LinkPlugin />
<MarkdownShortcutPlugin transformers={EDITOR_TRANSFORMERS} />
<MarkdownSyncPlugin value={value} initialContent={initialContent} onChange={onChange} />
{autoFocus && <AutoFocusPlugin />}
</ScrollArea>
</LexicalComposer>
</div>
)
}
export default MarkdownEditor
@@ -0,0 +1,32 @@
import type { EditorThemeClasses } from 'lexical'
export const editorTheme: EditorThemeClasses = {
paragraph: 'editor-paragraph',
quote: 'editor-quote',
heading: {
h1: 'editor-heading-h1',
h2: 'editor-heading-h2',
h3: 'editor-heading-h3',
},
list: {
checklist: 'editor-checklist',
listitem: 'editor-listitem',
listitemChecked: 'editor-listitem-checked',
listitemUnchecked: 'editor-listitem-unchecked',
nested: {
listitem: 'editor-nested-listitem',
},
ol: 'editor-list-ol',
ul: 'editor-list-ul',
},
link: 'editor-link',
text: {
bold: 'editor-text-bold',
italic: 'editor-text-italic',
underline: 'editor-text-underline',
strikethrough: 'editor-text-strikethrough',
underlineStrikethrough: 'editor-text-underlineStrikethrough',
code: 'editor-text-code',
},
code: 'editor-code-block',
}
@@ -0,0 +1,495 @@
import React, { useCallback, useEffect, useState } from 'react'
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import {
$getSelection,
$isRangeSelection,
$createParagraphNode,
FORMAT_TEXT_COMMAND,
SELECTION_CHANGE_COMMAND,
UNDO_COMMAND,
REDO_COMMAND,
CAN_UNDO_COMMAND,
CAN_REDO_COMMAND,
COMMAND_PRIORITY_CRITICAL,
COMMAND_PRIORITY_LOW,
type RangeSelection,
type TextNode,
type ElementNode,
} from 'lexical'
import {
$isListNode,
ListNode,
INSERT_ORDERED_LIST_COMMAND,
INSERT_UNORDERED_LIST_COMMAND,
INSERT_CHECK_LIST_COMMAND,
REMOVE_LIST_COMMAND,
} from '@lexical/list'
import {
$createHeadingNode,
$createQuoteNode,
$isHeadingNode,
type HeadingTagType,
} from '@lexical/rich-text'
import { $createCodeNode } from '@lexical/code'
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link'
import { $isAtNodeEnd, $setBlocksType } from '@lexical/selection'
import { $getNearestNodeOfType } from '@lexical/utils'
import {
Bold,
Italic,
Underline,
Strikethrough,
Code,
Quote,
List,
ListOrdered,
ListTodo,
Heading1,
Heading2,
Heading3,
Link as LinkIcon,
RemoveFormatting,
Undo2,
Redo2,
} from 'lucide-react'
const blockTypes = {
paragraph: 'Normal',
h1: 'Heading 1',
h2: 'Heading 2',
h3: 'Heading 3',
bullet: 'Bullet List',
number: 'Numbered List',
check: 'Check List',
quote: 'Quote',
code: 'Code Block',
} as const
type BlockType = keyof typeof blockTypes
function getSelectedNode(selection: RangeSelection): TextNode | ElementNode {
const anchor = selection.anchor
const focus = selection.focus
const anchorNode = selection.anchor.getNode()
const focusNode = selection.focus.getNode()
if (anchorNode === focusNode) {
return anchorNode
}
const isBackward = selection.isBackward()
if (isBackward) {
return $isAtNodeEnd(focus) ? anchorNode : focusNode
} else {
return $isAtNodeEnd(anchor) ? focusNode : anchorNode
}
}
export function ToolbarPlugin({ rightContent }: { rightContent?: React.ReactNode } = {}) {
const [editor] = useLexicalComposerContext()
const [canUndo, setCanUndo] = useState(false)
const [canRedo, setCanRedo] = useState(false)
const [blockType, setBlockType] = useState<BlockType>('paragraph')
const [isBold, setIsBold] = useState(false)
const [isItalic, setIsItalic] = useState(false)
const [isUnderline, setIsUnderline] = useState(false)
const [isStrikethrough, setIsStrikethrough] = useState(false)
const [isCode, setIsCode] = useState(false)
const [isLink, setIsLink] = useState(false)
const updateToolbar = useCallback(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
setIsBold(selection.hasFormat('bold'))
setIsItalic(selection.hasFormat('italic'))
setIsUnderline(selection.hasFormat('underline'))
setIsStrikethrough(selection.hasFormat('strikethrough'))
setIsCode(selection.hasFormat('code'))
// Update link state
const node = getSelectedNode(selection)
const parent = node.getParent()
setIsLink($isLinkNode(parent) || $isLinkNode(node))
// Update block type
const anchorNode = selection.anchor.getNode()
const element =
anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow()
const elementKey = element.getKey()
const elementDom = editor.getElementByKey(elementKey)
if (elementDom !== null) {
if ($isListNode(element)) {
const parentList = $getNearestNodeOfType(anchorNode, ListNode)
const type = parentList ? parentList.getListType() : element.getListType()
setBlockType(type as BlockType)
} else if ($isHeadingNode(element)) {
setBlockType(element.getTag() as BlockType)
} else {
const type = element.getType()
if (type in blockTypes) {
setBlockType(type as BlockType)
} else {
setBlockType('paragraph')
}
}
}
}
}, [editor])
useEffect(() => {
return editor.registerCommand(
SELECTION_CHANGE_COMMAND,
() => {
updateToolbar()
return false
},
COMMAND_PRIORITY_CRITICAL,
)
}, [editor, updateToolbar])
useEffect(() => {
return editor.registerUpdateListener(({ editorState }) => {
editorState.read(() => {
updateToolbar()
})
})
}, [editor, updateToolbar])
useEffect(() => {
const unregisterUndo = editor.registerCommand(
CAN_UNDO_COMMAND,
(payload: boolean) => {
setCanUndo(payload)
return false
},
COMMAND_PRIORITY_LOW,
)
const unregisterRedo = editor.registerCommand(
CAN_REDO_COMMAND,
(payload: boolean) => {
setCanRedo(payload)
return false
},
COMMAND_PRIORITY_LOW,
)
return () => {
unregisterUndo()
unregisterRedo()
}
}, [editor])
const formatParagraph = () => {
editor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createParagraphNode())
}
})
}
const formatHeading = (headingSize: HeadingTagType) => {
editor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createHeadingNode(headingSize))
}
})
}
const formatBulletList = () => {
if (blockType !== 'bullet') {
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)
} else {
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
}
}
const formatNumberedList = () => {
if (blockType !== 'number') {
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)
} else {
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
}
}
const formatCheckList = () => {
if (blockType !== 'check') {
editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined)
} else {
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
}
}
const formatQuote = () => {
if (blockType !== 'quote') {
editor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createQuoteNode())
}
})
} else {
formatParagraph()
}
}
const formatCodeBlock = () => {
if (blockType !== 'code') {
editor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
$setBlocksType(selection, () => $createCodeNode())
}
})
} else {
formatParagraph()
}
}
const insertLink = useCallback(() => {
if (!isLink) {
const url = prompt('Enter link URL (e.g., https://example.com):')
if (url) {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, url)
}
} else {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)
}
}, [editor, isLink])
const clearFormatting = useCallback(() => {
editor.update(() => {
const selection = $getSelection()
if ($isRangeSelection(selection)) {
selection.setFormat(0)
$setBlocksType(selection, () => $createParagraphNode())
}
})
}, [editor])
const handleBlockTypeChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const value = e.target.value as BlockType
switch (value) {
case 'paragraph':
formatParagraph()
break
case 'h1':
case 'h2':
case 'h3':
formatHeading(value)
break
case 'bullet':
formatBulletList()
break
case 'number':
formatNumberedList()
break
case 'check':
formatCheckList()
break
case 'quote':
formatQuote()
break
case 'code':
formatCodeBlock()
break
}
}
return (
<div className="shumai-editor-toolbar flex items-center justify-between">
<div className="shumai-editor-toolbar-left flex items-center flex-wrap gap-1">
{/* Undo / Redo */}
<button
type="button"
disabled={!canUndo}
onMouseDown={(e) => e.preventDefault()}
onClick={() => editor.dispatchCommand(UNDO_COMMAND, undefined)}
title="Undo"
aria-label="Undo"
>
<Undo2 className="h-4 w-4" />
</button>
<button
type="button"
disabled={!canRedo}
onMouseDown={(e) => e.preventDefault()}
onClick={() => editor.dispatchCommand(REDO_COMMAND, undefined)}
title="Redo"
aria-label="Redo"
>
<Redo2 className="h-4 w-4" />
</button>
<div className="toolbar-divider" />
{/* Block Type Dropdown */}
<select value={blockType} onChange={handleBlockTypeChange} aria-label="Block formatting">
<option value="paragraph">Normal</option>
<option value="h1">Heading 1</option>
<option value="h2">Heading 2</option>
<option value="h3">Heading 3</option>
<option value="bullet">Bullet List</option>
<option value="number">Numbered List</option>
<option value="check">Check List</option>
<option value="quote">Quote</option>
<option value="code">Code Block</option>
</select>
<div className="toolbar-divider" />
{/* Inline Styles */}
<button
type="button"
className={isBold ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')}
title="Bold (Ctrl+B)"
aria-label="Bold"
>
<Bold className="h-4 w-4" />
</button>
<button
type="button"
className={isItalic ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')}
title="Italic (Ctrl+I)"
aria-label="Italic"
>
<Italic className="h-4 w-4" />
</button>
<button
type="button"
className={isUnderline ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')}
title="Underline (Ctrl+U)"
aria-label="Underline"
>
<Underline className="h-4 w-4" />
</button>
<button
type="button"
className={isStrikethrough ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')}
title="Strikethrough"
aria-label="Strikethrough"
>
<Strikethrough className="h-4 w-4" />
</button>
<button
type="button"
className={isCode ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code')}
title="Inline Code"
aria-label="Inline Code"
>
<Code className="h-4 w-4" />
</button>
<button
type="button"
className={isLink ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={insertLink}
title="Insert Link"
aria-label="Link"
>
<LinkIcon className="h-4 w-4" />
</button>
<div className="toolbar-divider" />
{/* Quick Insert / Block shortcuts */}
<button
type="button"
className={blockType === 'h1' ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => formatHeading('h1')}
title="H1"
aria-label="Heading 1"
>
<Heading1 className="h-4 w-4" />
</button>
<button
type="button"
className={blockType === 'h2' ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => formatHeading('h2')}
title="H2"
aria-label="Heading 2"
>
<Heading2 className="h-4 w-4" />
</button>
<button
type="button"
className={blockType === 'h3' ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={() => formatHeading('h3')}
title="H3"
aria-label="Heading 3"
>
<Heading3 className="h-4 w-4" />
</button>
<button
type="button"
className={blockType === 'bullet' ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={formatBulletList}
title="Bullet List"
aria-label="Bullet List"
>
<List className="h-4 w-4" />
</button>
<button
type="button"
className={blockType === 'number' ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={formatNumberedList}
title="Numbered List"
aria-label="Numbered List"
>
<ListOrdered className="h-4 w-4" />
</button>
<button
type="button"
className={blockType === 'check' ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={formatCheckList}
title="Check List"
aria-label="Check List"
>
<ListTodo className="h-4 w-4" />
</button>
<button
type="button"
className={blockType === 'quote' ? 'active' : ''}
onMouseDown={(e) => e.preventDefault()}
onClick={formatQuote}
title="Quote"
aria-label="Quote"
>
<Quote className="h-4 w-4" />
</button>
<div className="toolbar-divider" />
{/* Clear formatting */}
<button
type="button"
onMouseDown={(e) => e.preventDefault()}
onClick={clearFormatting}
title="Clear Formatting"
aria-label="Clear Formatting"
>
<RemoveFormatting className="h-4 w-4" />
</button>
</div>
{rightContent && (
<div className="flex items-center gap-2 ml-auto flex-shrink-0">{rightContent}</div>
)}
</div>
)
}
@@ -0,0 +1,16 @@
import {
CHECK_LIST,
ELEMENT_TRANSFORMERS,
MULTILINE_ELEMENT_TRANSFORMERS,
TEXT_FORMAT_TRANSFORMERS,
TEXT_MATCH_TRANSFORMERS,
type Transformer,
} from '@lexical/markdown'
export const EDITOR_TRANSFORMERS: Transformer[] = [
CHECK_LIST,
...ELEMENT_TRANSFORMERS,
...MULTILINE_ELEMENT_TRANSFORMERS,
...TEXT_FORMAT_TRANSFORMERS,
...TEXT_MATCH_TRANSFORMERS,
]
@@ -74,12 +74,7 @@ export function SortControl({ fields, sort, onSortChange, disabled }: SortContro
return (
<Popover>
<PopoverTrigger asChild>
<Button
variant={sort ? 'secondary' : 'ghost'}
size="sm"
className="h-8"
disabled={disabled}
>
<Button variant={sort ? 'secondary' : 'ghost'} size="sm" disabled={disabled}>
{sort ? m.sorted_by({ field: currentField.label }) : m.sort_by()}
</Button>
</PopoverTrigger>
+7 -2
View File
@@ -20,6 +20,7 @@ export function TopNav() {
ancestorFolders,
currentAsset,
isRootFolder,
customTerminalBreadcrumb,
fileId,
downloadInfo,
versions,
@@ -35,6 +36,7 @@ export function TopNav() {
} = projectState
const isFileView = !!fileId
const isAgentsMd = !!customTerminalBreadcrumb
const isShareConfig = !!shareId && !isFileView
@@ -105,8 +107,11 @@ export function TopNav() {
ancestorFolders={ancestorFolders}
currentAsset={currentAsset}
isRootFolder={isRootFolder}
displayStyle={isFileView || isShareConfig ? undefined : displayStyle}
onDisplayStyleChange={isFileView || isShareConfig ? undefined : onDisplayStyleChange}
customTerminalBreadcrumb={customTerminalBreadcrumb}
displayStyle={isFileView || isShareConfig || isAgentsMd ? undefined : displayStyle}
onDisplayStyleChange={
isFileView || isShareConfig || isAgentsMd ? undefined : onDisplayStyleChange
}
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
onLeftSidebarToggle={onLeftSidebarToggle}
isRightSidebarCollapsed={isRightSidebarCollapsed}
+16 -2
View File
@@ -516,7 +516,14 @@
"auth_community_cta": "Join our community of developers and designers.",
"versions": "Versions",
"manage_versions": "Manage versions...",
"manage_versions": "Manage versions",
"manage_versions_title": "Manage versions",
"remove_from_stack": "Remove from stack",
"version_removed_successfully": "Version removed from stack",
"failed_to_remove_version": "Failed to remove version",
"version_reordered_successfully": "Version order updated",
"failed_to_reorder_versions": "Failed to reorder versions",
"no_versions_found": "No versions found",
"compare_versions": "Compare Versions",
"exit_compare": "Exit compare",
"switch_version": "Switch version",
@@ -1035,5 +1042,12 @@
"preview_backdrop": "Preview Background",
"dark_grid": "Dark Grid",
"light_grid": "Light Grid",
"sample_backdrop": "Sample Media"
"sample_backdrop": "Sample Media",
"saved": "Saved",
"read_only": "Read-only",
"agents_md": "AGENTS.md",
"agents_md_placeholder": "Give AI agents instructions and context for this project or folder.\n\nShumai automatically loads this file, along with AGENTS.md files from parent folders up to the project level, whenever an agent works here.\n\nUse it to define things like:\n- What this project or folder contains\n- Rules the agent should follow\n- Terminology, style, or workflow\n- How metadata and autofill should be generated",
"agents_md_readonly_hint": "Only team owners can edit this file.",
"agents_md_save_failed": "Failed to save",
"agents_md_loading": "Loading AGENTS.md..."
}
+16 -2
View File
@@ -516,7 +516,14 @@
"auth_community_cta": "加入我们的开发者和设计师社区。",
"versions": "版本",
"manage_versions": "管理版本...",
"manage_versions": "管理版本",
"manage_versions_title": "管理版本",
"remove_from_stack": "从版本堆栈中移除",
"version_removed_successfully": "已从版本堆栈中移除版本",
"failed_to_remove_version": "移除版本失败",
"version_reordered_successfully": "版本顺序已更新",
"failed_to_reorder_versions": "版本重新排序失败",
"no_versions_found": "暂无版本",
"compare_versions": "对比版本",
"exit_compare": "退出对比",
"switch_version": "切换版本",
@@ -1035,5 +1042,12 @@
"preview_backdrop": "预览背景",
"dark_grid": "深色网格",
"light_grid": "浅色网格",
"sample_backdrop": "示例媒体"
"sample_backdrop": "示例媒体",
"saved": "已保存",
"read_only": "只读",
"agents_md": "AGENTS.md",
"agents_md_placeholder": "为在此项目或文件夹中工作的 AI Agent 提供指引和上下文。\n\n当 Agent 在此处工作时,Shumai 会自动加载此文件以及向上追溯至项目根目录各级父文件夹中的 AGENTS.md 文件。\n\n您可以用它来定义:\n- 此项目或文件夹包含的内容\n- Agent 应当遵守的规则\n- 术语、风格或工作流规范\n- 元数据和自动填充的生成方式",
"agents_md_readonly_hint": "只有团队所有者可以修改此文件。",
"agents_md_save_failed": "保存失败",
"agents_md_loading": "正在加载 AGENTS.md..."
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/webui",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"type": "module",
"main": "./index.html",
+14
View File
@@ -494,6 +494,13 @@ export * from "./auth_feature_teams.js";
export * from "./auth_community_cta.js";
export * from "./versions.js";
export * from "./manage_versions.js";
export * from "./manage_versions_title.js";
export * from "./remove_from_stack.js";
export * from "./version_removed_successfully.js";
export * from "./failed_to_remove_version.js";
export * from "./version_reordered_successfully.js";
export * from "./failed_to_reorder_versions.js";
export * from "./no_versions_found.js";
export * from "./compare_versions.js";
export * from "./exit_compare.js";
export * from "./switch_version.js";
@@ -980,4 +987,11 @@ export * from "./preview_backdrop.js";
export * from "./dark_grid.js";
export * from "./light_grid.js";
export * from "./sample_backdrop.js";
export * from "./saved.js";
export * from "./read_only.js";
export * from "./agents_md.js";
export * from "./agents_md_placeholder.js";
export * from "./agents_md_readonly_hint.js";
export * from "./agents_md_save_failed.js";
export * from "./agents_md_loading.js";
export type LocalizedString = import("../runtime.js").LocalizedString;
+15 -1
View File
@@ -496,6 +496,13 @@ export * from './auth_feature_teams.js'
export * from './auth_community_cta.js'
export * from './versions.js'
export * from './manage_versions.js'
export * from './manage_versions_title.js'
export * from './remove_from_stack.js'
export * from './version_removed_successfully.js'
export * from './failed_to_remove_version.js'
export * from './version_reordered_successfully.js'
export * from './failed_to_reorder_versions.js'
export * from './no_versions_found.js'
export * from './compare_versions.js'
export * from './exit_compare.js'
export * from './switch_version.js'
@@ -981,4 +988,11 @@ export * from './aspect_1_1.js'
export * from './preview_backdrop.js'
export * from './dark_grid.js'
export * from './light_grid.js'
export * from './sample_backdrop.js'
export * from './sample_backdrop.js'
export * from './saved.js'
export * from './read_only.js'
export * from './agents_md.js'
export * from './agents_md_placeholder.js'
export * from './agents_md_readonly_hint.js'
export * from './agents_md_save_failed.js'
export * from './agents_md_loading.js'
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "AGENTS.md" |
*
* @param {Agents_MdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md: ((inputs?: Agents_MdInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Agents_MdInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Agents_MdInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Agents_MdInputs */
const en_agents_md = /** @type {(inputs: Agents_MdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`AGENTS.md`)
};
const zh_agents_md = /** @type {(inputs: Agents_MdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`AGENTS.md`)
};
/**
* | output |
* | --- |
* | "AGENTS.md" |
*
* @param {Agents_MdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md = /** @type {((inputs?: Agents_MdInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Agents_MdInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_agents_md(inputs)
return zh_agents_md(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Loading AGENTS.md..." |
*
* @param {Agents_Md_LoadingInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_loading: ((inputs?: Agents_Md_LoadingInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Agents_Md_LoadingInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Agents_Md_LoadingInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Agents_Md_LoadingInputs */
const en_agents_md_loading = /** @type {(inputs: Agents_Md_LoadingInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Loading AGENTS.md...`)
};
const zh_agents_md_loading = /** @type {(inputs: Agents_Md_LoadingInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`正在加载 AGENTS.md...`)
};
/**
* | output |
* | --- |
* | "Loading AGENTS.md..." |
*
* @param {Agents_Md_LoadingInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_loading = /** @type {((inputs?: Agents_Md_LoadingInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Agents_Md_LoadingInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_agents_md_loading(inputs)
return zh_agents_md_loading(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Give AI agents instructions and context for this project or folder. Shumai automatically loads this file, along with AGENTS.md files from parent folders up t..." |
*
* @param {Agents_Md_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_placeholder: ((inputs?: Agents_Md_PlaceholderInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Agents_Md_PlaceholderInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Agents_Md_PlaceholderInputs = {};
@@ -0,0 +1,45 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Agents_Md_PlaceholderInputs */
const en_agents_md_placeholder = /** @type {(inputs: Agents_Md_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Give AI agents instructions and context for this project or folder.
Shumai automatically loads this file, along with AGENTS.md files from parent folders up to the project level, whenever an agent works here.
Use it to define things like:
- What this project or folder contains
- Rules the agent should follow
- Terminology, style, or workflow
- How metadata and autofill should be generated`)
};
const zh_agents_md_placeholder = /** @type {(inputs: Agents_Md_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`为在此项目或文件夹中工作的 AI Agent 提供指引和上下文。
当 Agent 在此处工作时,Shumai 会自动加载此文件以及向上追溯至项目根目录各级父文件夹中的 AGENTS.md 文件。
您可以用它来定义:
- 此项目或文件夹包含的内容
- Agent 应当遵守的规则
- 术语、风格或工作流规范
- 元数据和自动填充的生成方式`)
};
/**
* | output |
* | --- |
* | "Give AI agents instructions and context for this project or folder. Shumai automatically loads this file, along with AGENTS.md files from parent folders up t..." |
*
* @param {Agents_Md_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_placeholder = /** @type {((inputs?: Agents_Md_PlaceholderInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Agents_Md_PlaceholderInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_agents_md_placeholder(inputs)
return zh_agents_md_placeholder(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Only team owners can edit this file." |
*
* @param {Agents_Md_Readonly_HintInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_readonly_hint: ((inputs?: Agents_Md_Readonly_HintInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Agents_Md_Readonly_HintInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Agents_Md_Readonly_HintInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Agents_Md_Readonly_HintInputs */
const en_agents_md_readonly_hint = /** @type {(inputs: Agents_Md_Readonly_HintInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Only team owners can edit this file.`)
};
const zh_agents_md_readonly_hint = /** @type {(inputs: Agents_Md_Readonly_HintInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`只有团队所有者可以修改此文件。`)
};
/**
* | output |
* | --- |
* | "Only team owners can edit this file." |
*
* @param {Agents_Md_Readonly_HintInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_readonly_hint = /** @type {((inputs?: Agents_Md_Readonly_HintInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Agents_Md_Readonly_HintInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_agents_md_readonly_hint(inputs)
return zh_agents_md_readonly_hint(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Failed to save" |
*
* @param {Agents_Md_Save_FailedInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_save_failed: ((inputs?: Agents_Md_Save_FailedInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Agents_Md_Save_FailedInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Agents_Md_Save_FailedInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Agents_Md_Save_FailedInputs */
const en_agents_md_save_failed = /** @type {(inputs: Agents_Md_Save_FailedInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Failed to save`)
};
const zh_agents_md_save_failed = /** @type {(inputs: Agents_Md_Save_FailedInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`保存失败`)
};
/**
* | output |
* | --- |
* | "Failed to save" |
*
* @param {Agents_Md_Save_FailedInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agents_md_save_failed = /** @type {((inputs?: Agents_Md_Save_FailedInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Agents_Md_Save_FailedInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_agents_md_save_failed(inputs)
return zh_agents_md_save_failed(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Failed to remove version" |
*
* @param {Failed_To_Remove_VersionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const failed_to_remove_version: ((inputs?: Failed_To_Remove_VersionInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Failed_To_Remove_VersionInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Failed_To_Remove_VersionInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Failed_To_Remove_VersionInputs */
const en_failed_to_remove_version = /** @type {(inputs: Failed_To_Remove_VersionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Failed to remove version`)
};
const zh_failed_to_remove_version = /** @type {(inputs: Failed_To_Remove_VersionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`移除版本失败`)
};
/**
* | output |
* | --- |
* | "Failed to remove version" |
*
* @param {Failed_To_Remove_VersionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const failed_to_remove_version = /** @type {((inputs?: Failed_To_Remove_VersionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Failed_To_Remove_VersionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_failed_to_remove_version(inputs)
return zh_failed_to_remove_version(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Failed to reorder versions" |
*
* @param {Failed_To_Reorder_VersionsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const failed_to_reorder_versions: ((inputs?: Failed_To_Reorder_VersionsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Failed_To_Reorder_VersionsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Failed_To_Reorder_VersionsInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Failed_To_Reorder_VersionsInputs */
const en_failed_to_reorder_versions = /** @type {(inputs: Failed_To_Reorder_VersionsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Failed to reorder versions`)
};
const zh_failed_to_reorder_versions = /** @type {(inputs: Failed_To_Reorder_VersionsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`版本重新排序失败`)
};
/**
* | output |
* | --- |
* | "Failed to reorder versions" |
*
* @param {Failed_To_Reorder_VersionsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const failed_to_reorder_versions = /** @type {((inputs?: Failed_To_Reorder_VersionsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Failed_To_Reorder_VersionsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_failed_to_reorder_versions(inputs)
return zh_failed_to_reorder_versions(inputs)
});
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* | output |
* | --- |
* | "Manage versions..." |
* | "Manage versions" |
*
* @param {Manage_VersionsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
+3 -3
View File
@@ -6,17 +6,17 @@ import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {{}} Manage_VersionsInputs */
const en_manage_versions = /** @type {(inputs: Manage_VersionsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Manage versions...`)
return /** @type {LocalizedString} */ (`Manage versions`)
};
const zh_manage_versions = /** @type {(inputs: Manage_VersionsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`管理版本...`)
return /** @type {LocalizedString} */ (`管理版本`)
};
/**
* | output |
* | --- |
* | "Manage versions..." |
* | "Manage versions" |
*
* @param {Manage_VersionsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Manage versions" |
*
* @param {Manage_Versions_TitleInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const manage_versions_title: ((inputs?: Manage_Versions_TitleInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Manage_Versions_TitleInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Manage_Versions_TitleInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Manage_Versions_TitleInputs */
const en_manage_versions_title = /** @type {(inputs: Manage_Versions_TitleInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Manage versions`)
};
const zh_manage_versions_title = /** @type {(inputs: Manage_Versions_TitleInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`管理版本`)
};
/**
* | output |
* | --- |
* | "Manage versions" |
*
* @param {Manage_Versions_TitleInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const manage_versions_title = /** @type {((inputs?: Manage_Versions_TitleInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Manage_Versions_TitleInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_manage_versions_title(inputs)
return zh_manage_versions_title(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "No versions found" |
*
* @param {No_Versions_FoundInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_versions_found: ((inputs?: No_Versions_FoundInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<No_Versions_FoundInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type No_Versions_FoundInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} No_Versions_FoundInputs */
const en_no_versions_found = /** @type {(inputs: No_Versions_FoundInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`No versions found`)
};
const zh_no_versions_found = /** @type {(inputs: No_Versions_FoundInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`暂无版本`)
};
/**
* | output |
* | --- |
* | "No versions found" |
*
* @param {No_Versions_FoundInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_versions_found = /** @type {((inputs?: No_Versions_FoundInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<No_Versions_FoundInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_no_versions_found(inputs)
return zh_no_versions_found(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Read-only" |
*
* @param {Read_OnlyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const read_only: ((inputs?: Read_OnlyInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Read_OnlyInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Read_OnlyInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Read_OnlyInputs */
const en_read_only = /** @type {(inputs: Read_OnlyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Read-only`)
};
const zh_read_only = /** @type {(inputs: Read_OnlyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`只读`)
};
/**
* | output |
* | --- |
* | "Read-only" |
*
* @param {Read_OnlyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const read_only = /** @type {((inputs?: Read_OnlyInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Read_OnlyInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_read_only(inputs)
return zh_read_only(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Remove from stack" |
*
* @param {Remove_From_StackInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const remove_from_stack: ((inputs?: Remove_From_StackInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Remove_From_StackInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Remove_From_StackInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Remove_From_StackInputs */
const en_remove_from_stack = /** @type {(inputs: Remove_From_StackInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Remove from stack`)
};
const zh_remove_from_stack = /** @type {(inputs: Remove_From_StackInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`从版本堆栈中移除`)
};
/**
* | output |
* | --- |
* | "Remove from stack" |
*
* @param {Remove_From_StackInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const remove_from_stack = /** @type {((inputs?: Remove_From_StackInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Remove_From_StackInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_remove_from_stack(inputs)
return zh_remove_from_stack(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Saved" |
*
* @param {SavedInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const saved: ((inputs?: SavedInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<SavedInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type SavedInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} SavedInputs */
const en_saved = /** @type {(inputs: SavedInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Saved`)
};
const zh_saved = /** @type {(inputs: SavedInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`已保存`)
};
/**
* | output |
* | --- |
* | "Saved" |
*
* @param {SavedInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const saved = /** @type {((inputs?: SavedInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<SavedInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_saved(inputs)
return zh_saved(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Version removed from stack" |
*
* @param {Version_Removed_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const version_removed_successfully: ((inputs?: Version_Removed_SuccessfullyInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Version_Removed_SuccessfullyInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Version_Removed_SuccessfullyInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Version_Removed_SuccessfullyInputs */
const en_version_removed_successfully = /** @type {(inputs: Version_Removed_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Version removed from stack`)
};
const zh_version_removed_successfully = /** @type {(inputs: Version_Removed_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`已从版本堆栈中移除版本`)
};
/**
* | output |
* | --- |
* | "Version removed from stack" |
*
* @param {Version_Removed_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const version_removed_successfully = /** @type {((inputs?: Version_Removed_SuccessfullyInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Version_Removed_SuccessfullyInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_version_removed_successfully(inputs)
return zh_version_removed_successfully(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Version order updated" |
*
* @param {Version_Reordered_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const version_reordered_successfully: ((inputs?: Version_Reordered_SuccessfullyInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Version_Reordered_SuccessfullyInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Version_Reordered_SuccessfullyInputs = {};

Some files were not shown because too many files have changed in this diff Show More