fix: emit session:reset hook before transcript archival
This commit is contained in:
parent
a54be14070
commit
9cabdeff38
@ -558,6 +558,25 @@ export async function initSessionState(params: {
|
||||
},
|
||||
);
|
||||
|
||||
// When a session is auto-reset (idle timeout or daily reset), emit a
|
||||
// session:reset internal hook so the session-memory hook can persist
|
||||
// the outgoing session context — just as it does for manual /new and /reset.
|
||||
// This MUST fire before archiveSessionTranscripts() so the handler can still
|
||||
// read the original transcript file (which archival renames).
|
||||
if (isNewSession && !resetTriggered && previousSessionEntry) {
|
||||
const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
|
||||
const autoResetEvent = createInternalHookEvent("session", "reset", sessionKey, {
|
||||
sessionEntry,
|
||||
previousSessionEntry,
|
||||
commandSource: "auto-reset",
|
||||
workspaceDir,
|
||||
cfg,
|
||||
});
|
||||
void triggerInternalHook(autoResetEvent).catch((err) => {
|
||||
log.debug("session:reset hook error (auto-reset)", { error: String(err) });
|
||||
});
|
||||
}
|
||||
|
||||
// Archive old transcript so it doesn't accumulate on disk (#14869).
|
||||
if (previousSessionEntry?.sessionId) {
|
||||
archiveSessionTranscripts({
|
||||
@ -586,23 +605,6 @@ export async function initSessionState(params: {
|
||||
IsNewSession: isNewSession ? "true" : "false",
|
||||
};
|
||||
|
||||
// When a session is auto-reset (idle timeout or daily reset), emit a
|
||||
// session:reset internal hook so the session-memory hook can persist
|
||||
// the outgoing session context — just as it does for manual /new and /reset.
|
||||
if (isNewSession && !resetTriggered && previousSessionEntry) {
|
||||
const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
|
||||
const autoResetEvent = createInternalHookEvent("session", "reset", sessionKey, {
|
||||
sessionEntry,
|
||||
previousSessionEntry,
|
||||
commandSource: "auto-reset",
|
||||
workspaceDir,
|
||||
cfg,
|
||||
});
|
||||
void triggerInternalHook(autoResetEvent).catch((err) => {
|
||||
log.debug("session:reset hook error (auto-reset)", { error: String(err) });
|
||||
});
|
||||
}
|
||||
|
||||
// Run session plugin hooks (fire-and-forget)
|
||||
const hookRunner = getGlobalHookRunner();
|
||||
if (hookRunner && isNewSession) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user