Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix(coding-agent): show a preparing turn's prompt in the TUI queued-messages area (#2063)

Sebastian Müllera144f9a43bbc
diff --git a/packages/coding-agent/.changes/res-1306-compaction-queue-visibility.md b/packages/coding-agent/.changes/res-1306-compaction-queue-visibility.md
new file mode 100644
index 0000000000..c90404748d
--- /dev/null
+++ b/packages/coding-agent/.changes/res-1306-compaction-queue-visibility.md
@@ -0,0 +1 @@
+- Fixed a queued prompt disappearing from the interactive queued-messages area while its own pre-turn compaction runs; it now stays visible there (as a "Starting" entry) until the turn begins.
diff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.ts
index 0384563214..8d7a60660d 100644
--- a/packages/coding-agent/src/core/agent-session.ts
+++ b/packages/coding-agent/src/core/agent-session.ts
@@ -7695,7 +7695,7 @@ export class AgentSession {
active: {
kind: active.payload.kind,
phase,
- label: compactRlmText(active.payload.text),
+ label: compactRlmText(queuedAgentMessagePreview(active)),
},
}
: {}),
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index f2881ea821..5ad529c91e 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -360,13 +360,13 @@ function isLabeledQueuedPreview(message: string): boolean {
);
}
-export function formatQueuedMessagePreview(message: string, label: "Steering" | "Follow-up"): string {
+export function formatQueuedMessagePreview(message: string, label: "Steering" | "Follow-up" | "Starting"): string {
return isLabeledQueuedPreview(message) ? message : `${label}: ${message}`;
}
export function styleQueuedMessagePreview(
message: string,
- label: "Steering" | "Follow-up",
+ label: "Steering" | "Follow-up" | "Starting",
isRecognizedSlashCommand: (name: string) => boolean,
): string {
const preview = formatQueuedMessagePreview(message, label);
@@ -8221,9 +8221,18 @@ export class InteractiveMode {
// their own container below the execution indicator and recap.
this.queuedMessagesContainer.clear();
const { steering: steeringMessages, followUp: followUpMessages } = this.getAllQueuedMessages();
+ const active = this.connectionState?.sessionActions.active;
+ // A queued turn leaves its lane once the pump selects it; its own pre-turn compaction can hold it here for minutes.
+ const startingTurn = active?.kind === "turn" && active.phase === "preparing" ? active.label : undefined;
const hasQueuedMessages = steeringMessages.length > 0 || followUpMessages.length > 0;
- if (hasQueuedMessages) {
+ if (hasQueuedMessages || startingTurn !== undefined) {
this.queuedMessagesContainer.addChild(new Spacer(1));
+ if (startingTurn !== undefined) {
+ const text = styleQueuedMessagePreview(startingTurn, "Starting", (name) =>
+ this.isRecognizedSlashCommand(name),
+ );
+ this.queuedMessagesContainer.addChild(new TruncatedText(text, 1, 0));
+ }
for (const message of steeringMessages) {
const text = styleQueuedMessagePreview(message, "Steering", (name) => this.isRecognizedSlashCommand(name));
this.queuedMessagesContainer.addChild(new TruncatedText(text, 1, 0));
@@ -8232,6 +8241,8 @@ export class InteractiveMode {
const text = styleQueuedMessagePreview(message, "Follow-up", (name) => this.isRecognizedSlashCommand(name));
this.queuedMessagesContainer.addChild(new TruncatedText(text, 1, 0));
}
+ }
+ if (hasQueuedMessages) {
const dequeueHint = this.getAppKeyDisplay("app.message.navigateOlder");
const hintText = theme.fg("dim", `╰─ ${dequeueHint} to browse and edit queued messages`);
this.queuedMessagesContainer.addChild(new TruncatedText(hintText, 1, 0));
diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.ts
index 4358bc3e57..a6886a4987 100644
--- a/packages/coding-agent/test/interactive-mode-status.test.ts
+++ b/packages/coding-agent/test/interactive-mode-status.test.ts
@@ -20,25 +20,12 @@ import type { ToolExecutionComponent } from "../src/modes/interactive/components
import { InteractiveMode } from "../src/modes/interactive/interactive-mode.js";
import { QueueSelection } from "../src/modes/interactive/queue-selection.js";
import { initTheme } from "../src/modes/interactive/theme/theme.js";
+import { createDeferred } from "./suite/scheduling.js";
function renderAll(container: Container, width = 120): string {
return container.children.flatMap((child) => child.render(width)).join("\n");
}
-function createDeferred<T>(): {
- promise: Promise<T>;
- resolve(value: T): void;
- reject(error: unknown): void;
-} {
- let resolve!: (value: T) => void;
- let reject!: (error: unknown) => void;
- const promise = new Promise<T>((nextResolve, nextReject) => {
- resolve = nextResolve;
- reject = nextReject;
- });
- return { promise, resolve, reject };
-}
-
function createConnectionState(overrides: Partial<AgentConnectionState> = {}): AgentConnectionState {
return {
activeSessionId: "active-1",
@@ -534,6 +521,27 @@ describe("InteractiveMode connection events", () => {
expect(fakeThis.flushPendingBashComponents).toHaveBeenCalledOnce();
});
+ test("RES-1306: shows a queued turn's prompt while its own pre-turn compaction holds it in preparing", () => {
+ initTheme("dark");
+ const queuedMessagesContainer = new Container();
+ const fakeThis = createResyncHarness({
+ queuedMessagesContainer,
+ pendingMessagesContainer: new Container(),
+ pendingBashComponents: [],
+ });
+ delete fakeThis.updatePendingMessagesDisplay;
+ const render = (phase: "preparing" | "running") => {
+ const active = { kind: "turn" as const, phase, label: "queued before compaction" };
+ fakeThis.connectionState = createConnectionState({
+ sessionActions: { queuedCount: 0, steering: [], followUps: [], active },
+ });
+ fakeThis.updatePendingMessagesDisplay();
+ return renderAll(queuedMessagesContainer);
+ };
+ expect(render("preparing")).toContain("queued before compaction");
+ expect(render("running")).toBe("");
+ });
+
test("renderCurrentSessionState waits for replacement handling before rendering", async () => {
const calls: string[] = [];
const fakeThis = {