fix(desktop): 发送后立即清空输入框,避免与气泡重叠 - #3388
Conversation
本机/SSH 原先要等 onSend(含 enqueue)结束后才清 composer,乐观气泡已经出现时输入框里还留着同一段字。现在与 device-link 一样在点击后先清,失败再恢复草稿。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/components/new-chat/ChatInput.tsx | 将本机与 SSH 发送改为提前清空,并增加按会话追踪的发送、清空和失败恢复状态。 |
| apps/desktop/src/renderer/components/new-chat/useComposerSendFocusRestore.ts | 焦点恢复现在仅依赖输入是否锁定,使发送仍在处理中但已允许输入时能够恢复焦点。 |
| apps/desktop/src/renderer/tests/dispatchSendClear.test.ts | 覆盖发送前立即清空以及返回 false、抛错时恢复草稿的契约。 |
| apps/desktop/src/renderer/components/new-chat/tests/useComposerSendFocusRestore.test.tsx | 更新焦点锁定测试,并覆盖发送尚未结束但输入已重新开放的状态。 |
Sequence Diagram
sequenceDiagram
participant U as 用户
participant C as 输入框
participant S as onSend
U->>C: 点击发送
C->>C: 保存点击时草稿并立即清空
C->>S: 等待发送链路
alt 发送成功
S-->>C: 接受
C->>C: 保留等待期间的新输入
else 拒绝或异常
S-->>C: 失败
C->>C: 恢复原草稿并保留较新内容
end
Reviews (8): Last reviewed commit: "fix(desktop): 切回任务时等乐观清空后再放开打字" | Re-trigger Greptile
MagicLizi
left a comment
There was a problem hiding this comment.
审查未通过(P1×1)。切任务后失败恢复可能把目标任务草稿写进源任务。
apps/desktop/src/renderer/components/new-chat/ChatInput.tsx:5175— Local/SSH 在await onSend前新增的 restore snapshot 刷新没有用editorOwnsSourceDraft。hydration / voice freeze 之后无条件执行documentBeforeOptimisticClear = editor.getJSON()。复用的 ChatInput 切走任务后 live editor 已是目标任务草稿;onSend === false/ throw / effort dirty 会调用restoreOptimisticallyClearedComposer(),把当前任务正文/附件写进源任务 draft slot。同函数里 lock、serialize、clearSentComposer都有 ownership 门,只有这段新刷新没有。请仅在editorOwnsSourceDraft(...)为 true 时刷新 snapshot;切走后保留 click-time / frozen extras。
Local/SSH 发送在 hydration 后刷新 restore snapshot 时必须仍持有源任务编辑器。复用的 ChatInput 切走后 live editor 已是目标任务,无条件刷新会在 onSend 失败时把目标草稿写进源 slot。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
@MagicLizi 已按你的 P1 修了:hydration 后刷新 restore snapshot 现在先过 commit: caf15c2 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: caf15c2d37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@dashhuang 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/components/new-chat/ChatInput.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
语音 stop-and-send 可能在切到任务 B 之后才真正 dispatch。此时 live editor 已是 B,无条件 snapshot 会在 A 发送失败时把 B 的正文写进 A。初始快照与 remote 的 click-time serialize 都先过 editorOwnsSourceDraft,切走后改用 frozen extras / 源 draft slot。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe4c1228a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
本机 onSend 未返回时若整段解锁,发送按钮会亮着但 in-flight guard 把下一次发送静默丢掉,权限选择也会提前可改。清空后只允许继续输入,发送和设置控件等到 enqueue 结束再开。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91bbad0b55
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
切走再回来时按 in-flight key 恢复 send 锁,避免按钮亮着点了被静默丢掉。语音 refinement 在切任务后落地时,把定稿文本写进 restore snapshot,失败恢复不再丢掉听写结果。同步 setEditable 源码契约。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e33086abb0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
收敛检查点(第 5 轮)离可合并还差什么: 失败族收口 + MagicLizi 对最新 HEAD 复审 + CI 绿。不是再加一层锁。 失败族当前 composer 的发送锁必须是「这个 storageKey 是否仍有在途 dispatchSend」的投影。 这族已经出现过的症状(同一不变量,不同入口):
唯一 owner
本轮修法把 |
A 的发送结算时若已切到 B,无条件 setAllowTypeDuringSend(false) 会在 B 仍在途时把 B 的编辑器锁死。两个 React 锁 flag 都只在 current storageKey 仍是这次发送的源任务时清零。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
命中 UI 路径(apps/desktop/src/renderer/components/new-chat/ChatInput.tsx)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
|
@MagicLizi 已在 PR 描述「UI 变化」补了发送后时序的 HTML 示意(改前叠字 / 改后输入框立即清空)。这次没有新控件或视觉语言改动,只改清空时机,所以没有另附实机截图。 原先那条 P1(hydration 后无条件刷新 restore snapshot)已在后续 commit 用 |
MagicLizi
left a comment
There was a problem hiding this comment.
发送后虽然立刻清空了输入框,但焦点恢复仍卡在旧的发送锁上,用户没法马上接着打下一句。
- [P1] apps/desktop/src/renderer/components/new-chat/useComposerSendFocusRestore.ts:69
Local/SSH 路径会先captureSendFocusForRestore()再setSendDispatchInFlight(true),composerMutationLocked也因此为 true。清空后allowTypeDuringSend已经用composerTypingLocked重新允许输入,但useComposerSendFocusRestore仍在sendDispatchInFlight || composerMutationLocked时直接 return。这两个旗标要等到onSend结束才落下,空输入框会暂时失焦,立刻打字进不去。
请在「允许打字」时恢复焦点(看!composerTypingLocked),并补一条sendDispatchInFlight && allowTypeDuringSend的 hook 测试。用较慢的 local/SSH 发送路径、不清点输入框再打字验证。
乐观清空后发送锁仍在,焦点恢复却还等 sendDispatchInFlight。 改成只看 composerTypingLocked,慢路径发送后也能马上接着打字。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
@MagicLizi 已修:焦点恢复只看 commit: 476811a |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 476811ab03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
发送在途但尚未 clearSentComposer 时,切走再切回不能把 allowTypeDuringSend 直接打开,否则下一句会被并进第一次发送。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
|
合了。发送后输入框立刻空出来,气泡和草稿不会再叠在一起,这个每天都会碰到的顿挫终于消掉了。 |
这次改了什么
摘要
本机/SSH 发送一条消息后,聊天气泡已经出来,输入框里同一段字还会停一会儿,看起来像文字叠在一起。
原因是本地发送要等
onSend整条链路(effort 等待、slash、鉴权、enqueue IPC)结束后才清输入框;而sendMessage会先把乐观气泡画进对话。device-link 远程发送早就在点击时清掉了。这次让本机/SSH 也走同一套:校验通过后立刻清空输入框,发送被拒或抛错再把草稿恢复回来。清空后输入框重新可编辑,失败恢复会保留用户在等待期间新打的字。
变更类型
fix缺陷修复feat新功能refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
ChatInput.dispatchSend在 awaitonSend之前清空当前会话输入框onSend返回 false、抛错)统一恢复点击时草稿UI 变化
无新控件、无文案、无配色或版式改动,只调整发送后输入框清空时机。
发送后界面时序(HTML 示意,非实机截图):
怎么验证的
自动验证
手工验证
未在本机启动 Desktop 实机点发送。根因是
dispatchSend明确把本机清空挂在await onSend之后,而sendMessageCore会先同步插入乐观气泡。未执行的验证
pnpm test:unit因无关的 mobile splash 超时未算绿风险
风险分类
影响与回滚
return false,会把刚清掉的草稿立刻填回,行为与改前一致提交前检查
git commit -s,见 DCO)