fix full-suite isolation regressions
This commit is contained in:
@@ -11,9 +11,24 @@ type PromptContext = {
|
||||
tools?: Record<string, boolean>
|
||||
}
|
||||
|
||||
type RecentPromptContextDeps = {
|
||||
isSqliteBackend: typeof isSqliteBackend
|
||||
getMessageDir: typeof getMessageDir
|
||||
findNearestMessageWithFields: typeof findNearestMessageWithFields
|
||||
findNearestMessageWithFieldsFromSDK: typeof findNearestMessageWithFieldsFromSDK
|
||||
}
|
||||
|
||||
const defaultDeps: RecentPromptContextDeps = {
|
||||
isSqliteBackend,
|
||||
getMessageDir,
|
||||
findNearestMessageWithFields,
|
||||
findNearestMessageWithFieldsFromSDK,
|
||||
}
|
||||
|
||||
export async function resolveRecentPromptContextForSession(
|
||||
ctx: PluginInput,
|
||||
sessionID: string
|
||||
sessionID: string,
|
||||
deps: RecentPromptContextDeps = defaultDeps,
|
||||
): Promise<PromptContext> {
|
||||
try {
|
||||
const messagesResp = await ctx.client.session.messages({ path: { id: sessionID } })
|
||||
@@ -59,11 +74,11 @@ export async function resolveRecentPromptContextForSession(
|
||||
}
|
||||
|
||||
let currentMessage = null
|
||||
if (isSqliteBackend()) {
|
||||
currentMessage = await findNearestMessageWithFieldsFromSDK(ctx.client, sessionID)
|
||||
if (deps.isSqliteBackend()) {
|
||||
currentMessage = await deps.findNearestMessageWithFieldsFromSDK(ctx.client, sessionID)
|
||||
} else {
|
||||
const messageDir = getMessageDir(sessionID)
|
||||
currentMessage = messageDir ? findNearestMessageWithFields(messageDir) : null
|
||||
const messageDir = deps.getMessageDir(sessionID)
|
||||
currentMessage = messageDir ? deps.findNearestMessageWithFields(messageDir) : null
|
||||
}
|
||||
const model = currentMessage?.model
|
||||
const tools = normalizePromptTools(currentMessage?.tools)
|
||||
|
||||
Reference in New Issue
Block a user