Skip to content

fix: immediately run push on commit & push#1830

Merged
charlesvien merged 1 commit intomainfrom
04-22-fix_immediately_run_push_on_commit_push
Apr 23, 2026
Merged

fix: immediately run push on commit & push#1830
charlesvien merged 1 commit intomainfrom
04-22-fix_immediately_run_push_on_commit_push

Conversation

@jonathanlab
Copy link
Copy Markdown
Contributor

@jonathanlab jonathanlab commented Apr 22, 2026

Closes #1814

@jonathanlab jonathanlab changed the base branch from 04-22-fix_add_back_shift-tab_support to graphite-base/1830 April 22, 2026 12:53
@jonathanlab jonathanlab force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from 08abd30 to f8c2d77 Compare April 22, 2026 12:53
@jonathanlab jonathanlab changed the base branch from graphite-base/1830 to 04-22-fix_increase_sidebar_min_width April 22, 2026 12:53
@jonathanlab jonathanlab marked this pull request as ready for review April 22, 2026 12:54
@jonathanlab jonathanlab force-pushed the 04-22-fix_increase_sidebar_min_width branch from 430e157 to f88cc92 Compare April 22, 2026 12:56
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/git-interaction/hooks/useGitInteraction.ts
Line: 413-416

Comment:
**Stale `pushMode` closure when commit-push is used**

`runPush()` reads `store.pushMode` from the Zustand snapshot captured at the last React render, but `modal.openPush(...)` updates the Zustand store synchronously via `set()` without triggering a re-render before `runPush()` is called. The component hasn't re-rendered between these two calls, so `store.pushMode` is still the *previously persisted* value.

A concrete failure case: a user previously pushed to a remote repo (`pushMode = "push"` persisted), then switches to a repo without a remote and uses "commit & push". `modal.openPush("publish")` sets the store to `"publish"`, but `runPush()` still reads the stale `"push"` from the closure and calls `trpcClient.git.push` instead of `trpcClient.git.publish`.

The simplest fix is to derive the mode from the same expression used in `openPush` and pass it explicitly:

```typescript
const mode = git.hasRemote ? "push" : "publish";
modal.openPush(mode);
await runPush(mode);
```

…and update `runPush` to accept an optional `mode` parameter, falling back to `store.pushMode` for the standalone push flow.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: immediately run push on commit & pu..." | Re-trigger Greptile

Comment on lines 413 to +416
if (store.commitNextStep === "commit-push") {
modal.openPush(git.hasRemote ? "push" : "publish");
await runPush();
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Stale pushMode closure when commit-push is used

runPush() reads store.pushMode from the Zustand snapshot captured at the last React render, but modal.openPush(...) updates the Zustand store synchronously via set() without triggering a re-render before runPush() is called. The component hasn't re-rendered between these two calls, so store.pushMode is still the previously persisted value.

A concrete failure case: a user previously pushed to a remote repo (pushMode = "push" persisted), then switches to a repo without a remote and uses "commit & push". modal.openPush("publish") sets the store to "publish", but runPush() still reads the stale "push" from the closure and calls trpcClient.git.push instead of trpcClient.git.publish.

The simplest fix is to derive the mode from the same expression used in openPush and pass it explicitly:

const mode = git.hasRemote ? "push" : "publish";
modal.openPush(mode);
await runPush(mode);

…and update runPush to accept an optional mode parameter, falling back to store.pushMode for the standalone push flow.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/git-interaction/hooks/useGitInteraction.ts
Line: 413-416

Comment:
**Stale `pushMode` closure when commit-push is used**

`runPush()` reads `store.pushMode` from the Zustand snapshot captured at the last React render, but `modal.openPush(...)` updates the Zustand store synchronously via `set()` without triggering a re-render before `runPush()` is called. The component hasn't re-rendered between these two calls, so `store.pushMode` is still the *previously persisted* value.

A concrete failure case: a user previously pushed to a remote repo (`pushMode = "push"` persisted), then switches to a repo without a remote and uses "commit & push". `modal.openPush("publish")` sets the store to `"publish"`, but `runPush()` still reads the stale `"push"` from the closure and calls `trpcClient.git.push` instead of `trpcClient.git.publish`.

The simplest fix is to derive the mode from the same expression used in `openPush` and pass it explicitly:

```typescript
const mode = git.hasRemote ? "push" : "publish";
modal.openPush(mode);
await runPush(mode);
```

…and update `runPush` to accept an optional `mode` parameter, falling back to `store.pushMode` for the standalone push flow.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dis legit ?

@jonathanlab jonathanlab force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from f8c2d77 to c7b587f Compare April 22, 2026 13:36
@charlesvien charlesvien force-pushed the 04-22-fix_increase_sidebar_min_width branch from f88cc92 to 25b215d Compare April 22, 2026 15:38
@charlesvien charlesvien force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from c7b587f to cb07e28 Compare April 22, 2026 15:38
@charlesvien charlesvien force-pushed the 04-22-fix_increase_sidebar_min_width branch from 25b215d to 8027df2 Compare April 22, 2026 22:55
@charlesvien charlesvien force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from cb07e28 to 172016f Compare April 22, 2026 22:56
@jonathanlab jonathanlab force-pushed the 04-22-fix_increase_sidebar_min_width branch from 8027df2 to 6e52943 Compare April 23, 2026 10:19
@jonathanlab jonathanlab force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from 172016f to b5e3a2e Compare April 23, 2026 10:20
@jonathanlab jonathanlab force-pushed the 04-22-fix_increase_sidebar_min_width branch from 6e52943 to 1db72f2 Compare April 23, 2026 10:41
@jonathanlab jonathanlab force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from b5e3a2e to 4691a08 Compare April 23, 2026 10:42
@charlesvien charlesvien force-pushed the 04-22-fix_increase_sidebar_min_width branch from 1db72f2 to 79f4277 Compare April 23, 2026 10:48
@charlesvien charlesvien force-pushed the 04-22-fix_increase_sidebar_min_width branch from 79f4277 to b6575d8 Compare April 23, 2026 10:48
@charlesvien charlesvien force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from 4691a08 to 34161ec Compare April 23, 2026 10:48
@charlesvien charlesvien changed the base branch from 04-22-fix_increase_sidebar_min_width to graphite-base/1830 April 23, 2026 10:56
@charlesvien charlesvien force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from 34161ec to cbac191 Compare April 23, 2026 10:56
@graphite-app graphite-app Bot changed the base branch from graphite-base/1830 to main April 23, 2026 10:56
@charlesvien charlesvien force-pushed the 04-22-fix_immediately_run_push_on_commit_push branch from cbac191 to d483201 Compare April 23, 2026 10:56
@charlesvien charlesvien merged commit 247538a into main Apr 23, 2026
16 checks passed
Copy link
Copy Markdown
Member

Merge activity

@charlesvien charlesvien deleted the 04-22-fix_immediately_run_push_on_commit_push branch April 23, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If I click "Commit and push" it shouldn't prompt me to push again

4 participants