Skip to content

Commit 95f1e28

Browse files
nullStack65claude
andcommitted
fix(chat): keep private notes out of title generation and search
Close the remaining note-privacy gap (F1) on the chatter-fold PR. Title regeneration fed every user message, private notes included, to the title model; the formatter and the initial-title path now drop notes. The agent search filter bound a boolean that node:sqlite rejects, so every message search failed; it now binds 0 or 1. Model: claude-opus-5-5 Task: fix Agent: Magpie Lane: magpie Harness: t3/claude-code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9f0588c commit 95f1e28

5 files changed

Lines changed: 90 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/ThreadSearch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export const messageHitsQuery = (
333333
-- neither find nor a jump can reach them.
334334
AND messages.message_id NOT LIKE 'async-answer:%'
335335
AND ${messageSenderCondition(sql, sender)}
336-
AND (${includeHumanNotes} OR json_extract(messages.payload_json, '$.humanNote') IS NOT 1)
336+
AND (${includeHumanNotes ? 1 : 0} OR json_extract(messages.payload_json, '$.humanNote') IS NOT 1)
337337
-- Nor can they reach a rolled-back turn, or a message of a stopped turn
338338
-- that no shown item carries, such as a queued prompt that never ran.
339339
AND NOT EXISTS (

‎apps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.ts‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,81 @@ describe("ThreadTitleRegenerationService", () => {
550550
}).pipe(Effect.provide(NodeServices.layer)),
551551
);
552552

553+
it.effect("keeps a person's private note out of the title model until it is promoted", () =>
554+
Effect.gen(function* () {
555+
const harness = makeHarness();
556+
yield* Effect.gen(function* () {
557+
const threads = yield* ThreadManagement.ThreadManagementService;
558+
const titleRegeneration = yield* ThreadTitleRegeneration.ThreadTitleRegenerationService;
559+
const threadId = yield* createThread({
560+
command: "command:title:note:create",
561+
thread: "thread:title:note",
562+
});
563+
yield* dispatchUserMessage({
564+
command: "command:title:note:prompt",
565+
threadId,
566+
text: "Investigate the flaky login test",
567+
});
568+
yield* threads.dispatch({
569+
type: "thread.metadata.update",
570+
commandId: CommandId.make("command:title:note:share"),
571+
threadId,
572+
inboxRouting: {
573+
owner: null,
574+
assignee: null,
575+
audience: "shared",
576+
attentionKind: "FYI",
577+
reason: "decision",
578+
},
579+
});
580+
const noteId = MessageId.make("command:title:note:note:message");
581+
yield* threads.dispatch({
582+
type: "message.dispatch",
583+
commandId: CommandId.make("command:title:note:note"),
584+
threadId,
585+
messageId: noteId,
586+
text: "Private aside about the board",
587+
attachments: [],
588+
humanNote: true,
589+
dispatchMode: { type: "start_immediately" },
590+
createdBy: "user",
591+
creationSource: "web",
592+
});
593+
const note = (yield* threads.getThreadRecords(threadId, ["messages"])).messages.find(
594+
(message) => message.id === noteId,
595+
);
596+
assert.equal(note?.humanNote, true);
597+
598+
const regenerate = yield* armRegeneration({
599+
command: "command:title:note:regenerate",
600+
threadId,
601+
});
602+
yield* titleRegeneration.execute({
603+
threadId,
604+
requestId: regenerate,
605+
kind: { type: "regenerate" },
606+
});
607+
// Even if a note id reaches the initial path, its text stays private.
608+
const initial = yield* armRegeneration({
609+
command: "command:title:note:initial",
610+
threadId,
611+
});
612+
yield* titleRegeneration.execute({
613+
threadId,
614+
requestId: initial,
615+
kind: { type: "initial", messageId: noteId },
616+
});
617+
618+
const [regenerated, initialCall] = harness.generateThreadTitle.mock.calls.map(
619+
([call]) => call,
620+
);
621+
assert.include(regenerated?.message, "USER:\nInvestigate the flaky login test");
622+
assert.notInclude(regenerated?.message, "Private aside");
623+
assert.notInclude(initialCall?.message ?? "", "Private aside");
624+
}).pipe(Effect.provide(harness.layer));
625+
}).pipe(Effect.provide(NodeServices.layer)),
626+
);
627+
553628
it.effect.each([
554629
{ name: "its first message", followUp: true },
555630
{ name: "no message of its own yet", followUp: false },

‎apps/server/src/orchestration-v2/ThreadTitleRegenerationService.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ const make = Effect.gen(function* () {
178178
const message = projection.messages.find(
179179
(candidate) => candidate.id === messageId && !candidate.streaming,
180180
);
181+
// A private note never reaches the title model.
181182
context =
182-
message === undefined
183+
message === undefined || message.humanNote === true
183184
? { message: "", attachments: [] }
184185
: {
185186
message: isAttachmentOnlyBootstrapPrompt(message.text) ? "" : message.text,

‎packages/provider-core/src/server/threadTitleContext.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ describe("thread title context", () => {
5555
expect(result.message.match(/USER:/g)).toHaveLength(1);
5656
});
5757

58+
it("leaves a person's private note out of the model context", () => {
59+
const result = formatThreadTitleContext([
60+
{ role: "user", text: "Private aside about the board", humanNote: true },
61+
{ role: "user", text: "Fix Android pairing." },
62+
{ role: "assistant", text: "Found the cause." },
63+
]);
64+
expect(result.message).toBe("USER:\nFix Android pairing.\n\nASSISTANT:\nFound the cause.");
65+
});
66+
5867
it("cuts both ends of a long message without splitting an emoji", () => {
5968
const result = limitTitleMessage(`${"a".repeat(9)}🚀${"b".repeat(20)}🚀${"c".repeat(9)}`, 41);
6069
expect(result).toBe(`${"a".repeat(9)}\n[Content truncated]\n${"c".repeat(9)}`);

‎packages/provider-core/src/server/threadTitleContext.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export type ThreadTitleMessage = {
66
readonly role: "user" | "assistant" | "system" | "reasoning";
77
readonly text: string;
88
readonly attachments?: ReadonlyArray<ChatAttachment> | undefined;
9+
/** A person's private note. The model sees it only after it is promoted as its own message. */
10+
readonly humanNote?: true | undefined;
911
};
1012

1113
const MAX_CONTEXT = 8_000;
@@ -34,6 +36,7 @@ export function formatThreadTitleContext(messages: ReadonlyArray<ThreadTitleMess
3436
if (
3537
message.role === "system" ||
3638
message.role === "reasoning" ||
39+
message.humanNote === true ||
3740
(!message.text.trim() && !message.attachments?.length)
3841
)
3942
return [];

0 commit comments

Comments
 (0)