@chrysb/alphaclaw 0.8.1-beta.1 → 0.8.1-beta.2
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.
|
@@ -25,6 +25,8 @@ export const WebhookDetail = ({
|
|
|
25
25
|
const {
|
|
26
26
|
authMode,
|
|
27
27
|
selectedWebhook,
|
|
28
|
+
isWebhookLoading,
|
|
29
|
+
webhookLoadError,
|
|
28
30
|
selectedWebhookManaged,
|
|
29
31
|
selectedDeliveryAgentName,
|
|
30
32
|
selectedDeliveryChannel,
|
|
@@ -53,9 +55,19 @@ export const WebhookDetail = ({
|
|
|
53
55
|
</h2>
|
|
54
56
|
</div>
|
|
55
57
|
|
|
56
|
-
${
|
|
57
|
-
?
|
|
58
|
-
|
|
58
|
+
${isWebhookLoading
|
|
59
|
+
? html`<div class="bg-black/20 border border-border rounded-lg p-3">
|
|
60
|
+
<p class="text-xs text-gray-500">Loading webhook details...</p>
|
|
61
|
+
</div>`
|
|
62
|
+
: webhookLoadError
|
|
63
|
+
? html`<div class="bg-black/20 border border-border rounded-lg p-3">
|
|
64
|
+
<p class="text-xs text-red-300">
|
|
65
|
+
${webhookLoadError?.message || "Could not load webhook details"}
|
|
66
|
+
</p>
|
|
67
|
+
</div>`
|
|
68
|
+
: hasOauthCallback
|
|
69
|
+
? null
|
|
70
|
+
: html`<div class="bg-black/20 border border-border rounded-lg p-3 space-y-4">
|
|
59
71
|
${selectedWebhookManaged
|
|
60
72
|
? null
|
|
61
73
|
: html`
|
|
@@ -152,7 +164,7 @@ export const WebhookDetail = ({
|
|
|
152
164
|
`}
|
|
153
165
|
</div>`}
|
|
154
166
|
|
|
155
|
-
${selectedWebhookManaged || !hasOauthCallback
|
|
167
|
+
${isWebhookLoading || webhookLoadError || selectedWebhookManaged || !hasOauthCallback
|
|
156
168
|
? null
|
|
157
169
|
: html`
|
|
158
170
|
<div class="bg-black/20 border border-border rounded-lg p-3 space-y-2">
|
|
@@ -304,7 +316,7 @@ export const WebhookDetail = ({
|
|
|
304
316
|
</div>
|
|
305
317
|
</div>
|
|
306
318
|
|
|
307
|
-
${selectedWebhookManaged
|
|
319
|
+
${selectedWebhookManaged && !isWebhookLoading && !webhookLoadError
|
|
308
320
|
? html`
|
|
309
321
|
<div class="rounded-lg border border-yellow-500/30 bg-yellow-500/10 p-3">
|
|
310
322
|
<p class="text-xs text-yellow-200">
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
fetchWebhookDetail,
|
|
6
6
|
rotateWebhookOauthCallback,
|
|
7
7
|
} from "../../../lib/api.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useCachedFetch } from "../../../hooks/use-cached-fetch.js";
|
|
9
9
|
import { showToast } from "../../toast.js";
|
|
10
10
|
import { formatAgentFallbackName } from "../helpers.js";
|
|
11
11
|
|
|
@@ -22,18 +22,30 @@ export const useWebhookDetail = ({
|
|
|
22
22
|
const [showRotateOauthConfirm, setShowRotateOauthConfirm] = useState(false);
|
|
23
23
|
const [sendingTestWebhook, setSendingTestWebhook] = useState(false);
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const detailCacheKey = useMemo(
|
|
26
|
+
() => `/api/webhooks/${encodeURIComponent(String(selectedHookName || ""))}`,
|
|
27
|
+
[selectedHookName],
|
|
28
|
+
);
|
|
29
|
+
const detailFetchState = useCachedFetch(
|
|
30
|
+
detailCacheKey,
|
|
26
31
|
async () => {
|
|
27
32
|
if (!selectedHookName) return null;
|
|
28
33
|
const data = await fetchWebhookDetail(selectedHookName);
|
|
29
34
|
return data.webhook || null;
|
|
30
35
|
},
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
{
|
|
37
|
+
enabled: !!selectedHookName,
|
|
38
|
+
maxAgeMs: 15000,
|
|
39
|
+
},
|
|
33
40
|
);
|
|
41
|
+
const agentsFetchState = useCachedFetch("/api/agents", fetchAgents, {
|
|
42
|
+
enabled: true,
|
|
43
|
+
maxAgeMs: 30000,
|
|
44
|
+
});
|
|
34
45
|
|
|
35
|
-
const
|
|
36
|
-
|
|
46
|
+
const agents = Array.isArray(agentsFetchState.data?.agents)
|
|
47
|
+
? agentsFetchState.data.agents
|
|
48
|
+
: [];
|
|
37
49
|
const agentNameById = useMemo(
|
|
38
50
|
() =>
|
|
39
51
|
new Map(
|
|
@@ -45,7 +57,9 @@ export const useWebhookDetail = ({
|
|
|
45
57
|
[agents],
|
|
46
58
|
);
|
|
47
59
|
|
|
48
|
-
const selectedWebhook =
|
|
60
|
+
const selectedWebhook = detailFetchState.data;
|
|
61
|
+
const isWebhookLoading = !!selectedHookName && detailFetchState.loading;
|
|
62
|
+
const webhookLoadError = detailFetchState.error;
|
|
49
63
|
const selectedWebhookManaged = Boolean(selectedWebhook?.managed);
|
|
50
64
|
const selectedDeliveryAgentId =
|
|
51
65
|
String(selectedWebhook?.agentId || "main").trim() || "main";
|
|
@@ -125,9 +139,9 @@ export const useWebhookDetail = ({
|
|
|
125
139
|
effectiveAuthMode === "query" ? curlCommandQuery : curlCommandHeaders;
|
|
126
140
|
|
|
127
141
|
const refreshDetail = useCallback(() => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, [
|
|
142
|
+
detailFetchState.refresh({ force: true });
|
|
143
|
+
agentsFetchState.refresh({ force: true });
|
|
144
|
+
}, [agentsFetchState.refresh, detailFetchState.refresh]);
|
|
131
145
|
|
|
132
146
|
const handleSendTestWebhook = useCallback(async () => {
|
|
133
147
|
if (!selectedHookName || sendingTestWebhook) return;
|
|
@@ -229,6 +243,8 @@ export const useWebhookDetail = ({
|
|
|
229
243
|
state: {
|
|
230
244
|
authMode,
|
|
231
245
|
selectedWebhook,
|
|
246
|
+
isWebhookLoading,
|
|
247
|
+
webhookLoadError,
|
|
232
248
|
selectedWebhookManaged,
|
|
233
249
|
selectedDeliveryAgentName,
|
|
234
250
|
selectedDeliveryChannel,
|