@lukeashford/aurelius 3.6.0 → 3.7.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.
package/dist/index.d.mts CHANGED
@@ -823,6 +823,10 @@ interface ChatInputProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, 'o
823
823
  * Called whenever the input value changes, giving the consumer access to the current text
824
824
  */
825
825
  onInputChange?: (value: string) => void;
826
+ /**
827
+ * Initial value for the input, used for state restoration (e.g. from DB or localStorage)
828
+ */
829
+ initialInputValue?: string;
826
830
  /**
827
831
  * Whether to automatically focus the input when it becomes enabled
828
832
  */
@@ -1469,6 +1473,10 @@ interface ChatInterfaceProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
1469
1473
  * Called whenever the chat input value changes, giving the consumer access to the current text.
1470
1474
  */
1471
1475
  onInputChange?: (value: string) => void;
1476
+ /**
1477
+ * Initial value for the input, used for state restoration (e.g. from DB or localStorage)
1478
+ */
1479
+ initialInputValue?: string;
1472
1480
  /**
1473
1481
  * Additional tools to add to the tool sidebars. Each ExternalToolDefinition provides
1474
1482
  * an id, icon, label, group ('top-left' | 'bottom-left' | 'top-right' | 'bottom-right'),
package/dist/index.d.ts CHANGED
@@ -823,6 +823,10 @@ interface ChatInputProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, 'o
823
823
  * Called whenever the input value changes, giving the consumer access to the current text
824
824
  */
825
825
  onInputChange?: (value: string) => void;
826
+ /**
827
+ * Initial value for the input, used for state restoration (e.g. from DB or localStorage)
828
+ */
829
+ initialInputValue?: string;
826
830
  /**
827
831
  * Whether to automatically focus the input when it becomes enabled
828
832
  */
@@ -1469,6 +1473,10 @@ interface ChatInterfaceProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
1469
1473
  * Called whenever the chat input value changes, giving the consumer access to the current text.
1470
1474
  */
1471
1475
  onInputChange?: (value: string) => void;
