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(tui):修复vscode终端/rename 后,tab 标题没有修改

openJiuwen-bot2d3cab9ca3b8
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
index 707e8da894..928782a237 100644
--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
@@ -14,7 +14,9 @@ import {
truncateToWidth,
} from "@mariozechner/pi-tui";
import { spawnSync } from "node:child_process";
-import { statSync } from "node:fs";
+import * as fs from "node:fs";
+import * as path from "node:path";
+import * as os from "node:os";
import type { CliPiAppState } from "../app-state.js";
import { openFileInEditor as openInExternalEditor } from "../core/utils/editor.js";
import {
@@ -812,6 +814,9 @@ export class AppScreen implements Component, Focusable {
this.unsubscribe = this.state.onChange(() => {
this.handleStateChange();
});
+ // Ensure VSCode user settings have terminal.integrated.tabs.title
+ // set to ${sequence} so OSC 0 sequences update the tab title.
+ this.ensureVscodeSettings();
// Set initial terminal window title
this.tui.terminal.setTitle("jiuwenswarm");
// Inject editor refs into app-state so tryAutoRestoreAfterCancel can
@@ -835,6 +840,48 @@ export class AppScreen implements Component, Focusable {
}, 0);
}
+ private ensureVscodeSettings(): void {
+ if (process.env.TERM_PROGRAM !== "vscode") return;
+ try {
+ const userSettingsPath = this.getVscodeUserSettingsPath();
+ if (!userSettingsPath) return;
+
+ let settings: Record<string, unknown> = {};
+ try {
+ const raw = fs.readFileSync(userSettingsPath, "utf-8");
+ settings = JSON.parse(raw);
+ } catch {
+ // File doesn't exist or is invalid — start fresh.
+ }
+
+ if (settings["terminal.integrated.tabs.title"] === "${sequence}") return;
+ settings["terminal.integrated.tabs.title"] = "${sequence}";
+ fs.mkdirSync(path.dirname(userSettingsPath), { recursive: true });
+ fs.writeFileSync(userSettingsPath, JSON.stringify(settings, null, 2), "utf-8");
+ } catch {
+ // Best-effort only — silent failure.
+ }
+ }
+
+ private getVscodeUserSettingsPath(): string | null {
+ switch (process.platform) {
+ case "win32":
+ return process.env.APPDATA
+ ? path.join(process.env.APPDATA, "Code", "User", "settings.json")
+ : null;
+ case "darwin":
+ return process.env.HOME
+ ? path.join(process.env.HOME, "Library", "Application Support", "Code", "User", "settings.json")
+ : null;
+ case "linux":
+ return process.env.HOME
+ ? path.join(process.env.HOME, ".config", "Code", "User", "settings.json")
+ : null;
+ default:
+ return null;
+ }
+ }
+
private initStartupPrompt(): void {
const cwd = process.cwd();
if (isTrustedDir(cwd)) {
@@ -4286,7 +4333,7 @@ export class AppScreen implements Component, Focusable {
}
try {
- const stats = statSync(path);
+ const stats = fs.statSync(path);
if (!stats.isFile()) {
return false;
}