qwen-code/packages/cli/src
Shaojin Wen 61ad9db9c1
feat(cli): queue input editing — pop queued messages for editing via ↑/ESC (#2871)
* feat(cli): add queue input editing via Up arrow key

Allow users to edit queued messages by pressing the Up arrow key when
the cursor is at the top of the input. All queued messages are popped
into the input field for revision before resubmission, reducing wasted
turns from incorrect queued instructions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: add missing mocks for InputPrompt tests and attachment mode guard

- Add popAllQueuedMessages mock and messageQueue to UIState/UIActions
  mocks in InputPrompt.test.tsx to fix 25 test failures
- Add !isAttachmentMode guard to prevent queue pop from conflicting
  with attachment navigation
- Add single-message popAllMessages test case

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address Copilot review - restrict to Up arrow, add tests, update docs

- Only trigger queue pop on NAVIGATION_UP (arrow key), not HISTORY_UP
  (Ctrl+P), preserving existing Ctrl+P history navigation behavior
- Update AsyncMessageQueue class docs to describe popLast() LIFO semantics
- Add InputPrompt tests: Up arrow pops queue, Up arrow falls back to
  history when queue empty, Ctrl+P not intercepted by queue pop

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: update fileoverview docs and make popAllMessages atomic via ref

- Update @fileoverview to describe FIFO+LIFO capability instead of
  "Simple FIFO queue"
- Use queueRef to make popAllMessages atomic, preventing duplicate
  pops from key auto-repeat before React re-renders

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: sync queueRef in addMessage/clearQueue and fall through on null pop

- Update queueRef inside addMessage setter and clearQueue to keep ref
  in sync between renders, preventing stale reads after clearQueue
- When popAllQueuedMessages returns null (queue already cleared), fall
  through to normal history navigation instead of consuming the key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: remove dead popLast() and align popAllMessages separator to \n\n

- Remove unused AsyncMessageQueue.popLast() (no production callers)
- Change popAllMessages join separator from \n to \n\n for consistency
  with getQueuedMessagesText and auto-submit behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use hook's drainQueue for mid-turn drain to prevent double-consumption race

The midTurnDrainRef previously used a separate messageQueueRef (synced
from React state), while popAllMessages uses the hook's internal
queueRef. If a tool completed between popAllMessages clearing queueRef
and React re-rendering, midTurnDrainRef would read stale data and
consume the same messages a second time.

Switching to the hook's drainQueue makes both paths read from the same
synchronous ref, eliminating the window for double consumption.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: add missing popAllMessages mock and prepend branch test

Add popAllMessages to useMessageQueue mock in AppContainer tests.
Add test for prepending queued messages before existing input text.

* feat: add ESC trigger, cursor preservation, and progressive hint

- ESC pops queued messages before double-ESC clear logic
- Cursor stays at user's editing position after pop via moveToOffset
- Extract popQueueIntoInput helper to share logic between Up and ESC
- QueuedMessageDisplay hint hides after 3 empty→non-empty transitions

* test: add null-pop fallthrough test for queue race condition

Verify that when React state shows non-empty queue but the ref is
already drained (popAllQueuedMessages returns null), Up arrow falls
through to normal history navigation instead of getting stuck.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 14:38:32 +08:00
..
acp-integration feat(plan): add "Yes, restore previous mode" option when exiting plan mode (#3008) 2026-04-09 14:25:38 +08:00
commands fix(weixin): add missing iLink headers to QR code login and clean up error output (#3044) 2026-04-10 11:36:02 +08:00
config fix: prevent statusline script from corrupting settings.json (#3091) 2026-04-11 11:55:18 +08:00
constants feat: add qwen3.6-plus model to ModelStudio Coding Plan (#3015) 2026-04-08 18:57:07 +08:00
core test: add tests for confirmation-bus, prompt-registry, and cli/core modules (#2272) 2026-04-09 13:54:59 +08:00
i18n feat(cli): queue input editing — pop queued messages for editing via ↑/ESC (#2871) 2026-04-11 14:38:32 +08:00
nonInteractive refactor(core): rename TaskTool to AgentTool 2026-03-19 14:55:14 +08:00
patches
services Merge pull request #2923 from QwenLM/feature/status-line-customization 2026-04-09 19:23:08 +08:00
test-utils feat(cli): make /btw command non-blocking with parallel execution 2026-03-20 00:25:51 +08:00
ui feat(cli): queue input editing — pop queued messages for editing via ↑/ESC (#2871) 2026-04-11 14:38:32 +08:00
utils fix: prevent statusline script from corrupting settings.json (#3091) 2026-04-11 11:55:18 +08:00
gemini.test.tsx remove hooks experimental and refactor hook Config 2026-04-01 11:50:23 +08:00
gemini.tsx Merge pull request #2628 from QwenLM/feat/channels-telegram 2026-04-01 16:19:08 +08:00
nonInteractiveCli.test.ts feat(cron): make cron tools opt-in via experimental settings 2026-03-29 02:25:28 +00:00
nonInteractiveCli.ts fix(cron): prevent concurrent cron execution and queue properly 2026-03-30 19:49:17 +08:00
nonInteractiveCliCommands.test.ts feat(cli): make /btw command non-blocking with parallel execution 2026-03-20 00:25:51 +08:00
nonInteractiveCliCommands.ts fix(cli): fix /plan command bugs and clean up hallucinated i18n keys 2026-04-06 06:56:41 +08:00
validateNonInterActiveAuth.test.ts refactor(debug): replace ConsolePatcher with debugLogger and update error reporting 2026-02-02 17:37:54 +08:00
validateNonInterActiveAuth.ts Merge branch 'main' into feat/debug-logging-refactor 2026-02-01 20:47:38 +08:00