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
feat(cli): welcome 保留在transcript
gallonH1ec073d79a66
diff --git a/jiuwenclaw/cli/src/ui/app-screen.ts b/jiuwenclaw/cli/src/ui/app-screen.tsindex a1799e222c..093cad0e84 100644--- a/jiuwenclaw/cli/src/ui/app-screen.ts+++ b/jiuwenclaw/cli/src/ui/app-screen.ts@@ -459,6 +459,9 @@ export class AppScreen implements Component, Focusable {private animationTimer: ReturnType<typeof setInterval> | null = null;private animationPhase = 0;private runningStartedAtMs: number | null = null;+ private pendingSubmittedInput: string | null = null;+ private pendingSubmittedBaseline = 0;+ private pendingSubmittedSessionId: string | null = null;constructor(private readonly tui: TUI,@@ -677,6 +680,8 @@ export class AppScreen implements Component, Focusable {questionLines,editorLines,composerPreviewLines,+ pendingInput: this.pendingSubmittedInput ?? undefined,+ pendingInputBaseline: this.pendingSubmittedInput ? this.pendingSubmittedBaseline : undefined,showFullThinking: snapshot.transcriptMode === "detailed",showToolDetails: snapshot.transcriptMode === "detailed",showShortcutHelp: false,@@ -717,19 +722,26 @@ export class AppScreen implements Component, Focusable {await this.openResumeSessionList();return;}- await this.commands.execute(text, {- ...this.state.getCommandContext(),- exitApp: this.exit,- });+ this.beginPendingSubmittedInput(text, snapshot);this.editor.addToHistory(text);this.editor.setText("");this.composerAttachments = [];+ try {+ await this.commands.execute(text, {+ ...this.state.getCommandContext(),+ exitApp: this.exit,+ });+ } finally {+ this.clearPendingSubmittedInput();+ }return;}if (snapshot.isProcessing || snapshot.isPaused) {+ this.beginPendingSubmittedInput(text, snapshot);const requestId = this.state.supplement(content);if (!requestId) {+ this.clearPendingSubmittedInput();this.state.addItem({kind: "error",id: `offline-${Date.now()}`,@@ -745,8 +757,10 @@ export class AppScreen implements Component, Focusable {return;}+ this.beginPendingSubmittedInput(text, snapshot);const requestId = this.state.sendMessage(content);if (!requestId) {+ this.clearPendingSubmittedInput();this.state.addItem({kind: "error",id: `offline-${Date.now()}`,@@ -764,6 +778,13 @@ export class AppScreen implements Component, Focusable {private handleStateChange(): void {const snapshot = this.state.getSnapshot();+ if (+ this.pendingSubmittedInput &&+ (snapshot.sessionId !== this.pendingSubmittedSessionId ||+ snapshot.entries.length !== this.pendingSubmittedBaseline)+ ) {+ this.clearPendingSubmittedInput(false);+ }const questionId = snapshot.pendingQuestion?.requestId ?? null;if (questionId && questionId !== this.activeQuestionId) {this.activeQuestionId = questionId;@@ -793,6 +814,25 @@ export class AppScreen implements Component, Focusable {this.tui.requestRender();}+ private beginPendingSubmittedInput(+ text: string,+ snapshot: ReturnType<CliPiAppState["getSnapshot"]>,+ ): void {+ this.pendingSubmittedInput = text;+ this.pendingSubmittedBaseline = snapshot.entries.length;+ this.pendingSubmittedSessionId = snapshot.sessionId;+ this.tui.requestRender();+ }++ private clearPendingSubmittedInput(requestRender = true): void {+ this.pendingSubmittedInput = null;+ this.pendingSubmittedBaseline = 0;+ this.pendingSubmittedSessionId = null;+ if (requestRender) {+ this.tui.requestRender();+ }+ }+private syncTeamPanelSelection(snapshot: ReturnType<CliPiAppState["getSnapshot"]>): void {const memberIds = orderedMemberIds(snapshot.teamMemberEvents, snapshot.teamMessageEvents);if (memberIds.length === 0) {diff --git a/jiuwenclaw/cli/src/ui/screen-layout.ts b/jiuwenclaw/cli/src/ui/screen-layout.tsindex 535b13c6c5..f73b34c0b4 100644--- a/jiuwenclaw/cli/src/ui/screen-layout.ts+++ b/jiuwenclaw/cli/src/ui/screen-layout.ts@@ -13,6 +13,8 @@ export interface ScreenLayoutOptions {questionLines: string[];editorLines: string[];composerPreviewLines: string[];+ pendingInput?: string;+ pendingInputBaseline?: number;showFullThinking: boolean;showToolDetails: boolean;showShortcutHelp: boolean;@@ -161,6 +163,8 @@ export function buildAppScreenLines(snapshot: AppSnapshot, options: ScreenLayoutoptions.showFullThinking,options.showToolDetails,options.animationPhase,+ options.pendingInput,+ options.pendingInputBaseline,);const todoLines = options.showTodos ? renderTodoList(snapshot.todos, options.width) : [];const teamStatusLines =diff --git a/jiuwenclaw/cli/src/ui/transcript-renderer.ts b/jiuwenclaw/cli/src/ui/transcript-renderer.tsindex 8cdb955652..4da726b490 100644--- a/jiuwenclaw/cli/src/ui/transcript-renderer.ts+++ b/jiuwenclaw/cli/src/ui/transcript-renderer.ts@@ -1,21 +1,44 @@import type { AppSnapshot } from "../app-state.js";import { renderHistoryEntry } from "./components/messages/index.js";import { shouldEmphasizeAssistantTransition } from "./components/messages/presentation-rules.js";+import { prefixedLines, renderStyledMarkdownLines } from "./rendering/text.js";+import { palette } from "./theme.js";import { selectTranscriptEntries } from "./transcript-entry-selection.js";import { buildWelcomeLines } from "./welcome.js";+function renderPendingUserInput(width: number, content: string): string[] {+ const lines = renderStyledMarkdownLines(+ Math.max(1, width - 2),+ content,+ {+ color: palette.text.dim,+ },+ 0,+ 0,+ );+ return prefixedLines(lines, width, "> ", palette.text.user, " ");+}+export function buildTranscriptLines(snapshot: AppSnapshot,width: number,showFullThinking: boolean,showToolDetails: boolean,animationPhase: number,+ pendingInput?: string,+ pendingInputBaseline?: number,): string[] {const { entries: displayEntries, latestThinkingId } = selectTranscriptEntries(snapshot);- const allLines: string[] = [];- if (displayEntries.length === 0) {- allLines.push(...buildWelcomeLines(width, snapshot.connectionStatus));+ const allLines: string[] = [...buildWelcomeLines(width, snapshot.connectionStatus)];+ const showPendingInput =+ typeof pendingInput === "string" &&+ pendingInput.length > 0 &&+ typeof pendingInputBaseline === "number" &&+ snapshot.entries.length <= pendingInputBaseline;++ if (displayEntries.length === 0 && showPendingInput) {+ allLines.push(...renderPendingUserInput(width, pendingInput));}for (const [index, entry] of displayEntries.entries()) {@@ -43,5 +66,9 @@ export function buildTranscriptLines(}}+ if (displayEntries.length > 0 && showPendingInput) {+ allLines.push(...renderPendingUserInput(width, pendingInput));+ }+return allLines;}