feat(react-ui): expose selectedImages via useCopilotChatImageUploads hook#1
Open
oxyflour wants to merge 1 commit into
Open
feat(react-ui): expose selectedImages via useCopilotChatImageUploads hook#1oxyflour wants to merge 1 commit into
useCopilotChatImageUploads hook#1oxyflour wants to merge 1 commit into
Conversation
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.
Motivation
CopilotChat中维护的selectedImages状态能够被组件树外部的子组件访问和操作,从而支持自定义上传/预览/提交等场景。Description
CopilotChatImageUploadsContext并导出钩子useCopilotChatImageUploads,通过上下文向下提供selectedImages、setSelectedImages、clearSelectedImages和removeSelectedImage。CopilotChat内实现并复用clearSelectedImages方法以统一清空图片队列与重置文件输入框状态,并把该方法用于发送消息的清理流程(handleSendMessage)。CopilotChatImageUploadsContext.Provider包裹原有渲染树以确保 hook 在CopilotChat子树中可用。packages/v1/react-ui/src/components/chat/index.tsx中导出useCopilotChatImageUploads以便外部直接 import 使用。Testing
pnpm prettier --write packages/v1/react-ui/src/components/chat/Chat.tsx packages/v1/react-ui/src/components/chat/index.tsx成功。pnpm nx run @copilotkit/react-ui:check-types在该环境中失败,失败原因为工作区模块解析限制(例如@copilotkit/react-core/@copilotkit/runtime-client-gql无法解析)以及其它与本变更无关的现有类型错误。pnpm nx run @copilotkit/react-ui:build --excludeTaskDependencies时 JavaScript 构建成功但 DTS(类型声明生成)在当前环境下因同样的模块解析问题失败。Codex Task