fix(grok): Harden ACP resume with replay-idle load readiness #3156
main fromrefs/pull/3156/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/GrokAdapter.ts line 1179Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -852,3 +854,12 @@852854 // superseded prompt resolving (usually cancelled) while another853855 // is in flight or pending must leave the merged turn running.854856 if (ctx.promptsInFlight === 1) {857+ const completedAt = yield* nowIso;858+ const { activeTurnId: _completedTurnId, ...readySession } = ctx.session;859+ ctx.activeTurnId = undefined;860+ ctx.session = {861+ ...readySession,862+ status: "ready",863+ updatedAt: completedAt,864+ ...(prepared.displayModel ? { model: prepared.displayModel } : {}),865+ };apps/server/src/provider/acp/AcpSessionRuntime.ts line 851OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -759,0 +831,21 @@831+832+const resolveXAiPromptCompletionFallback = ({833+ pendingRef,834+ notification,835+}: {836+ readonly pendingRef: Ref.Ref<ReadonlyArray<PendingXAiPromptCompletion>>;837+ readonly notification: XAiPromptCompleteNotification;838+}) =>839+ Ref.modify(pendingRef, (pending) => {840+ const index = pending.findIndex((entry) => entry.sessionId === notification.sessionId);841+ if (index < 0) {842+ return [Effect.void, pending] as const;843+ }844+ const entry = pending[index];845+ if (!entry) {846+ return [Effect.void, pending] as const;847+ }848+ return [849+ Deferred.succeed(entry.deferred, promptResponseFromXAi(notification)).pipe(Effect.asVoid),850+ [...pending.slice(0, index), ...pending.slice(index + 1)],851+ ] as const;
- apps/server/src/provider/Layers/GrokAdapter.ts line 905OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -872,13 +902,4 @@872902 };873903 }),874904 );875- }).pipe(876- Effect.ensuring(877- Effect.sync(() => {878- const liveCtx = sessions.get(input.threadId);879- if (liveCtx) {880- liveCtx.promptsInFlight = Math.max(0, liveCtx.promptsInFlight - 1);881- }882- }),883- ),884- );905+ }).pipe(Effect.ensuring(settlePromptInFlight(input.threadId, prepared.turnId)));
- apps/server/src/provider/Layers/GrokAdapter.ts line 875OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -852,3 +873,3 @@852873 // superseded prompt resolving (usually cancelled) while another853874 // is in flight or pending must leave the merged turn running.854875 if (ctx.promptsInFlight === 1) {
- apps/server/src/provider/Layers/GrokAdapter.ts line 1088Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -801,12 +847,21 @@801847 }),802848 ),803849 );804850 }),805851 );852+ const promptSettled = yield* Ref.make(false);853+854+ const promptFailureMessageRef = yield* Ref.make<string | undefined>(undefined);806855807856 return yield* Effect.gen(function* () {808857 const result = yield* prepared.acp809858 .prompt({810859 prompt: prepared.promptParts,811860 })812861 .pipe(862+ Effect.tapError((error) =>863+ Ref.set(864+ promptFailureMessageRef,865+ mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error).message,866+ ),867+ ),
- apps/server/src/provider/Layers/GrokAdapter.ts line 1179Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -851,4 +910,17 @@851- // Only the last remaining prompt settles the turn — a steer-852- // superseded prompt resolving (usually cancelled) while another853- // is in flight or pending must leave the merged turn running.854- if (ctx.promptsInFlight === 1) {910+ // Only the last remaining prompt settles the turn. A steer-911+ // superseded prompt resolving while another is in flight or912+ // pending must leave the merged turn running.913+ if (914+ remainingPrompts === 0 &&915+ ctx.activeTurnId === prepared.turnId &&916+ ctx.session.activeTurnId === prepared.turnId917+ ) {918+ const completedAt = yield* nowIso;919+ const { activeTurnId: _completedTurnId, ...readySession } = ctx.session;920+ ctx.activeTurnId = undefined;921+ ctx.session = {922+ ...readySession,923+ status: "ready",924+ updatedAt: completedAt,925+ ...(prepared.displayModel ? { model: prepared.displayModel } : {}),926+ };
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/provider/Layers/GrokAdapter.ts line 1259Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -874,9 +958,14 @@874958 );875959 }).pipe(876960 Effect.ensuring(877- Effect.sync(() => {878- const liveCtx = sessions.get(input.threadId);879- if (liveCtx) {880- liveCtx.promptsInFlight = Math.max(0, liveCtx.promptsInFlight - 1);961+ Effect.gen(function* () {962+ if (yield* Ref.get(promptSettled)) {963+ return;881964 }882- }),965+966+ if (yield* Ref.get(promptRpcSucceeded)) {967+ yield* withThreadLock(968+ input.threadId,969+ settlePromptInFlight(input.threadId, prepared.turnId),970+ );971+ return;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/GrokAdapter.ts line 148OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -140,3 +144,5 @@140144 return typeof value === "object" && value !== null && !Array.isArray(value);141145 }142146147+const resolveNotificationTurnId = (ctx: GrokSessionContext): TurnId | undefined =>148+ ctx.activeTurnId ?? ctx.streamingTurnId;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- packages/client-runtime/src/state/threadReducer.ts line 214OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -195,13 +195,20 @@195+ const turnChanged =196+ existingMessage?.turnId !== undefined &&197+ message.turnId !== null &&198+ existingMessage.turnId !== message.turnId;195199 const messages = existingMessage196200 ? Arr.map(thread.messages, (entry) =>197201 entry.id !== message.id198202 ? entry199203 : {200204 ...entry,201205 text: message.streaming202- ? `${entry.text}${message.text}`206+ ? turnChanged207+ ? message.text208+ : `${entry.text}${message.text}`203209 : message.text.length > 0204210 ? message.text205211 : entry.text,206212 streaming: message.streaming,207213 ...(message.turnId !== undefined ? { turnId: message.turnId } : {}),214+ ...(turnChanged ? { createdAt: message.createdAt } : {}),
mwolson(GitHub profile, opens in a new tab) changed the title
- apps/web/src/hooks/useRafThrottledValue.ts lines 34 to 39OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +19,21 @@19+ frameRef.current = null;20+ }21+ setDisplayed(value);22+ return;23+ }24+25+ if (frameRef.current !== null) {26+ return;27+ }28+29+ frameRef.current = requestAnimationFrame(() => {30+ frameRef.current = null;31+ setDisplayed(latestRef.current);32+ });33+34+ return () => {35+ if (frameRef.current !== null) {36+ cancelAnimationFrame(frameRef.current);37+ frameRef.current = null;38+ }39+ };
- apps/server/src/orchestration/Layers/ProjectionPipeline.ts line 827OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -816,8 +816,12 @@816816 messageId: event.payload.messageId,817817 });818818 const previousMessage = Option.getOrUndefined(existingMessage);819+ const turnChanged =820+ previousMessage?.turnId !== undefined &&821+ event.payload.turnId !== null &&822+ previousMessage.turnId !== event.payload.turnId;819823 const nextText = Option.match(existingMessage, {820824 onNone: () => event.payload.text,821825 onSome: (message) => {822826 if (event.payload.streaming) {823- return `${message.text}${event.payload.text}`;827+ return turnChanged ? event.payload.text : `${message.text}${event.payload.text}`;
- apps/server/src/orchestration/projector.ts line 417OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -413,20 +417 @@413- const messages = existingMessage414- ? thread.messages.map((entry) =>415- entry.id === message.id416- ? {417- ...entry,418- text: message.streaming419- ? `${entry.text}${message.text}`420- : message.text.length > 0421- ? message.text422- : entry.text,423- streaming: message.streaming,424- updatedAt: message.updatedAt,425- turnId: message.turnId,426- ...(message.attachments !== undefined427- ? { attachments: message.attachments }428- : {}),429- }430- : entry,431- )432- : [...thread.messages, message];417+ const messages = isLateStreamingOnCompletedAssistant({apps/server/src/provider/Layers/GrokAdapter.ts lines 297 to 433Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -242,0 +273,21 @@273+ liveCtx.streamingTurnId = turnId;274+ liveCtx.activeTurnId = undefined;275+ liveCtx.session = {276+ ...readySession,277+ status: "ready",278+ updatedAt,279+ };280+ if (shouldEmitFailedTurn) {281+ yield* offerRuntimeEvent({282+ type: "turn.completed",283+ ...(yield* makeEventStamp()),284+ provider: PROVIDER,285+ threadId,286+ turnId,287+ payload: {288+ state: "failed",289+ errorMessage: options.errorMessage,290+ },291+ });292+ }293+ });apps/server/src/provider/acp/AcpSessionRuntime.ts line 555OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -499,9 +545,11 @@499545 cwd: options.cwd,500546 mcpServers: options.mcpServers ?? [],501547 } satisfies EffectAcpSchema.LoadSessionRequest;548+ const sessionLoadTimeout = Duration.fromInputUnsafe(549+ options.sessionLoadTimeout ?? defaultSessionLoadTimeout,550+ );502551 const resumed = yield* runLoggedRequest(503552 "session/load",504553 loadPayload,505554 acp.agent.loadSession(loadPayload),506- ).pipe(Effect.exit);507- if (Exit.isSuccess(resumed)) {555+ ).pipe(Effect.timeoutOption(sessionLoadTimeout), Effect.exit);apps/server/src/provider/acp/AcpSessionRuntime.ts lines 51 to 54OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -32,3 +35,20 @@3235 return JSON.stringify(value);3336 }343738+const XAiPromptCompleteNotification = Schema.Struct({39+ sessionId: Schema.String,40+ promptId: Schema.optional(Schema.String),41+ stopReason: Schema.optional(Schema.String),42+ agentResult: Schema.optional(Schema.NullOr(Schema.Unknown)),43+});44+45+type XAiPromptCompleteNotification = typeof XAiPromptCompleteNotification.Type;46+47+const decodeXAiPromptCompleteNotification = Schema.decodeUnknownEffect(48+ XAiPromptCompleteNotification,49+);50+51+interface PendingXAiPromptCompletion {52+ readonly sessionId: string;53+ readonly deferred: Deferred.Deferred<EffectAcpSchema.PromptResponse>;54+}apps/server/src/provider/acp/AcpSessionRuntime.ts line 1005OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -857,0 +985,21 @@985+ }).pipe(Effect.flatten);986+ }),987+ );988+989+const rememberCompletedXAiPromptId = (990+ completedPromptIdsRef: Ref.Ref<ReadonlyArray<string>>,991+ response: EffectAcpSchema.PromptResponse,992+) => {993+ const promptId = promptIdFromResponse(response);994+ if (promptId === undefined) {995+ return Effect.void;996+ }997+ return Ref.update(completedPromptIdsRef, (completedPromptIds) => {998+ if (completedPromptIds.includes(promptId)) {999+ return completedPromptIds;1000+ }1001+ return [...completedPromptIds, promptId].slice(-completedXAiPromptIdLimit);1002+ });1003+};1004+1005+function promptIdFromResponse(response: EffectAcpSchema.PromptResponse): string | undefined {apps/server/src/provider/Layers/GrokAdapter.ts line 920OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -843,7 +910,11 @@843910 ];844911 ctx.session = {845912 ...ctx.session,913+ status: "running",846914 activeTurnId: prepared.turnId,847915 updatedAt: yield* nowIso,848916 ...(prepared.displayModel ? { model: prepared.displayModel } : {}),849917 };918+ const remainingPrompts = Math.max(0, ctx.promptsInFlight - 1);919+ ctx.promptsInFlight = remainingPrompts;920+ yield* Ref.set(promptSettled, true);apps/server/src/orchestration/Layers/ProjectionPipeline.ts line 819OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -816,4 +820,19 @@816820 messageId: event.payload.messageId,817821 });818822 const previousMessage = Option.getOrUndefined(existingMessage);823+ if (824+ isLateStreamingOnCompletedAssistant({825+ existing: previousMessage,826+ incoming: {827+ role: event.payload.role,828+ streaming: event.payload.streaming,829+ turnId: event.payload.turnId,830+ },831+ })832+ ) {833+ return;834+ }835+ const turnChanged = assistantSegmentTurnChanged(previousMessage, {836+ turnId: event.payload.turnId,837+ });819838 const nextText = Option.match(existingMessage, {
- apps/server/src/provider/Layers/GrokAdapter.ts line 920OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -843,7 +910,11 @@843910 ];844911 ctx.session = {845912 ...ctx.session,913+ status: "running",846914 activeTurnId: prepared.turnId,847915 updatedAt: yield* nowIso,848916 ...(prepared.displayModel ? { model: prepared.displayModel } : {}),849917 };918+ const remainingPrompts = Math.max(0, ctx.promptsInFlight - 1);919+ ctx.promptsInFlight = remainingPrompts;920+ yield* Ref.set(promptSettled, true);apps/server/src/provider/Layers/GrokAdapter.ts line 1047Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -778,20 +833,10 @@778833779- if (steeringTurnId === undefined) {780- yield* offerRuntimeEvent({781- type: "turn.started",782- ...(yield* makeEventStamp()),783- provider: PROVIDER,784- threadId: input.threadId,785- turnId,786- payload: displayModel ? { model: displayModel } : {},787- });788- }789-790834 return {791835 acp: ctx.acp,792836 acpSessionId: ctx.acpSessionId,793837 displayModel,794838 promptParts,795839 turnId,840+ emitTurnStarted: steeringTurnId === undefined,796841 };797842 }).pipe(
- packages/shared/src/orchestrationMessages.ts lines 7 to 11OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,11 @@1+type AssistantSegmentMessage = {2+ readonly role: string;3+ readonly streaming: boolean;4+ readonly turnId: string | null;5+};6+7+export function assistantSegmentTurnChanged(8+ existing: Pick<AssistantSegmentMessage, "turnId"> | undefined,9+ incoming: Pick<AssistantSegmentMessage, "turnId">,10+): boolean {11+ return existing !== undefined && incoming.turnId != null && existing.turnId !== incoming.turnId;apps/server/src/orchestration/projector.ts line 419OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -415,18 +417,3 @@415- entry.id === message.id416- ? {417- ...entry,418- text: message.streaming419- ? `${entry.text}${message.text}`420- : message.text.length > 0421- ? message.text422- : entry.text,423- streaming: message.streaming,424- updatedAt: message.updatedAt,425- turnId: message.turnId,426- ...(message.attachments !== undefined427- ? { attachments: message.attachments }428- : {}),429- }430- : entry,431- )432- : [...thread.messages, message];417+ const messages = isLateStreamingOnCompletedAssistant({418+ existing: existingMessage,419+ incoming: message,
- apps/server/src/provider/acp/AcpSessionRuntime.ts line 620Resolvedby mwolson(GitHub profile, opens in a new tab)@@ -522,0 +622,21 @@622+ ),623+ Effect.tap((result) =>624+ logRequest({625+ method: "session/load",626+ payload: loadPayload,627+ status: "succeeded",628+ result,629+ }),630+ ),631+ Effect.onError((cause) =>632+ logRequest({633+ method: "session/load",634+ payload: loadPayload,635+ status: "failed",636+ cause,637+ }),638+ ),639+ );640+641+ return loaded;642+ }).pipe(Effect.ensuring(Ref.set(sessionLoadGateRef, Option.none())));apps/server/src/provider/Layers/GrokAdapter.ts line 845OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -765,3 +839,7 @@765839 const displayModel = currentModelId766840 ? resolveGrokAcpBaseModelId(currentModelId)767841 : undefined;842+ for (let yieldAttempt = 0; yieldAttempt < 8; yieldAttempt += 1) {843+ yield* Effect.yieldNow;844+ }845+ ctx.streamingTurnId = undefined;
- apps/server/src/orchestration/projector.ts line 422OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -418,15 +417,6 @@418- text: message.streaming419- ? `${entry.text}${message.text}`420- : message.text.length > 0421- ? message.text422- : entry.text,423- streaming: message.streaming,424- updatedAt: message.updatedAt,425- turnId: message.turnId,426- ...(message.attachments !== undefined427- ? { attachments: message.attachments }428- : {}),429- }430- : entry,431- )432- : [...thread.messages, message];417+ const messages = isLateStreamingOnCompletedAssistant({418+ existing: existingMessage,419+ incoming: message,420+ })421+ ? thread.messages422+ : (() => {apps/server/src/provider/acp/AcpRuntimeModel.ts line 490Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -416,0 +434,21 @@434+ readonly gateRef: Ref.Ref<Option.Option<SessionLoadGate>>;435+}): Effect.Effect<EffectAcpSchema.LoadSessionResponse, never> =>436+ Effect.gen(function* () {437+ const pollInterval = Duration.millis(25);438+ while (true) {439+ const gate = yield* Ref.get(input.gateRef);440+ if (441+ Option.isSome(gate) &&442+ gate.value.active &&443+ gate.value.lastActivityAtMillis !== undefined444+ ) {445+ const idleGapMillis = Duration.toMillis(gate.value.idleGap);446+ if (Date.now() - gate.value.lastActivityAtMillis >= idleGapMillis) {447+ return syntheticLoadSessionResponseFromInitialize(gate.value.initializeResult);448+ }449+ }450+ yield* Effect.sleep(pollInterval);451+ }452+ });453+454+export function syntheticLoadSessionResponseFromInitialize(apps/server/src/provider/acp/AcpSessionRuntime.ts line 359Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -331,3 +373,3 @@331373 const acp = yield* Effect.service(EffectAcpClient.AcpClient).pipe(Effect.provide(acpContext));332374333375 yield* acp.handleSessionUpdate((notification) =>
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/provider/acp/AcpSessionRuntime.ts line 1032OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -856,2 +1012,21 @@8561012 ] as const;8571013 }).pipe(Effect.flatMap((event) => (event ? Queue.offer(queue, event) : Effect.void)));1014+1015+const registerXAiPromptCompletionFallback = (1016+ pendingRef: Ref.Ref<ReadonlyArray<PendingXAiPromptCompletion>>,1017+ sessionId: string,1018+ promptId: string,1019+) =>1020+ Deferred.make<EffectAcpSchema.PromptResponse>().pipe(1021+ Effect.tap((deferred) =>1022+ Ref.update(pendingRef, (pending) => [...pending, { sessionId, promptId, deferred }]),1023+ ),1024+ Effect.map((deferred) => ({ deferred, promptId })),1025+ );1026+1027+const unregisterXAiPromptCompletionFallback = (1028+ pendingRef: Ref.Ref<ReadonlyArray<PendingXAiPromptCompletion>>,1029+ deferred: Deferred.Deferred<EffectAcpSchema.PromptResponse>,1030+) => Ref.update(pendingRef, (pending) => pending.filter((entry) => entry.deferred !== deferred));1031+1032+const resolveXAiPromptCompletionFallback = ({apps/server/src/provider/Layers/GrokAdapter.ts lines 267 to 275OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -242,0 +255,21 @@255+ readonly errorMessage?: string;256+ readonly completedStopReason?: EffectAcpSchema.StopReason | null;257+ },258+ ) =>259+ Effect.gen(function* () {260+ const liveCtx = sessions.get(threadId);261+ if (!liveCtx) {262+ return;263+ }264+ if (liveCtx.acpSessionId !== expectedAcpSessionId) {265+ return;266+ }267+ const remainingPrompts = Math.max(0, liveCtx.promptsInFlight - 1);268+ liveCtx.promptsInFlight = remainingPrompts;269+ if (270+ remainingPrompts > 0 ||271+ liveCtx.activeTurnId !== turnId ||272+ liveCtx.session.activeTurnId !== turnId273+ ) {274+ return;275+ }
- apps/server/src/provider/Layers/GrokAdapter.ts line 148OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -140,3 +144,5 @@140144 return typeof value === "object" && value !== null && !Array.isArray(value);141145 }142146147+const resolveNotificationTurnId = (ctx: GrokSessionContext): TurnId | undefined =>148+ ctx.streamingTurnId ?? ctx.activeTurnId;apps/server/src/provider/Layers/GrokAdapter.ts line 1179Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -854,0 +957,21 @@957+ // Only the last remaining prompt settles the turn. A steer-958+ // superseded prompt resolving while another is in flight or959+ // pending must leave the merged turn running.960+ if (961+ remainingPrompts === 0 &&962+ ctx.activeTurnId === prepared.turnId &&963+ ctx.session.activeTurnId === prepared.turnId964+ ) {965+ for (let yieldAttempt = 0; yieldAttempt < 8; yieldAttempt += 1) {966+ yield* Effect.yieldNow;967+ }968+ const completedAt = yield* nowIso;969+ const { activeTurnId: _completedTurnId, ...readySession } = ctx.session;970+ ctx.streamingTurnId = prepared.turnId;971+ ctx.activeTurnId = undefined;972+ ctx.session = {973+ ...readySession,974+ status: "ready",975+ updatedAt: completedAt,976+ ...(prepared.displayModel ? { model: prepared.displayModel } : {}),977+ };
- apps/server/src/provider/Layers/GrokAdapter.ts line 1274Resolvedby mwolson(GitHub profile, opens in a new tab)@@ -883,5 +1012,20 @@1012+ settlePromptInFlight(input.threadId, prepared.turnId, prepared.acpSessionId, {1013+ completedStopReason: promptResult?.stopReason ?? null,1014+ }),1015+ );1016+ return;1017+ }1018+1019+ const errorMessage = yield* Ref.get(promptFailureMessageRef);1020+ yield* withThreadLock(1021+ input.threadId,1022+ settlePromptInFlight(input.threadId, prepared.turnId, prepared.acpSessionId, {1023+ errorMessage: errorMessage ?? "Grok prompt request failed.",1024+ }),1025+ );1026+ }).pipe(Effect.catch(() => Effect.void)),8831027 ),8841028 );8851029 });8861030887- const interruptTurn: GrokAdapterShape["interruptTurn"] = (threadId) =>1031+ const interruptTurn: GrokAdapterShape["interruptTurn"] = (threadId, turnId) =>apps/server/src/provider/acp/AcpSessionRuntime.ts line 402OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -340,2 +382,21 @@382+ sessionLoadGateRef,383+ Option.some({384+ ...gate.value,385+ lastActivityAtMillis,386+ }),387+ );388+ return;389+ }390+ if (sessionUpdateIsReplay(notification)) {391+ return;392+ }393+ yield* handleSessionUpdate({394+ queue: eventQueue,395+ modeStateRef,396+ toolCallsRef,397+ assistantSegmentRef,398+ params: notification,399+ });340400 }),341401 );402+ yield* acp.handleUnknownExtNotification((method, payload) => {
- apps/mobile/src/lib/threadActivity.ts line 1262OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -1259,4 +1259,4 @@12591259 ...loadedMessages.map<RawThreadFeedEntry>((message) => ({12601260 type: "message",12611261 id: message.id,1262- createdAt: message.createdAt,1262+ createdAt: message.role === "assistant" ? message.updatedAt : message.createdAt,
- apps/server/src/orchestration/projector.ts line 417OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -412,19 +416,2 @@412- const existingMessage = thread.messages.find((entry) => entry.id === message.id);413- const messages = existingMessage414- ? thread.messages.map((entry) =>415- entry.id === message.id416- ? {417- ...entry,418- text: message.streaming419- ? `${entry.text}${message.text}`420- : message.text.length > 0421- ? message.text422- : entry.text,423- streaming: message.streaming,424- updatedAt: message.updatedAt,425- turnId: message.turnId,426- ...(message.attachments !== undefined427- ? { attachments: message.attachments }428- : {}),429- }430- : entry,416+ const applied = applyAssistantSegmentMessageUpdate(thread.messages, message);417+ const cappedMessages = applied.messages.slice(-MAX_THREAD_MESSAGES);
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
e88888ef-ddd4-4d21-8038-d79d0f20e24eYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share