Skip to content

fix(chat): send a queued follow-up with the steer shortcut - #1921

Merged
vastsa merged 6 commits into
vastsa:mainfrom
zszz3:fix/send-queued-now-shortcut
Oct 28, 2026
Merged

vastsa merged 6 commits into
vastsa:mainfrom
zszz3:fix/send-queued-now-shortcut

Conversation

@zszz3

@zszz3 zszz3 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

fixes #1920

问题

后续消息排队后草稿已被清空,⌥/Alt+Enter(§3.5 的「立即转向」)找不到草稿就静默返回,等于键盘路径断裂,只能鼠标点队列行的「立即发送」。

改动

  • useComposerSubmit:草稿序列化后为空时,若本次是转向提交且发送未被拦,就把队列中第一条可发送的行交给 sendQueuedNow——和行内「立即发送」按钮走完全相同的 store → Host 链路(Host 决定投递为 steering 还是继续排队),不新增 IPC,也不绕过权限/审批。
  • lib/queued-prompts.ts 新增纯函数 nextSendableQueuedPrompt:跳过等待 Host admission 的 pending: 行和已提升的行,连按依次提升下一条。
  • 有草稿时行为不变(只推送草稿,不动队列);sendBlocked(等待审批 / 粘贴中 / 原生输入被拦)时不提升任何行。

验证

  • 新增 apps/desktop/test/composer-queued-send-now-shortcut.test.mjs:真实执行 nextSendableQueuedPrompt(跳过 pending / promoted / 空队列),并锁定 hook 的转向分支与 Composer 的接线(不可退化为 sendPrompt)。
  • pnpm --filter @pi-desktop/desktop test:4427 tests / 0 fail / 3 skipped。
  • pnpm build:js、pnpm --filter @pi-desktop/desktop typecheck、pnpm lint:biome、node scripts/check-architecture.mjs、node scripts/check-style-tokens.mjs、docs check:docs 均通过。
  • 手动在 dev 构建里验证:排队后清空输入框按 ⌥+Enter,首行变为「等待发送」并进入当前轮;带草稿时仍只推送草稿。

未跑:Electron UI E2E(verify:ui:* / test:e2e:*),按仓库规则需维护者明确要求;本改动不涉及持久化、IPC 协议或权限边界,docs/spec/06-delivery/04-e2e-test-plan.md 的 E2E-011f 已补步骤 13/14 待正式 UI 场景执行。

zszz3 added 2 commits October 27, 2026 19:03
A follow-up queued while the turn is running leaves the composer empty, so
Alt+Enter found no draft and silently did nothing: the only way to promote
that row was its Send now button. With an empty composer the shortcut now
promotes the first waiting row through the same store action, so keyboard and
pointer reach the same Host delivery path.

Rows still awaiting Host admission and already promoted rows are skipped, a
visible draft keeps taking precedence over the queue, and a blocked composer
promotes nothing.
Readers of the Send now rules should not have to reach §3.5 to learn that the
keyboard equivalent exists.
@zszz3

zszz3 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

CI 里只有 Trusted extensions Electron E2E 失败,失败点是 scripts/e2e-provider-client-certificate.mjs:

baseline: Electron 43 net.fetch failed before HTTP
AssertionError: provider client certificate E2E hung and was killed by SIGKILL after 65s

也就是 #1751 那类「探针在 xvfb 下卡住、靠 SIGKILL 兜底」的基础设施超时,和本 PR 的改动(renderer 里 composer 提交路径 + 一份 spec)没有交集。依据:

  • 同一分支本地执行 node scripts/e2e-provider-client-certificate.mjs 通过:provider client certificate E2E passed(那行 baseline: ... failed before HTTP 是探针的正常输出,本地同样会打印)。
  • 该 job 在多个无关分支上也是同一处失败:fix/live-transcript-bookmark (40474670234)、fix/tool-result-image-persistence (40372994569)、chore/release-0.22.0-beta.1 (40333724305),以及 main 自己的 40329624795。
  • 两次重跑(40493338980 / 40495507265)里的其余 job 全绿:Docs checks、Head contains latest base、JS build/typecheck/lint/architecture/test、Rust format/lint/test、Rust Windows/transcript cache E2E。

我没有这个仓库的 actions 权限(rerun-failed-jobs 返回 Must have admin rights),麻烦维护者帮忙重跑一次该 job,谢谢。

@muzimu217 muzimu217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the new branch against the row button it is meant to stand in for, and the eligibility matches exactly.

ComposerStatus.tsx:62 computes sendNowLocked = approvalPending || actionsLocked, where actionsLocked = promoted || pending (:61). The shortcut path requires steering && !sendBlocked, and sendBlocked is approvalPending || pasting || nativeInputBlocked (Composer.tsx:249), while nextSendableQueuedPrompt skips pending: ids and rows carrying priority (lib/queued-prompts.ts:54-63). So the shortcut promotes precisely the row whose own button would be enabled — no divergence to drift apart later.

Two details that make the change safe in the ways it could have gone wrong:

  • serializedContent is serializeComposerFileReferences(rawText, activeFileReferences), so a draft holding only an image chip still serializes to a non-empty @path. The new empty branch therefore cannot swallow an attachment-only send; it only runs when the composer is genuinely empty.
  • The new branch sits after serializedContent is computed but before the rest of the submit path, and it inherits sendBlocked, so pasting and native-input blocking keep behaving as they do for a normal send.

One question, not a defect: the new branch does not consult steeringAllowed (sessionAllows(capabilitySession, "canSteer")), while the non-empty path does. On a session that cannot steer, Alt+Enter with an empty composer will now promote a queued row where it previously did nothing. That may be exactly what you intend — the row's own Send now is not gated on canSteer either, and the Host decides delivery — but the spec text you added says "the steering shortcut ... promotes the first waiting row" without mentioning the capability, so either gate the branch on steeringAllowed or state in §3.5 that the shortcut degrades to "send the next queued follow-up" when steering is unavailable. The second reading seems more useful to me, and it is the one your current code implements; it just needs the sentence.

zszz3 added 2 commits October 28, 2026 01:01
…bility

The empty-composer shortcut mirrors the row's Send now, which is not gated
on canSteer; the Host decides delivery. Say so, so the spec does not read as
if the shortcut only works where steering is available.
@zszz3

zszz3 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. I kept the current behavior, so the shortcut is not gated on canSteer, the same as the row's Send now. I stated it in §3.5 in 981855a: where steering is unavailable, the Host keeps the promoted row queued, so the shortcut sends the next queued follow-up as soon as the turn ends. No code change.

I also merged the latest main (no force-push). On the merged result: desktop typecheck ok, desktop suite 4433 tests / 0 fail, architecture check ok. The earlier Trusted extensions Electron E2E failure is the provider-client-certificate hang described above, and the new push triggers a fresh run.

vastsa and others added 2 commits October 28, 2026 10:20
Exercise the submit hook through its public boundary so the shortcut behavior is proven for empty, blocked, and populated drafts.
@vastsa
vastsa merged commit 5dfa023 into vastsa:main Oct 28, 2026
5 of 6 checks passed
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.

输入框为空时无法用快捷键立即发送已排队的后续消息

3 participants