@devries-cameron20 / t3code Mirror · read-only / commits / 732198d3a9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 14:45 UTC

fix(web): a disabled Push names the real reason when there are local changes (#36786)

Co-authored-by: Alex Southwell <4596216+saphid@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Julius Marminge committed Nov 14, 2026 at 07:22 UTC 732198d3a964acb444f8b6d7f78bc56b43ed5f76
3 files changed +72 -62
apps/web/src/components/GitActionsControl.logic.test.ts
+12
@@ -10,6 +10,7 @@ import {
10 resolveDefaultBranchActionDialogCopy,
11 resolveLiveThreadBranchUpdate,
12 resolveQuickAction,
13 + getMenuActionDisabledReason,
14 } from "./GitActionsControl.logic";
15
16 function status(overrides: Partial<VcsStatusResult> = {}): VcsStatusResult {
@@ -32,6 +33,12 @@ function status(overrides: Partial<VcsStatusResult> = {}): VcsStatusResult {
33 };
34 }
35
36 +function pushDisabledReason(gitStatus: VcsStatusResult): string | null {
37 + const item = buildMenuItems(gitStatus, false).find((menuItem) => menuItem.id === "push");
38 + assert.isDefined(item);
39 + return getMenuActionDisabledReason({ item, gitStatus, isBusy: false, hasPrimaryRemote: true });
40 +}
41 +
42 describe("when: ref is clean, ahead, and has an open PR", () => {
43 it("resolveQuickAction prefers push", () => {
44 const quick = resolveQuickAction(
@@ -77,6 +84,7 @@ describe("when: ref is clean, up to date, and has no open PR", () => {
84 buildMenuItems(dirtyFeature, false).find((item) => item.id === "pr")?.disabled,
85 false,
86 );
87 + assert.equal(pushDisabledReason(dirtyFeature), "No local commits to push.");
88 });
89
90 it("offers the actions menu only when something in it is usable", () => {
@@ -129,6 +137,10 @@ describe("when: local changes are behind upstream", () => {
137 action: "commit",
138 } as const;
139 assert.deepEqual(resolveQuickAction(behind, false), commit);
140 + assert.equal(
141 + pushDisabledReason({ ...behind, aheadCount: 1 }),
142 + "Branch is behind upstream. Pull/rebase before pushing.",
143 + );
144 assert.deepEqual(
145 resolveQuickAction(
146 {
apps/web/src/components/GitActionsControl.logic.ts
+59
@@ -175,6 +175,65 @@ export function buildMenuItems(
175 ];
176 }
177
178 +export function getMenuActionDisabledReason({
179 + item,
180 + gitStatus,
181 + isBusy,
182 + hasPrimaryRemote,
183 +}: {
184 + item: GitActionMenuItem;
185 + gitStatus: VcsStatusResult | null;
186 + isBusy: boolean;
187 + hasPrimaryRemote: boolean;
188 +}): string | null {
189 + if (!item.disabled) return null;
190 + if (isBusy) return "Git action in progress.";
191 + if (!gitStatus) return "Git status is unavailable.";
192 +
193 + const hasBranch = gitStatus.refName !== null;
194 + const hasChanges = gitStatus.hasWorkingTreeChanges;
195 + const isAhead = gitStatus.aheadCount > 0;
196 + const isBehind = gitStatus.behindCount > 0;
197 + const terminology = changeRequestTerminologyFor(gitStatus);
198 +
199 + if (item.id === "commit") {
200 + if (!hasChanges) {
201 + return "Worktree is clean. Make changes before committing.";
202 + }
203 + return "Commit is currently unavailable.";
204 + }
205 +
206 + if (item.id === "push") {
207 + if (!hasBranch) {
208 + return "Detached HEAD: check out a branch before pushing.";
209 + }
210 + if (isBehind) {
211 + return "Branch is behind upstream. Pull/rebase before pushing.";
212 + }
213 + if (!gitStatus.hasUpstream && !hasPrimaryRemote) {
214 + return 'Add an "origin" remote before pushing.';
215 + }
216 + if (!isAhead) {
217 + return "No local commits to push.";
218 + }
219 + return "Push is currently unavailable.";
220 + }
221 +
222 + if (!hasBranch) {
223 + return `Detached HEAD: check out a branch before creating a ${terminology.singular}.`;
224 + }
225 + if (!gitStatus.hasUpstream && !hasPrimaryRemote) {
226 + return `Add an "origin" remote before creating a ${terminology.singular}.`;
227 + }
228 + if ((gitStatus.aheadOfDefaultCount ?? gitStatus.aheadCount) <= 0) {
229 + return `No local commits to include in a ${terminology.singular}.`;
230 + }
231 + if (isBehind) {
232 + return `Branch is behind upstream. Pull/rebase before creating a ${terminology.singular}.`;
233 + }
234 + return `Create ${terminology.singular} is currently unavailable.`;
235 +}
236 +
237 export function hasUsableGitMenuContent(input: {
238 readonly menuItems: readonly GitActionMenuItem[];
239 readonly canWriteSourceControl: boolean;
apps/web/src/components/GitActionsControl.tsx
+1 -62
@@ -59,6 +59,7 @@ import {
59 resolveGitActionProgressPresentation,
60 resolveGitActionResultToastTiming,
61 resolveLiveThreadBranchUpdate,
62 + getMenuActionDisabledReason,
63 resolveThreadBranchMetadataPatch,
64 resolveQuickAction,
65 resolveThreadBranchUpdate,
@@ -228,68 +229,6 @@ function getPublishProviderReadiness(input: {
229 return { ready: true, hint: null };
230 }
231
231 -function getMenuActionDisabledReason({
232 - item,
233 - gitStatus,
234 - isBusy,
235 - hasPrimaryRemote,
236 -}: {
237 - item: GitActionMenuItem;
238 - gitStatus: VcsStatusResult | null;
239 - isBusy: boolean;
240 - hasPrimaryRemote: boolean;
241 -}): string | null {
242 - if (!item.disabled) return null;
243 - if (isBusy) return "Git action in progress.";
244 - if (!gitStatus) return "Git status is unavailable.";
245 -
246 - const hasBranch = gitStatus.refName !== null;
247 - const hasChanges = gitStatus.hasWorkingTreeChanges;
248 - const isAhead = gitStatus.aheadCount > 0;
249 - const isBehind = gitStatus.behindCount > 0;
250 - const terminology = getSourceControlPresentation(gitStatus.sourceControlProvider).terminology;
251 -
252 - if (item.id === "commit") {
253 - if (!hasChanges) {
254 - return "Worktree is clean. Make changes before committing.";
255 - }
256 - return "Commit is currently unavailable.";
257 - }
258 -
259 - if (item.id === "push") {
260 - if (!hasBranch) {
261 - return "Detached HEAD: check out a branch before pushing.";
262 - }
263 - if (hasChanges) {
264 - return "Commit or stash local changes before pushing.";
265 - }
266 - if (isBehind) {
267 - return "Branch is behind upstream. Pull/rebase before pushing.";
268 - }
269 - if (!gitStatus.hasUpstream && !hasPrimaryRemote) {
270 - return 'Add an "origin" remote before pushing.';
271 - }
272 - if (!isAhead) {
273 - return "No local commits to push.";
274 - }
275 - return "Push is currently unavailable.";
276 - }
277 -
278 - if (!hasBranch) {
279 - return `Detached HEAD: check out a branch before creating a ${terminology.singular}.`;
280 - }
281 - if (!gitStatus.hasUpstream && !hasPrimaryRemote) {
282 - return `Add an "origin" remote before creating a ${terminology.singular}.`;
283 - }
284 - if ((gitStatus.aheadOfDefaultCount ?? gitStatus.aheadCount) <= 0) {
285 - return `No local commits to include in a ${terminology.singular}.`;
286 - }
287 - if (isBehind) {
288 - return `Branch is behind upstream. Pull/rebase before creating a ${terminology.singular}.`;
289 - }
290 - return `Create ${terminology.singular} is currently unavailable.`;
291 -}
292 -
232 const COMMIT_DIALOG_TITLE = "Commit changes";
233 const COMMIT_DIALOG_DESCRIPTION =
234 "Review and confirm your commit. Leave the message blank to auto-generate one.";