dsh-neotui 0.1.3 → 0.1.4

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.3",
3
+ "version": "0.1.4",
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/md.js CHANGED
@@ -161,6 +161,9 @@ function highlightLine(line, lang) {
161
161
  // Returns array of lines; each line = array of segments.
162
162
 
163
163
  export function renderMd(text, width, sink = null, opts = {}) {
164
+ // defensive: snapshot-derived blocks can carry non-string text; a `.replace`
165
+ // on an object would throw mid-frame and freeze the whole terminal
166
+ if (typeof text !== "string") text = String(text ?? "");
164
167
  const hardBreaks = !!opts.hardBreaks;
165
168
  const lines = [];
166
169
  const pushLine = (segs = []) => {
package/src/text.js CHANGED
@@ -26,6 +26,7 @@ export function wcwidth(cp) {
26
26
  }
27
27
 
28
28
  export function strWidth(s) {
29
+ if (typeof s !== "string") s = String(s ?? "");
29
30
  let w = 0;
30
31
  for (const ch of s) w += wcwidth(ch.codePointAt(0));
31
32
  return w;
package/src/views.js CHANGED
@@ -2951,6 +2951,15 @@ export class App {
2951
2951
  if (this.toastMsg && Date.now() > this.toastUntil) { this.toastMsg = null; this.dirty = true; }
2952
2952
  } catch (e) {
2953
2953
  this.log("render error (kept running):", e);
2954
+ // stderr is invisible under the alt screen — record the stack where
2955
+ // it can be read, then flush whatever composed before the throw so
2956
+ // the terminal never sits frozen on the previous frame.
2957
+ try {
2958
+ const dir = process.env.DSH_HOME ?? join(process.env.HOME ?? ".", ".dsh");
2959
+ mkdirSync(dir, { recursive: true });
2960
+ appendFileSync(join(dir, "tui-error.log"), `${new Date().toISOString()} ${e?.stack ?? e}\n`);
2961
+ } catch {}
2962
+ try { this.term?.output?.write?.(this.screen.render()); } catch {}
2954
2963
  this.dirty = true;
2955
2964
  }
2956
2965
  this.timer = setTimeout(tick, 33);