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:/btw支持摁c复制会话

openJiuwen-bot344fe24f53b0
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
index deea6891e8..338fb09cb3 100644
--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
@@ -36,6 +36,7 @@ import {
} from "../core/commands/CommandService.js";
import type { SlashCommand } from "../core/commands/types.js";
import { addCommandEcho, addError, addInfo } from "../core/commands/helpers.js";
+import { copyToClipboard } from "../core/commands/clipboard.js";
import { CheckboxList, CheckboxGroup as CheckboxGroupType } from "./components/checkbox-list.js";
import type { FileAttachment } from "../core/protocol.js";
import {
@@ -3022,6 +3023,16 @@ export class AppScreen implements Component, Focusable {
this.tui.requestRender();
return true;
}
+ // 复制当前 /btw 整条记录(问题+回答)到剪贴板(按 c —— 对齐 claudecode /btw 快捷键)。
+ // 注意:overlay 显示时输入栏仍在,小写 c 会被吞触发复制;
+ // 想在输入框输入小写 c 需先 Esc 关闭 overlay。
+ if (matchesKey(data, "c")) {
+ const overlay = this.state.getSnapshot().btwOverlay;
+ if (overlay) {
+ void this.copyBtwEntry(overlay.question, overlay.answer);
+ }
+ return true;
+ }
// x 删除当前 btw 条目(剩余非空则跳到相邻,为空则关闭 overlay)
if (data.toLowerCase() === "x") {
this.state.deleteCurrentBtwEntry();
@@ -3064,6 +3075,28 @@ export class AppScreen implements Component, Focusable {
}
}
+ /**
+ * 复制 /btw 整条记录(问题 + 回答)到系统剪贴板,并在状态栏显示短暂反馈。
+ * 使用 transientNotice(独立于 transcript,固定在屏幕底部渲染),
+ * 与 /copy 命令的反馈保持一致。格式仿 overlay 标题行:/btw <question> + 回答。
+ */
+ private async copyBtwEntry(question: string, answer: string): Promise<void> {
+ const text = `/btw ${question}\n\n${answer}`;
+ const ok = await copyToClipboard(text);
+ this.transientNotice = ok
+ ? "已复制 /btw 问答到剪贴板"
+ : "无法访问剪贴板(系统不支持)";
+ if (this.transientNoticeTimer) {
+ clearTimeout(this.transientNoticeTimer);
+ }
+ this.transientNoticeTimer = setTimeout(() => {
+ this.transientNotice = null;
+ this.transientNoticeTimer = null;
+ this.tui.requestRender();
+ }, 2500);
+ this.tui.requestRender();
+ }
+
private clearPendingSubmittedInput(requestRender = true): void {
this.pendingSubmittedInput = null;
this.pendingSubmittedBaseline = 0;
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/screen-layout.ts b/jiuwenswarm/channels/tui/frontend/src/ui/screen-layout.ts
index d3ff84c011..227bf30e5d 100644
--- a/jiuwenswarm/channels/tui/frontend/src/ui/screen-layout.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/ui/screen-layout.ts
@@ -243,8 +243,8 @@ function renderBtwOverlay(
const totalEarly = overlayTotal ?? (overlayIndex !== undefined && overlayIndex >= 0 ? 1 : 0);
const earlyHint =
totalEarly > 1
- ? `Esc dismiss | ←/→ history ${(overlayIndex ?? 0) + 1}/${totalEarly} | x delete`
- : "Esc dismiss | x delete";
+ ? `Esc dismiss | ←/→ history ${(overlayIndex ?? 0) + 1}/${totalEarly} | c copy | x delete`
+ : "Esc dismiss | c copy | x delete";
return {
lines: [
padToWidth(palette.text.accent(headerText), safeWidth),
@@ -271,6 +271,7 @@ function renderBtwOverlay(
// 用数组拼接避免尾部多余管道符(不可滚动分支末尾不再出现 " | ")
const hintParts = ["Esc dismiss"];
if (showHistory) hintParts.push(`←/→ history ${posLabel}`);
+ hintParts.push("c copy");
hintParts.push("x delete");
if (answerLines.length > bodyHeight) {
hintParts.push("↑/↓ scroll", "PgUp/PgDn page", `${rangeStart}-${rangeEnd}/${answerLines.length}`);