-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(pull-requests): refresh data after thread turns #9496
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
base: main
Are you sure you want to change the base?
Changes from all commits
f5a4410
54077db
d2126f2
bf50eac
69fe35c
c181635
8b943a9
a90e325
d91144c
65b1ef2
3b54ca4
0ac7540
e588f96
19c9de8
b372bed
ea106a9
6571dd6
2f435f3
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 |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import type { OrchestrationDispatchError } from "../Errors.ts"; | |
| import { isGitRepository } from "../../git/Utils.ts"; | ||
| import { VcsStatusBroadcaster } from "../../vcs/VcsStatusBroadcaster.ts"; | ||
| import * as WorkspaceEntries from "../../workspace/WorkspaceEntries.ts"; | ||
| import * as PullRequestService from "../../pullRequest/PullRequestService.ts"; | ||
|
|
||
| const nowIso = Effect.map(DateTime.now, DateTime.formatIso); | ||
|
|
||
|
|
@@ -88,6 +89,9 @@ const make = Effect.gen(function* () { | |
| const receiptBus = yield* RuntimeReceiptBus; | ||
| const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries; | ||
| const vcsStatusBroadcaster = yield* VcsStatusBroadcaster; | ||
| const pullRequests = yield* PullRequestService.PullRequestService; | ||
| const startedTurns = new Map<ThreadId, TurnId>(); | ||
| const pending = new Set<ThreadId>(); | ||
|
|
||
| const appendRevertFailureActivity = (input: { | ||
| readonly threadId: ThreadId; | ||
|
|
@@ -854,6 +858,7 @@ const make = Effect.gen(function* () { | |
|
|
||
| const processDomainEvent = Effect.fn("processDomainEvent")(function* (event: OrchestrationEvent) { | ||
| if (event.type === "thread.turn-start-requested" || event.type === "thread.message-sent") { | ||
| if (event.type === "thread.turn-start-requested") pending.add(event.payload.threadId); | ||
| yield* ensurePreTurnBaselineFromDomainTurnStart(event); | ||
| return; | ||
| } | ||
|
|
@@ -897,14 +902,46 @@ const make = Effect.gen(function* () { | |
| const processRuntimeEvent = Effect.fn("processRuntimeEvent")(function* ( | ||
| event: ProviderRuntimeEvent, | ||
| ) { | ||
| if (event.type === "session.exited") { | ||
| startedTurns.delete(event.threadId); | ||
| pending.delete(event.threadId); | ||
| return; | ||
| } | ||
|
|
||
| if (event.type === "turn.started") { | ||
| const turnId = toTurnId(event.turnId); | ||
| const activeTurnId = (yield* providerService.listSessions()).find((session) => | ||
| sameId(session.threadId, event.threadId), | ||
| )?.activeTurnId; | ||
| const mayReplace = pending.has(event.threadId) && sameId(activeTurnId, turnId); | ||
| if (turnId !== null && (!startedTurns.has(event.threadId) || mayReplace)) { | ||
| startedTurns.set(event.threadId, turnId); | ||
| pending.delete(event.threadId); | ||
| } | ||
|
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. Sticky pending allows unrelated turn replaceMedium Severity
Additional Locations (2)Reviewed by Cursor Bugbot for commit 2f435f3. Configure here. |
||
| yield* ensurePreTurnBaselineFromTurnStart(event); | ||
| return; | ||
| } | ||
|
|
||
| if (event.type === "turn.completed") { | ||
| if (event.type === "turn.completed" || event.type === "turn.aborted") { | ||
| const turnId = toTurnId(event.turnId); | ||
| yield* refreshLocalGitStatusFromTurnCompletion(event); | ||
| const thread = yield* resolveThreadDetail(event.threadId); | ||
| const startedTurnId = startedTurns.get(event.threadId); | ||
| const isTrackedTurn = sameId(startedTurnId, turnId); | ||
| if (isTrackedTurn) startedTurns.delete(event.threadId); | ||
| if (event.type === "turn.completed") { | ||
| yield* refreshLocalGitStatusFromTurnCompletion(event); | ||
| } | ||
| if ( | ||
| turnId !== null && | ||
| thread !== undefined && | ||
| (isTrackedTurn || | ||
| sameId(thread.session?.activeTurnId, turnId) || | ||
| (startedTurnId === undefined && !thread.session?.activeTurnId)) | ||
|
cursor[bot] marked this conversation as resolved.
maria-rcks marked this conversation as resolved.
|
||
| ) { | ||
| pending.delete(event.threadId); | ||
| yield* pullRequests.refreshAfterTurn; | ||
| } | ||
|
maria-rcks marked this conversation as resolved.
|
||
| if (event.type === "turn.aborted") return; | ||
| yield* captureCheckpointFromTurnCompletion(event).pipe( | ||
| Effect.catch((error) => | ||
| Effect.flatMap(nowIso, (createdAt) => | ||
|
|
@@ -963,7 +1000,12 @@ const make = Effect.gen(function* () { | |
|
|
||
| yield* forkParked( | ||
| Stream.runForEach(providerService.streamEvents, (event) => { | ||
| if (event.type !== "turn.started" && event.type !== "turn.completed") { | ||
| if ( | ||
| event.type !== "turn.started" && | ||
| event.type !== "turn.completed" && | ||
| event.type !== "turn.aborted" && | ||
| event.type !== "session.exited" | ||
| ) { | ||
| return Effect.void; | ||
| } | ||
| return worker.enqueue({ source: "runtime", event }); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.