Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions plugins/side-chat/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@ describe("resolveReplySeedText", () => {
});

describe("createSideChat rpc", () => {
it("limits the reply-seed lookup to the latest timeline segment", async () => {
const timeline = vi.fn(async () =>
timelineResult([conversationRow("latest answer")]),
);
const fork = vi.fn(async () => makeThreadResponse({ id: "thr_fork" }));
const { harness } = await loadPlugin({ timeline, fork });

await harness.callRpc("createSideChat", {
sourceThreadId: "thr_src",
sourceSeqEnd: 7,
anchorText: "latest answer",
});

expect(timeline).toHaveBeenCalledWith({
threadId: "thr_src",
includeNestedRows: "true",
segmentLimit: "1",
});
});

it("forks hidden+isolated with a seed when the anchor is an earlier message", async () => {
const fork = vi.fn(async () => makeThreadResponse({ id: "thr_fork" }));
const { harness } = await loadPlugin({
Expand Down
5 changes: 5 additions & 0 deletions plugins/side-chat/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@ export const sideChatRpcContract = defineRpcContract({
export default async function plugin(bb: BbPluginApi) {
bb.rpc.register(sideChatRpcContract, {
async createSideChat({ sourceThreadId, sourceSeqEnd, anchorText }) {
// The seed rule reads only the source's *last* conversation message, and
// every timeline segment is anchored at a user message — so the newest
// segment always holds it. Without this the lookup projects the default
// 20 segments of nested rows on the activation path.
const timeline = await bb.sdk.threads.timeline({
threadId: sourceThreadId,
includeNestedRows: "true",
segmentLimit: "1",
});
const seedText = resolveReplySeedText({
anchorText,
Expand Down