fix(hooks): store a hook delivered twice only once
A doubled hook registration (plugin + leftover checkout install) POSTs every event twice with a byte-identical payload, so the timeline showed each row twice and token/alert/lane side effects ran twice. POST /api/hooks/event now skips a payload identical to the session's LATEST event from the last 10s (findRecentDuplicateEvent). Latest-only keeps two legitimately identical Stop events of consecutive turns, which always have other events between.
This commit is contained in:
@@ -172,7 +172,7 @@ describe("hook ingestor — sessions.name sync from transcript", () => {
|
||||
]);
|
||||
await req("POST", "/api/hooks/event", {
|
||||
hook_type: "Stop",
|
||||
data: { session_id: sid, cwd, transcript_path: tpath },
|
||||
data: { session_id: sid, cwd, transcript_path: tpath, turn: 1 },
|
||||
});
|
||||
assert.equal(stmts.getSession.get(sid).name, "keep-me");
|
||||
|
||||
@@ -184,7 +184,7 @@ describe("hook ingestor — sessions.name sync from transcript", () => {
|
||||
]);
|
||||
await req("POST", "/api/hooks/event", {
|
||||
hook_type: "Stop",
|
||||
data: { session_id: sid, cwd, transcript_path: tpath },
|
||||
data: { session_id: sid, cwd, transcript_path: tpath, turn: 2 },
|
||||
});
|
||||
assert.equal(stmts.getSession.get(sid).name, "renamed-explicitly");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user