From 4a671a9bc26ed9e3300b351368ed5f1863005a9c Mon Sep 17 00:00:00 2001 From: suyao Date: Tue, 23 Sep 2025 05:37:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E7=BB=9F=E4=B8=80=E8=AE=A1=E5=88=92=E6=96=87=E6=A1=A3?= =?UTF-8?q?=EF=BC=8C=E5=AE=9A=E4=B9=89=E9=85=8D=E7=BD=AE=E5=B1=82=E5=92=8C?= =?UTF-8?q?=E5=85=B1=E4=BA=ABUI=E7=BB=84=E4=BB=B6=E7=9A=84=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/pages/home/Inputbar/TODO.md | 44 +++++++++++++++++++ .../Tools/MessageAgentTools/ReadTool.tsx | 6 +-- .../Tools/MessageAgentTools/WebSearchTool.tsx | 2 +- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/renderer/src/pages/home/Inputbar/TODO.md diff --git a/src/renderer/src/pages/home/Inputbar/TODO.md b/src/renderer/src/pages/home/Inputbar/TODO.md new file mode 100644 index 0000000000..117b246dc1 --- /dev/null +++ b/src/renderer/src/pages/home/Inputbar/TODO.md @@ -0,0 +1,44 @@ +# Inputbar Unification Plan + +## Goal +Create a single configurable input bar that supports chat topics, agent sessions, and other contexts (e.g. mini window) without duplicating UI logic. Remove `AgentSessionInputbar.tsx` in favour of the shared implementation. + +## Tasks + +### 1. Configuration Layer +- [ ] Add `InputbarScope` registry (e.g. `src/renderer/src/config/registry/inputbar.ts`). +- [ ] Define per-scope options (features toggles, placeholders, min/max rows, token counter, quick panel, attachments, knowledge picker, mention models, translate button, abort button, etc.). +- [ ] Register defaults for chat (`TopicType.Chat`), agent session (`TopicType.Session`), and mini window scope. + +### 2. Shared UI Composer +- [ ] Extract common UI from `Inputbar.tsx` into new `InputComposer` component that reads config + callbacks. +- [ ] Ensure composer handles textarea sizing, focus, drag/drop, token estimation, attachments, toolbar slots based on config. +- [ ] Provide controlled props for text, files, mentioned models, loading states, quick panel interactions. + +### 3. Chat Wrapper Migration +- [ ] Refactor `Inputbar.tsx` to: + - Resolve scope via topic type. + - Fetch config via registry. + - Supply send/abort/translate/knowledge handlers to composer. + - Remove inline UI duplication now covered by composer. +- [ ] Verify chat-specific behaviour (knowledge save, auto translate, quick panel, model mentions) via config flags and callbacks. + +### 4. Agent Session Wrapper Migration +- [ ] Rebuild session input bar (currently `AgentSessionInputbar.tsx`) as thin wrapper using composer and session scope config. +- [ ] Use session-specific hooks for message creation, model resolution, aborting, and streaming state. +- [ ] Once parity confirmed, delete `AgentSessionInputbar.tsx` and update all imports. + +### 6. Cross-cutting Cleanup +- [ ] Remove duplicated state caches (`_text`, `_files`, `_mentionedModelsCache`) once wrappers manage persistence appropriately. +- [ ] Update typings (`MessageInputBaseParams`, etc.) if composer needs shared interfaces. +- [ ] Ensure quick panel integration works for all scopes (guard behind config flag). + +### 7. Verification +- [ ] Run `yarn build:check` (after cleaning existing lint issues in WebSearchTool/ReadTool). +- [ ] Manual QA for chat topics, agent sessions, and mini window input: send, abort, attachments, translate, quick panel triggers, knowledge save. +- [ ] Add doc entry summarising registry usage and scope configuration. + +## Notes +- Aligns with the approach taken for `MessageMenubar` scope registry. +- Composer should accept refs for external focus triggers (e.g. `MessageGroup` or session auto-focus). +- Plan to remove now-unused session-specific styles/components once migration completes. diff --git a/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/ReadTool.tsx b/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/ReadTool.tsx index 078c9e4dfa..79f68c03bf 100644 --- a/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/ReadTool.tsx +++ b/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/ReadTool.tsx @@ -1,10 +1,10 @@ -import { AccordionItem, ScrollShadow } from '@heroui/react' +import { AccordionItem } from '@heroui/react' import { FileText } from 'lucide-react' +import ReactMarkdown from 'react-markdown' import { ToolTitle } from './GenericTools' -import { AgentToolsType } from './types' -import ReactMarkdown from 'react-markdown' import type { ReadToolInput as ReadToolInputType, ReadToolOutput as ReadToolOutputType } from './types' +import { AgentToolsType } from './types' export function ReadTool({ input, output }: { input: ReadToolInputType; output?: ReadToolOutputType }) { // 如果有输出,计算统计信息 diff --git a/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/WebSearchTool.tsx b/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/WebSearchTool.tsx index 7e9d85c5cc..ea38e3d3ce 100644 --- a/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/WebSearchTool.tsx +++ b/src/renderer/src/pages/home/Messages/Tools/MessageAgentTools/WebSearchTool.tsx @@ -1,7 +1,7 @@ import { AccordionItem } from '@heroui/react' import { Globe } from 'lucide-react' -import { SimpleFieldInputTool, ToolTitle } from './GenericTools' +import { ToolTitle } from './GenericTools' import type { WebSearchToolInput, WebSearchToolOutput } from './types' export function WebSearchTool({ input, output }: { input: WebSearchToolInput; output?: WebSearchToolOutput }) {