Repository navigation
Commit c33e1aa
fix(cli): keep one-shot system-reminder prefixes out of shell mode (#12605)
* fix(cli): keep one-shot system-reminder prefixes out of shell mode
Fixes #11626.
Two gaps let `<system-reminder>` text reach bash or misroute queued
input around shell mode:
- handleFinalSubmit prepended the recovered-agents and the
worktree-restore one-shot notices even in shell mode, where the
leading `<system-reminder>` is a bash syntax error — and consuming
the one-shot latch there dropped the notice before any model turn
could see it. Both notices are now gated on `!shellModeActive` and
stay armed for the next model-bound prompt. (The workflow-keyword
reminder was already shell-gated.)
- The queue drain routed submissions on the live shell-mode flag at
drain time, so a flip while an entry waited in the queue could send
a shell command to the model or a model prompt to bash. Shell intent
is now recorded at submit time (addMessage/restoreMessages), travels
with the queued entry, and the drain/submitQuery route on
`shellModeIntent ?? shellModeActive`; batches stay intent-homogeneous
so one routing decision never misroutes another entry. Producers
that record no intent keep routing on the live flag, as before.
Tests: packages/cli src/ui/AppContainer.test.tsx,
hooks/use-llm-stream.test.tsx, hooks/useMessageQueue.test.ts — the new
cases are red on the unfixed source (prefix reached shell-mode
submissions; recorded intent ignored at drain) and green with the fix
(544 passed, 0 failed).
Co-authored-by: Qwen-Coder <[email protected]>
Patrol-Run: qwen-issue-patrol/jmuf0dfzl0a
* fix(cli): batch queued submissions by the head's intent run
popNextSubmission selected every queue entry matching the first plain
entry's recorded shell intent, so a later same-intent entry overtook an
earlier different-intent one. Queueing a model prompt, a shell command
and a second model prompt while a turn was responding drained both
prompts as one batch and left the command queued behind them: the model
answered the second prompt against the pre-command tree, and the command
then ran with no prompt consuming its output.
Take the contiguous same-intent run from the head instead. That keeps
per-entry routing and submission order together; the only cost is one
extra model turn when a shell command sits between two prompts, which no
longer merge. batch[0] is still plainMessages[0], so the batch turnKey
and the key peekNextUserBatchKey reserves for the Goal runtime are
unchanged.
The case that pinned the old reorder now asserts order preservation, and
a new case pins that adjacent same-intent entries still aggregate.
Review finding: R1-5 on PR 12605.
Co-authored-by: Qwen-Coder <[email protected]>
Patrol-Run: qwen-pr-closeout/jmufqt39629
* test(cli): pin the drain's shell-intent wire, correct stale gate comments
The submitQuery metadata spread in the queued-submission drain is the
only production hop that carries a queue entry's recorded shell intent to
the router, and nothing pinned it: deleting those three lines left all
three suites green, because the use-llm-stream cases inject the intent
into submitQuery by hand and the existing drain assertions use
objectContaining on a different key, which cannot fail on a missing one.
Extend the existing persistent-admission-failure drain case instead of
adding a second harness: its submission now records shellMode, the new
assertion pins the metadata key itself, and the restore leg is asserted
on intent rather than arity (third argument stays true, as that leg
defers).
Also correct two comments in this file that this change falsified: they
said the other notices handleFinalSubmit prepends do not check shell
mode and that the gate is load-bearing only through the workflow
reminder's call site. Every notice the handler prepends is now gated at
its own call site, and the two #11626 cases below depend on the
recovered-agents and worktree gates rather than on this one.
Review findings: R1-2 and R1-1 on PR 12605.
Co-authored-by: Qwen-Coder <[email protected]>
Patrol-Run: qwen-pr-closeout/jmufqt39629
* test(cli): pin the deferred leg's shell-intent argument
Ctrl+Q is not shell-gated (InputPrompt.tsx binds QUEUE_MESSAGE after the
`if (!shellModeActive)` block closes), so a shell-mode submission can take
the deferUntilIdle branch of handleFinalSubmit. That leg's addMessage call
was only asserted with the 4th argument false, which is indistinguishable
from the parameter's default: replacing shellModeActive with false at
AppContainer.tsx:3253 kept the whole suite green. Add the shell-mode arm so
both directions of the argument are pinned.
Co-authored-by: Qwen-Coder <[email protected]>
Patrol-Run: qwen-pr-closeout/jmufv3et42h
---------
Co-authored-by: yiliang114 <[email protected]>
Co-authored-by: Qwen-Coder <[email protected]>1 parent 177c2f6 commit c33e1aa
6 files changed
Lines changed: 615 additions & 25 deletions
File tree
- packages/cli/src/ui
- hooks
0 commit comments