fix(delegate-task): start sync prompts asynchronously
This commit is contained in:
@@ -4,17 +4,17 @@ import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
|
||||
import type { OpencodeClient } from "./types"
|
||||
import { sendSyncPrompt } from "./sync-prompt-sender"
|
||||
import {
|
||||
promptSyncWithModelSuggestionRetry,
|
||||
promptWithModelSuggestionRetry,
|
||||
} from "../../shared/model-suggestion-retry"
|
||||
|
||||
type PromptSyncRetryClient = Parameters<typeof promptSyncWithModelSuggestionRetry>[0]
|
||||
type PromptSyncRetryArgs = Parameters<typeof promptSyncWithModelSuggestionRetry>[1]
|
||||
type PromptRetryClient = Parameters<typeof promptWithModelSuggestionRetry>[0]
|
||||
type PromptRetryArgs = Parameters<typeof promptWithModelSuggestionRetry>[1]
|
||||
|
||||
describe("sendSyncPrompt session routing", () => {
|
||||
test("#given a sync child session directory #when sending the prompt #then prompt uses that OpenCode directory route", async () => {
|
||||
// given
|
||||
const promptCalls: PromptSyncRetryArgs[] = []
|
||||
const promptSyncWithRetry = mock(async (_client: PromptSyncRetryClient, input: PromptSyncRetryArgs) => {
|
||||
const promptCalls: PromptRetryArgs[] = []
|
||||
const promptWithRetry = mock(async (_client: PromptRetryClient, input: PromptRetryArgs) => {
|
||||
promptCalls.push(input)
|
||||
})
|
||||
|
||||
@@ -37,7 +37,7 @@ describe("sendSyncPrompt session routing", () => {
|
||||
taskId: undefined,
|
||||
},
|
||||
{
|
||||
promptSyncWithModelSuggestionRetry: promptSyncWithRetry,
|
||||
promptWithModelSuggestionRetry: promptWithRetry,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -48,9 +48,9 @@ describe("sendSyncPrompt session routing", () => {
|
||||
|
||||
test("#given oracle prompt returns unexpected EOF #when sending the prompt #then the sync route keeps the same directory route", async () => {
|
||||
// given
|
||||
const promptSyncCalls: PromptSyncRetryArgs[] = []
|
||||
const promptSyncWithRetry = mock(async (_client: PromptSyncRetryClient, input: PromptSyncRetryArgs) => {
|
||||
promptSyncCalls.push(input)
|
||||
const promptCalls: PromptRetryArgs[] = []
|
||||
const promptWithRetry = mock(async (_client: PromptRetryClient, input: PromptRetryArgs) => {
|
||||
promptCalls.push(input)
|
||||
throw new Error("JSON Parse error: Unexpected EOF")
|
||||
})
|
||||
|
||||
@@ -73,13 +73,13 @@ describe("sendSyncPrompt session routing", () => {
|
||||
taskId: undefined,
|
||||
},
|
||||
{
|
||||
promptSyncWithModelSuggestionRetry: promptSyncWithRetry,
|
||||
promptWithModelSuggestionRetry: promptWithRetry,
|
||||
},
|
||||
)
|
||||
|
||||
// then
|
||||
expect(result).toBeNull()
|
||||
expect(promptSyncCalls).toHaveLength(1)
|
||||
expect(promptSyncCalls[0]?.query).toEqual({ directory: "/parent/project" })
|
||||
expect(promptCalls).toHaveLength(1)
|
||||
expect(promptCalls[0]?.query).toEqual({ directory: "/parent/project" })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user