@@ -145,7 +145,6 @@ import {
145145 ChevronDownIcon ,
146146 GitBranchIcon ,
147147 HistoryIcon ,
148- RadioTowerIcon ,
149148 TriangleAlertIcon ,
150149 WifiOffIcon ,
151150} from "lucide-react" ;
@@ -239,7 +238,6 @@ import {
239238import { ThreadErrorBanner } from "./chat/ThreadErrorBanner" ;
240239import { resolveThreadPr } from "./ThreadStatusIndicators" ;
241240import { ComposerBannerStack , type ComposerBannerStackItem } from "./chat/ComposerBannerStack" ;
242- import { Switch } from "./ui/switch" ;
243241import {
244242 DRAFT_HERO_TRANSITION_ANIMATION_ID ,
245243 DRAFT_HERO_TRANSITION_DURATION_MS ,
@@ -1143,6 +1141,10 @@ function ChatViewContent(props: ChatViewProps) {
11431141 const upsertKeybinding = useAtomCommand ( serverEnvironment . upsertKeybinding , {
11441142 reportFailure : false ,
11451143 } ) ;
1144+ const setClaudeThreadRemoteControl = useAtomCommand (
1145+ serverEnvironment . setClaudeThreadRemoteControl ,
1146+ { reportFailure : false } ,
1147+ ) ;
11461148 const openTerminal = useAtomCommand ( terminalEnvironment . open , "terminal open" ) ;
11471149 const writeTerminal = useAtomCommand ( terminalEnvironment . write , "terminal write" ) ;
11481150 const closeTerminalMutation = useAtomCommand ( terminalEnvironment . close , "terminal close" ) ;
@@ -1289,11 +1291,17 @@ function ChatViewContent(props: ChatViewProps) {
12891291 > ( { } ) ;
12901292 const [ pendingServerThreadEnvMode , setPendingServerThreadEnvMode ] =
12911293 useState < DraftThreadEnvMode | null > ( null ) ;
1292- // Remote Control can only be decided once, at thread creation — it's a
1293- // launch flag for the session's underlying `claude` process, not
1294- // something that can be toggled after it's already running. Reset
1295- // whenever the viewed thread changes so it never leaks between drafts.
1296- const [ draftRemoteControlEnabled , setDraftRemoteControlEnabled ] = useState ( false ) ;
1294+ // Remote Control is a launch flag for the session's underlying `claude`
1295+ // process, not something a running process can be told to flip live. For
1296+ // a draft thread this is just picked up at send time (see
1297+ // `bootstrap.createThread.remoteControl` below). For an existing thread
1298+ // it's applied via `setClaudeThreadRemoteControl`, which stops the
1299+ // thread's active session so it relaunches with the flag on its next
1300+ // turn. Local display state only — reset per thread since there's no
1301+ // read-path yet for whatever's actually bound server-side.
1302+ const [ remoteControlEnabled , setRemoteControlEnabled ] = useState ( false ) ;
1303+ const [ remoteControlPending , setRemoteControlPending ] = useState ( false ) ;
1304+ const [ resumeBannerHidden , setResumeBannerHidden ] = useState ( false ) ;
12971305 const [ pendingServerThreadBranch , setPendingServerThreadBranch ] = useState < string | null > ( ) ;
12981306 const [
12991307 pendingServerThreadStartFromOriginByThreadId ,
@@ -4134,6 +4142,45 @@ function ChatViewContent(props: ChatViewProps) {
41344142 }
41354143 void handleSwitchCheckoutToThread ( ) ;
41364144 } , [ gitStatusQuery . data ?. hasWorkingTreeChanges , handleSwitchCheckoutToThread ] ) ;
4145+ const handleToggleRemoteControl = useCallback (
4146+ async ( nextEnabled : boolean ) => {
4147+ setRemoteControlEnabled ( nextEnabled ) ;
4148+ if ( isLocalDraftThread || ! activeThread ) {
4149+ // Draft threads only pick this up at send time (see
4150+ // `bootstrap.createThread.remoteControl`) — nothing to call yet.
4151+ return ;
4152+ }
4153+ setRemoteControlPending ( true ) ;
4154+ const result = await setClaudeThreadRemoteControl ( {
4155+ environmentId,
4156+ input : {
4157+ threadId : activeThread . id ,
4158+ providerInstanceId : activeThread . modelSelection . instanceId ,
4159+ enabled : nextEnabled ,
4160+ } ,
4161+ } ) ;
4162+ setRemoteControlPending ( false ) ;
4163+ if ( result . _tag === "Failure" ) {
4164+ setRemoteControlEnabled ( ! nextEnabled ) ;
4165+ toastManager . add (
4166+ stackedThreadToast ( {
4167+ type : "error" ,
4168+ title : "Couldn't update Remote Control" ,
4169+ description : "Something went wrong applying the change. Try again." ,
4170+ } ) ,
4171+ ) ;
4172+ return ;
4173+ }
4174+ toastManager . add (
4175+ stackedThreadToast ( {
4176+ type : "success" ,
4177+ title : nextEnabled ? "Remote Control enabled" : "Remote Control disabled" ,
4178+ description : "Applies the next time this thread's session starts." ,
4179+ } ) ,
4180+ ) ;
4181+ } ,
4182+ [ isLocalDraftThread , activeThread , environmentId , setClaudeThreadRemoteControl ] ,
4183+ ) ;
41374184 const pendingResumeSessionIntent = useResumeSessionIntentStore ( ( store ) =>
41384185 isLocalDraftThread && activeThread ? ( store . intentByThreadId [ activeThread . id ] ?? null ) : null ,
41394186 ) ;
@@ -4152,6 +4199,7 @@ function ChatViewContent(props: ChatViewProps) {
41524199 } , [ ] ) ;
41534200 const resumeSessionBannerItem = useMemo < ComposerBannerStackItem | null > ( ( ) => {
41544201 if ( ! pendingResumeSessionIntent || ! isLocalDraftThread || ! activeThread ) return null ;
4202+ if ( resumeBannerHidden ) return null ;
41554203 const draftThreadId = activeThread . id ;
41564204 return {
41574205 id : `resume-session:${ pendingResumeSessionIntent . resumeExternalSessionId } ` ,
@@ -4164,43 +4212,31 @@ function ChatViewContent(props: ChatViewProps) {
41644212 Cancel
41654213 </ Button >
41664214 ) ,
4215+ // Hides the banner without cancelling the resume — the resume still
4216+ // happens on send. Kept separate from the `actions` Cancel button
4217+ // above (which does cancel) via the same deferred-animation path
4218+ // already used for the branch-mismatch banner below: unlike Cancel,
4219+ // hiding isn't correctness-critical, so the 220ms dismiss race is
4220+ // harmless here.
4221+ dismissLabel : "Hide (still resumes on send)" ,
4222+ onDismiss : ( ) => setResumeBannerHidden ( true ) ,
41674223 } ;
4168- } , [ pendingResumeSessionIntent , isLocalDraftThread , activeThread , cancelResumeSessionIntent ] ) ;
4169- const canOfferRemoteControlToggle =
4170- isLocalDraftThread && selectedProvider === ProviderDriverKind . make ( "claudeAgent" ) ;
4171- const remoteControlBannerItem = useMemo < ComposerBannerStackItem | null > ( ( ) => {
4172- if ( ! canOfferRemoteControlToggle ) return null ;
4173- return {
4174- id : "draft-remote-control" ,
4175- variant : "info" ,
4176- icon : < RadioTowerIcon /> ,
4177- title : "Remote Control" ,
4178- description : "Attach to this session from claude.ai or the Claude mobile app once it starts." ,
4179- actions : (
4180- < Switch
4181- checked = { draftRemoteControlEnabled }
4182- onCheckedChange = { ( checked ) => setDraftRemoteControlEnabled ( Boolean ( checked ) ) }
4183- aria-label = "Enable Remote Control for this session"
4184- />
4185- ) ,
4186- } ;
4187- } , [ canOfferRemoteControlToggle , draftRemoteControlEnabled ] ) ;
4224+ } , [
4225+ pendingResumeSessionIntent ,
4226+ isLocalDraftThread ,
4227+ activeThread ,
4228+ resumeBannerHidden ,
4229+ cancelResumeSessionIntent ,
4230+ ] ) ;
41884231 const composerBannerItems = useMemo < ComposerBannerStackItem [ ] > ( ( ) => {
41894232 const parkedThreadItems = parkedThreadBannerItem === null ? [ ] : [ parkedThreadBannerItem ] ;
41904233 const resumeSessionItems = resumeSessionBannerItem === null ? [ ] : [ resumeSessionBannerItem ] ;
4191- const remoteControlItems = remoteControlBannerItem === null ? [ ] : [ remoteControlBannerItem ] ;
41924234 if ( ! localCheckoutBranchMismatch || ! showBranchMismatchBanner || ! activeBranchMismatchKey ) {
4193- return [
4194- ...systemComposerBannerItems ,
4195- ...resumeSessionItems ,
4196- ...remoteControlItems ,
4197- ...parkedThreadItems ,
4198- ] ;
4235+ return [ ...systemComposerBannerItems , ...resumeSessionItems , ...parkedThreadItems ] ;
41994236 }
42004237 return [
42014238 ...systemComposerBannerItems ,
42024239 ...resumeSessionItems ,
4203- ...remoteControlItems ,
42044240 {
42054241 id : `branch-mismatch:${ activeBranchMismatchKey } ` ,
42064242 variant : "info" ,
@@ -4245,7 +4281,6 @@ function ChatViewContent(props: ChatViewProps) {
42454281 } , [
42464282 activeBranchMismatchKey ,
42474283 resumeSessionBannerItem ,
4248- remoteControlBannerItem ,
42494284 handleRestoreThreadBranch ,
42504285 isRestoringThreadBranch ,
42514286 localCheckoutBranchMismatch ,
@@ -4260,7 +4295,11 @@ function ChatViewContent(props: ChatViewProps) {
42604295 } , [ activeThread ?. id ] ) ;
42614296
42624297 useEffect ( ( ) => {
4263- setDraftRemoteControlEnabled ( false ) ;
4298+ setRemoteControlEnabled ( false ) ;
4299+ } , [ activeThread ?. id ] ) ;
4300+
4301+ useEffect ( ( ) => {
4302+ setResumeBannerHidden ( false ) ;
42644303 } , [ activeThread ?. id ] ) ;
42654304
42664305 useEffect ( ( ) => {
@@ -4843,7 +4882,7 @@ function ChatViewContent(props: ChatViewProps) {
48434882 worktreePath : activeThread . worktreePath ,
48444883 createdAt : activeThread . createdAt ,
48454884 ...( resumeExternalSessionId ? { resumeExternalSessionId } : { } ) ,
4846- ...( draftRemoteControlEnabled ? { remoteControl : true } : { } ) ,
4885+ ...( remoteControlEnabled ? { remoteControl : true } : { } ) ,
48474886 } ,
48484887 }
48494888 : { } ) ,
@@ -5933,6 +5972,12 @@ function ChatViewContent(props: ChatViewProps) {
59335972 planSidebarOpen = { planSidebarOpen }
59345973 runtimeMode = { runtimeMode }
59355974 interactionMode = { interactionMode }
5975+ showRemoteControlToggle = {
5976+ selectedProvider === ProviderDriverKind . make ( "claudeAgent" )
5977+ }
5978+ remoteControlEnabled = { remoteControlEnabled }
5979+ remoteControlPending = { remoteControlPending }
5980+ onToggleRemoteControl = { handleToggleRemoteControl }
59365981 lockedProvider = { lockedProvider }
59375982 providerStatuses = { providerStatuses as ServerProvider [ ] }
59385983 activeProjectDefaultModelSelection = {
0 commit comments