@lukeashford/aurelius 4.4.0 → 4.5.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.mjs CHANGED
@@ -3949,9 +3949,26 @@ var Message = React55.forwardRef(
3949
3949
  hideActions,
3950
3950
  attachments,
3951
3951
  onAttachmentOpen,
3952
+ onJumpHere,
3953
+ isActive,
3952
3954
  ...rest
3953
3955
  }, ref) => {
3954
3956
  const isUser = variant === "user";
3957
+ const isJumpInteractive = !!onJumpHere && !isActive && !isStreaming;
3958
+ const handleBubbleClick = useCallback12((e) => {
3959
+ if (!isJumpInteractive) {
3960
+ return;
3961
+ }
3962
+ const target = e.target;
3963
+ if (target.closest("a, button")) {
3964
+ return;
3965
+ }
3966
+ const selection = typeof window !== "undefined" ? window.getSelection() : null;
3967
+ if (selection && !selection.isCollapsed) {
3968
+ return;
3969
+ }
3970
+ onJumpHere();
3971
+ }, [isJumpInteractive, onJumpHere]);
3955
3972
  const { copied, copy } = useCopyToClipboard();
3956
3973
  const [isEditing, setIsEditing] = useState12(false);
3957
3974
  const [editValue, setEditValue] = useState12(typeof content === "string" ? content : "");
@@ -4058,8 +4075,12 @@ var Message = React55.forwardRef(
4058
4075
  {
4059
4076
  className: cx(
4060
4077
  "px-3 py-2 w-fit max-w-11/12",
4061
- VARIANT_STYLES3[variant]
4062
- )
4078
+ VARIANT_STYLES3[variant],
4079
+ isJumpInteractive && "cursor-pointer hover:brightness-110 transition-all duration-150"
4080
+ ),
4081
+ onClick: isJumpInteractive ? handleBubbleClick : void 0,
4082
+ role: isJumpInteractive ? "button" : void 0,
4083
+ "aria-label": isJumpInteractive ? "Jump to this message" : void 0
4063
4084
  },
4064
4085
  typeof content === "string" ? /* @__PURE__ */ React55.createElement(
4065
4086
  MarkdownContent,
@@ -6804,7 +6825,7 @@ var ChatInterface = React76.forwardRef(
6804
6825
  onMessageSubmit,
6805
6826
  onEditMessage,
6806
6827
  onRetryMessage,
6807
- onJumpToCheckpoint,
6828
+ onJumpHere,
6808
6829
  onJumpToLatest,
6809
6830
  onStop,
6810
6831
  onSelectConversation,
@@ -6980,16 +7001,16 @@ var ChatInterface = React76.forwardRef(
6980
7001
  },
6981
7002
  [tree, onTreeChange]
6982
7003
  );
6983
- const handleJumpToCheckpoint = useCallback22((checkpointId) => {
7004
+ const handleJumpHere = useCallback22((nodeId) => {
6984
7005
  if (!tree) return;
6985
- if (onJumpToCheckpoint) {
6986
- onJumpToCheckpoint(checkpointId);
7006
+ if (onJumpHere) {
7007
+ onJumpHere(nodeId);
6987
7008
  return;
6988
7009
  }
6989
7010
  if (onTreeChange) {
6990
- onTreeChange(setActiveLeaf(tree, checkpointId));
7011
+ onTreeChange(setActiveLeaf(tree, nodeId));
6991
7012
  }
6992
- }, [tree, onTreeChange, onJumpToCheckpoint]);
7013
+ }, [tree, onTreeChange, onJumpHere]);
6993
7014
  const handleJumpToLatest = useCallback22(() => {
6994
7015
  if (!tree) return;
6995
7016
  if (onJumpToLatest) {
@@ -7017,7 +7038,7 @@ var ChatInterface = React76.forwardRef(
7017
7038
  isActive: node.id === activeCheckpointId && !opts.muted,
7018
7039
  muted: opts.muted,
7019
7040
  branchInfo,
7020
- onJumpHere: () => handleJumpToCheckpoint(node.id)
7041
+ onJumpHere: () => handleJumpHere(node.id)
7021
7042
  };
7022
7043
  }
7023
7044
  const actions = enableMessageActions ? {
@@ -7025,6 +7046,7 @@ var ChatInterface = React76.forwardRef(
7025
7046
  onEdit: node.role === "user" && onEditMessage ? (newContent) => onEditMessage(node.id, newContent) : void 0,
7026
7047
  onRetry: node.role === "assistant" && onRetryMessage ? () => onRetryMessage(node.id) : void 0
7027
7048
  } : void 0;
7049
+ const isActiveLeaf = tree?.activeLeafId === node.id;
7028
7050
  return {
7029
7051
  kind: "message",
7030
7052
  id: node.id,
@@ -7041,7 +7063,9 @@ var ChatInterface = React76.forwardRef(
7041
7063
  artifactId: a.artifactId,
7042
7064
  status: a.status ?? "analyzed"
7043
7065
  })) : void 0,
7044
- onAttachmentOpen: handleAttachmentOpen
7066
+ onAttachmentOpen: handleAttachmentOpen,
7067
+ isActive: isActiveLeaf,
7068
+ onJumpHere: () => handleJumpHere(node.id)
7045
7069
  };
7046
7070
  },
7047
7071
  [
@@ -7051,7 +7075,7 @@ var ChatInterface = React76.forwardRef(
7051
7075
  onEditMessage,
7052
7076
  onRetryMessage,
7053
7077
  handleBranchSwitch,
7054
- handleJumpToCheckpoint,
7078
+ handleJumpHere,
7055
7079
  handleAttachmentOpen
7056
7080
  ]
7057
7081
  );