fix: Allow for human interrupt to be passed without array

This commit is contained in:
bracesproul
2025-03-17 14:09:04 -07:00
parent c8bfb1cdc8
commit a0e9d7f5f3
4 changed files with 27 additions and 22 deletions

View File

@@ -100,6 +100,7 @@ export function ThreadActionsView({
const threadTitle = interrupt.action_request.action || "Unknown"; const threadTitle = interrupt.action_request.action || "Unknown";
const actionsDisabled = loading || streaming; const actionsDisabled = loading || streaming;
const ignoreAllowed = interrupt.config.allow_ignore;
return ( return (
<div className="flex flex-col min-h-full w-full gap-9"> <div className="flex flex-col min-h-full w-full gap-9">
@@ -138,14 +139,16 @@ export function ThreadActionsView({
> >
Mark as Resolved Mark as Resolved
</Button> </Button>
<Button {ignoreAllowed && (
variant="outline" <Button
className="text-gray-800 border-gray-500 font-normal bg-white" variant="outline"
onClick={handleIgnore} className="text-gray-800 border-gray-500 font-normal bg-white"
disabled={actionsDisabled} onClick={handleIgnore}
> disabled={actionsDisabled}
Ignore >
</Button> Ignore
</Button>
)}
</div> </div>
{/* Actions */} {/* Actions */}

View File

@@ -5,10 +5,11 @@ import { HumanInterrupt } from "@langchain/langgraph/prebuilt";
import { useStreamContext } from "@/providers/Stream"; import { useStreamContext } from "@/providers/Stream";
interface ThreadViewProps { interface ThreadViewProps {
interrupt: HumanInterrupt; interrupt: HumanInterrupt | HumanInterrupt[];
} }
export function ThreadView({ interrupt }: ThreadViewProps) { export function ThreadView({ interrupt }: ThreadViewProps) {
const interruptObj = Array.isArray(interrupt) ? interrupt[0] : interrupt;
const thread = useStreamContext(); const thread = useStreamContext();
const [showDescription, setShowDescription] = useState(false); const [showDescription, setShowDescription] = useState(false);
const [showState, setShowState] = useState(false); const [showState, setShowState] = useState(false);
@@ -39,13 +40,13 @@ export function ThreadView({ interrupt }: ThreadViewProps) {
{showSidePanel ? ( {showSidePanel ? (
<StateView <StateView
handleShowSidePanel={handleShowSidePanel} handleShowSidePanel={handleShowSidePanel}
description={interrupt.description} description={interruptObj.description}
values={thread.values} values={thread.values}
view={showState ? "state" : "description"} view={showState ? "state" : "description"}
/> />
) : ( ) : (
<ThreadActionsView <ThreadActionsView
interrupt={interrupt} interrupt={interruptObj}
handleShowSidePanel={handleShowSidePanel} handleShowSidePanel={handleShowSidePanel}
showState={showState} showState={showState}
showDescription={showDescription} showDescription={showDescription}

View File

@@ -131,7 +131,7 @@ export function AssistantMessage({
<CustomComponent message={message} thread={thread} /> <CustomComponent message={message} thread={thread} />
{isAgentInboxInterruptSchema(interrupt?.value) && isLastMessage && ( {isAgentInboxInterruptSchema(interrupt?.value) && isLastMessage && (
<ThreadView interrupt={interrupt.value[0]} /> <ThreadView interrupt={interrupt.value} />
)} )}
<div <div
className={cn( className={cn(

View File

@@ -2,16 +2,17 @@ import { HumanInterrupt } from "@langchain/langgraph/prebuilt";
export function isAgentInboxInterruptSchema( export function isAgentInboxInterruptSchema(
value: unknown, value: unknown,
): value is HumanInterrupt[] { ): value is HumanInterrupt | HumanInterrupt[] {
const valueAsObject = Array.isArray(value) ? value[0] : value;
return ( return (
Array.isArray(value) && valueAsObject &&
"action_request" in value[0] && "action_request" in valueAsObject &&
typeof value[0].action_request === "object" && typeof valueAsObject.action_request === "object" &&
"config" in value[0] && "config" in valueAsObject &&
typeof value[0].config === "object" && typeof valueAsObject.config === "object" &&
"allow_respond" in value[0].config && "allow_respond" in valueAsObject.config &&
"allow_accept" in value[0].config && "allow_accept" in valueAsObject.config &&
"allow_edit" in value[0].config && "allow_edit" in valueAsObject.config &&
"allow_ignore" in value[0].config "allow_ignore" in valueAsObject.config
); );
} }