-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix PR List Update on Post Status Click #1207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2920878
d25fd4d
a409b92
e29564b
8bf032b
6c07a7c
c669b5d
1dd1649
3cd6ea2
82218af
0c91a5d
9f6239a
e807cc9
04c5f0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,10 +52,11 @@ interface PRDetailProps { | |
| onCheckNewCommits: () => Promise<NewCommitsCheck>; | ||
| onCancelReview: () => void; | ||
| onPostReview: (selectedFindingIds?: string[], options?: { forceApprove?: boolean }) => Promise<boolean>; | ||
| onPostComment: (body: string) => void; | ||
| onPostComment: (body: string) => Promise<boolean>; | ||
| onMergePR: (mergeMethod?: 'merge' | 'squash' | 'rebase') => void; | ||
| onAssignPR: (username: string) => void; | ||
| onGetLogs: () => Promise<PRLogsType | null>; | ||
| onMarkReviewPosted?: (prNumber: number) => Promise<void>; | ||
| } | ||
|
|
||
| function getStatusColor(status: PRReviewResult['overallStatus']): string { | ||
|
|
@@ -89,6 +90,7 @@ export function PRDetail({ | |
| onMergePR, | ||
| onAssignPR: _onAssignPR, | ||
| onGetLogs, | ||
| onMarkReviewPosted, | ||
| }: PRDetailProps) { | ||
| const { t } = useTranslation('common'); | ||
| // Selection state for findings | ||
|
|
@@ -780,12 +782,17 @@ ${reviewResult.summary} | |
|
|
||
| ${t('prReview.blockedStatusMessageFooter')}`; | ||
|
|
||
| await Promise.resolve(onPostComment(blockedStatusMessage)); | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Approve handler silently fails on post errorLow Severity The |
||
| const success = await onPostComment(blockedStatusMessage); | ||
|
|
||
| // Only mark as posted on success if PR hasn't changed | ||
| if (pr.number === currentPr) { | ||
| // Only mark as posted on success if PR hasn't changed AND comment was posted successfully | ||
| if (success && pr.number === currentPr) { | ||
| setBlockedStatusPosted(true); | ||
| setBlockedStatusError(null); | ||
| // Update the store to mark review as posted so PR list reflects the change | ||
| // Pass prNumber explicitly to avoid race conditions with PR selection changes | ||
| await onMarkReviewPosted?.(currentPr); | ||
This comment was marked as outdated.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Store update skipped when user switches PRs during postingMedium Severity The |
||
| } else if (!success && pr.number === currentPr) { | ||
| setBlockedStatusError('Failed to post comment'); | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } catch (err) { | ||
| console.error('Failed to post blocked status comment:', err); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,7 @@ interface UseGitHubPRsResult { | |||||
| postComment: (prNumber: number, body: string) => Promise<boolean>; | ||||||
| mergePR: (prNumber: number, mergeMethod?: "merge" | "squash" | "rebase") => Promise<boolean>; | ||||||
| assignPR: (prNumber: number, username: string) => Promise<boolean>; | ||||||
| markReviewPosted: (prNumber: number) => Promise<void>; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| getReviewStateForPR: (prNumber: number) => { | ||||||
| isReviewing: boolean; | ||||||
| startedAt: string | null; | ||||||
|
|
@@ -557,6 +558,41 @@ export function useGitHubPRs( | |||||
| [projectId, fetchPRs] | ||||||
| ); | ||||||
|
|
||||||
| const markReviewPosted = useCallback( | ||||||
| async (prNumber: number): Promise<void> => { | ||||||
| if (!projectId) return; | ||||||
|
|
||||||
| // Persist to disk first | ||||||
| const success = await window.electronAPI.github.markReviewPosted(projectId, prNumber); | ||||||
| if (!success) return; | ||||||
|
|
||||||
| // Get the current timestamp for consistent update | ||||||
| const postedAt = new Date().toISOString(); | ||||||
|
|
||||||
| // Update the in-memory store | ||||||
| const existingState = getPRReviewState(projectId, prNumber); | ||||||
| if (existingState?.result) { | ||||||
| // If we have the result loaded, update it with hasPostedFindings and postedAt | ||||||
| usePRReviewStore.getState().setPRReviewResult( | ||||||
| projectId, | ||||||
| { ...existingState.result, hasPostedFindings: true, postedAt }, | ||||||
| { preserveNewCommitsCheck: true } | ||||||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| ); | ||||||
| } else { | ||||||
| // If result not loaded yet (race condition), reload from disk to get updated state | ||||||
| const result = await window.electronAPI.github.getPRReview(projectId, prNumber); | ||||||
| if (result) { | ||||||
| usePRReviewStore.getState().setPRReviewResult( | ||||||
| projectId, | ||||||
| result, | ||||||
| { preserveNewCommitsCheck: true } | ||||||
| ); | ||||||
| } | ||||||
| } | ||||||
|
Comment on lines
+589
to
+591
This comment was marked as outdated.
Sorry, something went wrong. |
||||||
| }, | ||||||
| [projectId, getPRReviewState] | ||||||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| ); | ||||||
|
|
||||||
| return { | ||||||
| prs, | ||||||
| isLoading, | ||||||
|
|
@@ -585,6 +621,7 @@ export function useGitHubPRs( | |||||
| postComment, | ||||||
| mergePR, | ||||||
| assignPR, | ||||||
| markReviewPosted, | ||||||
| getReviewStateForPR, | ||||||
| }; | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.