File tree Expand file tree Collapse file tree
packages/client-runtime/src/operations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,6 +122,10 @@ export function BranchToolbarBranchSelector({
122122 threadEnvironment . updateMetadata ,
123123 "thread metadata update" ,
124124 ) ;
125+ // An automatic default loses to any launch that lands first; that rejection is expected.
126+ const updateEmptyThreadMetadata = useAtomCommand ( threadEnvironment . updateMetadata , {
127+ reportFailure : false ,
128+ } ) ;
125129 const switchRef = useAtomCommand ( vcsEnvironment . switchRef , {
126130 reportFailure : false ,
127131 } ) ;
@@ -188,12 +192,14 @@ export function BranchToolbarBranchSelector({
188192 } ) ;
189193 }
190194 if ( hasServerThread ) {
191- void updateThreadMetadata ( {
195+ void ( automatic ? updateEmptyThreadMetadata : updateThreadMetadata ) ( {
192196 environmentId,
193197 input : {
194198 threadId : activeThreadId ,
195199 branch,
196200 worktreePath,
201+ // A launched thread records its own worktree; a late default must not reset it.
202+ ...( automatic ? { expectedEmpty : true } : { } ) ,
197203 } ,
198204 } ) ;
199205 }
@@ -228,6 +234,7 @@ export function BranchToolbarBranchSelector({
228234 effectiveEnvMode ,
229235 draftThread ?. environmentSelection ,
230236 stopThreadSession ,
237+ updateEmptyThreadMetadata ,
231238 updateThreadMetadata ,
232239 ] ,
233240 ) ;
Original file line number Diff line number Diff line change @@ -131,6 +131,8 @@ export interface UpdateThreadMetadataInput extends ThreadCommandInput {
131131 readonly regenerateTitle ?: boolean ;
132132 /** Link (object) or unlink (null) a pull request (#8160). */
133133 readonly linkedPullRequest ?: ThreadLinkedPullRequest | null ;
134+ /** Apply only while no message or run has landed on the thread. */
135+ readonly expectedEmpty ?: boolean ;
134136}
135137
136138export interface SetThreadRuntimeModeInput extends ThreadCommandInput {
@@ -577,6 +579,7 @@ export const updateThreadMetadata = Effect.fn("EnvironmentCommands.updateThreadM
577579 ...( input . title === undefined ? { } : { title : input . title } ) ,
578580 ...( input . branch === undefined ? { } : { branch : input . branch } ) ,
579581 ...( input . worktreePath === undefined ? { } : { worktreePath : input . worktreePath } ) ,
582+ ...( input . expectedEmpty === true ? { expectedEmpty : true } : { } ) ,
580583 ...( input . regenerateTitle === undefined ? { } : { regenerateTitle : input . regenerateTitle } ) ,
581584 ...( input . linkedPullRequest === undefined
582585 ? { }
You can’t perform that action at this time.
0 commit comments