@wrongstack/tui 1.0.16 → 1.0.17

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -8
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -67706,7 +67706,7 @@ function validatePasteContent(content) {
67706
67706
  error: `paste: C0 control char 0x${code.toString(16)} at position ${i} is not allowed.`
67707
67707
  };
67708
67708
  }
67709
- if (code > 0 && code < 9) nonPrintableCount++;
67709
+ if (code === 127 || code >= 128 && code <= 159) nonPrintableCount++;
67710
67710
  }
67711
67711
  if (content.length > 10 && nonPrintableCount / content.length > 0.3) {
67712
67712
  return {
@@ -77082,20 +77082,28 @@ function buildContinuationMessage(active) {
77082
77082
  const scope = active.scope ? ` Stay within the original scope: ${active.scope}.` : "";
77083
77083
  return `This is ${roundLabel}; we're continuing the bug hunt.${scope}`;
77084
77084
  }
77085
- function submitAfterCurrentRun(submit, command) {
77086
- setTimeout(() => submit(command), 0);
77085
+ function submitAfterCurrentRun(submit) {
77086
+ return setTimeout(submit, 0);
77087
77087
  }
77088
77088
  function useBugHuntLoop(dispatch, submit, historyGen) {
77089
77089
  const activeRef = (0, import_react113.useRef)(null);
77090
77090
  const replayCommandRef = (0, import_react113.useRef)(null);
77091
+ const pendingSubmitRef = (0, import_react113.useRef)(null);
77092
+ const cancelPendingSubmit = (0, import_react113.useCallback)(() => {
77093
+ if (pendingSubmitRef.current !== null) clearTimeout(pendingSubmitRef.current);
77094
+ pendingSubmitRef.current = null;
77095
+ replayCommandRef.current = null;
77096
+ }, []);
77097
+ (0, import_react113.useEffect)(() => cancelPendingSubmit, [cancelPendingSubmit]);
77091
77098
  const lastHistoryGenRef = (0, import_react113.useRef)(historyGen);
77092
77099
  (0, import_react113.useEffect)(() => {
77093
77100
  if (historyGen === void 0) return;
77094
77101
  if (historyGen === lastHistoryGenRef.current) return;
77095
77102
  lastHistoryGenRef.current = historyGen;
77103
+ cancelPendingSubmit();
77096
77104
  activeRef.current = null;
77097
77105
  replayCommandRef.current = null;
77098
- }, [historyGen]);
77106
+ }, [historyGen, cancelPendingSubmit]);
77099
77107
  const onBugHuntStarted = (0, import_react113.useCallback)(
77100
77108
  (command, totalRounds) => {
77101
77109
  const active = activeRef.current;
@@ -77109,6 +77117,7 @@ function useBugHuntLoop(dispatch, submit, historyGen) {
77109
77117
  });
77110
77118
  return;
77111
77119
  }
77120
+ cancelPendingSubmit();
77112
77121
  activeRef.current = {
77113
77122
  command,
77114
77123
  scope: parseBugHuntScope(command),
@@ -77117,14 +77126,16 @@ function useBugHuntLoop(dispatch, submit, historyGen) {
77117
77126
  };
77118
77127
  dispatch({ type: "bugHuntRunningOpen", info: { currentRound: 1, totalRounds } });
77119
77128
  },
77120
- [dispatch]
77129
+ [dispatch, cancelPendingSubmit]
77121
77130
  );
77122
77131
  const onRunFinished = (0, import_react113.useCallback)(
77123
77132
  (status) => {
77124
77133
  const active = activeRef.current;
77125
77134
  if (!active) return;
77135
+ if (status === "done" && pendingSubmitRef.current !== null) return;
77126
77136
  dispatch({ type: "bugHuntRunningClose" });
77127
77137
  if (status !== "done") {
77138
+ cancelPendingSubmit();
77128
77139
  activeRef.current = null;
77129
77140
  dispatch({
77130
77141
  type: "addEntry",
@@ -77151,7 +77162,6 @@ function useBugHuntLoop(dispatch, submit, historyGen) {
77151
77162
  const snapshot = { ...active };
77152
77163
  const continueWithNextRound = () => {
77153
77164
  const continuation = buildContinuationMessage(snapshot);
77154
- replayCommandRef.current = continuation;
77155
77165
  dispatch({
77156
77166
  type: "bugHuntRunningOpen",
77157
77167
  info: {
@@ -77159,11 +77169,16 @@ function useBugHuntLoop(dispatch, submit, historyGen) {
77159
77169
  totalRounds: snapshot.totalRounds
77160
77170
  }
77161
77171
  });
77162
- submitAfterCurrentRun(submit, continuation);
77172
+ pendingSubmitRef.current = submitAfterCurrentRun(() => {
77173
+ pendingSubmitRef.current = null;
77174
+ if (activeRef.current !== active) return;
77175
+ replayCommandRef.current = continuation;
77176
+ submit(continuation);
77177
+ });
77163
77178
  };
77164
77179
  continueWithNextRound();
77165
77180
  },
77166
- [dispatch, submit]
77181
+ [dispatch, submit, cancelPendingSubmit]
77167
77182
  );
77168
77183
  const consumeReplay = (0, import_react113.useCallback)((command) => {
77169
77184
  if (replayCommandRef.current !== command) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/tui",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack terminal UI: Ink-based interactive renderer with history, pickers, and slash menus.",
6
6
  "repository": {
@@ -26,12 +26,12 @@
26
26
  "!dist/**/*.map"
27
27
  ],
28
28
  "dependencies": {
29
- "@wrongstack/core": "1.0.16",
30
- "@wrongstack/kanban": "1.0.16",
31
- "@wrongstack/runtime": "1.0.16",
32
- "@wrongstack/sage": "1.0.16",
33
- "@wrongstack/sdd": "1.0.16",
34
- "@wrongstack/tools": "1.0.16",
29
+ "@wrongstack/core": "1.0.17",
30
+ "@wrongstack/kanban": "1.0.17",
31
+ "@wrongstack/runtime": "1.0.17",
32
+ "@wrongstack/sage": "1.0.17",
33
+ "@wrongstack/sdd": "1.0.17",
34
+ "@wrongstack/tools": "1.0.17",
35
35
  "string-width": "8.2.2",
36
36
  "wrap-ansi": "^10.0.1"
37
37
  },