44 resolveLatestMergeBackRun ,
55} from "@t3tools/client-runtime/state/thread-workflows" ;
66import type { EnvironmentId , ThreadId } from "@t3tools/contracts" ;
7+ import { useAtomValue } from "@effect/atom-react" ;
78import { useNavigate } from "@tanstack/react-router" ;
89import { ArrowUpFromLineIcon , MoreHorizontalIcon , PenLineIcon , Trash2Icon } from "lucide-react" ;
910import { useState } from "react" ;
@@ -13,7 +14,7 @@ import {
1314 SIDE_CHAT_EDITABLE_RUNTIME_MODE ,
1415 useSideChatActions ,
1516} from "../../hooks/useSideChatActions" ;
16- import { useEnvironmentProviders } from "../../state/environments " ;
17+ import { serverEnvironment } from "../../state/server " ;
1718import { useThreadProjection , useThreadShell } from "../../state/entities" ;
1819import { buildThreadRouteParams } from "../../threadRoutes" ;
1920import { Badge } from "../ui/badge" ;
@@ -42,20 +43,23 @@ export function SideChatHeader(props: { environmentId: EnvironmentId; threadId:
4243 const composerRuntimeMode = useComposerDraftStore (
4344 ( store ) => store . getComposerDraft ( childRef ) ?. runtimeMode ?? null ,
4445 ) ;
45- const providers = useEnvironmentProviders ( ) . get ( props . environmentId ) ;
46+ // A provider without auto-accept-edits would fall back to asking, so the
47+ // switch must not claim edits are allowed there.
48+ const providerInstanceId = shell ?. runtime ?. providerInstanceId ?? shell ?. modelSelection . instanceId ;
49+ const canAllowEdits = useAtomValue (
50+ serverEnvironment . providersValueAtom ( props . environmentId ) ,
51+ ( providers ) => {
52+ const modes = providers ?. find (
53+ ( provider ) => provider . instanceId === providerInstanceId ,
54+ ) ?. supportedRuntimeModes ;
55+ return (
56+ modes === undefined || modes . length === 0 || modes . includes ( SIDE_CHAT_EDITABLE_RUNTIME_MODE )
57+ ) ;
58+ } ,
59+ ) ;
4660
4761 if ( shell === null ) return null ;
4862 const allowEdits = ( composerRuntimeMode ?? shell . runtimeMode ) !== "approval-required" ;
49- // A provider without auto-accept-edits would fall back to asking, so the
50- // switch must not claim edits are allowed there.
51- const providerInstanceId = shell . runtime ?. providerInstanceId ?? shell . modelSelection . instanceId ;
52- const supportedRuntimeModes = providers ?. find (
53- ( provider ) => provider . instanceId === providerInstanceId ,
54- ) ?. supportedRuntimeModes ;
55- const canAllowEdits =
56- supportedRuntimeModes === undefined ||
57- supportedRuntimeModes . length === 0 ||
58- supportedRuntimeModes . includes ( SIDE_CHAT_EDITABLE_RUNTIME_MODE ) ;
5963 const mergeRun = childProjection === null ? null : resolveLatestMergeBackRun ( childProjection ) ;
6064 const canBringBack = shell . lineage . relationshipToParent === "fork" && mergeRun !== null ;
6165 const bringBackReason =
@@ -116,7 +120,7 @@ export function SideChatHeader(props: { environmentId: EnvironmentId; threadId:
116120 < TooltipPopup side = "bottom" >
117121 { canAllowEdits
118122 ? "Shares the main thread's files. Off, it asks before changing anything."
119- : "This provider asks before every edit ." }
123+ : "This provider can't approve only edits automatically ." }
120124 </ TooltipPopup >
121125 </ Tooltip >
122126 < Menu >
0 commit comments