fix(prompt-gate): share message reservations
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
promptSyncWithModelSuggestionRetry,
|
||||
promptWithModelSuggestionRetry,
|
||||
} from "./model-suggestion-retry"
|
||||
import { promptAsyncAfterSessionIdle } from "./prompt-async-gate"
|
||||
|
||||
type OpencodeClient = PluginInput["client"]
|
||||
|
||||
@@ -52,7 +53,28 @@ export function promptAsyncInDirectory(
|
||||
args: PromptAsyncArgs,
|
||||
directory: string,
|
||||
): Promise<unknown> {
|
||||
return client.session.promptAsync(routeSessionPrompt(args, directory))
|
||||
const routedArgs = routeSessionPrompt(args, directory)
|
||||
const sessionID = routedArgs.path?.id
|
||||
if (!sessionID) {
|
||||
return client.session.promptAsync(routedArgs)
|
||||
}
|
||||
|
||||
return promptAsyncAfterSessionIdle({
|
||||
client,
|
||||
sessionID,
|
||||
input: routedArgs,
|
||||
source: "session-route",
|
||||
settleMs: 0,
|
||||
postDispatchHoldMs: 0,
|
||||
}).then((result) => {
|
||||
if (result.status === "failed") {
|
||||
throw result.error
|
||||
}
|
||||
if (result.status !== "dispatched") {
|
||||
throw new Error(`promptAsync skipped by gate: ${result.status}`)
|
||||
}
|
||||
return result.response
|
||||
})
|
||||
}
|
||||
|
||||
export function promptWithRetryInDirectory(
|
||||
|
||||
Reference in New Issue
Block a user