Skip to content

Commit b468f3e

Browse files
committed
fix(web): an automatic base-branch default only applies to an empty thread
1 parent e0d5f88 commit b468f3e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎apps/web/src/components/BranchToolbarBranchSelector.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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
);

‎packages/client-runtime/src/operations/commands.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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

136138
export 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
? {}

0 commit comments

Comments
 (0)