@@ -44,6 +44,7 @@ export type SettingsViewProps = {
4444 providerConnectedIds : string [ ] ;
4545 providerAuthBusy : boolean ;
4646 openProviderAuthModal : ( ) => Promise < void > ;
47+ disconnectProvider : ( providerId : string ) => Promise < string | void > ;
4748 openworkServerStatus : OpenworkServerStatus ;
4849 openworkServerUrl : string ;
4950 openworkReconnectBusy : boolean ;
@@ -330,27 +331,27 @@ export default function SettingsView(props: SettingsViewProps) {
330331 } ;
331332
332333 const [ providerConnectError , setProviderConnectError ] = createSignal < string | null > ( null ) ;
334+ const [ providerDisconnectStatus , setProviderDisconnectStatus ] = createSignal < string | null > ( null ) ;
335+ const [ providerDisconnectError , setProviderDisconnectError ] = createSignal < string | null > ( null ) ;
336+ const [ providerDisconnectingId , setProviderDisconnectingId ] = createSignal < string | null > ( null ) ;
333337 const [ openworkReconnectStatus , setOpenworkReconnectStatus ] = createSignal < string | null > ( null ) ;
334338 const [ openworkReconnectError , setOpenworkReconnectError ] = createSignal < string | null > ( null ) ;
335339 const [ openworkRestartBusy , setOpenworkRestartBusy ] = createSignal ( false ) ;
336340 const [ openworkRestartStatus , setOpenworkRestartStatus ] = createSignal < string | null > ( null ) ;
337341 const [ openworkRestartError , setOpenworkRestartError ] = createSignal < string | null > ( null ) ;
338342 const providerConnectedCount = createMemo ( ( ) => ( props . providerConnectedIds ?? [ ] ) . length ) ;
339343 const providerAvailableCount = createMemo ( ( ) => ( props . providers ?? [ ] ) . length ) ;
340- const connectedProviderNames = createMemo ( ( ) => {
344+ const connectedProviders = createMemo ( ( ) => {
341345 const connectedIds = props . providerConnectedIds ?? [ ] ;
342- if ( ! connectedIds . length ) return [ ] as string [ ] ;
343-
346+ if ( ! connectedIds . length ) return [ ] as { id : string ; name : string } [ ] ;
344347 const providersById = new Map ( ( props . providers ?? [ ] ) . map ( ( provider ) => [ provider . id , provider ] ) ) ;
345- const names = connectedIds
348+ return connectedIds
346349 . map ( ( id ) => {
347350 const provider = providersById . get ( id ) ;
348351 const label = provider ?. name ?. trim ( ) || provider ?. id ?. trim ( ) || id . trim ( ) ;
349- return label ;
352+ return { id , name : label || id } ;
350353 } )
351- . filter ( ( name ) => name . length > 0 ) ;
352-
353- return Array . from ( new Set ( names ) ) ;
354+ . filter ( ( entry ) => entry . id . trim ( ) ) ;
354355 } ) ;
355356 const providerStatusLabel = createMemo ( ( ) => {
356357 if ( ! providerAvailableCount ( ) ) return "Unavailable" ;
@@ -373,6 +374,8 @@ export default function SettingsView(props: SettingsViewProps) {
373374 const handleOpenProviderAuth = async ( ) => {
374375 if ( props . busy || props . providerAuthBusy ) return ;
375376 setProviderConnectError ( null ) ;
377+ setProviderDisconnectError ( null ) ;
378+ setProviderDisconnectStatus ( null ) ;
376379 try {
377380 await props . openProviderAuthModal ( ) ;
378381 } catch ( error ) {
@@ -381,6 +384,28 @@ export default function SettingsView(props: SettingsViewProps) {
381384 }
382385 } ;
383386
387+ const handleDisconnectProvider = async ( providerId : string ) => {
388+ const resolved = providerId . trim ( ) ;
389+ if ( ! resolved || props . busy || props . providerAuthBusy || providerDisconnectingId ( ) ) return ;
390+ const confirmed =
391+ typeof window === "undefined"
392+ ? true
393+ : window . confirm ( `Disconnect ${ resolved } ? This removes the stored credentials.` ) ;
394+ if ( ! confirmed ) return ;
395+ setProviderDisconnectError ( null ) ;
396+ setProviderDisconnectStatus ( null ) ;
397+ setProviderDisconnectingId ( resolved ) ;
398+ try {
399+ const result = await props . disconnectProvider ( resolved ) ;
400+ setProviderDisconnectStatus ( result || `Disconnected ${ resolved } .` ) ;
401+ } catch ( error ) {
402+ const message = error instanceof Error ? error . message : "Failed to disconnect provider" ;
403+ setProviderDisconnectError ( message ) ;
404+ } finally {
405+ setProviderDisconnectingId ( null ) ;
406+ }
407+ } ;
408+
384409 const handleReconnectOpenworkServer = async ( ) => {
385410 if ( props . busy || props . openworkReconnectBusy ) return ;
386411 if ( ! props . openworkServerUrl . trim ( ) ) return ;
@@ -997,13 +1022,26 @@ export default function SettingsView(props: SettingsViewProps) {
9971022 < div class = "text-xs text-gray-10" > { providerSummary ( ) } </ div >
9981023 </ div >
9991024
1000- < Show when = { connectedProviderNames ( ) . length > 0 } >
1001- < div class = "flex flex-wrap items-center gap-2" >
1002- < For each = { connectedProviderNames ( ) } >
1003- { ( name ) => (
1004- < span class = "rounded-full border border-green-7/30 bg-green-3/40 px-2 py-1 text-[11px] font-medium text-green-12" >
1005- { name }
1006- </ span >
1025+ < Show when = { connectedProviders ( ) . length > 0 } >
1026+ < div class = "space-y-2" >
1027+ < For each = { connectedProviders ( ) } >
1028+ { ( provider ) => (
1029+ < div class = "flex flex-wrap items-center justify-between gap-3 rounded-xl border border-gray-6/60 bg-gray-1/40 px-3 py-2" >
1030+ < div class = "min-w-0" >
1031+ < div class = "text-sm font-medium text-gray-12 truncate" > { provider . name } </ div >
1032+ < div class = "text-[11px] text-gray-8 font-mono truncate" > { provider . id } </ div >
1033+ </ div >
1034+ < Button
1035+ variant = "outline"
1036+ class = "text-xs h-8 py-0 px-3"
1037+ onClick = { ( ) => void handleDisconnectProvider ( provider . id ) }
1038+ disabled = {
1039+ props . busy || props . providerAuthBusy || providerDisconnectingId ( ) !== null
1040+ }
1041+ >
1042+ { providerDisconnectingId ( ) === provider . id ? "Disconnecting..." : "Disconnect" }
1043+ </ Button >
1044+ </ div >
10071045 ) }
10081046 </ For >
10091047 </ div >
@@ -1014,6 +1052,16 @@ export default function SettingsView(props: SettingsViewProps) {
10141052 { providerConnectError ( ) }
10151053 </ div >
10161054 </ Show >
1055+ < Show when = { providerDisconnectStatus ( ) } >
1056+ < div class = "rounded-xl border border-gray-6/60 bg-gray-1/40 px-3 py-2 text-xs text-gray-10" >
1057+ { providerDisconnectStatus ( ) }
1058+ </ div >
1059+ </ Show >
1060+ < Show when = { providerDisconnectError ( ) } >
1061+ < div class = "rounded-xl border border-red-7/30 bg-red-1/40 px-3 py-2 text-xs text-red-11" >
1062+ { providerDisconnectError ( ) }
1063+ </ div >
1064+ </ Show >
10171065
10181066 < div class = "text-[11px] text-gray-9" >
10191067 API keys are stored locally by OpenCode. Set your default model in the < span class = "font-medium" > Model</ span > tab.
0 commit comments