Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AcpSessionManagementSection.tsx

744 lines28.3 KB

1import { thrownErrorMessage } from "@t3tools/client-runtime/errors";
2import {
3 AcpRegistryOperationError,
4 AuthOrchestrationOperateScope,
5 AuthProvidersManageScope,
6 AuthOrchestrationReadScope,
7} from "@t3tools/contracts";
8import { useEnvironmentScope, readEnvironmentScope } from "~/state/session";
9import type {
10 AcpRegistryConfigurableProvider,
11 AcpRegistrySession,
12 EnvironmentId,
13 ProjectId,
14 ProviderInstanceId,
15 ServerProvider,
16} from "@t3tools/contracts";
17import {
18 isAtomCommandInterrupted,
19 squashAtomCommandFailure,
20 type AtomCommandResult,
21} from "@t3tools/client-runtime/state/runtime";
22import * as Schema from "effect/Schema";
23import { useLayoutEffect, useRef, useState } from "react";
24import { msg, T, useGT } from "gt-react";
25import { m } from "../../i18n/messages";
26​
27import { ensureLocalApi } from "../../localApi";
28import { serverEnvironment } from "../../state/server";
29import { useAtomCommand } from "../../state/use-atom-command";
30import { Button } from "../ui/button";
31import { Input } from "../ui/input";
32import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
33import { toastManager } from "../ui/toast";
34import { SettingsRow } from "./settingsLayout";
35​
36interface AcpSessionProject {
37 readonly id: ProjectId;
38 readonly title: string;
39 readonly workspaceRoot: string;
41​
42const isAcpRegistryOperationError = Schema.is(AcpRegistryOperationError);
43​
44type SessionOwnership = Pick<AcpRegistrySession, "importedThreadId" | "nativeHistoryPending">;
45​
46function needsImport(session: AcpRegistrySession) {
47 return session.importedThreadId === null || session.nativeHistoryPending === true;
49​
50function reportFailure(title: string, result: AtomCommandResult<unknown, unknown>) {
51 if (result._tag !== "Failure" || isAtomCommandInterrupted(result)) return;
52 const error = squashAtomCommandFailure(result);
53 toastManager.add({
54 type: "error",
55 title,
56 description:
57 error instanceof Error
58 ? (thrownErrorMessage(error, m) ?? error.message)
59 : m(msg("The ACP operation failed.")),
60 });
62​
63function parseProviderHeaders(
64 text: string,
65):
66 | { readonly ok: true; readonly headers: Record<string, string> | undefined }
67 | { readonly ok: false; readonly error: string } {
68 if (text.trim().length === 0) return { ok: true, headers: undefined };
69 let parsed: unknown;
70 try {
71 parsed = JSON.parse(text);
72 } catch (error) {
73 return {
74 ok: false,
75 error:
76 error instanceof Error
77 ? (thrownErrorMessage(error, m) ?? error.message)
78 : m(msg("Headers must be valid JSON.")),
79 };
80 }
81 if (
82 typeof parsed !== "object" ||
83 parsed === null ||
84 Array.isArray(parsed) ||
85 !Object.values(parsed).every((value) => typeof value === "string")
86 ) {
87 return { ok: false, error: m(msg("Headers must be a JSON object with string values.")) };
88 }
89 return { ok: true, headers: parsed as Record<string, string> };
91​
92interface AcpSessionManagementProps {
93 readonly environmentId: EnvironmentId;
94 readonly instanceId: ProviderInstanceId;
95 readonly provider: ServerProvider;
96 readonly projects: ReadonlyArray<AcpSessionProject>;
97 readonly readOnly: boolean;
99​
100export function AcpSessionManagementSection(props: AcpSessionManagementProps) {
101 const [selectedProjectId, setSelectedProjectId] = useState<ProjectId | null>(null);
102 const projectId =
103 props.projects.find((project) => project.id === selectedProjectId)?.id ??
104 props.projects[0]?.id ??
105 null;
106 if (selectedProjectId !== projectId) setSelectedProjectId(projectId);
107​
108 return (
109 <InstanceSessionManagement
110 key={JSON.stringify([props.environmentId, props.instanceId])}
111 {...props}
112 projectId={projectId}
113 onProjectChange={setSelectedProjectId}
114 />
115 );
117​
118function InstanceSessionManagement(
119 props: AcpSessionManagementProps & {
120 readonly projectId: ProjectId | null;
121 readonly onProjectChange: (projectId: ProjectId) => void;
122 },
123) {
124 const gt = useGT();
125 const canOperate = useEnvironmentScope(props.environmentId, AuthOrchestrationOperateScope);
126 const canRead = useEnvironmentScope(props.environmentId, AuthOrchestrationReadScope);
127 const { projectId } = props;
128 const projectGeneration = useRef(0);
129 const deletionsDuringList = useRef<Set<string> | null>(null);
130 const ownershipDuringList = useRef<Map<string, SessionOwnership> | null>(null);
131 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Late continuations must not act on a replaced project scope.
132 useLayoutEffect(() => {
133 return () => {
134 projectGeneration.current += 1;
135 deletionsDuringList.current = null;
136 ownershipDuringList.current = null;
137 };
138 // oxlint-disable-next-line react/exhaustive-effect-dependencies -- Retiring a project invalidates its pending operations even when the instance stays mounted.
139 }, [projectId]);
140 const [sessions, setSessions] = useState<ReadonlyArray<AcpRegistrySession>>([]);
141 const [nextCursor, setNextCursor] = useState<string | null>(null);
142 const [loading, setLoading] = useState(false);
143 const [importingSessionId, setImportingSessionId] = useState<string | null>(null);
144 const [deletingSessionId, setDeletingSessionId] = useState<string | null>(null);
145 const [loggingOut, setLoggingOut] = useState(false);
146 const [providers, setProviders] = useState<ReadonlyArray<AcpRegistryConfigurableProvider>>([]);
147 const [loadingProviders, setLoadingProviders] = useState(false);
148 const [savingProviderId, setSavingProviderId] = useState<string | null>(null);
149 const [providerDrafts, setProviderDrafts] = useState<
150 Readonly<Record<string, { apiType: string; baseUrl: string; headers: string }>>
151 >({});
152 const [previousProjectId, setPreviousProjectId] = useState(projectId);
153 if (previousProjectId !== projectId) {
154 setPreviousProjectId(projectId);
155 setSessions([]);
156 setNextCursor(null);
157 setLoading(false);
158 setImportingSessionId(null);
159 setDeletingSessionId(null);
160 setProviders([]);
161 setLoadingProviders(false);
162 setSavingProviderId(null);
163 setProviderDrafts({});
164 }
165 const listSessions = useAtomCommand(serverEnvironment.listAcpRegistrySessions, {
166 reportFailure: false,
167 });
168 const importSession = useAtomCommand(serverEnvironment.importAcpRegistrySession, {
169 reportFailure: false,
170 });
171 const deleteSession = useAtomCommand(serverEnvironment.deleteAcpRegistrySession, {
172 reportFailure: false,
173 });
174 const listProviders = useAtomCommand(serverEnvironment.listAcpRegistryProviders, {
175 reportFailure: false,
176 });
177 const setProvider = useAtomCommand(serverEnvironment.setAcpRegistryProvider, {
178 reportFailure: false,
179 });
180 const disableProvider = useAtomCommand(serverEnvironment.disableAcpRegistryProvider, {
181 reportFailure: false,
182 });
183 const logout = useAtomCommand(serverEnvironment.logoutAcpRegistry, { reportFailure: false });
184 const canList = props.provider.nativeSessions?.canList === true;
185 const canImport =
186 props.provider.nativeSessions?.canLoad === true ||
187 props.provider.nativeSessions?.canResume === true;
188 const canLogout =
189 props.provider.auth.canLogout === true && !props.provider.setup?.canAuthenticate;
190 const canDelete = props.provider.nativeSessions?.canDelete === true;
191 const canConfigureProviders = props.provider.configurableProviders === true;
192 const projectOperationPending =
193 loading ||
194 importingSessionId !== null ||
195 deletingSessionId !== null ||
196 loadingProviders ||
197 savingProviderId !== null;
198​
199 if (!canList && !canLogout && !canConfigureProviders) return null;
200​
201 const loadSessions = async (cursor?: string) => {
202 const generation = projectGeneration.current;
203 if (projectId === null || loading) return;
204 const deletedSessionIds = new Set<string>();
205 deletionsDuringList.current = deletedSessionIds;
206 const ownershipUpdates = new Map<string, SessionOwnership>();
207 ownershipDuringList.current = ownershipUpdates;
208 setLoading(true);
209 const result = await listSessions({
210 environmentId: props.environmentId,
211 input: {
212 instanceId: props.instanceId,
213 projectId,
214 ...(cursor === undefined ? {} : { cursor }),
215 },
216 });
217 if (generation !== projectGeneration.current) return;
218 deletionsDuringList.current = null;
219 ownershipDuringList.current = null;
220 setLoading(false);
221 if (result._tag === "Success") {
222 // A pending list can return a snapshot taken before a deletion or import completed.
223 const listedSessions = result.value.sessions
224 .filter((session) => !deletedSessionIds.has(session.sessionId))
225 .map((session) => {
226 const ownership = ownershipUpdates.get(session.sessionId);
227 return ownership === undefined ? session : { ...session, ...ownership };
228 });
229 setSessions((current) =>
230 cursor === undefined ? listedSessions : [...current, ...listedSessions],
231 );
232 setNextCursor(result.value.nextCursor ?? result.value.longNextCursor ?? null);
233 return;
234 }
235 reportFailure(gt`Could not list ACP sessions`, result);
236 };
237​
238 const recordOwnership = (sessionId: string, ownership: SessionOwnership) => {
239 ownershipDuringList.current?.set(sessionId, ownership);
240 setSessions((current) =>
241 current.map((candidate) =>
242 candidate.sessionId === sessionId ? { ...candidate, ...ownership } : candidate,
243 ),
244 );
245 };
246​
247 const importNativeSession = async (session: AcpRegistrySession) => {
248 const generation = projectGeneration.current;
249 if (
250 !readEnvironmentScope(props.environmentId, AuthOrchestrationOperateScope) ||
251 projectId === null ||
252 importingSessionId !== null
253 )
254 return;
255 setImportingSessionId(session.sessionId);
256 const result = await importSession({
257 environmentId: props.environmentId,
258 input: {
259 instanceId: props.instanceId,
260 projectId,
261 sessionId: session.sessionId,
262 title: session.title,
263 updatedAt: session.updatedAt,
264 },
265 });
266 if (generation !== projectGeneration.current) return;
267 setImportingSessionId(null);
268 if (result._tag === "Success") {
269 recordOwnership(session.sessionId, {
270 importedThreadId: result.value.threadId,
271 nativeHistoryPending: false,
272 });
273 toastManager.add({
274 type: "success",
275 title: result.value.imported ? gt`ACP session imported` : gt`ACP session already imported`,
276 });
277 return;
278 }
279 const error = result._tag === "Failure" ? squashAtomCommandFailure(result) : undefined;
280 const threadId = isAcpRegistryOperationError(error) ? error.threadId : undefined;
281 if (threadId !== undefined) {
282 // The thread now owns the native session; only its history copy needs a retry.
283 recordOwnership(session.sessionId, {
284 importedThreadId: threadId,
285 nativeHistoryPending: true,
286 });
287 }
288 reportFailure(gt`Could not import ACP session`, result);
289 };
290​
291 const deleteNativeSession = async (session: AcpRegistrySession) => {
292 const generation = projectGeneration.current;
293 if (projectId === null || deletingSessionId !== null || session.importedThreadId !== null)
294 return;
295 const confirmed = await ensureLocalApi().dialogs.confirm(
296 gt`Permanently delete native ACP session "${{ session: session.title ?? session.sessionId }}"?`,
297 { variant: "destructive" },
298 );
299 if (
300 generation !== projectGeneration.current ||
301 !confirmed ||
302 !readEnvironmentScope(props.environmentId, AuthOrchestrationOperateScope)
303 )
304 return;
305 setDeletingSessionId(session.sessionId);
306 const result = await deleteSession({
307 environmentId: props.environmentId,
308 input: { instanceId: props.instanceId, projectId, sessionId: session.sessionId },
309 });
310 if (generation !== projectGeneration.current) return;
311 setDeletingSessionId(null);
312 if (result._tag === "Success") {
313 deletionsDuringList.current?.add(session.sessionId);
314 setSessions((current) =>
315 current.filter((candidate) => candidate.sessionId !== session.sessionId),
316 );
317 return;
318 }
319 reportFailure(gt`Could not delete ACP session`, result);
320 };
321​
322 const loadProviders = async (resetProviderId?: string) => {
323 const generation = projectGeneration.current;
324 if (projectId === null || loadingProviders) return;
325 setLoadingProviders(true);
326 const result = await listProviders({
327 environmentId: props.environmentId,
328 input: { instanceId: props.instanceId, projectId },
329 });
330 if (generation !== projectGeneration.current) return;
331 setLoadingProviders(false);
332 if (result._tag === "Success") {
333 setProviders(result.value.providers);
334 setProviderDrafts((current) =>
335 Object.fromEntries(
336 result.value.providers.map((provider) => [
337 provider.providerId,
338 (resetProviderId !== undefined && provider.providerId !== resetProviderId
339 ? current[provider.providerId]
340 : undefined) ?? {
341 apiType: provider.current?.apiType ?? provider.supported[0] ?? "",
342 baseUrl: provider.current?.baseUrl ?? "",
343 headers: "",
344 },
345 ]),
346 ),
347 );
348 return;
349 }
350 reportFailure(gt`Could not list ACP providers`, result);
351 };
352​
353 const saveProvider = async (provider: AcpRegistryConfigurableProvider) => {
354 const generation = projectGeneration.current;
355 if (
356 !readEnvironmentScope(props.environmentId, AuthProvidersManageScope) ||
357 projectId === null ||
358 savingProviderId !== null ||
359 loadingProviders
360 )
361 return;
362 const draft = providerDrafts[provider.providerId];
363 if (draft === undefined || draft.apiType.length === 0 || draft.baseUrl.length === 0) return;
364 const parsedHeaders = parseProviderHeaders(draft.headers);
365 if (!parsedHeaders.ok) {
366 toastManager.add({
367 type: "error",
368 title: gt`Invalid provider headers`,
369 description: parsedHeaders.error,
370 });
371 return;
372 }
373 const headers = parsedHeaders.headers;
374 setSavingProviderId(provider.providerId);
375 const result = await setProvider({
376 environmentId: props.environmentId,
377 input: {
378 instanceId: props.instanceId,
379 projectId,
380 providerId: provider.providerId,
381 apiType: draft.apiType,
382 baseUrl: draft.baseUrl,
383 ...(headers === undefined ? {} : { headers }),
384 },
385 });
386 if (generation !== projectGeneration.current) return;
387 setSavingProviderId(null);
388 if (result._tag === "Success") {
389 await loadProviders(provider.providerId);
390 return;
391 }
392 reportFailure(gt`Could not configure ACP provider`, result);
393 };
394​
395 const disableConfiguredProvider = async (provider: AcpRegistryConfigurableProvider) => {
396 const generation = projectGeneration.current;
397 if (projectId === null || savingProviderId !== null || loadingProviders || provider.required)
398 return;
399 const confirmed = await ensureLocalApi().dialogs.confirm(
400 gt`Disable ACP provider "${{ provider: provider.providerId }}"?`,
401 { variant: "destructive" },
402 );
403 if (
404 generation !== projectGeneration.current ||
405 !confirmed ||
406 !readEnvironmentScope(props.environmentId, AuthProvidersManageScope)
407 )
408 return;
409 setSavingProviderId(provider.providerId);
410 const result = await disableProvider({
411 environmentId: props.environmentId,
412 input: { instanceId: props.instanceId, projectId, providerId: provider.providerId },
413 });
414 if (generation !== projectGeneration.current) return;
415 setSavingProviderId(null);
416 if (result._tag === "Success") {
417 await loadProviders(provider.providerId);
418 return;
419 }
420 reportFailure(gt`Could not disable ACP provider`, result);
421 };
422​
423 const logoutProvider = async () => {
424 if (loggingOut || !readEnvironmentScope(props.environmentId, AuthProvidersManageScope)) return;
425 setLoggingOut(true);
426 const result = await logout({
427 environmentId: props.environmentId,
428 input: { instanceId: props.instanceId },
429 });
430 setLoggingOut(false);
431 if (result._tag === "Success") {
432 setSessions([]);
433 setNextCursor(null);
434 return;
435 }
436 reportFailure(gt`Could not log out of ACP agent`, result);
437 };
438​
439 return (
440 <div className="grid gap-3">
441 <SettingsRow
442 title={gt`Native sessions`}
443 description={gt`Resume agent-owned conversations as T3 threads.`}
444 status={
445 canList && props.projects.length === 0
446 ? gt`Add a project before importing sessions.`
447 : undefined
448 }
449 control={
450 <div className="flex flex-wrap items-center gap-2">
451 {canLogout ? (
452 <Button
453 type="button"
454 size="sm"
455 variant="outline"
456 disabled={props.readOnly || loggingOut}
457 onClick={() => void logoutProvider()}
458 >
459 {loggingOut ? gt`Logging out` : gt`Log out`}
460 </Button>
461 ) : null}
462 {canList && props.projects.length > 0 ? (
463 <>
464 <Select
465 value={projectId ?? ""}
466 disabled={!canRead || projectOperationPending}
467 onValueChange={(value) => {
468 if (value === null) return;
469 props.onProjectChange(value as ProjectId);
470 }}
471 >
472 <SelectTrigger
473 aria-label={gt`Project for ACP sessions`}
474 className="w-40"
475 size="sm"
476 >
477 <SelectValue>
478 {props.projects.find((project) => project.id === projectId)?.title}
479 </SelectValue>
480 </SelectTrigger>
481 <SelectPopup>
482 {props.projects.map((project) => (
483 <SelectItem key={project.id} value={project.id}>
484 {project.title}
485 </SelectItem>
486 ))}
487 </SelectPopup>
488 </Select>
489 <Button
490 type="button"
491 size="sm"
492 variant="outline"
493 disabled={!canRead || loading || projectId === null}
494 onClick={() => void loadSessions()}
495 >
496 {loading ? gt`Loading` : sessions.length === 0 ? gt`List sessions` : gt`Refresh`}
497 </Button>
498 </>
499 ) : null}
500 </div>
501 }
502 >
503 {canList && (sessions.length > 0 || nextCursor !== null) ? (
504 <>
505 {sessions.length > 0 ? (
506 <div className="divide-y divide-border/60 border-y border-border/60">
507 {sessions.map((session) => (
508 <div
509 key={session.sessionId}
510 className="flex min-w-0 items-center justify-between gap-3 py-2"
511 >
512 <div className="min-w-0">
513 <p className="truncate text-xs text-foreground">
514 {session.title ?? session.sessionId}
515 </p>
516 <code className="block truncate text-3xs text-muted-foreground">
517 {session.sessionId}
518 </code>
519 </div>
520 <div className="flex shrink-0 items-center gap-1">
521 <Button
522 type="button"
523 size="xs"
524 variant="ghost-muted"
525 disabled={
526 !canOperate ||
527 !canImport ||
528 !needsImport(session) ||
529 importingSessionId !== null
530 }
531 onClick={() => void importNativeSession(session)}
532 >
533 {!needsImport(session)
534 ? gt`Imported`
535 : importingSessionId === session.sessionId
536 ? gt`Importing`
537 : gt({ context: "verb" })`Import`}
538 </Button>
539 {canDelete ? (
540 <Button
541 type="button"
542 size="xs"
543 variant="ghost-muted"
544 disabled={
545 !canOperate ||
546 session.importedThreadId !== null ||
547 deletingSessionId !== null
548 }
549 onClick={() => void deleteNativeSession(session)}
550 >
551 {deletingSessionId === session.sessionId
552 ? gt`Deleting`
553 : gt({ context: "verb, deletes a session" })`Delete`}
554 </Button>
555 ) : null}
556 </div>
557 </div>
558 ))}
559 </div>
560 ) : null}
561​
562 {nextCursor !== null ? (
563 <Button
564 type="button"
565 size="xs"
566 variant="ghost-muted"
567 className="w-fit"
568 disabled={!canRead || loading}
569 onClick={() => void loadSessions(nextCursor)}
570 >
571 {loading ? gt`Loading` : gt`Load more`}
572 </Button>
573 ) : null}
574 </>
575 ) : null}
576 </SettingsRow>
577​
578 {canConfigureProviders ? (
579 <div className="grid gap-3 border-t border-border/60 px-3 py-3 sm:px-4">
580 <div className="flex flex-wrap items-center justify-between gap-2">
581 <div>
582 <p className="text-xs font-medium text-foreground">
583 <T>Agent providers</T>
584 </p>
585 <p className="text-xs text-muted-foreground">
586 <T>Configure non-secret routing. Headers are write-only.</T>
587 </p>
588 </div>
589 <Button
590 type="button"
591 size="xs"
592 variant="outline"
593 disabled={
594 !canRead || loadingProviders || savingProviderId !== null || projectId === null
595 }
596 onClick={() => void loadProviders()}
597 >
598 {loadingProviders
599 ? gt`Loading`
600 : providers.length === 0
601 ? gt`List providers`
602 : gt`Refresh`}
603 </Button>
604 </div>
605​
606 {!canList && props.projects.length > 1 ? (
607 <Select
608 value={projectId ?? ""}
609 disabled={!canRead || projectOperationPending}
610 onValueChange={(value) => {
611 if (value === null) return;
612 props.onProjectChange(value as ProjectId);
613 }}
614 >
615 <SelectTrigger
616 aria-label={gt`Project for ACP providers`}
617 className="min-w-48"
618 size="xs"
619 >
620 <SelectValue>
621 {props.projects.find((project) => project.id === projectId)?.title}
622 </SelectValue>
623 </SelectTrigger>
624 <SelectPopup>
625 {props.projects.map((project) => (
626 <SelectItem key={project.id} value={project.id}>
627 {project.title}
628 </SelectItem>
629 ))}
630 </SelectPopup>
631 </Select>
632 ) : null}
633​
634 {providers.length > 0 ? (
635 <div className="divide-y divide-border/60 border-y border-border/60">
636 {providers.map((provider) => {
637 const draft = providerDrafts[provider.providerId] ?? {
638 apiType: provider.current?.apiType ?? provider.supported[0] ?? "",
639 baseUrl: provider.current?.baseUrl ?? "",
640 headers: "",
641 };
642 const updateDraft = (update: Partial<typeof draft>) =>
643 setProviderDrafts((current) => ({
644 ...current,
645 [provider.providerId]: { ...draft, ...update },
646 }));
647 return (
648 <div key={provider.providerId} className="grid gap-2 py-3">
649 <div className="flex items-center justify-between gap-2">
650 <div className="min-w-0">
651 <p className="truncate text-xs font-medium text-foreground">
652 {provider.providerId}
653 </p>
654 <p className="text-3xs text-muted-foreground">
655 {provider.current === null
656 ? gt({ context: "ACP provider status" })`Disabled`
657 : gt`Configured`}
658 {provider.required ? ` · ${gt`Required`}` : ""}
659 </p>
660 </div>
661 <div className="flex items-center gap-1">
662 <Button
663 type="button"
664 size="xs"
665 variant="outline"
666 disabled={
667 props.readOnly ||
668 savingProviderId !== null ||
669 loadingProviders ||
670 draft.apiType.length === 0 ||
671 draft.baseUrl.length === 0
672 }
673 onClick={() => void saveProvider(provider)}
674 >
675 {savingProviderId === provider.providerId
676 ? gt`Saving`
677 : gt({ context: "verb" })`Save`}
678 </Button>
679 {!provider.required && provider.current !== null ? (
680 <Button
681 type="button"
682 size="xs"
683 variant="ghost-muted"
684 disabled={
685 props.readOnly || savingProviderId !== null || loadingProviders
686 }
687 onClick={() => void disableConfiguredProvider(provider)}
688 >
689 <T>Disable</T>
690 </Button>
691 ) : null}
692 </div>
693 </div>
694 <div className="grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]">
695 <Select
696 value={draft.apiType}
697 disabled={props.readOnly || savingProviderId !== null}
698 onValueChange={(value) => {
699 if (value !== null) updateDraft({ apiType: value });
700 }}
701 >
702 <SelectTrigger
703 aria-label={gt`${{ provider: provider.providerId }} protocol`}
704 size="sm"
705 >
706 <SelectValue>{draft.apiType}</SelectValue>
707 </SelectTrigger>
708 <SelectPopup>
709 {provider.supported.map((protocol) => (
710 <SelectItem key={protocol} value={protocol}>
711 {protocol}
712 </SelectItem>
713 ))}
714 </SelectPopup>
715 </Select>
716 <Input
717 size="sm"
718 type="url"
719 aria-label={gt`${{ provider: provider.providerId }} base URL`}
720 placeholder="https://api.example.com"
721 value={draft.baseUrl}
722 disabled={props.readOnly || savingProviderId !== null}
723 onValueChange={(value) => updateDraft({ baseUrl: value })}
724 />
725 </div>
726 <Input
727 size="sm"
728 type="password"
729 aria-label={gt`${{ provider: provider.providerId }} write-only headers JSON`}
730 placeholder={gt`Write-only headers JSON, e.g. ${{ example: '{"Authorization":"Bearer …"}' }}`}
731 value={draft.headers}
732 disabled={props.readOnly || savingProviderId !== null}
733 onValueChange={(value) => updateDraft({ headers: value })}
734 />
735 </div>
736 );
737 })}
738 </div>
739 ) : null}
740 </div>
741 ) : null}
742 </div>
743 );