Skip to content

feat(mobile-web): send a prompt suggestion with one tap - #3656

Open
gordon-gs wants to merge 1 commit into
GCWing:mainfrom
gordon-gs:feat/prompt-suggestion-one-tap-send
Open

gordon-gs wants to merge 1 commit into
GCWing:mainfrom
gordon-gs:feat/prompt-suggestion-one-tap-send

Conversation

@gordon-gs

Copy link
Copy Markdown

问题

Remote 端聊天页的建议气泡(prompt suggestion)只有一个动作:把建议文本填进输入框。

这在触屏上要两次点击才能发出去 —— 第一次点气泡、第二次点发送键。而且点完气泡它立刻消失(显示条件是「输入框为空」),第二次点击的落点还换了地方。

桌面端有 Tab 键可以先落到输入框再随手回车,触屏没有对应物。

改动

气泡主体保持原行为(只填入、不发送),旁边新增一个独立的发送控件,一步直达:

  • 气泡 = 采纳建议,填入输入框并聚焦
  • 气泡右侧的箭头按钮 = 直接提交这条建议

实现上复用现有提交通道,没有新开一条发送路径:

handleSend 增加一个可选的显式文本参数,onClick 传进来的事件对象会被类型判断挡掉(typeof === 'string'),所以原有的 onSend={handleSend} 语义不变。

const explicitText = typeof overrideText === 'string' ? overrideText : null;
const text = (explicitText ?? input).trim();

草稿保护:本来清理草稿的逻辑是「发送成功后,如果输入框内容没被改过就清空」。一键发送时草稿根本没参与,所以这条清理被跳过 —— 用户打了一半的内容不会被建议顶掉。

具体文件

文件 改动
src/mobile-web/src/components/ChatComposerBar.tsx 气泡拆成 accept + send 两个控件,新增 onSendPromptSuggestion
src/mobile-web/src/pages/ChatPage.tsx handleSend 支持显式文本,接通 onSendPromptSuggestion
src/mobile-web/src/styles/components/chat-input.scss 气泡行改为 flex 布局,保留 label 省略号
src/mobile-web/src/i18n/messages.ts 新增 chat.promptSuggestionSend(en / zh-CN / zh-TW)
src/mobile-web/tests/fixtures/prompt-suggestion.tsx fixture 支持一键发送
src/mobile-web/tests/prompt-suggestion-browser.test.mjs 新增用例:点箭头 → 记录发送、textarea 不被填充

验证

pnpm --dir src/mobile-web run type-check
pnpm --dir src/mobile-web run test:prompt-suggestion-browser

两条都通过;原有的「气泡布局在 320/390/768/1200 下不溢出、点击只采纳不提交」用例仍然通过,说明默认交互没有被改坏。

范围

只改 Remote web 端。iOS / Android / HarmonyOS 的原生 composer 目前仍是「只采纳」,如果这个方向认可,可以按同样的语义跟进。

The suggestion bubble only accepts the text into the composer, so sending
a suggestion always costs a second tap on the send button, and accepting
first hides the bubble because it is gated on an empty editor.

Keep the bubble as the accept affordance and add a trailing control that
submits the suggestion directly. The send path reuses the existing
submission handler with an explicit text override, so toast/queue/error
handling stays in one place, and the draft is left untouched — a
half-typed message must never be clobbered by a suggestion.

Covered by the existing prompt-suggestion browser fixture plus a new case
asserting one tap records a send and does not fill the textarea.

iOS, Android and HarmonyOS composers still accept-only; this change
covers the Remote web surface.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant