Conversation
28c0766 to
0316799
Compare
0316799 to
95e49b1
Compare
|
@Chevey339 找时间可以审一下谢谢 |
95e49b1 to
0c0cc5c
Compare
0c0cc5c to
25c6855
Compare
|
冲突处理好了。 |
|
AI-assisted review:
|
1977a83 提交说明
|
fec6436 to
7b28c7e
Compare
Introduce shared building blocks for the re_editor migration: - Add PlainTextCodeEditor wrapper and theme-based style builder - Add CodeLineEditingController.setTextSafely() helper (IME-safe) - Add input height constraints helper for large text inputs Also include small supporting cleanups in utils.
- Add fallback HTML template and catch asset load failures in markdown preview - Make base64 image sanitizer regex group access null-safe to avoid crashes
- Replace TextField/TextEditingController with CodeLineEditingController and PlainTextCodeEditor in translate pages (mobile + desktop) - Buffer streaming output and flush on a short timer to reduce UI churn - Track runId to prevent stale stream chunks from overwriting new runs
- Migrate model prompt editors to CodeLineEditingController + PlainTextCodeEditor - Apply shared input height constraints for large prompt fields - Reduce duplicated CodeEditor configuration across sheets/dialogs
- Migrate instruction injection prompt editors to CodeLineEditingController and PlainTextCodeEditor (mobile + desktop) - Reuse shared input height constraints and safe controller text sync
- Migrate message editing UI (page/sheet/desktop dialog) to CodeLineEditingController - Replace hand-rolled text syncing with setTextSafely() to avoid IME issues
- Migrate Service Account JSON editor to PlainTextCodeEditor - Sync CodeLineEditingController content safely (IME-aware) - Debounce config writes (400ms) and flush on blur/dispose
Migrate the chat input stack from TextField/TextEditingController to re_editor (CodeLineEditingController + PlainTextCodeEditor) and unify shortcut handling. BREAKING CHANGE: Chat input controllers are now CodeLineEditingController. External code must migrate: - ChatInputBar.controller (TextEditingController? -> CodeLineEditingController?) - ChatInputSection.inputController (TextEditingController -> CodeLineEditingController) - HomePageController.inputController (TextEditingController -> CodeLineEditingController)
Restore IME-safe enter handling, touch paste access, and pending JSON edits after the re_editor migration. Also align empty-message saves across edit surfaces.
7b28c7e to
1977a83
Compare
refactor(editor): 统一文本编辑迁移至 re_editor,抽取共享组件与防抖保存
共享 PlainTextCodeEditor · Markdown 预览加固 · 多场景迁移至 CodeLineEditingController · BREAKING
Fixes #186
Refactor
是
25
▰▰▰▰▰▱▱▱▱▱核心目标
架构设计总览
flowchart LR subgraph Shared["共享层"] Editor["PlainTextCodeEditor\n(shared widget)"] --> Style["buildPlainTextCodeEditorStyle()"] Editor --> Utils["CodeLineEditingControllerX\nsetTextSafely()"] Editor --> Height["input_height_constraints\ncomputeInputMaxHeight()"] end subgraph Usage["使用场景"] Translate["翻译页\nmobile + desktop"] --> Editor Model["模型配置\nprompt sheets / OCR prompt"] --> Editor Instruction["指令注入\nprompt editors"] --> Editor MsgEdit["消息编辑\npage + sheet + dialog"] --> Editor Settings["桌面设置\nproviders pane"] --> Editor ChatInput["聊天输入栏\nBREAKING"] --> Utils end subgraph Markdown["Markdown 配套"] Preview["markdown_preview_html\nfallback template"] --> Render["WebView preview"] Sanitize["markdown_media_sanitizer\nnull-safe group"] --> Render end变更详情漫游
共享编辑器与工具
plain_text_code_editor.dartlib/shared/widgets/
统一 PlainTextCodeEditor
CodeEditor的通用配置:NonCodeChunkAnalyzer、隐藏 indicator、统一主题样式re_editor_utils.dartlib/utils/
setTextSafely:统一安全同步
String到CodeLineEditingValue的转换与 selection 定位controller.text,降低同步失败导致的数据丢失风险input_height_constraints.dartlib/shared/widgets/
viewInsets、预留区域与最小高度,减少弹层/编辑器溢出。小计: +260
Markdown 预览与媒体安全
markdown_preview_html.dartmarkdown_media_sanitizer.dartsurfaceContainerHighest,与新配色体系更一致-21页面迁移(翻译 / 模型 / 指令 / 消息编辑 / 设置)
translate_page.dartdesktop_translate_page.dartrunId防回填,减少 chunk 级频繁刷新带来的 UI 抖动。-217default_model_page.dartdefault_model_pane.dartocr_prompt_sheet.dartPlainTextCodeEditor;桌面默认模型 pane 保留现有TextField交互,但接入统一高度约束,避免大文本输入区域溢出。-559instruction_injection_page.dartinstruction_injection_pane.dartsetTextSafely()统一同步逻辑,减少 composing/selection 被打断的风险。-44message_edit_page.dartmessage_edit_sheet.dartmessage_edit_dialog.dartsetTextSafely()处理文本同步。-97desktop_settings_page.dartproviders_pane.dartCodeLineEditingController+PlainTextCodeEditor,引入debounce(400ms)、失焦保存与 dispose flush。desktop_settings_page.dart仅补齐接入所需依赖与结构衔接。-38聊天输入迁移(BREAKING)
chat_input_bar.dartchat_input_section.darthome_page.darthome_page_controller.dartPlainTextCodeEditor,统一短文本编辑模式replaceSelection()、applyNewLine()、makeCursorVisible()等 API 替代原有 TextField 逻辑_ComposingAwareNewLineAction等路径中处理CodeLineEditingController的原生编辑能力-737依赖与杂项
pubspec.yamlapp_directories.dartavatar_cache.dartsandbox_path_resolver.dartre_editor: ^0.8.0-4行为变化对比
各页面自建 TextField / CodeEditor,风格与行为不一chunk 级频繁刷新,容易造成 UI 抖动和旧流回填每次输入都可能触发写入,存在卡顿/乱序风险模板缺失或异常媒体片段可能导致预览失败基于 TextField / TextEditingController 的分散逻辑风险控制与回滚
refactor(chat-input)!相关提交,必要时整体回滚本 PR。审阅指引
验证清单
构建与静态检查
预期:无新增错误;核心路径可运行
手动验证 - 编辑与保存
手动验证 - 聊天输入(BREAKING 路径)
本 PR 由 XiaoBuHaly:refactor/re-editor-input 发起