fix(hooks): backfill reset command hooks for native /new path
This commit is contained in:
committed by
Peter Steinberger
parent
bbdf895d42
commit
aec41a588b
@@ -16,6 +16,7 @@ import { resolveCommandAuthorization } from "../command-auth.js";
|
||||
import type { MsgContext } from "../templating.js";
|
||||
import { SILENT_REPLY_TOKEN } from "../tokens.js";
|
||||
import type { GetReplyOptions, ReplyPayload } from "../types.js";
|
||||
import { emitResetCommandHooks, type ResetCommandAction } from "./commands-core.js";
|
||||
import { resolveDefaultModel } from "./directive-handling.js";
|
||||
import { resolveReplyDirectives } from "./get-reply-directives.js";
|
||||
import { handleInlineActions } from "./get-reply-inline-actions.js";
|
||||
@@ -272,6 +273,27 @@ export async function getReplyFromConfig(
|
||||
provider = resolvedProvider;
|
||||
model = resolvedModel;
|
||||
|
||||
const maybeEmitMissingResetHooks = async () => {
|
||||
if (!resetTriggered || !command.isAuthorizedSender || command.resetHookTriggered) {
|
||||
return;
|
||||
}
|
||||
const resetMatch = command.commandBodyNormalized.match(/^\/(new|reset)(?:\s|$)/);
|
||||
if (!resetMatch) {
|
||||
return;
|
||||
}
|
||||
const action: ResetCommandAction = resetMatch[1] === "reset" ? "reset" : "new";
|
||||
await emitResetCommandHooks({
|
||||
action,
|
||||
ctx,
|
||||
cfg,
|
||||
command,
|
||||
sessionKey,
|
||||
sessionEntry,
|
||||
previousSessionEntry,
|
||||
workspaceDir,
|
||||
});
|
||||
};
|
||||
|
||||
const inlineActionResult = await handleInlineActions({
|
||||
ctx,
|
||||
sessionCtx,
|
||||
@@ -311,8 +333,10 @@ export async function getReplyFromConfig(
|
||||
skillFilter: mergedSkillFilter,
|
||||
});
|
||||
if (inlineActionResult.kind === "reply") {
|
||||
await maybeEmitMissingResetHooks();
|
||||
return inlineActionResult.reply;
|
||||
}
|
||||
await maybeEmitMissingResetHooks();
|
||||
directives = inlineActionResult.directives;
|
||||
abortedLastRun = inlineActionResult.abortedLastRun ?? abortedLastRun;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user