@xp266/dshtui 0.1.7 → 0.1.8

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/lib/dialog.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./prod-react-Dzof4qJx.mjs";
2
- import { L as panelAnchorRow, c as asTextItem, i as Dialog, l as registerWidget, n as panelLegend, o as rowHeight, r as CloseGuardContext, s as wrapStatusLines, t as PanelSurface } from "./surface-DSDGGCSN.mjs";
2
+ import { L as panelAnchorRow, c as asTextItem, i as Dialog, l as registerWidget, n as panelLegend, o as rowHeight, r as CloseGuardContext, s as wrapStatusLines, t as PanelSurface } from "./surface-bsX86Swt.mjs";
3
3
  export { CloseGuardContext, Dialog, PanelSurface, asTextItem, panelAnchorRow, panelLegend, registerWidget, rowHeight, wrapStatusLines };
package/lib/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./prod-react-Dzof4qJx.mjs";
2
- import { $ as colToCharIndex, A as writeCursorShape, At as colorLevel, B as hintBlockTop, C as useCaret, Ct as permissionModeInfo, D as SelectableText, Dt as subscribePalettes, E as markKeymapConsumed, Et as setThemeMode, F as inputContentContains, Ft as installCrashHandlers, G as segmentsKey, H as inputStatusRow, I as messageBackgroundWidth, It as warn, J as sliceByColumns, K as wrapSegments, L as panelAnchorRow, M as isMouseResidue, Mt as env, N as writeMouseDisable, Nt as configureLogs, O as SelectionContext, Ot as themeMode, P as hintSpan, Pt as error, Q as charWidth, R as panelContains, S as caretNonceText, St as paletteColor, T as isKeyConsumed, Tt as replacePalettes, U as glyphs, V as inputFrameTop, W as mergeRuns, X as selectedRange, Y as clampFocusRow, Z as toScreenSelection, _ as editDeleteWordRight, _t as registerFieldKind, a as DIALOG_MAX_HEIGHT, at as truncate, b as caretNonceBold, bt as specialFieldFactory, ct as charactersChipLabel, d as editCursorLeft, dt as fieldStyleOf, et as errorText, f as editCursorRight, ft as hasFieldChar, g as editDeleteWordLeft, gt as linesChipLabel, h as editDelete, ht as isFieldChar, i as Dialog, it as textWidth, j as createMouseController, jt as setColorLevel, k as Region, kt as keyedRegistry, l as registerWidget, lt as fieldExpandOf, m as editCursorWordRight, mt as imageChipLabel, n as panelLegend, nt as locToPoint, ot as wrapLines, p as editCursorWordLeft, pt as hasFieldSlots, q as chromeSelectionText, r as CloseGuardContext, rt as segmentGraphemes, st as allocateField, t as PanelSurface, tt as lineBreaks, u as editBackspace, ut as fieldSlotOf, v as editInsert, vt as releaseFields, w as beginKeyEvent, wt as registerPalette, x as caretNonceColor, xt as COLORS, y as CapText, yt as releaseUnreferenced, z as scrollbarColumn } from "./surface-DSDGGCSN.mjs";
2
+ import { $ as colToCharIndex, A as Region, At as colorLevel, B as hintBlockTop, C as caretNonceText, Ct as permissionModeInfo, D as markKeymapConsumed, Dt as subscribePalettes, E as isKeyConsumed, Et as setThemeMode, F as inputContentContains, Ft as installCrashHandlers, G as segmentsKey, H as inputStatusRow, I as messageBackgroundWidth, It as warn, J as sliceByColumns, K as wrapSegments, L as panelAnchorRow, M as isMouseResidue, Mt as env, N as writeStdoutRaw, Nt as configureLogs, O as SelectableText, Ot as themeMode, P as hintSpan, Pt as error, Q as charWidth, R as panelContains, S as caretNonceColor, St as paletteColor, T as beginKeyEvent, Tt as replacePalettes, U as glyphs, V as inputFrameTop, W as mergeRuns, X as selectedRange, Y as clampFocusRow, Z as toScreenSelection, _ as editDeleteWordRight, _t as registerFieldKind, a as DIALOG_MAX_HEIGHT, at as truncate, b as writeCursorShape, bt as specialFieldFactory, ct as charactersChipLabel, d as editCursorLeft, dt as fieldStyleOf, et as errorText, f as editCursorRight, ft as hasFieldChar, g as editDeleteWordLeft, gt as linesChipLabel, h as editDelete, ht as isFieldChar, i as Dialog, it as textWidth, j as createMouseController, jt as setColorLevel, k as SelectionContext, kt as keyedRegistry, l as registerWidget, lt as fieldExpandOf, m as editCursorWordRight, mt as imageChipLabel, n as panelLegend, nt as locToPoint, ot as wrapLines, p as editCursorWordLeft, pt as hasFieldSlots, q as chromeSelectionText, r as CloseGuardContext, rt as segmentGraphemes, st as allocateField, t as PanelSurface, tt as lineBreaks, u as editBackspace, ut as fieldSlotOf, v as editInsert, vt as releaseFields, w as useCaret, wt as registerPalette, x as caretNonceBold, xt as COLORS, y as CapText, yt as releaseUnreferenced, z as scrollbarColumn } from "./surface-bsX86Swt.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { readFileSync, statSync } from "node:fs";
5
5
  import { join, resolve } from "node:path";
