@parhelia/core 0.1.12447 → 0.1.12451

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.
@@ -1,33 +1,49 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, forwardRef, useImperativeHandle } from "react";
2
+ import { useState, useRef, forwardRef, useImperativeHandle } from "react";
3
3
  import { Dialog, DialogContent, DialogTitle, DialogFooter, } from "../components/ui/dialog";
4
4
  import { Button } from "../components/ui/button";
5
5
  import { AlertTriangle } from "lucide-react";
6
6
  import { cn } from "../lib/utils";
7
7
  const ConfirmationDialog = forwardRef((_props, ref) => {
8
8
  const [visible, setVisible] = useState(false);
9
+ const resolvedRef = useRef(false);
9
10
  const [props, setProps] = useState();
10
11
  const showAccept = props?.showAccept === undefined ? true : props.showAccept;
11
12
  useImperativeHandle(ref, () => ({
12
13
  confirm: (props) => {
13
- setVisible(true);
14
+ resolvedRef.current = false;
14
15
  setProps(props);
16
+ setVisible(true);
15
17
  },
16
18
  }));
17
19
  const handleAccept = () => {
20
+ if (resolvedRef.current)
21
+ return;
22
+ resolvedRef.current = true;
18
23
  props?.accept();
19
24
  setVisible(false);
20
25
  };
21
26
  const handleReject = () => {
27
+ if (resolvedRef.current)
28
+ return;
29
+ resolvedRef.current = true;
22
30
  if (props?.reject)
23
31
  props.reject();
24
32
  setVisible(false);
25
33
  };
26
- const handleCancel = () => {
34
+ const handleOpenChange = (open) => {
35
+ if (open) {
36
+ setVisible(true);
37
+ return;
38
+ }
39
+ if (!resolvedRef.current) {
40
+ resolvedRef.current = true;
41
+ props?.reject?.();
42
+ }
27
43
  setVisible(false);
28
44
  };
29
45
  const isDestructive = props?.acceptLabel === "Delete" || props?.acceptLabel === "Remove";
30
- return (_jsx(Dialog, { open: visible, onOpenChange: setVisible, children: _jsx(DialogContent, { className: "gap-0 p-0 sm:max-w-[480px] max-h-[80vh] flex flex-col", "data-testid": "confirmation-dialog", children: _jsxs("div", { className: "flex flex-col pt-8 overflow-hidden", children: [_jsx("div", { className: "px-8 pb-4 overflow-y-auto max-h-[50vh]", children: _jsxs("div", { className: "flex items-start gap-4", children: [_jsx("div", { className: cn("flex size-10 shrink-0 items-center justify-center rounded-full", isDestructive ? "bg-red-50 text-red-600" : "bg-amber-50 text-amber-600"), children: props?.icon ? (props.icon) : (_jsx(AlertTriangle, { className: "size-5", strokeWidth: 2 })) }), _jsxs("div", { className: "flex flex-col gap-1 min-w-0 flex-1", children: [_jsx(DialogTitle, { className: "text-xl font-bold", "data-testid": "confirmation-dialog-title", children: props?.header || "Confirmation" }), _jsx("div", { className: "text-sm leading-relaxed text-muted-foreground mt-1", children: props?.message })] })] }) }), _jsxs(DialogFooter, { className: "bg-gray-50/50 mt-4 border-t px-8 py-6 sm:flex-wrap", children: [props?.showCancel && (_jsx(Button, { variant: "outline", onClick: handleCancel, className: "min-w-[100px] w-full sm:w-auto bg-white whitespace-normal break-words text-center max-w-full", children: "Cancel" })), props?.rejectLabel && (_jsx(Button, { variant: "outline", onClick: handleReject, className: "min-w-[100px] w-full sm:w-auto bg-white whitespace-normal break-words text-center max-w-full", children: props.rejectLabel })), showAccept && (_jsx(Button, { onClick: handleAccept, variant: props?.acceptLabel === "Delete" ? "destructive" : "default", className: "min-w-[100px] w-full sm:w-auto whitespace-normal break-words text-center max-w-full", children: props?.acceptLabel || "Yes" }))] })] }) }) }));
46
+ return (_jsx(Dialog, { open: visible, onOpenChange: handleOpenChange, children: _jsx(DialogContent, { className: "gap-0 p-0 sm:max-w-[480px] max-h-[80vh] flex flex-col", "data-testid": "confirmation-dialog", children: _jsxs("div", { className: "flex flex-col pt-8 overflow-hidden", children: [_jsx("div", { className: "px-8 pb-4 overflow-y-auto max-h-[50vh]", children: _jsxs("div", { className: "flex items-start gap-4", children: [_jsx("div", { className: cn("flex size-10 shrink-0 items-center justify-center rounded-full", isDestructive ? "bg-red-50 text-red-600" : "bg-amber-50 text-amber-600"), children: props?.icon ? (props.icon) : (_jsx(AlertTriangle, { className: "size-5", strokeWidth: 2 })) }), _jsxs("div", { className: "flex flex-col gap-1 min-w-0 flex-1", children: [_jsx(DialogTitle, { className: "text-xl font-bold", "data-testid": "confirmation-dialog-title", children: props?.header || "Confirmation" }), _jsx("div", { className: "text-sm leading-relaxed text-muted-foreground mt-1", children: props?.message })] })] }) }), _jsxs(DialogFooter, { className: "bg-gray-50/50 mt-4 border-t px-8 py-6 sm:flex-wrap", children: [props?.showCancel && (_jsx(Button, { variant: "outline", onClick: handleReject, className: "min-w-[100px] w-full sm:w-auto bg-white whitespace-normal break-words text-center max-w-full", children: "Cancel" })), props?.rejectLabel && (_jsx(Button, { variant: "outline", onClick: handleReject, className: "min-w-[100px] w-full sm:w-auto bg-white whitespace-normal break-words text-center max-w-full", children: props.rejectLabel })), showAccept && (_jsx(Button, { onClick: handleAccept, variant: props?.acceptLabel === "Delete" ? "destructive" : "default", className: "min-w-[100px] w-full sm:w-auto whitespace-normal break-words text-center max-w-full", children: props?.acceptLabel || "Yes" }))] })] }) }) }));
31
47
  });
32
48
  export default ConfirmationDialog;
33
49
  //# sourceMappingURL=ConfirmationDialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmationDialog.js","sourceRoot":"","sources":["../../src/editor/ConfirmationDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EACL,MAAM,EACN,aAAa,EAEb,WAAW,EACX,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAsBlC,MAAM,kBAAkB,GAAG,UAAU,CAGnC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;IAChB,MAAM,CAAC,OAAO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AC,CAAC,wBAAwB,CAAC,CAAC,CAAC,4BAA4B,CACxE,YAEA,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CACb,KAAK,CAAC,IAAI,CACX,CAAC,CAAC,CAAC,CACF,KAAC,aAAa,IAAC,SAAS,EAAC,QAAQ,EAAC,WAAW,EAAE,CAAC,GAAI,CACrD,GACG,EACN,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,WAAW,IAAC,SAAS,EAAC,mBAAmB,iBAAa,2BAA2B,YAC/E,KAAK,EAAE,MAAM,IAAI,cAAc,GACpB,EACd,cAAK,SAAS,EAAC,oDAAoD,YAChE,KAAK,EAAE,OAAO,GACX,IACF,IACF,GACF,EAEN,MAAC,YAAY,IAAC,SAAS,EAAC,oDAAoD,aACzE,KAAK,EAAE,UAAU,IAAI,CACpB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAC,8FAA8F,uBAGjG,CACV,EACA,KAAK,EAAE,WAAW,IAAI,CACrB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAC,8FAA8F,YAEvG,KAAK,CAAC,WAAW,GACX,CACV,EACA,UAAU,IAAI,CACb,KAAC,MAAM,IACL,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,KAAK,EAAE,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EACpE,SAAS,EAAC,qFAAqF,YAE9F,KAAK,EAAE,WAAW,IAAI,KAAK,GACrB,CACV,IACY,IACX,GACQ,GACT,CACV,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"ConfirmationDialog.js","sourceRoot":"","sources":["../../src/editor/ConfirmationDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAA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K,SAAS,EAAC,oDAAoD,YAChE,KAAK,EAAE,OAAO,GACX,IACF,IACF,GACF,EAEN,MAAC,YAAY,IAAC,SAAS,EAAC,oDAAoD,aACzE,KAAK,EAAE,UAAU,IAAI,CACpB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAC,8FAA8F,uBAGjG,CACV,EACA,KAAK,EAAE,WAAW,IAAI,CACrB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAC,8FAA8F,YAEvG,KAAK,CAAC,WAAW,GACX,CACV,EACA,UAAU,IAAI,CACb,KAAC,MAAM,IACL,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,KAAK,EAAE,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EACpE,SAAS,EAAC,qFAAqF,YAE9F,KAAK,EAAE,WAAW,IAAI,KAAK,GACrB,CACV,IACY,IACX,GACQ,GACT,CACV,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
@@ -745,6 +745,8 @@ const convertAgentMessagesToAiFormat = (agentMessages) => {
745
745
  // Pass through message IDs for approval/rejection events
746
746
  messageId: toolCall.messageId,
747
747
  dbMessageId: toolCall.dbMessageId,
748
+ responseTimeMs: toolCall.responseTimeMs,
749
+ createdDate: toolCall.createdDate,
748
750
  };
749
751
  })
