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(tui): add dim info view and execution time display
zhengkailand24772758152
diff --git a/jiuwenswarm/channels/tui/frontend/src/app-state.ts b/jiuwenswarm/channels/tui/frontend/src/app-state.tsindex 3d50be9878..0ed36c0b66 100644--- a/jiuwenswarm/channels/tui/frontend/src/app-state.ts+++ b/jiuwenswarm/channels/tui/frontend/src/app-state.ts@@ -112,6 +112,16 @@ export interface AppSnapshot {memoryWarnings: { path: string; kind: string; char_count: number; threshold: number; message: string }[];}+function formatElapsed(ms: number): string {+ if (!Number.isFinite(ms) || ms < 0) {+ return "0s";+ }+ const totalSeconds = Math.max(0, Math.floor(ms / 1000));+ const minutes = Math.floor(totalSeconds / 60);+ const seconds = totalSeconds % 60;+ return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;+}+export class CliPiAppState {private listeners = new Set<() => void>();private entries: HistoryItem[] = [];@@ -175,6 +185,8 @@ export class CliPiAppState {private suppressInterruptResult = false;/** 本地中断请求标志,cancel() 调用时立即置 true,用于 long-running 命令的中断检测。 */private interruptRequested = false;+ /** 当前回合的起始时间戳,用于在回合结束时计算执行耗时。 */+ private turnStartedAt: number | null = null;private readonly eventDelegate: AppEventDelegate = {getConnectionStatus: () => this.connectionStatus,getSessionId: () => this.sessionId,@@ -277,6 +289,14 @@ export class CliPiAppState {};this.usageByModel.set(key, entry);},+ addWorkedForEntry: () => {+ if (this.turnStartedAt === null) return;+ const elapsed = Date.now() - this.turnStartedAt;+ this.turnStartedAt = null;+ this.addItem(+ addInfo(this.sessionId, `Worked for ${formatElapsed(elapsed)}`, undefined, { view: "dim" }),+ );+ },};constructor(@@ -777,6 +797,7 @@ readonly request = async <T = Record<string, unknown>>(];}this.streamingState = StreamingState.Responding;+ this.turnStartedAt = Date.now();this.emitChange();return requestId;};diff --git a/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.ts b/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.tsindex f420b4e512..1056a3d135 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.ts@@ -103,6 +103,8 @@ export interface AppEventDelegate {tryAutoRestoreAfterCancel(): Promise<void>;/** 累加 chat.usage_summary 事件的 token/cost 数据(按 model 分桶)。 */appendUsageSummary(usage: Record<string, unknown>, model?: string): void;+ /** 回合结束时记录执行耗时条目到对话区。 */+ addWorkedForEntry(): void;}function _handleSwitchModeToolResult(@@ -372,6 +374,7 @@ function handleFinal(],);delegate.setStreamingState(StreamingState.Idle);+ delegate.addWorkedForEntry();return true;}@@ -409,6 +412,7 @@ function handleError(});delegate.setLastError(message);delegate.setStreamingState(StreamingState.Idle);+ delegate.addWorkedForEntry();return true;}diff --git a/jiuwenswarm/channels/tui/frontend/src/core/types.ts b/jiuwenswarm/channels/tui/frontend/src/core/types.tsindex 6be345920f..57da3b8ff9 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/types.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/types.ts@@ -28,7 +28,7 @@ export interface SystemMeta {}export interface InfoMeta {- view?: "help" | "list" | "kv";+ view?: "help" | "list" | "kv" | "dim";title?: string;items?: Array<{ label: string; value?: string; description?: string }>;groups?: Array<{diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/meta-components.ts b/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/meta-components.tsindex 90fac3a7b1..ca48823f43 100644--- a/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/meta-components.ts+++ b/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/meta-components.ts@@ -87,10 +87,11 @@ export class InfoMessageComponent implements Component {return renderGroupedHelpView(width, meta);}+ const textColor = meta?.view === "dim" ? palette.text.dim : palette.text.info;const lines: string[] = [];const innerWidth = Math.max(1, width);const title = meta?.title ?? this.entry.content;- lines.push(...renderWrappedText(innerWidth, `· ${title}`, palette.text.info));+ lines.push(...renderWrappedText(innerWidth, `· ${title}`, textColor));if (this.entry.mediaItems?.length) {lines.push(...renderMediaItems(width, this.entry.mediaItems));}diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/presentation-rules.ts b/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/presentation-rules.tsindex 9e4787fcc9..db10fee4b2 100644--- a/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/presentation-rules.ts+++ b/jiuwenswarm/channels/tui/frontend/src/ui/components/messages/presentation-rules.ts@@ -31,10 +31,11 @@ export function shouldGapAfterEntry(entry: HistoryItem, compact: boolean): boolecase "thinking":return !compact;case "system":- case "info":case "diff":case "command_echo":return false;+ case "info":+ return entry.meta?.view === "dim";}}