Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: add render of command echo

huanggawa6b70ce55cfa1
diff --git a/jiuwenclaw/cli/src/core/commands/builtins/clear.ts b/jiuwenclaw/cli/src/core/commands/builtins/clear.ts
index f37b174e24..bb7151ade7 100644
--- a/jiuwenclaw/cli/src/core/commands/builtins/clear.ts
+++ b/jiuwenclaw/cli/src/core/commands/builtins/clear.ts
@@ -1,5 +1,5 @@
import { generateSessionId } from "../../session-state.js";
-import { addError, addInfo } from "../helpers.js";
+import { addCommandEcho, addError, addInfo } from "../helpers.js";
import { CommandKind, type SlashCommand } from "../types.js";
export function createClearCommand(): SlashCommand {
@@ -28,6 +28,7 @@ export function createClearCommand(): SlashCommand {
ctx.updateSession(nextId);
ctx.setSessionTitle("");
ctx.clearEntries();
+ ctx.addItem(addCommandEcho(nextId, "/clear"));
ctx.addItem(addInfo(nextId, `Started a fresh conversation in ${nextId}`, "i"));
await ctx.restoreHistory(nextId);
},
diff --git a/jiuwenclaw/cli/src/core/commands/helpers.ts b/jiuwenclaw/cli/src/core/commands/helpers.ts
index 3251bde0c6..c83f27c071 100644
--- a/jiuwenclaw/cli/src/core/commands/helpers.ts
+++ b/jiuwenclaw/cli/src/core/commands/helpers.ts
@@ -14,6 +14,7 @@ export function makeItem(
const id = `${kind}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
if (kind === "info") return { kind, id, sessionId, content, icon, meta, at: now() };
if (kind === "error") return { kind, id, sessionId, content, at: now() };
+ if (kind === "command_echo") return { kind, id, sessionId, content, at: now() };
return { kind: "system", id, sessionId, content, at: now() };
}
@@ -30,6 +31,10 @@ export function addError(sessionId: string, content: string): HistoryItem {
return makeItem(sessionId, "error", content);
}
+export function addCommandEcho(sessionId: string, content: string): HistoryItem {
+ return makeItem(sessionId, "command_echo", content);
+}
+
export function addDiff(
sessionId: string,
content: string,
diff --git a/jiuwenclaw/cli/src/core/types.ts b/jiuwenclaw/cli/src/core/types.ts
index 803d240d58..a5d70260be 100644
--- a/jiuwenclaw/cli/src/core/types.ts
+++ b/jiuwenclaw/cli/src/core/types.ts
@@ -204,6 +204,7 @@ export type HistoryItem =
meta?: SystemMeta;
at: string;
}
+ | { kind: "command_echo"; id: string; sessionId: string; content: string; at: string }
| { kind: "error"; id: string; sessionId: string; content: string; at: string }
| {
kind: "info";
diff --git a/jiuwenclaw/cli/src/ui/app-screen.ts b/jiuwenclaw/cli/src/ui/app-screen.ts
index b2d9a836af..e136306d86 100644
--- a/jiuwenclaw/cli/src/ui/app-screen.ts
+++ b/jiuwenclaw/cli/src/ui/app-screen.ts
@@ -23,7 +23,7 @@ import {
syncComposerImageTokens,
} from "../core/attachments.js";
import { CommandService, parseSlashCommand } from "../core/commands/CommandService.js";
-import { addError, addInfo } from "../core/commands/helpers.js";
+import { addCommandEcho, addError, addInfo } from "../core/commands/helpers.js";
import type { FileAttachment } from "../core/protocol.js";
import {
type ModelListPayload,
@@ -746,18 +746,21 @@ export class AppScreen implements Component, Focusable {
if (/^\/(?:resume|continue)\s*$/.test(text)) {
this.editor.addToHistory(text);
this.editor.setText("");
+ this.state.addItem(addCommandEcho(snapshot.sessionId, text));
await this.openResumeSessionList();
return;
}
if (/^\/model\s*$/.test(text)) {
this.editor.addToHistory(text);
this.editor.setText("");
+ this.state.addItem(addCommandEcho(snapshot.sessionId, text));
await this.openModelList();
return;
}
this.beginPendingSubmittedInput(text, snapshot);
this.editor.addToHistory(text);
this.editor.setText("");
+ this.state.addItem(addCommandEcho(snapshot.sessionId, text));
try {
await this.commands.execute(text, {
...this.state.getCommandContext(),
diff --git a/jiuwenclaw/cli/src/ui/components/messages/basic-message-components.ts b/jiuwenclaw/cli/src/ui/components/messages/basic-message-components.ts
index e9868f21b6..180106a64e 100644
--- a/jiuwenclaw/cli/src/ui/components/messages/basic-message-components.ts
+++ b/jiuwenclaw/cli/src/ui/components/messages/basic-message-components.ts
@@ -5,6 +5,7 @@ export {
UserMessageComponent,
} from "./content-components.js";
export {
+ CommandEchoComponent,
CompactMessageComponent,
ErrorMessageComponent,
InfoMessageComponent,
diff --git a/jiuwenclaw/cli/src/ui/components/messages/meta-components.ts b/jiuwenclaw/cli/src/ui/components/messages/meta-components.ts
index 3d46ae2220..3d6745bc0b 100644
--- a/jiuwenclaw/cli/src/ui/components/messages/meta-components.ts
+++ b/jiuwenclaw/cli/src/ui/components/messages/meta-components.ts
@@ -1,7 +1,7 @@
import type { Component } from "@mariozechner/pi-tui";
import type { HistoryItem } from "../../../core/types.js";
import { palette } from "../../theme.js";
-import { prefixedLines, renderWrappedText, summarize } from "../../rendering/text.js";
+import { padToWidth, prefixedLines, renderWrappedText, summarize } from "../../rendering/text.js";
import { renderClaudeResponseLines, renderMediaItems } from "./shared.js";
export class SystemMessageComponent implements Component {
@@ -30,6 +30,16 @@ export class ErrorMessageComponent implements Component {
}
}
+export class CommandEchoComponent implements Component {
+ constructor(private readonly entry: Extract<HistoryItem, { kind: "command_echo" }>) {}
+
+ invalidate(): void {}
+
+ render(width: number): string[] {
+ return [padToWidth(palette.surface.user(`❯ ${this.entry.content}`), width)];
+ }
+}
+
export class InfoMessageComponent implements Component {
constructor(private readonly entry: Extract<HistoryItem, { kind: "info" }>) {}
diff --git a/jiuwenclaw/cli/src/ui/components/messages/presentation-rules.ts b/jiuwenclaw/cli/src/ui/components/messages/presentation-rules.ts
index bef5dc52c3..9e4787fcc9 100644
--- a/jiuwenclaw/cli/src/ui/components/messages/presentation-rules.ts
+++ b/jiuwenclaw/cli/src/ui/components/messages/presentation-rules.ts
@@ -33,6 +33,7 @@ export function shouldGapAfterEntry(entry: HistoryItem, compact: boolean): boole
case "system":
case "info":
case "diff":
+ case "command_echo":
return false;
}
}
diff --git a/jiuwenclaw/cli/src/ui/components/messages/render-compact-entry.ts b/jiuwenclaw/cli/src/ui/components/messages/render-compact-entry.ts
index 5790aeca2b..6653f8f06d 100644
--- a/jiuwenclaw/cli/src/ui/components/messages/render-compact-entry.ts
+++ b/jiuwenclaw/cli/src/ui/components/messages/render-compact-entry.ts
@@ -1,5 +1,6 @@
import type { HistoryItem } from "../../../core/types.js";
import {
+ CommandEchoComponent,
CompactAssistantMessageComponent,
CompactMessageComponent,
DiffComponent,
@@ -64,6 +65,11 @@ export function renderCompactEntry(
lines: new DiffComponent(entry).render(width),
gapAfter: shouldGapAfterEntry(entry, true),
};
+ case "command_echo":
+ return {
+ lines: new CommandEchoComponent(entry).render(width),
+ gapAfter: false,
+ };
default:
return {
lines: new CompactMessageComponent(entry).render(width),
diff --git a/jiuwenclaw/cli/src/ui/components/messages/render-detailed-entry.ts b/jiuwenclaw/cli/src/ui/components/messages/render-detailed-entry.ts
index 0ff2e8e406..2dd50adb1a 100644
--- a/jiuwenclaw/cli/src/ui/components/messages/render-detailed-entry.ts
+++ b/jiuwenclaw/cli/src/ui/components/messages/render-detailed-entry.ts
@@ -1,6 +1,7 @@
import type { HistoryItem } from "../../../core/types.js";
import {
AssistantMessageComponent,
+ CommandEchoComponent,
DiffComponent,
ErrorMessageComponent,
InfoMessageComponent,
@@ -63,6 +64,11 @@ export function renderDetailedEntry(
lines: new SystemMessageComponent(entry).render(width),
gapAfter: shouldGapAfterEntry(entry, false),
};
+ case "command_echo":
+ return {
+ lines: new CommandEchoComponent(entry).render(width),
+ gapAfter: false,
+ };
case "error":
return {
lines: new ErrorMessageComponent(entry).render(width),
diff --git a/jiuwenclaw/cli/src/ui/transcript-entry-selection.ts b/jiuwenclaw/cli/src/ui/transcript-entry-selection.ts
index df11357f70..6f964561f1 100644
--- a/jiuwenclaw/cli/src/ui/transcript-entry-selection.ts
+++ b/jiuwenclaw/cli/src/ui/transcript-entry-selection.ts
@@ -43,7 +43,8 @@ export function selectTranscriptEntries(snapshot: AppSnapshot): SelectedTranscri
entry.kind === "assistant" ||
entry.kind === "thinking" ||
entry.kind === "error" ||
- entry.kind === "info",
+ entry.kind === "info" ||
+ entry.kind === "command_echo",
);
} else if (snapshot.transcriptFoldMode === "thinking") {
entries = entries.filter((entry) => entry.kind !== "thinking");