-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
perf: T2I template editor preview #4574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - 我发现了 1 个问题,并留下了一些高层次的反馈:
- 建议在对话框打开时只获取一次版本并进行缓存/复用,而不是在
dialog打开和每次refreshPreview时都调用syncPreviewVersion(),以避免重复的网络请求。 - 如果其他组件也需要应用版本信息,获取版本的逻辑(
syncPreviewVersion)可能更适合抽取到一个共享的 composable 或 service 中,这样之后就不用在多个地方重复处理/api/stat/version了。 - 建议不要在
syncPreviewVersion中直接使用console.warn,可以考虑通过现有的 UI 通知或日志上报机制来处理错误,这样失败信息就能更一致地展示给用户或监控系统。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider fetching the version once on dialog open and caching/reusing it rather than calling `syncPreviewVersion()` both on `dialog` open and every `refreshPreview`, to avoid redundant network requests.
- The version-fetching logic (`syncPreviewVersion`) might be better extracted into a shared composable or service if other components also need the app version, so you don't duplicate the `/api/stat/version` handling in multiple places later.
- Instead of using `console.warn` directly in `syncPreviewVersion`, consider routing errors through your existing UI notification or logging mechanism so failures are surfaced consistently to users or monitoring.
## Individual Comments
### Comment 1
<location> `dashboard/src/components/shared/T2ITemplateEditor.vue:299-302` </location>
<code_context>
}
+
+const previewData = computed(() => ({
+ text: tm('t2iTemplateEditor.previewText') || '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。',
+ version: previewVersion.value
+}))
</code_context>
<issue_to_address>
**suggestion:** Using `||` means an intentionally empty translated string will fall back to the default text.
If `tm('t2iTemplateEditor.previewText')` returns an intentionally empty string, `||` will treat it as falsy and incorrectly fall back to the default Chinese text. To only fall back when the translation is missing (undefined/null), use nullish coalescing or an explicit check, e.g.:
```ts
const t = tm('t2iTemplateEditor.previewText')
text: t ?? defaultText
// or
text: t !== undefined ? t : defaultText
```
```suggestion
const previewData = computed(() => {
const t = tm('t2iTemplateEditor.previewText')
return {
text: t ?? '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。',
version: previewVersion.value
}
})
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进以后的 Review。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- Consider fetching the version once on dialog open and caching/reusing it rather than calling
syncPreviewVersion()both ondialogopen and everyrefreshPreview, to avoid redundant network requests. - The version-fetching logic (
syncPreviewVersion) might be better extracted into a shared composable or service if other components also need the app version, so you don't duplicate the/api/stat/versionhandling in multiple places later. - Instead of using
console.warndirectly insyncPreviewVersion, consider routing errors through your existing UI notification or logging mechanism so failures are surfaced consistently to users or monitoring.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider fetching the version once on dialog open and caching/reusing it rather than calling `syncPreviewVersion()` both on `dialog` open and every `refreshPreview`, to avoid redundant network requests.
- The version-fetching logic (`syncPreviewVersion`) might be better extracted into a shared composable or service if other components also need the app version, so you don't duplicate the `/api/stat/version` handling in multiple places later.
- Instead of using `console.warn` directly in `syncPreviewVersion`, consider routing errors through your existing UI notification or logging mechanism so failures are surfaced consistently to users or monitoring.
## Individual Comments
### Comment 1
<location> `dashboard/src/components/shared/T2ITemplateEditor.vue:299-302` </location>
<code_context>
}
+
+const previewData = computed(() => ({
+ text: tm('t2iTemplateEditor.previewText') || '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。',
+ version: previewVersion.value
+}))
</code_context>
<issue_to_address>
**suggestion:** Using `||` means an intentionally empty translated string will fall back to the default text.
If `tm('t2iTemplateEditor.previewText')` returns an intentionally empty string, `||` will treat it as falsy and incorrectly fall back to the default Chinese text. To only fall back when the translation is missing (undefined/null), use nullish coalescing or an explicit check, e.g.:
```ts
const t = tm('t2iTemplateEditor.previewText')
text: t ?? defaultText
// or
text: t !== undefined ? t : defaultText
```
```suggestion
const previewData = computed(() => {
const t = tm('t2iTemplateEditor.previewText')
return {
text: t ?? '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。',
version: previewVersion.value
}
})
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| const previewData = computed(() => ({ | ||
| text: tm('t2iTemplateEditor.previewText') || '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。', | ||
| version: previewVersion.value | ||
| })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: 使用 || 会导致有意配置为空字符串的翻译也回退到默认文案。
如果 tm('t2iTemplateEditor.previewText') 返回的是一个有意设置的空字符串,|| 会把它当作 falsy,从而错误地回退到默认的中文文案。为了只在翻译缺失(undefined/null)时回退,建议使用空值合并运算符或显式判断,例如:
const t = tm('t2iTemplateEditor.previewText')
text: t ?? defaultText
// or
text: t !== undefined ? t : defaultText| const previewData = computed(() => ({ | |
| text: tm('t2iTemplateEditor.previewText') || '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。', | |
| version: previewVersion.value | |
| })) | |
| const previewData = computed(() => { | |
| const t = tm('t2iTemplateEditor.previewText') | |
| return { | |
| text: t ?? '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。', | |
| version: previewVersion.value | |
| } | |
| }) |
Original comment in English
suggestion: Using || means an intentionally empty translated string will fall back to the default text.
If tm('t2iTemplateEditor.previewText') returns an intentionally empty string, || will treat it as falsy and incorrectly fall back to the default Chinese text. To only fall back when the translation is missing (undefined/null), use nullish coalescing or an explicit check, e.g.:
const t = tm('t2iTemplateEditor.previewText')
text: t ?? defaultText
// or
text: t !== undefined ? t : defaultText| const previewData = computed(() => ({ | |
| text: tm('t2iTemplateEditor.previewText') || '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。', | |
| version: previewVersion.value | |
| })) | |
| const previewData = computed(() => { | |
| const t = tm('t2iTemplateEditor.previewText') | |
| return { | |
| text: t ?? '这是一个示例文本,用于预览模板效果。\n\n这里可以包含多行文本,支持换行和各种格式。', | |
| version: previewVersion.value | |
| } | |
| }) |
* feat: astr live * chore: remove * feat: metrics * feat: enhance audio processing and metrics display in live mode * feat: genie tts * feat: enhance live mode audio processing and text handling * feat: add metrics * feat: eyes * feat: nervous * chore: update readme Added '自动压缩对话' feature and updated features list. * feat: skip saving head system messages in history (#4538) * feat: skip saving the first system message in history * fix: rename variable for clarity in system message handling * fix: update logic to skip all system messages until the first non-system message * fix: clarify logic for skipping initial system messages in conversation * chore: bump version to 4.12.2 * docs: update 4.12.2 changelog * refactor: update event types for LLM tool usage and response * chore: bump version to 4.12.3 * fix: ensure embedding dimensions are returned as integers in providers (#4547) * fix: ensure embedding dimensions are returned as integers in providers * chore: ruff format * perf: T2I template editor preview (#4574) * feat: add file drag upload feature for ChatUI (#4583) * feat(chat): add drag-drop upload and fix batch file upload * style(chat): adjust drop overlay to only cover input container * fix: streaming response for DingTalk (#4590) closes: #4384 * #4384 钉钉消息回复卡片模板 * chore: ruff format * chore: ruff format --------- Co-authored-by: ManJiang <man.jiang@jg-robust.com> Co-authored-by: Soulter <905617992@qq.com> * feat: implement persona folder for advanced persona management (#4443) * feat(db): add persona folder management for hierarchical organization Implement hierarchical folder structure for organizing personas: - Add PersonaFolder model with recursive parent-child relationships - Add folder_id and sort_order fields to Persona model - Implement CRUD operations for persona folders in database layer - Add migration support for existing databases - Extend PersonaManager with folder management methods - Add dashboard API routes for folder operations * feat(persona): add batch sort order update endpoint for personas and folders Add new API endpoint POST /persona/reorder to batch update sort_order for both personas and folders. This enables drag-and-drop reordering in the dashboard UI. Changes: - Add abstract batch_update_sort_order method to BaseDatabase - Implement batch_update_sort_order in SQLiteDatabase - Add batch_update_sort_order to PersonaManager with cache refresh - Add reorder_items route handler with input validation * feat(persona): add folder_id and sort_order params to persona creation Extend persona creation flow to support folder placement and ordering: - Add folder_id and sort_order parameters to insert_persona in db layer - Update PersonaManager.create_persona to accept and pass folder params - Add get_folder_detail API endpoint for retrieving folder information - Include folder_id and sort_order in persona creation response - Add session flush/refresh to return complete persona object * feat(dashboard): implement persona folder management UI - Add folder management system with tree view and breadcrumbs - Implement create, rename, delete, and move operations for folders - Add drag-and-drop support for organizing personas and folders - Create new PersonaManager component and Pinia store for state management - Refactor PersonaPage to support hierarchical structure - Update locale files with folder-related translations - Handle empty parent_id correctly in backend route * feat(dashboard): centralize folder expansion state in persona store Move folder expansion logic from local component state to global Pinia store to persist expansion state. - Add `expandedFolderIds` state and toggle actions to `personaStore` - Update `FolderTreeNode` to use store state instead of local data - Automatically navigate to target folder after moving a persona * feat(dashboard): add reusable folder management component library Extract folder management UI into reusable base components and create persona-specific wrapper components that integrate with personaStore. - Add base folder components (tree, breadcrumb, card, dialogs) with customizable labels for i18n support - Create useFolderManager composable for folder state management - Implement drag-and-drop support for moving personas between folders - Add persona-specific wrapper components connecting to personaStore - Reorganize PersonaManager into views/persona directory structure - Include comprehensive README documentation for component usage * refactor(dashboard): remove legacy persona folder management components Remove deprecated persona folder management Vue components that have been superseded by the new reusable folder management component library. Deleted components: - CreateFolderDialog.vue - FolderBreadcrumb.vue - FolderCard.vue - FolderTree.vue - FolderTreeNode.vue - MoveTargetNode.vue - MoveToFolderDialog.vue - PersonaCard.vue - PersonaManager.vue These components are replaced by the centralized folder management implementation introduced in commit 3fbb3db. * fix(dashboard): add delayed skeleton loading to prevent UI flicker Implement a 150ms delay before showing the skeleton loader in PersonaManager to prevent visual flicker during fast loading operations. - Add showSkeleton state with timer-based delay mechanism - Use v-fade-transition for smooth skeleton visibility transitions - Clean up timer on component unmount to prevent memory leaks - Only display skeleton when loading exceeds threshold duration * feat(dashboard): add generic folder item selector component for persona selection Introduce BaseFolderItemSelector.vue as a reusable component for selecting items within folder hierarchies. Refactor PersonaSelector to use this new base component instead of its previous flat list implementation. Changes: - Add BaseFolderItemSelector with folder tree navigation and item selection - Extend folder types with SelectableItem and FolderItemSelectorLabels - Refactor PersonaSelector to leverage the new base component - Add i18n translations for rootFolder and emptyFolder labels * feat(persona): add tree-view display for persona list command Add hierarchical folder tree output for the persona list command, showing personas organized by folders with visual tree connectors. - Add _build_tree_output method for recursive tree structure rendering - Display folders with 📁 icon and personas with 👤 icon - Show root-level personas separately from folder contents - Include total persona count in output * refactor(persona): simplify tree-view output with shorter indentation lines Replace complex tree connector logic with simpler depth-based indentation using "│ " prefix. Remove unnecessary parameters (prefix, is_last) and computed variables (has_content, total_items, item_idx) in favor of a cleaner depth-based approach. * feat(dashboard): add duplicate persona ID validation in create form Add frontend validation to prevent creating personas with duplicate IDs. Load existing persona IDs when opening the create form and validate against them in real-time. - Add existingPersonaIds array and loadExistingPersonaIds method - Add validation rule to check for duplicate persona IDs - Add i18n messages for duplicate ID error (en-US and zh-CN) - Fix minLength validation to require at least 1 character * i18n(persona): add createButton translation key for folder dialog Move create button label to folder-specific translation path instead of using generic buttons.create key. * feat(persona): show target folder name in persona creation dialog Add visual feedback showing which folder a new persona will be created in. - Add info alert in PersonaForm displaying the target folder name - Pass currentFolderName prop from PersonaManager and PersonaSelector - Add recursive findFolderName helper to resolve folder ID to name - Add i18n translations for createInFolder and rootFolder labels * style:format code * fix: remove 'persistent' attribute from dialog components --------- Co-authored-by: Soulter <905617992@qq.com> * perf: live mode entry * chore: remove japanese prompt --------- Co-authored-by: Anima-IGCenter <cacheigcrystal2@gmail.com> Co-authored-by: Clhikari <Clhikari@qq.com> Co-authored-by: jiangman202506 <jiangman202506@163.com> Co-authored-by: ManJiang <man.jiang@jg-robust.com> Co-authored-by: Ruochen Pan <67079377+RC-CHN@users.noreply.github.com>
This PR brings several improvements to the Template Editor preview:
/api/stat/version.Modifications / 改动点
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
通过使用动态数据来替代硬编码的值,为 T2I 模板编辑器预览提供版本号和预览文本,从而改进预览效果。
新功能:
/api/stat/version接口获取模板预览版本,并在预览中动态显示该版本信息。改进:
Original summary in English
Summary by Sourcery
Improve the T2I template editor preview by using dynamic data for version and preview text instead of hardcoded values.
New Features:
Enhancements: