Skip to content

Commit 70cc786

Browse files
nullStack65claude
andcommitted
fix(threads): leave slash commands and live replies out of the seen marker
Adapters on the release line match /compact and /goal exactly, so a catch-up block appended after a slash command turned it into a normal prompt. A slash command now reaches the provider unchanged. A reply that is still streaming is not counted as unseen. Review finding from the CLO-941 port review of the seen-marker catch-up (CLO-928). Model: claude-opus-5-5 Task: CLO-941 port the seen-marker catch-up (CLO-928) to the release line Agent: magpie Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1b5c2f8 commit 70cc786

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.seen-marker.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const SEEN_AT = "2026-11-20T03:00:00.000Z";
4444

4545
const sendWithHistory = (
4646
threadId: ThreadId,
47-
history: ReadonlyArray<readonly [string, "user" | "assistant"]>,
47+
history: ReadonlyArray<readonly [string, "user" | "assistant", "streaming"?]>,
4848
seenMarker?: ThreadSeenMarker,
4949
) =>
5050
Effect.gen(function* () {
@@ -66,7 +66,7 @@ const sendWithHistory = (
6666
});
6767
const now = yield* DateTime.now;
6868
yield* sink.write({
69-
events: history.map(([id, role], index) => ({
69+
events: history.map(([id, role, streaming], index) => ({
7070
id: EventId.make(`event:${threadId}:${id}`),
7171
type: "message.updated" as const,
7272
threadId,
@@ -79,7 +79,7 @@ const sendWithHistory = (
7979
role,
8080
text: id,
8181
attachments: [],
82-
streaming: false,
82+
streaming: streaming === "streaming",
8383
createdBy: role === "user" ? "user" : "agent",
8484
creationSource: role === "user" ? "web" : "provider",
8585
createdAt: DateTime.subtract(now, { seconds: history.length - index }),
@@ -129,6 +129,7 @@ it.layer(layerTest)("seen marker dispatch", (it) => {
129129
["message-assistant-1", "assistant"],
130130
["message-user-2", "user"],
131131
["message-assistant-2", "assistant"],
132+
["message-assistant-live", "assistant", "streaming"],
132133
],
133134
{ lastSeenMessageId: MessageId.make("message-user"), seenAt: SEEN_AT },
134135
);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6305,6 +6305,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
63056305
LEFT JOIN orchestration_v2_projection_messages AS later
63066306
ON later.thread_id = seen.thread_id
63076307
AND later.role = 'assistant'
6308+
AND later.streaming = 0
63086309
AND (later.created_at, later.message_id) > (seen.created_at, seen.message_id)
63096310
WHERE seen.message_id = ${messageId} AND seen.thread_id = ${threadId}
63106311
GROUP BY seen.message_id

‎packages/shared/src/seenMarker.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ describe("formatSeenMarkerForProvider", () => {
2626
expect(formatSeenMarkerForProvider("Ship the fix", undefined)).toBe("Ship the fix");
2727
});
2828

29-
it("keeps a slash command at the first character", () => {
29+
it("passes a slash command to the provider unchanged", () => {
3030
const marker = {
3131
lastSeenMessageId: MessageId.make("message-user-1"),
3232
seenAt,
3333
unseenCount: 2,
3434
};
35-
const command = formatSeenMarkerForProvider(" /review the diff", marker);
36-
expect(command.trim().startsWith("/review the diff")).toBe(true);
37-
expect(command.indexOf("<seen_marker")).toBeGreaterThan(command.indexOf("/review"));
35+
for (const command of ["/compact", " /review the diff", "/goal pause"]) {
36+
expect(formatSeenMarkerForProvider(command, marker)).toBe(command);
37+
}
3838
const prose = formatSeenMarkerForProvider("Review the diff", marker);
3939
expect(prose.startsWith("<seen_marker")).toBe(true);
4040
expect(prose.endsWith("Review the diff")).toBe(true);

‎packages/shared/src/seenMarker.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ export function formatSeenMarkerForProvider(
1111
`The user last saw message ${marker.lastSeenMessageId}; ${marker.unseenCount} ${noun} since are unseen. Open the reply with a short catch-up on only those.`,
1212
"</seen_marker>",
1313
].join("\n");
14-
if (text.trim().startsWith("/")) return `${text}\n\n${block}`;
14+
if (text.trim().startsWith("/")) return text;
1515
return `${block}\n\n${text}`;
1616
}

0 commit comments

Comments
 (0)