aitasks 1.2.2 → 1.3.0

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 +70 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1890,7 +1890,7 @@ var require_commander = __commonJS((exports) => {
1890
1890
  var require_package = __commonJS((exports, module) => {
1891
1891
  module.exports = {
1892
1892
  name: "aitasks",
1893
- version: "1.2.2",
1893
+ version: "1.3.0",
1894
1894
  description: "CLI task management tool built for AI agents",
1895
1895
  type: "module",
1896
1896
  bin: {
@@ -41546,7 +41546,7 @@ var wrapAnsiLine = (line, maxW) => {
41546
41546
  result2.push(current);
41547
41547
  return result2;
41548
41548
  };
41549
- var RightPane = ({ task, width, height, scrollOffset }) => {
41549
+ var RightPane = ({ task, width, height, scrollOffset, metricsRef }) => {
41550
41550
  const { lines, contentW } = import_react29.useMemo(() => {
41551
41551
  if (!task)
41552
41552
  return { lines: [], contentW: 20 };
@@ -41616,6 +41616,8 @@ var RightPane = ({ task, width, height, scrollOffset }) => {
41616
41616
  const visibleH = Math.max(3, height - 2);
41617
41617
  const maxOffset = Math.max(0, totalLines - visibleH);
41618
41618
  const offset = Math.min(scrollOffset, maxOffset);
41619
+ if (metricsRef)
41620
+ metricsRef.current = { maxOffset, visibleH };
41619
41621
  const visibleLines = lines.slice(offset, offset + visibleH);
41620
41622
  const scrollbar = import_react29.useMemo(() => {
41621
41623
  if (totalLines <= visibleH)
@@ -41858,6 +41860,8 @@ var TreeBoardComponent = ({ getTasks }) => {
41858
41860
  return;
41859
41861
  }
41860
41862
  if (input && !key.ctrl && !key.meta) {
41863
+ if (Date.now() < suppressUntilRef.current)
41864
+ return;
41861
41865
  setSearchQuery((q2) => q2 + input);
41862
41866
  return;
41863
41867
  }
@@ -41910,14 +41914,40 @@ var TreeBoardComponent = ({ getTasks }) => {
41910
41914
  leftWidthRef.current = leftWidth;
41911
41915
  const scrollOffsetRef = import_react29.useRef(scrollOffset);
41912
41916
  scrollOffsetRef.current = scrollOffset;
41917
+ const colsRef = import_react29.useRef(cols);
41918
+ colsRef.current = cols;
41919
+ const rowsRef = import_react29.useRef(rows);
41920
+ rowsRef.current = rows;
41921
+ const leftScrollOffsetRef = import_react29.useRef(leftScrollOffset);
41922
+ leftScrollOffsetRef.current = leftScrollOffset;
41923
+ const leftMaxOffsetRef = import_react29.useRef(0);
41924
+ const rightMetricsRef = import_react29.useRef({ maxOffset: 0, visibleH: 0 });
41925
+ const dragRef = import_react29.useRef(null);
41926
+ const visibleLeftRowsRef = import_react29.useRef([]);
41927
+ const suppressUntilRef = import_react29.useRef(0);
41928
+ const searchActiveRef = import_react29.useRef(false);
41913
41929
  import_react29.useEffect(() => {
41914
- process.stdout.write("\x1B[?1000h\x1B[?1006h");
41930
+ process.stdout.write("\x1B[?1002h\x1B[?1006h");
41931
+ const jumpToRow = (row, pane) => {
41932
+ const contentStart = 4;
41933
+ const visH = Math.max(1, rowsRef.current - 4);
41934
+ const relRow = Math.max(0, Math.min(row - contentStart, visH - 1));
41935
+ const ratio = visH > 1 ? relRow / (visH - 1) : 0;
41936
+ if (pane === "left") {
41937
+ setLeftScrollOffset(Math.round(ratio * leftMaxOffsetRef.current));
41938
+ } else {
41939
+ setScrollOffset(Math.round(ratio * rightMetricsRef.current.maxOffset));
41940
+ }
41941
+ };
41915
41942
  const onData = (buf) => {
41916
41943
  const str = buf.toString("latin1");
41917
- const sgr = str.match(/\x1b\[<(\d+);(\d+);(\d+)M/);
41944
+ const sgr = str.match(/\x1b\[<(\d+);(\d+);(\d+)([Mm])/);
41918
41945
  if (sgr) {
41919
41946
  const btn = parseInt(sgr[1], 10);
41920
41947
  const col = parseInt(sgr[2], 10) - 1;
41948
+ const row = parseInt(sgr[3], 10) - 1;
41949
+ const isRelease = sgr[4] === "m";
41950
+ suppressUntilRef.current = Date.now() + 150;
41921
41951
  if (btn === 64 || btn === 65) {
41922
41952
  if (col < leftWidthRef.current) {
41923
41953
  if (btn === 64)
@@ -41930,6 +41960,34 @@ var TreeBoardComponent = ({ getTasks }) => {
41930
41960
  if (btn === 65)
41931
41961
  setScrollOffset((o) => o + 8);
41932
41962
  }
41963
+ return;
41964
+ }
41965
+ if (isRelease) {
41966
+ dragRef.current = null;
41967
+ return;
41968
+ }
41969
+ if (btn === 0 || btn === 32) {
41970
+ const leftSbCol = leftWidthRef.current - 2;
41971
+ const rightSbCol = colsRef.current - 3;
41972
+ if (btn === 0) {
41973
+ if (col === leftSbCol)
41974
+ dragRef.current = "left";
41975
+ else if (col >= rightSbCol)
41976
+ dragRef.current = "right";
41977
+ else {
41978
+ dragRef.current = null;
41979
+ if (col < leftWidthRef.current - 1) {
41980
+ const visRowIdx = row - (searchActiveRef.current ? 4 : 3);
41981
+ const clicked = visibleLeftRowsRef.current[visRowIdx];
41982
+ if (clicked?.kind === "item")
41983
+ setSelectedIdx(clicked.itemIdx);
41984
+ }
41985
+ }
41986
+ }
41987
+ if (dragRef.current === "left")
41988
+ jumpToRow(row, "left");
41989
+ if (dragRef.current === "right")
41990
+ jumpToRow(row, "right");
41933
41991
  }
41934
41992
  return;
41935
41993
  }
@@ -41951,9 +42009,9 @@ var TreeBoardComponent = ({ getTasks }) => {
41951
42009
  }
41952
42010
  }
41953
42011
  };
41954
- process.stdin.on("data", onData);
42012
+ process.stdin.prependListener("data", onData);
41955
42013
  return () => {
41956
- process.stdout.write("\x1B[?1006l\x1B[?1000l");
42014
+ process.stdout.write("\x1B[?1006l\x1B[?1002l");
41957
42015
  process.stdin.off("data", onData);
41958
42016
  };
41959
42017
  }, []);
@@ -41962,9 +42020,12 @@ var TreeBoardComponent = ({ getTasks }) => {
41962
42020
  const leftVisibleH = Math.max(1, rows - 4);
41963
42021
  const leftTotalRows = leftRows.length;
41964
42022
  const leftMaxOffset = Math.max(0, leftTotalRows - leftVisibleH);
42023
+ leftMaxOffsetRef.current = leftMaxOffset;
42024
+ searchActiveRef.current = mode === "search" || !!searchQuery;
41965
42025
  const leftOffset = Math.min(leftScrollOffset, leftMaxOffset);
41966
42026
  const rawLeftRows = leftRows.slice(leftOffset, leftOffset + leftVisibleH);
41967
42027
  const visibleLeftRows = rawLeftRows[0]?.kind === "date-sep" ? rawLeftRows.slice(1) : rawLeftRows;
42028
+ visibleLeftRowsRef.current = visibleLeftRows;
41968
42029
  const leftScrollbar = (() => {
41969
42030
  const bar = Array(leftVisibleH).fill(" ");
41970
42031
  if (leftTotalRows > leftVisibleH) {
@@ -42194,7 +42255,8 @@ var TreeBoardComponent = ({ getTasks }) => {
42194
42255
  task: selectedTask,
42195
42256
  width: rightInner,
42196
42257
  height: rightHeight,
42197
- scrollOffset
42258
+ scrollOffset,
42259
+ metricsRef: rightMetricsRef
42198
42260
  }, undefined, false, undefined, this)
42199
42261
  }, undefined, false, undefined, this)
42200
42262
  ]
@@ -43073,4 +43135,4 @@ program2.parseAsync(process.argv).catch((err) => {
43073
43135
  process.exit(1);
43074
43136
  });
43075
43137
 
43076
- //# debugId=605E90B62461DFBE64756E2164756E21
43138
+ //# debugId=26C003F11D02306964756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aitasks",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "CLI task management tool built for AI agents",
5
5
  "type": "module",
6
6
  "bin": {