Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

chore: add replace key functionality for connectors (#159)

sayan-truefoundryb05c0fa13159
diff --git a/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorSettings.tsx b/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorSettings.tsx
index a621230a5..be279bd06 100644
--- a/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorSettings.tsx
+++ b/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorSettings.tsx
@@ -263,16 +263,6 @@ const ConnectorSettings = () => {
<h5 className="truncate text-sm font-medium text-foreground">{connector.name}</h5>
<p className="mt-0.5 line-clamp-2 text-sm text-muted-foreground sm:truncate">{connector.description}</p>
</div>
-
- {isConnected ? (
- <div className="flex items-center gap-2">
- <span className="flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2 py-0.5 text-xs font-medium text-foreground">
- <span className="h-1.5 w-1.5 rounded-full bg-primary"></span>
- {connector.authenticated ? 'Connected' : 'Added'}
- </span>
- <Icon name="chevron-right" className="size-4" />
- </div>
- ) : null}
</>
);
@@ -280,17 +270,41 @@ const ConnectorSettings = () => {
if (isConnected) {
return (
- <button
+ <article
key={connector.id}
- type="button"
- aria-label={`View ${connector.name} connector`}
- className={`${rowClassName} cursor-pointer transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`}
+ className={`${rowClassName} cursor-pointer transition-colors hover:bg-accent/40`}
onClick={() => {
setSelectedConnector(connector);
}}
>
- {content}
- </button>
+ <div className="flex min-w-0 flex-1 items-center gap-3">{content}</div>
+
+ <div className="flex items-center gap-2">
+ <div className="flex items-center gap-2">
+ <span className="flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2 py-0.5 text-xs font-medium text-foreground">
+ <span className="h-1.5 w-1.5 rounded-full bg-primary"></span>
+ {connector.authenticated ? 'Connected' : 'Added'}
+ </span>
+ <Icon name="chevron-right" className="size-4" />
+ </div>
+ {connector.auth.type === 'header' ? (
+ <Button
+ variant="secondary"
+ size="sm"
+ type="button"
+ disabled={busy || isOAuthLoading}
+ onClick={event => {
+ event.stopPropagation();
+ setApiKey('');
+ setConnectorAwaitingKey(connector);
+ }}
+ >
+ <Icon name="wrench" className="size-3" />
+ Replace Key
+ </Button>
+ ) : null}
+ </div>
+ </article>
);
}
@@ -342,6 +356,14 @@ const ConnectorSettings = () => {
</div>
</article>
);
+ const isReplacingKey = useMemo(() => {
+ return (
+ connectorAwaitingKey !== null &&
+ connectors.ordered.some(
+ (item: ConnectorListItem) => item.isConfigured && item.connector.id === connectorAwaitingKey.id,
+ )
+ );
+ }, [connectorAwaitingKey, connectors.ordered]);
if (selectedConnector) {
return (
@@ -432,7 +454,7 @@ const ConnectorSettings = () => {
onOpenChange={open => {
if (!open) closeApiKeyModal();
}}
- title={`Connect ${connectorAwaitingKey?.name ?? 'connector'}`}
+ title={`${isReplacingKey ? 'Replace key for' : 'Connect'} ${connectorAwaitingKey?.name ?? 'connector'}`}
description={connectorAwaitingKey?.url}
contentSized
className="md:max-w-xl"
@@ -479,7 +501,7 @@ const ConnectorSettings = () => {
Cancel
</Button>
<Button type="submit" disabled={!apiKey.trim() || busy || isOAuthLoading}>
- Connect
+ {isReplacingKey ? 'Replace Key' : 'Connect'}
</Button>
</footer>
</form>
diff --git a/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ModelSettings.tsx b/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ModelSettings.tsx
index ba606c346..7bd8b6ffa 100644
--- a/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ModelSettings.tsx
+++ b/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ModelSettings.tsx
@@ -66,7 +66,7 @@ const ModelSettings = () => {
() =>
configured.filter(
provider =>
- provider.name.toLowerCase().includes(normalizedQuery) ||
+ provider.name?.toLowerCase().includes(normalizedQuery) ||
provider.models.some(
model =>
model.name.toLowerCase().includes(normalizedQuery) || model.id.toLowerCase().includes(normalizedQuery),