@@ -2945,6 +2945,26 @@ function selectionText(messages, width, selection) {
2945
2945
  return lines.join("\n").replace(/[ \t]+$/gm, "").replace(/\n+$/, "");
2946
2946
  }
2947
2947
  //#endregion
2948
+ //#region src/terminal/restore.ts
2949
+ /**
2950
+ * Synchronously restore every terminal mode this TUI enables: cursor
2951
+ * visibility and shape, mouse tracking, bracketed paste, the kitty keyboard
2952
+ * protocol, and the alternate screen. Windows TTY writes through
2953
+ * process.stdout are asynchronous, so the restores ink queues at unmount
2954
+ * can be dropped when the process exits right after — every exit path must
2955
+ * call this synchronously before the process leaves.
2956
+ */
2957
+ function restoreTerminal() {
2958
+ writeStdoutRaw([
2959
+ "\x1B[?25h",
2960
+ "\x1B[0 q",
2961
+ "\x1B[?1003l\x1B[?1000l\x1B[?1002l\x1B[?1006l",
2962
+ "\x1B[?2004l",
2963
+ "\x1B[<u",
2964
+ "\x1B[?1049l"
2965
+ ].join(""));
2966
+ }
2967
+ //#endregion
2948
2968
  //#region src/ui/hooks/use-terminal-size.ts
2949
2969
  function useTerminalSize() {
2950
2970
  const { stdout } = useStdout();
@@ -9142,8 +9162,7 @@ function App({ bridge, screen, themeTick = 0 }) {
9142
9162
  }
9143
9163
  if (!exiting.current) {
9144
9164
  exiting.current = true;
9145
- writeCursorShape("reset");
9146
- writeMouseDisable();
9165
+ restoreTerminal();
9147
9166
  process.kill(process.pid, "SIGINT");
9148
9167
  setTimeout(() => process.exit(0), FORCE_EXIT_DELAY_MS).unref();
9149
9168
  }
@@ -11334,6 +11353,7 @@ function apply(ctx, config = Config(DEFAULT_CONFIG)) {
11334
11353
  writeCursorShape("reset");
11335
11354
  bridge?.dispose();
11336
11355
  app?.unmount();
11356
+ restoreTerminal();
11337
11357
  disposeCrashHandlers();
11338
11358
  };
11339
11359
  });
@@ -1434,18 +1434,6 @@ function createMouseController(onEvent) {
1434
1434
  }
1435
1435
  };
1436
1436
  }
