Initial TrueGrowth source import

This commit is contained in:
2026-07-07 09:36:36 +08:00
commit 3b6781d695
2283 changed files with 691996 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
# Change: 为 AI 输入栏增加剪贴板图片粘贴能力
## Why
当前主页面底部居中的 `AIInputBar` 只支持文本输入、文件选择上传和素材库选择,不支持直接从系统剪贴板粘贴图片。
这导致用户无法像其他多模态产品那样用 `Ctrl+V / Cmd+V` 快速把截图、复制图片等资源带入生成流程,也没有复用项目已有的图片校验、压缩和素材库入库逻辑。
## What Changes
-`AIInputBar` 增加剪贴板图片粘贴支持
-`AIInputBar` 的本地图片接入统一到现有图片上传规则:仅接受图片、限制体积、必要时压缩
- 粘贴进入的图片与手动上传的图片一致,自动写入素材库并进入输入栏内容预览
- 保持现有工作流提交流程不变,复用已有 `referenceImages` / `uploadedImages` 传递链路
## Impact
- Affected specs:
- `ai-input-bar`
- Affected code:
- `packages/drawnix/src/components/ai-input-bar/AIInputBar.tsx`
- `packages/drawnix/src/components/shared/SelectedContentPreview.tsx`
- `packages/drawnix/src/contexts/AssetContext.tsx`
- `apps/web-e2e/src/fixtures/test-app.ts`
## Analysis
当前实现的主要差异点如下:
1. `AIInputBar` 已支持上传按钮和素材库按钮,但没有注册任何 `paste` 监听,因此浏览器默认只会把可粘贴的文本写入 textarea。
2. `AIInputBar` 的本地上传链路只做了 `image/*` 过滤和 Base64 转换,没有复用 `ReferenceImageUpload` 中已经存在的大小限制、压缩和统一错误反馈逻辑。
3. 生成链路本身已经支持把输入栏中的图片作为 `referenceImages` 继续传给工作流、任务队列和模型适配层,因此新增粘贴能力主要是“补入口”和“统一处理”,不需要重构下游。

View File

@@ -0,0 +1,54 @@
## ADDED Requirements
### Requirement: AI Input Bar Clipboard Image Paste
`AIInputBar` SHALL accept image files from the system clipboard when the user is interacting with the input bar.
#### Scenario: Paste image while AI input bar is active
- **GIVEN** the user has focused the AI input textarea or another control inside `AIInputBar`
- **WHEN** the user pastes one or more clipboard image items
- **THEN** `AIInputBar` SHALL intercept the paste event
- **AND** add the pasted image resources to the input content preview
- **AND** keep them available for the next generation request as reference images
#### Scenario: Ignore paste outside AI input bar
- **GIVEN** the user focus is outside `AIInputBar`
- **WHEN** the user pastes clipboard image items
- **THEN** `AIInputBar` SHALL NOT import those images
### Requirement: Unified Local Image Intake Rules
Images entering `AIInputBar` from file selection or clipboard SHALL follow the same validation and processing rules.
#### Scenario: Reject unsupported clipboard content
- **GIVEN** the clipboard contains text or non-image files only
- **WHEN** the user pastes into `AIInputBar`
- **THEN** the existing text paste behavior SHALL remain unchanged
- **AND** no image preview item SHALL be added
#### Scenario: Apply existing image constraints
- **GIVEN** the user adds a local image through upload or paste
- **WHEN** the image exceeds the configured threshold for compression but is still within the supported size limit
- **THEN** the image SHALL be compressed before being attached
- **AND** the processed image SHALL be used for preview and generation
#### Scenario: Reject oversized image
- **GIVEN** the user adds a local image through upload or paste
- **WHEN** the image exceeds the supported maximum file size
- **THEN** the image SHALL be rejected
- **AND** the user SHALL receive an error message
### Requirement: Asset Library And Workflow Integration
Pasted images SHALL integrate with the existing asset library and workflow submission flow in the same way as uploaded images.
#### Scenario: Persist pasted image into asset library
- **GIVEN** the user pastes an image into `AIInputBar`
- **WHEN** the image is accepted by validation
- **THEN** the image SHALL be added to the asset library as a local image asset
#### Scenario: Reuse pasted image during generation
- **GIVEN** the user has pasted one or more images into `AIInputBar`
- **WHEN** the user submits a generation request
- **THEN** the resulting workflow context SHALL include those images as reference inputs
- **AND** downstream generation services SHALL receive them through the existing reference image pipeline

View File

@@ -0,0 +1,19 @@
# Tasks: AI 输入栏图片粘贴支持
## 1. 输入栏行为
- [x] 1.1 为 `AIInputBar` 增加剪贴板图片识别与粘贴处理
- [x] 1.2 限定粘贴生效范围,仅在 AI 输入栏聚焦或激活时接管图片粘贴
- [x] 1.3 保持纯文本粘贴行为不变,不影响现有 prompt 输入体验
## 2. 统一图片处理
- [x] 2.1 抽取或复用 AI 输入栏的图片导入逻辑,使文件选择与剪贴板图片走同一条处理链
- [x] 2.2 对齐现有图片上传规则:仅接受图片、限制最大体积、超阈值压缩、失败时提示
- [x] 2.3 将处理后的图片继续写入素材库,并显示在输入栏内容预览中
## 3. 集成验证
- [ ] 3.1 验证图片粘贴后可被正常移除、重复添加和参与生成
- [ ] 3.2 验证输入栏外部的粘贴不会误触发图片导入
- [x] 3.3 补充最小测试或手工验证记录