Force queued messages, wrap long terminal input and questions, Ctrl+J newline in the web UI

A further Enter on the empty input (terminal client, web UI) or Ctrl+Enter with text (web UI)
interrupts the running step and delivers the queued messages at once (POST /api/sessions/{id}/queue/force).
The terminal client shows queued messages above the input, wraps the input field and the question dialog.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-27 09:27:38 +01:00
1 parent 679151defc
commit e64328aa98
13 files changed
+437 -42

No files matched your search

+7
View File
@@ -113,6 +113,7 @@ pub fn router(app: AppState) -> Router {
.route("/sessions/{id}/shares", get(get_shares).put(put_shares))
.route("/sessions/{id}/queue", get(get_queue))
.route("/sessions/{id}/queue/flush", post(flush_queue))
.route("/sessions/{id}/queue/force", post(force_queue))
.route("/sessions/{id}/queue/{item}", delete(delete_queue_item))
.route("/permissions/{id}", post(reply_permission))
.route("/permissions/{id}/explain", post(explain_permission))
@@ -1359,6 +1360,12 @@ async fn flush_queue(Extension(user): Extension<User>, State(app): State<AppStat
Ok(Json(json!({"started": runner::flush_queue(app.clone(), &id)?})))
}
/// Interrupt the running step and deliver the queued messages at once.
async fn force_queue(Extension(user): Extension<User>, State(app): State<AppState>, Path(id): Path<String>) -> ApiResult {
writable(&app, &user, &id)?;
Ok(Json(json!({"forced": runner::force_queue(app.clone(), &id)?})))
}
pub(crate) async fn do_compact(app: AppState, id: String) {
let cancel = tokio_util::sync::CancellationToken::new();
app.with_runtime(&id, |r| r.cancel = Some(cancel.clone()));
+3
View File
@@ -45,6 +45,9 @@ pub struct Runtime {
pub step: Option<Value>,
/// Reasoning effort chosen for the current turn (overrides the model's default).
pub effort: Option<String>,
/// The user interrupted the turn to deliver the queued messages at once: they start the next turn
/// even though the run was cancelled.
pub force_queue: bool,
}
pub struct App {
+21 -1
View File
@@ -112,7 +112,8 @@ pub fn submit(app: Arc<App>, session_id: String, parts: Vec<Part>, source: &str)
let leftover = app.with_runtime(&session_id, |r| {
r.cancel = None;
r.effort = None;
if cancel.is_cancelled() { Vec::new() } else { take_queue(&app, &session_id) }
let forced = std::mem::take(&mut r.force_queue);
if cancel.is_cancelled() && !forced { Vec::new() } else { take_queue(&app, &session_id) }
});
app.emit(Event::SessionStatus { session_id: session_id.clone(), busy: false });
if leftover.is_empty() && !cancel.is_cancelled() {
@@ -139,6 +140,25 @@ pub fn flush_queue(app: Arc<App>, session_id: &str) -> Result<bool> {
Ok(true)
}
/// Deliver the queued messages now: the running step is interrupted and the messages start the next turn
/// at once (instead of waiting for the agent's next step). Without a running turn this is `flush_queue`.
/// Returns false when nothing is queued.
pub fn force_queue(app: Arc<App>, session_id: &str) -> Result<bool> {
if app.store.queue_list(session_id).unwrap_or_default().is_empty() {
return Ok(false);
}
if !app.is_busy(session_id) {
return flush_queue(app, session_id);
}
app.with_runtime(session_id, |r| {
if let Some(c) = &r.cancel {
r.force_queue = true;
c.cancel();
}
});
Ok(true)
}
pub fn abort(app: &App, session_id: &str) {
app.with_runtime(session_id, |r| {
if let Some(c) = &r.cancel {