1437
- //#endregion
1438
- //#region src/terminal/cursor-shape.ts
1439
- const SEQUENCES = {
1440
- beam: "\x1B[1 q",
1441
- block: "\x1B[2 q",
1442
- reset: "\x1B[0 q",
1443
- hide: "\x1B[?25l",
1444
- show: "\x1B[?25h"
1445
- };
1446
- function writeCursorShape(shape) {
1447
- writeStdoutRaw(SEQUENCES[shape]);
1448
- }
1449
1437
  const RegionContext = createContext({
1450
1438
  x: 0,
1451
1439
  y: 0
@@ -1651,6 +1639,18 @@ function caretNonceBold(cursor) {
1651
1639
  return Math.floor(cursor / 480) % 2 === 0;
1652
1640
  }
1653
1641
  //#endregion
1642
+ //#region src/terminal/cursor-shape.ts
1643
+ const SEQUENCES = {
1644
+ beam: "\x1B[1 q",
1645
+ block: "\x1B[2 q",
1646
+ reset: "\x1B[0 q",
1647
+ hide: "\x1B[?25l",
1648
+ show: "\x1B[?25h"
1649
+ };
1650
+ function writeCursorShape(shape) {
1651
+ writeStdoutRaw(SEQUENCES[shape]);
1652
+ }
1653
+ //#endregion
1654
1654
  //#region src/ui/chrome/caps.tsx
1655
1655
  function CapText({ background, top, width }) {
1656
1656
  if (glyphs.halfBlockCaps) return /* @__PURE__ */ jsx(Text, {
@@ -3136,4 +3136,4 @@ function PanelSurface({ columns, rows, body, bodyStart, background, blockWidth }
3136
3136
  }) });
3137
3137
  }
3138
3138
  //#endregion
3139
- export { colToCharIndex as $, writeCursorShape as A, colorLevel as At, hintBlockTop as B, useCaret as C, permissionModeInfo as Ct, SelectableText as D, subscribePalettes as Dt, markKeymapConsumed as E, setThemeMode as Et, inputContentContains as F, installCrashHandlers as Ft, segmentsKey as G, inputStatusRow as H, messageBackgroundWidth as I, warn as It, sliceByColumns as J, wrapSegments as K, panelAnchorRow as L, isMouseResidue as M, env as Mt, writeMouseDisable as N, configureLogs as Nt, SelectionContext as O, themeMode as Ot, hintSpan as P, error as Pt, charWidth as Q, panelContains as R, caretNonceText as S, paletteColor as St, isKeyConsumed as T, replacePalettes as Tt, glyphs as U, inputFrameTop as V, mergeRuns as W, selectedRange as X, clampFocusRow as Y, toScreenSelection as Z, editDeleteWordRight as _, registerFieldKind as _t, DIALOG_MAX_HEIGHT as a, truncate as at, caretNonceBold as b, specialFieldFactory as bt, asTextItem as c, charactersChipLabel as ct, editCursorLeft as d, fieldStyleOf as dt, errorText as et, editCursorRight as f, hasFieldChar as ft, editDeleteWordLeft as g, linesChipLabel as gt, editDelete as h, isFieldChar as ht, Dialog as i, textWidth as it, createMouseController as j, setColorLevel as jt, Region as k, keyedRegistry as kt, registerWidget as l, fieldExpandOf as lt, editCursorWordRight as m, imageChipLabel as mt, panelLegend as n, locToPoint as nt, rowHeight as o, wrapLines as ot, editCursorWordLeft as p, hasFieldSlots as pt, chromeSelectionText as q, CloseGuardContext as r, segmentGraphemes as rt, wrapStatusLines as s, allocateField as st, PanelSurface as t, lineBreaks as tt, editBackspace as u, fieldSlotOf as ut, editInsert as v, releaseFields as vt, beginKeyEvent as w, registerPalette as wt, caretNonceColor as x, COLORS as xt, CapText as y, releaseUnreferenced as yt, scrollbarColumn as z };
3139
+ export { colToCharIndex as $, Region as A, colorLevel as At, hintBlockTop as B, caretNonceText as C, permissionModeInfo as Ct, markKeymapConsumed as D, subscribePalettes as Dt, isKeyConsumed as E, setThemeMode as Et, inputContentContains as F, installCrashHandlers as Ft, segmentsKey as G, inputStatusRow as H, messageBackgroundWidth as I, warn as It, sliceByColumns as J, wrapSegments as K, panelAnchorRow as L, isMouseResidue as M, env as Mt, writeStdoutRaw as N, configureLogs as Nt, SelectableText as O, themeMode as Ot, hintSpan as P, error as Pt, charWidth as Q, panelContains as R, caretNonceColor as S, paletteColor as St, beginKeyEvent as T, replacePalettes as Tt, glyphs as U, inputFrameTop as V, mergeRuns as W, selectedRange as X, clampFocusRow as Y, toScreenSelection as Z, editDeleteWordRight as _, registerFieldKind as _t, DIALOG_MAX_HEIGHT as a, truncate as at, writeCursorShape as b, specialFieldFactory as bt, asTextItem as c, charactersChipLabel as ct, editCursorLeft as d, fieldStyleOf as dt, errorText as et, editCursorRight as f, hasFieldChar as ft, editDeleteWordLeft as g, linesChipLabel as gt, editDelete as h, isFieldChar as ht, Dialog as i, textWidth as it, createMouseController as j, setColorLevel as jt, SelectionContext as k, keyedRegistry as kt, registerWidget as l, fieldExpandOf as lt, editCursorWordRight as m, imageChipLabel as mt, panelLegend as n, locToPoint as nt, rowHeight as o, wrapLines as ot, editCursorWordLeft as p, hasFieldSlots as pt, chromeSelectionText as q, CloseGuardContext as r, segmentGraphemes as rt, wrapStatusLines as s, allocateField as st, PanelSurface as t, lineBreaks as tt, editBackspace as u, fieldSlotOf as ut, editInsert as v, releaseFields as vt, useCaret as w, registerPalette as wt, caretNonceBold as x, COLORS as xt, CapText as y, releaseUnreferenced as yt, scrollbarColumn as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xp266/dshtui",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "ink-based terminal UI plugin for DeepSeek Harness",
6
6
  "engines": {
package/src/index.tsx CHANGED
@@ -10,6 +10,7 @@ import { createChatBridge } from './chat/bridge.ts'
10
10
  import type { ChatBridge } from './chat/bridge.ts'
11
11
  import { createScreenCapture } from './terminal/screen.ts'
12
12
  import { writeCursorShape } from './terminal/cursor-shape.ts'
13
+ import { restoreTerminal } from './terminal/restore.ts'
13
14
  import { startHotTheme } from './hot-theme.ts'
14
15
  import { applyTheme } from './apply-theme.ts'
15
16
  import { registerPalette } from './theme.ts'
@@ -180,6 +181,7 @@ export function apply(ctx: Context, config: Config = Config(DEFAULT_CONFIG)) {
180
181
  writeCursorShape('reset')
181
182
  bridge?.dispose()
182
183
  app?.unmount()
184
+ restoreTerminal()
183
185
  disposeCrashHandlers()
184
186
  }
185
187
  })
@@ -0,0 +1,20 @@
1
+ import { writeStdoutRaw } from './mouse.ts'
2
+
3
+ /**
4
+ * Synchronously restore every terminal mode this TUI enables: cursor
5
+ * visibility and shape, mouse tracking, bracketed paste, the kitty keyboard
6
+ * protocol, and the alternate screen. Windows TTY writes through
7
+ * process.stdout are asynchronous, so the restores ink queues at unmount
8
+ * can be dropped when the process exits right after — every exit path must
9
+ * call this synchronously before the process leaves.
10
+ */
11
+ export function restoreTerminal(): void {
12
+ writeStdoutRaw([
13
+ '\x1b[?25h',
14
+ '\x1b[0 q',
15
+ '\x1b[?1003l\x1b[?1000l\x1b[?1002l\x1b[?1006l',
16
+ '\x1b[?2004l',
17
+ '\x1b[<u',
18
+ '\x1b[?1049l',
19
+ ].join(''))
20
+ }
package/src/ui/app.tsx CHANGED
@@ -9,8 +9,7 @@ import type { ChatBridge } from '../chat/bridge.ts'
9
9
  import type { AgentActivity } from '../chat/store.ts'
10
10
  import { rowIndexFor, selectionText } from './message/layout.ts'
11
11
  import { glyphs } from '../terminal/glyphs.ts'
12
- import { writeMouseDisable } from '../terminal/mouse.ts'
13
- import { writeCursorShape } from '../terminal/cursor-shape.ts'
12
+ import { restoreTerminal } from '../terminal/restore.ts'
14
13
  import { chromeSelectionText } from './selection-registry.ts'
15
14
  import type { ScreenCapture } from '../terminal/screen.ts'
16
15
  import type { LineSelection } from '../model/selection.ts'
@@ -336,8 +335,7 @@ export function App({ bridge, screen, themeTick = 0 }: AppProps) {
336
335
  exiting.current = true
337
336
  // Restore terminal modes synchronously before signaling: on Windows
338
337
  // the queued async writes of the dispose path can be lost at exit.
339
- writeCursorShape('reset')
340
- writeMouseDisable()
338
+ restoreTerminal()
341
339
  process.kill(process.pid, 'SIGINT')
342
340
  setTimeout(() => process.exit(0), FORCE_EXIT_DELAY_MS).unref()
343
341
  }