Skip to content

Commit 5b460c4

Browse files
vincentkocobviyus
authored andcommitted
fix(status): preserve rich message line breaks
1 parent 1f8c4d3 commit 5b460c4

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

extensions/codex/src/command-formatters.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ type CodexStatusProbes = {
2121
skills: SafeValue<JsonValue | undefined>;
2222
};
2323

24+
// Status rows are intentional layout, not GFM soft-wrapped prose.
25+
const CODEX_STATUS_LINE_BREAK = " \n";
26+
2427
/** Formats the combined `/codex status` probe result. */
2528
export function formatCodexStatus(probes: CodexStatusProbes): string {
2629
const connected =
@@ -66,7 +69,7 @@ export function formatCodexStatus(probes: CodexStatusProbes): string {
6669
: formatCodexDisplayText(probes.skills.error)
6770
}`,
6871
);
69-
return lines.join("\n");
72+
return lines.flatMap((line) => line.split("\n")).join(CODEX_STATUS_LINE_BREAK);
7073
}
7174

7275
/** Formats Codex model-list results for `/codex models`. */

extensions/codex/src/commands.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ describe("codex command", () => {
878878
"Rate limits: offline",
879879
"MCP servers: offline",
880880
"Skills: offline",
881-
].join("\n"),
881+
].join(" \n"),
882882
});
883883
expect(deps.readCodexStatusProbes).toHaveBeenCalledWith(undefined, config);
884884
});

src/auto-reply/status.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,17 @@ describe("buildStatusMessage", () => {
125125
resolvedHarness: "openclaw",
126126
queue: { mode: "collect", depth: 0 },
127127
modelAuth: "api-key",
128+
subagentsLine: "🤖 Subagents: 1\n- active run",
128129
now: 10 * 60_000, // 10 minutes later
129130
});
130131
const normalized = normalizeTestText(text);
131132

133+
expect(
134+
text
135+
.split("\n")
136+
.slice(0, -1)
137+
.every((line) => line.endsWith(" ")),
138+
).toBe(true);
132139
expect(normalized).toContain("OpenClaw");
133140
expect(normalized).toContain("Model: anthropic/test:opus");
134141
expect(normalized).toContain("api-key");
@@ -145,6 +152,7 @@ describe("buildStatusMessage", () => {
145152
expect(normalized).not.toContain("verbose");
146153
expect(normalized).toContain("elevated");
147154
expect(normalized).toContain("Queue: collect");
155+
expect(normalized).toContain("- active run");
148156
});
149157

150158
it("shows configured model costs for aws-sdk providers", () => {

src/status/status-message.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ type AgentConfig = Partial<AgentDefaults> & {
6969
model?: AgentDefaults["model"] | string;
7070
};
7171

72+
// Status rows are intentional layout, not GFM soft-wrapped prose.
73+
const STATUS_MARKDOWN_LINE_BREAK = " \n";
74+
7275
export const formatTokenCount = formatTokenCountShared;
7376

7477
type QueueStatus = {
@@ -873,7 +876,7 @@ export function buildStatusMessage(args: StatusArgs): string {
873876
`Context: ${contextUsageLabel}`,
874877
`🧹 Compactions: ${entry?.compactionCount ?? 0}`,
875878
]
876-
.filter(Boolean)
879+
.filter((line): line is string => Boolean(line))
877880
.join(" · ");
878881

879882
const queueMode = args.queue?.mode ?? "unknown";
@@ -1049,6 +1052,7 @@ export function buildStatusMessage(args: StatusArgs): string {
10491052
voiceLine,
10501053
activationLine,
10511054
]
1052-
.filter(Boolean)
1053-
.join("\n");
1055+
.filter((line): line is string => Boolean(line))
1056+
.flatMap((line) => line.split("\n"))
1057+
.join(STATUS_MARKDOWN_LINE_BREAK);
10541058
}

0 commit comments

Comments
 (0)