fix(coach): deep-link the proactive nudge to its conversation

The bottom-right launcher opened a blank new chat on an unread proactive
message instead of the thread the Coach wrote. Return the owning
conversation id from the nudge-status endpoint, have the launcher open
/coach?c=<id> on the unread path, and stamp the same deep link on the push
metadata so the notification lands in the exact conversation rather than
relying on a most-recent heuristic.
This commit is contained in:
Marc-André Bombeck committed 2026-06-27 13:31:17 +02:00
1 parent 914fa8d36e
commit 9ef79b2357
6 files changed
+80 -10

No files matched your search

+12 -3
View File
@@ -877,12 +877,17 @@ export async function runCoachNudgeTick(
// dot once the user opens the Coach). A persistence failure must
// not swallow the notification, so it is caught locally and the
// dispatch still fires.
let nudgeConversationId: string | null = null;
try {
await recordNudgeImpl({
const recorded = await recordNudgeImpl({
userId: user.id,
title,
body,
});
// v1.22 (W5) — keep the conversation id so the push deep-links
// precisely into the proactive thread instead of the generic
// `/coach`, closing the most-recent-heuristic gap on the web side.
nudgeConversationId = recorded.conversationId;
summary.persisted += 1;
} catch (persistErr: unknown) {
const message =
@@ -901,8 +906,12 @@ export async function runCoachNudgeTick(
scheduledAt: now.toISOString(),
trigger,
// Deep link — the web-push sender threads this into the
// service-worker payload's click target.
url: "/coach",
// service-worker payload's click target. Point at the exact
// proactive conversation when it persisted; fall back to the
// generic Coach surface if persistence failed.
url: nudgeConversationId
? `/coach?c=${nudgeConversationId}`
: "/coach",
},
});
+6
View File
@@ -779,6 +779,12 @@ export const coachPaths: NonNullable<ZodOpenApiObject["paths"]> = {
.describe(
"True when that message is newer than the last time the caller opened the Coach.",
),
conversationId: z
.string()
.nullable()
.describe(
"Conversation holding the newest assistant message; null when none exists. The client deep-links into it (`/coach?c=<id>`) on the unread path.",
),
}),
"CoachNudgeStatus",
),