openclaw/src/discord/monitor/thread-bindings.persona.test.ts
Onur Solmaz a7929abad8
Discord: thread bindings idle + max-age lifecycle (#27845) (thanks @osolmaz)
* refactor discord thread bindings to idle and max-age lifecycle

* fix: migrate legacy thread binding expiry and reduce hot-path disk writes

* refactor: remove remaining thread-binding ttl legacy paths

* fix: harden thread-binding lifecycle persistence

* Discord: fix thread binding types in message/reply paths

* Infra: handle win32 unknown inode in file identity checks

* Infra: relax win32 guarded-open identity checks

* Config: migrate threadBindings ttlHours to idleHours

* Revert "Infra: relax win32 guarded-open identity checks"

This reverts commit de94126771db072ecda6a014e80700310e76df61.

* Revert "Infra: handle win32 unknown inode in file identity checks"

This reverts commit 96fc5ddfb39762aa078d70dd4b4d3754e49a159b.

* Discord: re-read live binding state before sweep unbind

* fix: add changelog note for thread binding lifecycle update (#27845) (thanks @osolmaz)

---------

Co-authored-by: Onur Solmaz <onur@textcortex.com>
2026-02-27 10:02:39 +01:00

35 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
resolveThreadBindingPersona,
resolveThreadBindingPersonaFromRecord,
} from "./thread-bindings.persona.js";
import type { ThreadBindingRecord } from "./thread-bindings.types.js";
describe("thread binding persona", () => {
it("prefers explicit label and prefixes with gear", () => {
expect(resolveThreadBindingPersona({ label: "codex thread", agentId: "codex" })).toBe(
"⚙️ codex thread",
);
});
it("falls back to agent id when label is missing", () => {
expect(resolveThreadBindingPersona({ agentId: "codex" })).toBe("⚙️ codex");
});
it("builds persona from binding record", () => {
const record = {
accountId: "default",
channelId: "parent-1",
threadId: "thread-1",
targetKind: "acp",
targetSessionKey: "agent:codex:acp:session-1",
agentId: "codex",
boundBy: "system",
boundAt: Date.now(),
lastActivityAt: Date.now(),
label: "codex-thread",
} satisfies ThreadBindingRecord;
expect(resolveThreadBindingPersonaFromRecord(record)).toBe("⚙️ codex-thread");
});
});