Skip to content

Commit 9a4d84d

Browse files
fix(web): a failed commit keeps the commit message you typed
The Commit dialog cleared its message before the commit ran, so a commit rejected by a hook (or failing for any other reason) lost the typed message. runGitActionWithToast now reports whether the action succeeded, and Commit and Commit on new branch put the message back when it did not, unless a new message was already typed. Fixes #35750 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 59e64ee commit 9a4d84d

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ export default function GitActionsControl({
12381238
!isLocalDraftThread &&
12391239
!readEnvironmentScope(activeEnvironmentId, AuthOrchestrationOperateScope))
12401240
)
1241-
return;
1241+
return false;
12421242
const actionStatus = statusOverride ?? gitStatusForActions;
12431243
const actionBranch = actionStatus?.refName ?? null;
12441244
const actionIsDefaultBranch = featureBranch ? false : isDefaultRef;
@@ -1258,7 +1258,7 @@ export default function GitActionsControl({
12581258
action !== "commit_push" &&
12591259
action !== "commit_push_pr"
12601260
) {
1261-
return;
1261+
return false;
12621262
}
12631263
setPendingDefaultBranchAction({
12641264
action,
@@ -1268,7 +1268,7 @@ export default function GitActionsControl({
12681268
...(onConfirmed ? { onConfirmed } : {}),
12691269
...(filePaths ? { filePaths } : {}),
12701270
});
1271-
return;
1271+
return false;
12721272
}
12731273
onConfirmed?.();
12741274
setInlineSuccess(null);
@@ -1288,7 +1288,7 @@ export default function GitActionsControl({
12881288

12891289
if (result._tag === "Failure") {
12901290
if (isAtomCommandInterrupted(result)) {
1291-
return;
1291+
return false;
12921292
}
12931293

12941294
const error = squashAtomCommandFailure(result);
@@ -1302,7 +1302,7 @@ export default function GitActionsControl({
13021302
...(scopedToastData !== undefined ? { data: scopedToastData } : {}),
13031303
}),
13041304
);
1305-
return;
1305+
return false;
13061306
}
13071307

13081308
const actionResult = result.value;
@@ -1316,6 +1316,7 @@ export default function GitActionsControl({
13161316
scopeKey: successScopeKey,
13171317
expiresAtMs: inlineSuccessExpiresAt(),
13181318
});
1319+
return true;
13191320
}
13201321

13211322
const continuePendingDefaultBranchAction = (featureBranch: boolean) => {
@@ -1334,6 +1335,12 @@ export default function GitActionsControl({
13341335
});
13351336
};
13361337

1338+
// Keep a typed message for the retry unless the user already started a new one.
1339+
const restoreDialogCommitMessageOnFailure = (commitMessage: string) => (committed: boolean) => {
1340+
if (committed || !commitMessage) return;
1341+
setDialogCommitMessage((current) => current || commitMessage);
1342+
};
1343+
13371344
const runDialogActionOnNewBranch = () => {
13381345
if (!isCommitDialogOpen) return;
13391346
const commitMessage = dialogCommitMessage.trim();
@@ -1349,7 +1356,7 @@ export default function GitActionsControl({
13491356
...(!allSelected ? { filePaths: selectedFiles.map((f) => f.path) } : {}),
13501357
featureBranch: true,
13511358
skipDefaultBranchPrompt: true,
1352-
});
1359+
}).then(restoreDialogCommitMessageOnFailure(commitMessage));
13531360
};
13541361

13551362
const runQuickAction = () => {
@@ -1434,7 +1441,7 @@ export default function GitActionsControl({
14341441
action: "commit",
14351442
...(commitMessage ? { commitMessage } : {}),
14361443
...(!allSelected ? { filePaths: selectedFiles.map((f) => f.path) } : {}),
1437-
});
1444+
}).then(restoreDialogCommitMessageOnFailure(commitMessage));
14381445
};
14391446

14401447
const openChangedFileInEditor = (filePath: string) => {

0 commit comments

Comments
 (0)