Repository navigation
输入框草稿按群分存,改成自增高多行输入框 - #81
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
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.
改了什么
packages/web/src/state/composer-drafts.ts是一个模块级的 Map 加订阅,组件用useSyncExternalStore读,刷新页面就清空。setDraft(groupId, text)直接写这个模块,所以输入框卸载之后才回来的发送结果也能落地:项目页发送成功后清空原群的草稿,聊天页发送失败后把字写回原群。聊天和项目页都按群读草稿,切到别的群看到的是那个群自己的草稿,经过团队页、项目页再回来草稿还在。ComposerTextarea,按scrollHeight自增高,最高 8 行。Enter 提交所在的表单,Shift+Enter 换行。输入法组字时(isComposing,或 Safari 组字刚结束那下回车只剩keyCode 229)回车不发送。聊天和项目页都用它:两边共享同一个群的草稿,项目页如果还是单行<input>,会把草稿里的换行吞掉。.composer-textarea的最小高度取--control-h-md,和发送钮同高,上下内边距由(--control-h-md - 1lh) / 2推出来。项目页的输入框容器改成底部对齐,上下留出(--control-h-lg - --control-h-md) / 2。为什么
两个页面的草稿原来都是组件内的
useState。聊天组件换群时不重挂,草稿跟着带进新群,回车就发了过去;经过团队页或项目页时组件卸载,草稿就丢了。第一版改成每个 hook 实例持有一份快照,再用 effect 回写到模块变量。复核发现组件卸载之后写入会落空,于是改成现在这样直接写模块。
怎么验证
packages/web/e2e/composer-draft.spec.ts共 8 条:先红的证据:
<input>的隐式提交在 Chromium 组字时不触发)。把新代码里的isComposing/229 判断去掉,它就红。另外用 mock 加 Vite 真点了一遍聊天和项目页的单行、多行和发送,截图看过,没进仓库。
Mac App(WKWebView)里用真输入法的验证还没做,见 #32 的评论。
Closes #48
Closes #32
🤖 Generated with Claude Code
https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni