fix(team-mode): close peer message delivery races

This commit is contained in:
YeonGyu-Kim
2026-05-19 18:23:57 +09:00
parent bcea4a9d28
commit b2918fd4db
13 changed files with 492 additions and 47 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ import {
settleAfterSessionIdle,
} from "./session-idle-settle"
export const DEFAULT_PROMPT_ASYNC_POST_DISPATCH_HOLD_MS = 250
export const DEFAULT_PROMPT_ASYNC_POST_DISPATCH_HOLD_MS = 2_000
export const DEFAULT_PROMPT_DISPATCH_TIMEOUT_MS = 30_000
export const DEFAULT_PROMPT_GATE_MESSAGES_FETCH_TIMEOUT_MS = 5_000
export const DEFAULT_PROMPT_QUEUE_RETRY_MS = 250
@@ -420,7 +420,7 @@ function latestAssistantTurnBlocksInternalPrompt(messages: unknown[]): boolean {
const role = messageRole(message)
if (role === "assistant") {
const finish = messageFinish(message)
if (finish === undefined) {
if (finish === undefined || finish === "unknown") {
return true
}
if (!isRecord(message) || !Array.isArray(message.parts)) {
@@ -344,6 +344,9 @@ await dispatchInternalPrompt(options)
}
const contents = await readFile(filePath, "utf8")
if (!contents.includes("prompt")) {
continue
}
if (detectRawPromptInSnippet(contents)) {
offenders.push(relativeSourcePath(filePath))
}
@@ -395,6 +398,9 @@ await dispatchInternalPrompt(options)
// when
for (const filePath of files) {
const contents = await readFile(filePath, "utf8")
if (!contents.includes("dispatchInternalPrompt")) {
continue
}
const missingLines = findPromptGateCallsWithoutQueueBehavior(filePath, contents)
for (const line of missingLines) {
offenders.push(`${relativeSourcePath(filePath)}:${line}`)
@@ -413,6 +419,12 @@ await dispatchInternalPrompt(options)
// when
for (const filePath of files) {
const contents = await readFile(filePath, "utf8")
if (
!contents.includes("promptWithModelSuggestionRetry")
&& !contents.includes("promptSyncWithModelSuggestionRetry")
) {
continue
}
const missingLines = findPromptRetryCallsWithoutQueueBehavior(filePath, contents)
for (const line of missingLines) {
offenders.push(`${relativeSourcePath(filePath)}:${line}`)