1476
+ /**
1477
+ * Initial value for the input, used for state restoration (e.g. from DB or localStorage)
1478
+ */
1479
+ initialInputValue?: string;
1472
1480
  /**
1473
1481
  * Additional tools to add to the tool sidebars. Each ExternalToolDefinition provides
1474
1482
  * an id, icon, label, group ('top-left' | 'bottom-left' | 'top-right' | 'bottom-right'),
package/dist/index.js CHANGED
@@ -4799,11 +4799,12 @@ var ChatInput = import_react61.default.forwardRef(
4799
4799
  acceptedFileTypes,
4800
4800
  notice,
4801
4801
  onInputChange,
4802
+ initialInputValue = "",
4802
4803
  autoFocus = false,
4803
4804
  className,
4804
4805
  ...rest
4805
4806
  }, ref) => {
4806
- const [value, setValue] = (0, import_react61.useState)("");
4807
+ const [value, setValue] = (0, import_react61.useState)(initialInputValue);
4807
4808
  const [localAttachments, setLocalAttachments] = (0, import_react61.useState)([]);
4808
4809
  const [isDragOver, setIsDragOver] = (0, import_react61.useState)(false);
4809
4810
  const textareaRef = (0, import_react61.useRef)(null);
@@ -6459,15 +6460,13 @@ function sortTasks(tasks) {
6459
6460
  function TaskItem({ task, depth = 0 }) {
6460
6461
  const isTerminal = task.status === "done" || task.status === "cancelled" || task.status === "failed";
6461
6462
  const isSubtle = task.status === "cancelled" || task.status === "failed";
6462
- const showSubtasks = (task.status === "in_progress" || task.status === "done") && task.subtasks && task.subtasks.length > 0;
6463
+ const showSubtasks = task.subtasks && task.subtasks.length > 0;
6463
6464
  const sortedSubtasks = showSubtasks ? sortTasks(task.subtasks) : [];
6464
6465
  return /* @__PURE__ */ import_react74.default.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ import_react74.default.createElement(
6465
6466
  "div",
6466
6467
  {
6467
- className: cx(
6468
- "flex items-center gap-2 py-1",
6469
- depth > 0 && "pl-6"
6470
- )
6468
+ className: "flex items-center gap-2 py-1",
6469
+ style: { paddingLeft: `${depth * 1.5}rem` }
6471
6470
  },
6472
6471
  /* @__PURE__ */ import_react74.default.createElement(TaskIcon, { status: task.status }),
6473
6472
  /* @__PURE__ */ import_react74.default.createElement(
@@ -6489,8 +6488,12 @@ function TaskItem({ task, depth = 0 }) {
6489
6488
  }
6490
6489
  function hasInProgressTask(tasks) {
6491
6490
  return tasks.some((t) => {
6492
- if (t.status === "in_progress") return true;
6493
- if (t.subtasks && t.subtasks.length > 0) return hasInProgressTask(t.subtasks);
6491
+ if (t.status === "in_progress") {
6492
+ return true;
6493
+ }
6494
+ if (t.subtasks && t.subtasks.length > 0) {
6495
+ return hasInProgressTask(t.subtasks);
6496
+ }
6494
6497
  return false;
6495
6498
  });
6496
6499
  }
@@ -6499,7 +6502,9 @@ var TodosList = import_react74.default.forwardRef(
6499
6502
  const sortedTasks = (0, import_react74.useMemo)(() => sortTasks(tasks), [tasks]);
6500
6503
  const [isStopping, setIsStopping] = (0, import_react74.useState)(false);
6501
6504
  const handleStopClick = (0, import_react74.useCallback)(async () => {
6502
- if (!onStopAllTasks || isStopping) return;
6505
+ if (!onStopAllTasks || isStopping) {
6506
+ return;
6507
+ }
6503
6508
  try {
6504
6509
  setIsStopping(true);
6505
6510
  await onStopAllTasks();
@@ -6508,25 +6513,10 @@ var TodosList = import_react74.default.forwardRef(
6508
6513
  }
6509
6514
  }, [onStopAllTasks, isStopping]);
6510
6515
  const countCompleted = (taskList) => {
6511
- let count = 0;
6512
- for (const task of taskList) {
6513
- if (task.status === "done") {
6514
- count++;
6515
- }
6516
- if (task.subtasks) {
6517
- count += countCompleted(task.subtasks);
6518
- }
6519
- }
6520
- return count;
6516
+ return taskList.filter((task) => task.status === "done").length;
6521
6517
  };
6522
6518
  const countTotal = (taskList) => {
6523
- let count = taskList.length;
6524
- for (const task of taskList) {
6525
- if (task.subtasks) {
6526
- count += countTotal(task.subtasks);
6527
- }
6528
- }
6529
- return count;
6519
+ return taskList.length;
6530
6520
  };
6531
6521
  const showStopButton = !!onStopAllTasks && (hasInProgressTask(tasks) || isStopping);
6532
6522
  if (tasks.length === 0) {
@@ -6578,8 +6568,12 @@ TodosList.displayName = "TodosList";
6578
6568
  function areAllTasksSettled(tasks) {
6579
6569
  return tasks.every((t) => {
6580
6570
  const settled = t.status === "done" || t.status === "cancelled" || t.status === "failed";
6581
- if (!settled) return false;
6582
- if (t.subtasks && t.subtasks.length > 0) return areAllTasksSettled(t.subtasks);
6571
+ if (!settled) {
6572
+ return false;
6573
+ }
6574
+ if (t.subtasks && t.subtasks.length > 0) {
6575
+ return areAllTasksSettled(t.subtasks);
6576
+ }
6583
6577
  return true;
6584
6578
  });
6585
6579
  }
@@ -6849,6 +6843,7 @@ var ChatInterface = import_react78.default.forwardRef(
6849
6843
  onStopAllTasks,
6850
6844
  inputNotice,
6851
6845
  onInputChange,
6846
+ initialInputValue = "",
6852
6847
  tools: externalTools = [],
6853
6848
  autoFocus = true,
6854
6849
  className,
@@ -7144,6 +7139,7 @@ var ChatInterface = import_react78.default.forwardRef(
7144
7139
  onAttachmentsChange,
7145
7140
  notice: inputNotice,
7146
7141
  onInputChange,
7142
+ initialInputValue,
7147
7143
  autoFocus
7148
7144
  }
7149
7145
  )), /* @__PURE__ */ import_react78.default.createElement("div", { className: cx(