feat: 新增用户补充指引功能,含队列管理与 UI 交互#117
Open
xinggitxing wants to merge 1 commit into
Open
Conversation
…nd UI - Add PendingSupplementary queue (max 10 per session) with add/cancel/flush lifecycle - Inject supplementary messages as system messages before LLM calls (non-summarizing only) - Track isSummarizing phase: LLM responses without tool_calls mark summary phase - UI: Supplementary message list with up/down navigation, backspace cancel, enter submit - UI: Auto-refill unflushed supplementary text to PromptInput when agent becomes idle - UI: Keep PromptInput mounted (hidden via zero-height) to prevent buffer loss - UI: Render supplementary guidance messages in MessageView with distinct styling - Tests: 10 new test cases covering queue management, isolation, immutability, callbacks
Author
|
Issues #113 【TUI】不打断任务的情况下,补充发送引导信息。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
新增"补充指引"机制,允许用户在 LLM 正在处理提示词时(不中断当前轮次)发送额外指令。这实现了"边执行边引导"的交互模式,用户可输入指引文本进入队列,在下次 LLM API 调用前自动注入。
动机
此前当 LLM 忙碌时(例如在多步骤任务中执行工具调用),用户只能等待完成或直接中断智能体来发送新指令。本功能引入了一个非侵入式的补充消息队列:用户可以在智能体工作时输入并提交指引内容,系统会
将这些消息作为
system消息在下次 LLM API 调用前注入(跳过总结阶段)。核心变更
会话层(
src/session.ts)PendingSupplementary类型和MAX_SUPPLEMENTARY_QUEUE(每会话上限 10 条)MessageMeta.isSupplementary标记用于消息渲染addSupplementaryMessage、cancelSupplementaryMessage、countPendingSupplementary、listPendingSupplementary、isInSummaryPhaseflushSupplementaryMessages():将队列条目转换为system角色的SessionMessage[],内容前缀为[User Supplementary Guidance]\nactivateSession()中每次 LLM 调用前注入,但仅在 非总结阶段(上次 LLM 响应包含 tool_calls 时)isSummarizing标记跟踪 LLM 返回是否包含 tool_callsUI — App(
src/ui/App.tsx)supplementaryCount、supplementaryList、isSummarizingonSupplementaryStatusChanged回调将队列同步到 React 状态height: 0隐藏),防止视图切换时缓冲区丢失UI — PromptInput(
src/ui/PromptInput.tsx)isSummarizing时阻止输入,显示"等待总结完成..."UI — MessageView(
src/ui/components/MessageView/index.tsx)message.meta?.isSupplementary新增渲染分支:黄色边框的[Supplementary Guidance]信息块测试(
src/tests/session.test.ts)新增 10 个测试用例:
addSupplementaryMessage队列添加并返回 IDaddSupplementaryMessage队列满时返回 nullcancelSupplementaryMessage移除特定消息cancelSupplementaryMessage空会话返回 falseflushSupplementaryMessages返回正确角色和前缀的 system 消息isInSummaryPhase初始返回 falseonSupplementaryStatusChanged在添加和取消时被调用文件变更
src/session.tssrc/tests/session.test.tssrc/ui/App.tsxsrc/ui/PromptInput.tsxsrc/ui/components/MessageView/index.tsx测试结果
npm run check— 类型检查、代码规范、格式检查全部通过