dsh-neotui 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-neotui",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Neo-TUI: mouse-driven terminal UI client for DeepSeek Harness (B-tier per dsh-tui-design.md)",
5
5
  "type": "module",
6
6
  "bin": {
package/src/config.js CHANGED
@@ -62,3 +62,14 @@ export function userName() {
62
62
  export function userPrefix() {
63
63
  return `${userName()} > `;
64
64
  }
65
+
66
+ /** Fold defaults (settings → 默认展开/折叠): think/tool blocks and the
67
+ * todo list, with the shipped defaults when nothing is configured. */
68
+ export function foldDefaults() {
69
+ const fd = loadTuiConfig().foldDefaults ?? {};
70
+ return {
71
+ think: fd.think !== false, // think blocks default expanded
72
+ bash: fd.bash === true, // tool blocks default collapsed
73
+ todos: fd.todos !== false, // todo list default visible
74
+ };
75
+ }
package/src/panels.js CHANGED
@@ -10,7 +10,7 @@ import { join, basename, extname } from "node:path";
10
10
  import { spawn, execFileSync } from "node:child_process";
11
11
 
12
12
  import { T, cycleTheme, themeName } from "./theme.js";
13
- import { loadTuiConfig, saveTuiConfig, userPrefix, userName } from "./config.js";
13
+ import { loadTuiConfig, saveTuiConfig, userPrefix, userName, foldDefaults } from "./config.js";
14
14
  // Live theme accessor: K.K.DIM etc. resolve against the active palette at render time.
15
15
  const K = new Proxy({}, { get(_k, key) { return T[key]; } });
16
16
 
@@ -1591,6 +1591,13 @@ export class SettingsPanel extends Widget {
1591
1591
  ns: "TUI 界面", applies: "live", local: true,
1592
1592
  value: { userPrefix: userName() },
1593
1593
  });
1594
+ // 默认展开/折叠: the fold-related defaults as a local sub-panel of
1595
+ // booleans (click to toggle), persisted to the TUI config file.
1596
+ const fd = foldDefaults();
1597
+ this.namespaces.splice(1, 0, {
1598
+ ns: "默认展开/折叠", applies: "live", local: true,
1599
+ value: { 思考块默认展开: fd.think, 工具块默认展开: fd.bash, 任务清单默认显示: fd.todos },
1600
+ });
1594
1601
  this.selectNs(0);
1595
1602
  }
1596
1603
  selectNs(i) {
@@ -1719,6 +1726,27 @@ export class SettingsPanel extends Widget {
1719
1726
  if (ns.local) {
1720
1727
  // TUI-local config: write the config file, apply instantly.
1721
1728
  const v = applyOps(ns.value, this.pendingOps);
1729
+ if (ns.ns === "默认展开/折叠") {
1730
+ const patch = { foldDefaults: { think: !!v.思考块默认展开, bash: !!v.工具块默认展开, todos: !!v.任务清单默认显示 } };
1731
+ if (saveTuiConfig(patch)) {
1732
+ this.pendingOps = [];
1733
+ this.app.toast("已保存展开/折叠默认值(即时生效)");
1734
+ // apply live to the current chat
1735
+ const chat = this.app.chat;
1736
+ if (chat) {
1737
+ chat.thinkMode = v.思考块默认展开 ? "expanded" : "collapsed";
1738
+ chat.bashMode = v.工具块默认展开 ? "expanded" : "collapsed";
1739
+ chat.todosVisible = !!v.任务清单默认显示;
1740
+ chat.expanded.clear();
1741
+ chat.collapsedBlocks.clear();
1742
+ chat.queueRebuild();
1743
+ }
1744
+ await this.load();
1745
+ } else {
1746
+ this.app.toast("保存失败:无法写入 TUI 配置文件");
1747
+ }
1748
+ return;
1749
+ }
1722
1750
  const name = String(v.userPrefix ?? "").trim();
1723
1751
  if (saveTuiConfig({ userPrefix: name })) {
1724
1752
  this.pendingOps = [];
package/src/views.js CHANGED
@@ -5,8 +5,8 @@ import { truncate, strWidth, bars, fmtDuration, fmtClock, fmtDateTime } from "./
5
5
  import { readFileSync, appendFileSync, mkdirSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { Widget, List, ScrollView, Input, Popup, Menu, StatusBar } from "./widgets.js";
8
- import { userPrefix, saveTuiConfig, loadTuiConfig, userName } from "./config.js";
9
- export { userPrefix, saveTuiConfig, loadTuiConfig, userName } from "./config.js";
8
+ import { userPrefix, saveTuiConfig, loadTuiConfig, userName, foldDefaults } from "./config.js";
9
+ export { userPrefix, saveTuiConfig, loadTuiConfig, userName, foldDefaults } from "./config.js";
10
10
  import {
11
11
  Picker, buildCommandPalette, buildModelPicker, buildModePicker, buildPermissionPicker,
12
12
  modeName, permName, WorkspacePanel, TrajectoryPanel, DirPicker,
@@ -595,9 +595,10 @@ export class ChatView extends Widget {
595
595
  this.expanded = new Set(); // node indexes (user-message full text)
596
596
  this.expandedTools = new Set();
597
597
  this.collapsedBlocks = new Set(); // per-block COLLAPSE (default expanded): `${realIdx}:${bi}`
598
- this.thinkMode = "expanded"; // think blocks: expanded by default (t toggles)
599
- this.bashMode = "collapsed"; // tool blocks: collapsed by default (b toggles)
600
- this.todosVisible = true; // todo block above the input (Shift+T toggles)
598
+ const fd = foldDefaults();
599
+ this.thinkMode = fd.think ? "expanded" : "collapsed"; // t toggles
600
+ this.bashMode = fd.bash ? "expanded" : "collapsed"; // b toggles
601
+ this.todosVisible = fd.todos; // Shift+T toggles
601
602
  this.todoSeen = false; // once seen, the todo box keeps its height
602
603
  this.running = false;
603
604
  this.hasMore = false;