refactor: prune legacy group targets
This commit is contained in:
@@ -40,43 +40,43 @@ describe("history helpers", () => {
|
||||
|
||||
appendHistoryEntry({
|
||||
historyMap,
|
||||
historyKey: "room",
|
||||
historyKey: "group",
|
||||
limit: 2,
|
||||
entry: { sender: "A", body: "one" },
|
||||
});
|
||||
appendHistoryEntry({
|
||||
historyMap,
|
||||
historyKey: "room",
|
||||
historyKey: "group",
|
||||
limit: 2,
|
||||
entry: { sender: "B", body: "two" },
|
||||
});
|
||||
appendHistoryEntry({
|
||||
historyMap,
|
||||
historyKey: "room",
|
||||
historyKey: "group",
|
||||
limit: 2,
|
||||
entry: { sender: "C", body: "three" },
|
||||
});
|
||||
|
||||
expect(historyMap.get("room")?.map((entry) => entry.body)).toEqual(["two", "three"]);
|
||||
expect(historyMap.get("group")?.map((entry) => entry.body)).toEqual(["two", "three"]);
|
||||
});
|
||||
|
||||
it("builds context from map and appends entry", () => {
|
||||
const historyMap = new Map<string, { sender: string; body: string }[]>();
|
||||
historyMap.set("room", [
|
||||
historyMap.set("group", [
|
||||
{ sender: "A", body: "one" },
|
||||
{ sender: "B", body: "two" },
|
||||
]);
|
||||
|
||||
const result = buildHistoryContextFromMap({
|
||||
historyMap,
|
||||
historyKey: "room",
|
||||
historyKey: "group",
|
||||
limit: 3,
|
||||
entry: { sender: "C", body: "three" },
|
||||
currentMessage: "current",
|
||||
formatEntry: (entry) => `${entry.sender}: ${entry.body}`,
|
||||
});
|
||||
|
||||
expect(historyMap.get("room")?.map((entry) => entry.body)).toEqual(["one", "two", "three"]);
|
||||
expect(historyMap.get("group")?.map((entry) => entry.body)).toEqual(["one", "two", "three"]);
|
||||
expect(result).toContain(HISTORY_CONTEXT_MARKER);
|
||||
expect(result).toContain("A: one");
|
||||
expect(result).toContain("B: two");
|
||||
@@ -85,20 +85,20 @@ describe("history helpers", () => {
|
||||
|
||||
it("builds context from pending map without appending", () => {
|
||||
const historyMap = new Map<string, { sender: string; body: string }[]>();
|
||||
historyMap.set("room", [
|
||||
historyMap.set("group", [
|
||||
{ sender: "A", body: "one" },
|
||||
{ sender: "B", body: "two" },
|
||||
]);
|
||||
|
||||
const result = buildPendingHistoryContextFromMap({
|
||||
historyMap,
|
||||
historyKey: "room",
|
||||
historyKey: "group",
|
||||
limit: 3,
|
||||
currentMessage: "current",
|
||||
formatEntry: (entry) => `${entry.sender}: ${entry.body}`,
|
||||
});
|
||||
|
||||
expect(historyMap.get("room")?.map((entry) => entry.body)).toEqual(["one", "two"]);
|
||||
expect(historyMap.get("group")?.map((entry) => entry.body)).toEqual(["one", "two"]);
|
||||
expect(result).toContain(HISTORY_CONTEXT_MARKER);
|
||||
expect(result).toContain("A: one");
|
||||
expect(result).toContain("B: two");
|
||||
|
||||
@@ -229,7 +229,7 @@ export async function initSessionState(params: {
|
||||
channel: baseEntry?.channel,
|
||||
groupId: baseEntry?.groupId,
|
||||
subject: baseEntry?.subject,
|
||||
room: baseEntry?.room,
|
||||
groupChannel: baseEntry?.groupChannel,
|
||||
space: baseEntry?.space,
|
||||
deliveryContext: deliveryFields.deliveryContext,
|
||||
// Track originating channel for subagent announce routing.
|
||||
@@ -247,24 +247,24 @@ export async function initSessionState(params: {
|
||||
normalizedChannel &&
|
||||
getChannelDock(normalizedChannel)?.capabilities.chatTypes.includes("channel"),
|
||||
);
|
||||
const nextRoom =
|
||||
const nextGroupChannel =
|
||||
explicitChannel ??
|
||||
((groupResolution.chatType === "channel" || isChannelProvider) &&
|
||||
subject &&
|
||||
subject.startsWith("#")
|
||||
? subject
|
||||
: undefined);
|
||||
const nextSubject = nextRoom ? undefined : subject;
|
||||
const nextSubject = nextGroupChannel ? undefined : subject;
|
||||
sessionEntry.chatType = groupResolution.chatType ?? "group";
|
||||
sessionEntry.channel = channel;
|
||||
sessionEntry.groupId = groupResolution.id;
|
||||
if (nextSubject) sessionEntry.subject = nextSubject;
|
||||
if (nextRoom) sessionEntry.room = nextRoom;
|
||||
if (nextGroupChannel) sessionEntry.groupChannel = nextGroupChannel;
|
||||
if (space) sessionEntry.space = space;
|
||||
sessionEntry.displayName = buildGroupDisplayName({
|
||||
provider: sessionEntry.channel,
|
||||
subject: sessionEntry.subject,
|
||||
room: sessionEntry.room,
|
||||
groupChannel: sessionEntry.groupChannel,
|
||||
space: sessionEntry.space,
|
||||
id: groupResolution.id,
|
||||
key: sessionKey,
|
||||
|
||||
Reference in New Issue
Block a user