Skip to content

Commit 736916e

Browse files
committed
fix: authentication
1 parent 729391c commit 736916e

2 files changed

Lines changed: 78 additions & 14 deletions

File tree

src/components/Chat/PartTypes/PartApprovalTool.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,32 @@ export const PartApprovalTool: React.FC<ChatTaskToolRendererProps> = ({
8585
Error: {toolPart.errorText}
8686
</div>
8787
)
88+
89+
case 'output-available':
90+
return (
91+
<>
92+
{ toolPart.output === 'approve' && (
93+
<div className="flex items-center justify-center mt-3">
94+
<div className="inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200">
95+
<svg className="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
96+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
97+
</svg>
98+
Approved
99+
</div>
100+
</div>
101+
)}
102+
{ toolPart.output === 'deny' && (
103+
<div className="flex items-center justify-center mt-3">
104+
<div className="inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200">
105+
<svg className="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
106+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
107+
</svg>
108+
Denied
109+
</div>
110+
</div>
111+
)}
112+
</>
113+
)
88114

89115
default:
90116
return null
Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// tool-requestEndpointLogin
22

3-
import React from "react"
4-
import { OAuthModal } from "../Components/Oauth"
5-
import { set } from "date-fns"
3+
import React from 'react'
4+
import { OAuthModal } from '../Components/Oauth'
5+
import { set } from 'date-fns'
66

77
interface TaskToolPart {
88
type: string
9+
toolCallId: string
910
state: 'input-available' | 'output-available' | 'output-error'
1011
input?: any
1112
output?: any
@@ -18,21 +19,18 @@ interface ChatTaskToolRendererProps {
1819
addToolResult: (toolCallId: string, tool: string, output: any) => void
1920
}
2021

21-
export const PartAuthenticateTool: React.FC<ChatTaskToolRendererProps> = ({
22-
toolPart,
22+
export const PartAuthenticateTool: React.FC<ChatTaskToolRendererProps> = ({
23+
toolPart,
2324
index,
2425
addToolResult,
2526
}) => {
2627
const [open, setOpen] = React.useState(true)
2728
const handleOAuthSuccess = () => {
28-
addToolResult(toolPart.input?.toolCallId, toolPart.input?.tool, "Authentication completed")
29+
addToolResult(toolPart.toolCallId, toolPart.type, 'Authentication completed')
2930
setOpen(false)
3031
}
3132

32-
33-
3433
switch (toolPart.state) {
35-
3634
case 'input-available':
3735
return (
3836
<div key={index} className="mb-2">
@@ -43,27 +41,67 @@ export const PartAuthenticateTool: React.FC<ChatTaskToolRendererProps> = ({
4341
onSuccess={handleOAuthSuccess}
4442
description={toolPart.output?.reason || toolPart.input?.reason}
4543
/>
46-
{ !open && (
44+
{!open && (
4745
<div className="flex items-center justify-center mt-3">
4846
<div className="inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200">
4947
<svg className="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
50-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
48+
<path
49+
strokeLinecap="round"
50+
strokeLinejoin="round"
51+
strokeWidth={2}
52+
d="M5 13l4 4L19 7"
53+
/>
5154
</svg>
5255
Authentication completed
5356
</div>
5457
</div>
5558
)}
5659
</div>
5760
)
58-
61+
5962
case 'output-error':
6063
return (
6164
<div key={index} className="text-sm text-red-500">
6265
Error: {toolPart.errorText}
6366
</div>
6467
)
65-
68+
69+
case 'output-available':
70+
return (
71+
<>
72+
{toolPart.output === 'Authentication completed' ? (
73+
<div className="flex items-center justify-center mt-3">
74+
<div className="inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200">
75+
<svg className="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
76+
<path
77+
strokeLinecap="round"
78+
strokeLinejoin="round"
79+
strokeWidth={2}
80+
d="M5 13l4 4L19 7"
81+
/>
82+
</svg>
83+
Authentication completed
84+
</div>
85+
</div>
86+
) : (
87+
<div className="flex items-center justify-center mt-3">
88+
<div className="inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200">
89+
<svg className="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
90+
<path
91+
strokeLinecap="round"
92+
strokeLinejoin="round"
93+
strokeWidth={2}
94+
d="M6 18L18 6M6 6l12 12"
95+
/>
96+
</svg>
97+
Authentication failed
98+
</div>
99+
</div>
100+
)}
101+
</>
102+
)
103+
66104
default:
67105
return null
68106
}
69-
}
107+
}

0 commit comments

Comments
 (0)