750
752
  : [],
@@ -2001,6 +2003,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
2001
2003
  if (toolCallMessageId && message.data && toolCallId) {
2002
2004
  const toolCallError = message.data.functionError || message.data.error || "";
2003
2005
  const isPruned = !!message.data?.isPruned || /^PRUNED$/i.test(String(toolCallError));
2006
+ const toolCallCreatedDate = message.data.createdDate || message.timestamp || new Date().toISOString();
2004
2007
  const toolCall = {
2005
2008
  id: toolCallId,
2006
2009
  messageId: toolCallMessageId,
@@ -2013,7 +2016,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
2013
2016
  isPruned,
2014
2017
  isCompleted: false,
2015
2018
  responseTimeMs: message.data.responseTimeMs,
2016
- createdDate: new Date().toISOString(),
2019
+ createdDate: toolCallCreatedDate,
2017
2020
  requiresApproval: message.data?.requiresApproval,
2018
2021
  };
2019
2022
  // Check for existing tool call - search across ALL messages by toolCallId first
@@ -2255,6 +2258,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
2255
2258
  }
2256
2259
  else if (message.data && resultToolCallId && resultMessageId) {
2257
2260
  // Create new tool call if it doesn't exist
2261
+ const toolCallCreatedDate = message.data.createdDate || message.timestamp || new Date().toISOString();
2258
2262
  const toolCall = {
2259
2263
  id: resultToolCallId,
2260
2264
  messageId: resultMessageId,
@@ -2265,7 +2269,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
2265
2269
  functionError: message.data.functionError || message.data.error || "",
2266
2270
  isCompleted: true,
2267
2271
  responseTimeMs: message.data.responseTimeMs,
2268
- createdDate: new Date().toISOString(),
2272
+ createdDate: toolCallCreatedDate,
2269
2273
  };
2270
2274
  updatedMessage.toolCalls = [...updatedMessage.toolCalls, toolCall];
2271
2275
  }