-
Notifications
You must be signed in to change notification settings - Fork 64
fix(git): record every PR created for a local task #3840
Changes from 1 commit
4a302f5
a4e5cf8
338cd6d
13240e4
3fcc7b0
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 |
|---|---|---|
|
|
@@ -2228,7 +2228,7 @@ For git operations while detached: | |
| this.fetchGhLogin(session.repoPath), | ||
| ]); | ||
| if (!wasCreatedRecently(attribution.createdAt, Date.now())) return; | ||
| if (!wasCreatedByLogin(attribution.author, ghLogin)) return; | ||
| if (ghLogin && !wasCreatedByLogin(attribution.author, ghLogin)) return; | ||
|
frankh marked this conversation as resolved.
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.
When Rule Used: When implementing new features, ensure that owners... (source) Learned From Knowledge Base Used: workspace-server Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/workspace-server/src/services/agent/agent.ts
Line: 2231
Comment:
**Missing login bypasses attribution**
When `gh api user` transiently fails, any PR created within the five-minute window and present in agent output passes this guard without an author or repository match. This attaches an unrelated recent PR to the task and links the current branch as though the PR were created during this run, producing incorrect PR badge and branch state.
**Rule Used:** When implementing new features, ensure that owners... ([source](https://app.greptile.com/posthog-org-19734/-/custom-context?memory=9655b466-451a-401a-9ba0-5bf3e7b7f9f8))
**Learned From**
[PostHog/posthog#31236](https://github.com/PostHog/posthog/pull/31236)
**Knowledge Base Used:** [workspace-server](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/workspace-server.md)
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| this.log.info("Detected PR URL created during run", { taskRunId, prUrl }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,27 @@ export class TaskPrStatusService { | |
| }); | ||
| } | ||
|
|
||
| async accumulatePrUrl(taskId: string, prUrl: string): Promise<void> { | ||
| if (!this.workspaceRepo.findByTaskId(taskId)) return; | ||
| const details = await this.gitService | ||
| .getPrDetailsByUrl(prUrl) | ||
| .catch(() => null); | ||
|
Comment on lines
+74
to
+76
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. When two PRs are created for the same task before either details lookup finishes, their URLs are appended in lookup-completion order rather than creation order. Since the UI treats Knowledge Base Used: workspace-server Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/workspace-server/src/services/git/task-pr-status.ts
Line: 74-76
Comment:
**PR creation order is lost**
When two PRs are created for the same task before either details lookup finishes, their URLs are appended in lookup-completion order rather than creation order. Since the UI treats `prUrls[0]` as primary, the second-created PR is displayed as the primary badge when its lookup resolves first.
**Knowledge Base Used:** [workspace-server](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/workspace-server.md)
How can I resolve this? If you propose a fix, please make it concise. |
||
| const prState: SidebarPrState = details | ||
| ? mapPrState(details.state, details.merged, details.draft) | ||
| : null; | ||
| this.workspaceRepo.updatePrCache(taskId, { | ||
| prUrl, | ||
| prState, | ||
| accumulate: true, | ||
| }); | ||
| this.workspaceService.emit("taskPrInfoChanged", { | ||
| taskId, | ||
| prUrl, | ||
| prUrls: this.workspaceRepo.getPrUrls(taskId), | ||
| prState, | ||
| }); | ||
| } | ||
|
|
||
| private async computeWorktreeHasDiff(taskId: string): Promise<boolean> { | ||
| const workspace = await this.workspaceService.getWorkspace(taskId); | ||
| if ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the app shuts down after PR creation while
getPrDetailsByUrlis still pending, this discarded promise reaches the closed database and rejects without being handled. The create-PR flow has already reported success, but the new PR URL is never persisted and disappears from the task after restart.Rule Used: Always wrap asynchronous calls that may fail, such... (source)
Learned From
PostHog/posthog#32098
Knowledge Base Used:
apps/code)Prompt To Fix With AI