Skip to content

[feat] canvas: queue a message sent while a reply runs - #383

Open
wtz2333 wants to merge 5 commits into
ThinkFlowLab:mainfrom
wtz2333:feat/midturn-queue-composer
Open

wtz2333 wants to merge 5 commits into
ThinkFlowLab:mainfrom
wtz2333:feat/midturn-queue-composer

Conversation

@wtz2333

@wtz2333 wtz2333 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The composer no longer swaps Send for Stop while a reply runs. Both stay: the reply can still be stopped, and the draft can still be submitted, which hands it to POST /assistant/messages — 202 { queued } goes into the log as a queued bubble with its position, and an idle project streams its reply as before.
  • One stream now covers the whole chain: each start frame opens a new reply, an end frame carrying nextTurnId means the next queued message already began, and the final end closes the view. Stop follows the chain by tracking nextTurnId, so it stops the reply that is actually running.
  • A message that was queued and then cancelled by Stop stays visible as cancelled instead of disappearing.
  • New copy ships in both locales: queue button label and title, the queued bubble, the cancelled bubble, and the hint under the composer while typing during a run.

Depends on #381, which adds POST /assistant/messages: the endpoint is not on main yet, so this branch builds and its tests pass on its own, but the browser journeys need that backend to run. Please land #381 first.

Linked issue

Refs #379 (the same issue as #381; it stays open for runtime-native steering).

  • Refs #379 is included

Labels

  • Not applied: wtz2333 cannot add labels here (GitHub refuses AddLabelsToLabelable). Suggested: type:feat, area:canvas, area:agent.

Test plan

  • Local:
    • node --test tests/*.test.ts → 834 passed, including the new tests/assistantQueue.test.ts, which covers both answers of the endpoint (202 queued, 200 stream) and a stream that carries two replies.
    • node scripts/check-i18n.mjs → 3038 keys, 0 problems, Chinese source lines still under the baseline.
    • tsc --noEmit → clean. vite build → built.
  • Left to CI: the browser journeys (assistant_run_navigation, assistant_sessions, assistant_auxiliary_panels, default_entry, kimi_real) — they need the isolated API and Vite, and [feat] assistant: accept a follow-up message while a turn is still running / 运行中插入补充消息 #379's endpoint to be present, so they run against the merged combination.

Evidence that it works

  • Media attached, or N/A because: the browser journeys cover the composer; no recording was made in this environment (no isolated API + browsers here). The two endpoint paths are covered by unit tests.

Provider verification

  • Real-provider calls are described honestly, or none were made: none; the tests replace fetch.

Bilingual UI

  • Both locales are updated: zh-CN and en-US both gain assistant.panel.queue, queueHint, queued, queueWhileRunning and cancelled.

@github-actions github-actions Bot added area:agent Agent runtime, assistant chat and tools area:canvas Canvas, nodes and direct manipulation type:feat New capability or behaviour labels Nov 17, 2026
return;
}
setValue((previous) =>
previous.messages.some((message) => message.id === accepted.queued.id)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If the queued event arrives before the POST response, the message appears in the queue but its text stays in the composer. Please clear the submitted draft when the POST succeeds, even if the message is already displayed, and preserve any edits made while the request was in flight.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This still reproduces on 123d81e2: after a message is queued, its text stays in the input box, making it look unsent and easy to queue again. Please clear the submitted draft once it’s accepted and preserve any edits made while the request was in flight.

@wtz2333
wtz2333 force-pushed the feat/midturn-queue-composer branch from 391fba0 to 6766b1e Compare November 20, 2026 07:12
@github-actions github-actions Bot added the area:docs Documentation / 文档 label Nov 20, 2026
config = await asyncio.to_thread(configs.resolve, message['modelConfigId'], 'agent')
except Exception:
logger.warning('agent.queue.model_missing project_id=%s message_id=%s',
project_id, message.get('id'))
@FayeSpica

Copy link
Copy Markdown
Collaborator

@wtz2333 please resolve conflicts

wtz2333 and others added 4 commits November 26, 2026 11:09
A message waiting behind the active turn could be changed by nothing but
sending it: withdrawing it meant stopping the whole chain, which also threw
away the turn that was running.

Retracting removes a message that has not started, under the same lock the
chain takes when it picks the next one up, so it is either still waiting and
goes away or it has started and the caller is told to stop it instead. A
failure leaves the queue waiting rather than spending it, and continuing by
hand starts the oldest message without retyping it.

Refs ThinkFlowLab#379
A message waiting behind the active turn could be changed by nothing but
sending it: withdrawing it meant stopping the whole chain, which also threw
away the turn that was running.

Retracting removes a message that has not started, under the same lock the
chain takes when it picks the next one up, so it is either still waiting and
goes away or it has started and the caller is told to stop it instead. A
failure leaves the queue waiting rather than spending it, and continuing by
hand starts the oldest message without retyping it.

Refs ThinkFlowLab#379
Codex now runs as an app-server session instead of a one-shot exec, so a turn has a
channel for extra text while it works: POST /assistant/messages with delivery
"insert" hands the words to turn/steer and the answer keeps the work it has
already done. Runtimes without a native channel refuse the insert and say so,
leaving the queued delivery as the fallback.
@wtz2333
wtz2333 force-pushed the feat/midturn-queue-composer branch from 123d81e to 85db9a4 Compare November 26, 2026 03:25
While a reply streams, the composer kept the draft but replaced Send with
Stop and Enter returned without a word, so a supplement could only be
typed in and lost. It is sent now: the server answers 202 with the queued
message, the log shows it as queued, and the same stream keeps feeding the
replies that follow until the chain ends.

Refs ThinkFlowLab#379
@wtz2333
wtz2333 force-pushed the feat/midturn-queue-composer branch from 85db9a4 to 8ab8ef0 Compare November 26, 2026 03:26
@github-actions github-actions Bot added area:harness Harness and skill integration (Default, OpenCode, Codex, Claude Code, Jiuwen, DSH) area:i18n Localisation and bilingual UI labels Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent runtime, assistant chat and tools area:canvas Canvas, nodes and direct manipulation area:docs Documentation / 文档 area:harness Harness and skill integration (Default, OpenCode, Codex, Claude Code, Jiuwen, DSH) area:i18n Localisation and bilingual UI type:feat New capability or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants