Fix bottom anchoring and Claude wake routing

This commit is contained in:
Mohamed Boudra
2026-03-08 12:54:08 +07:00
parent 0c44e7db80
commit b339c5e61d
27 changed files with 3801 additions and 326 deletions
@@ -0,0 +1,37 @@
import type { BottomAnchorRouteRequest } from "@/components/use-bottom-anchor-controller";
export type RouteBottomAnchorIntent = {
routeKey: string;
reason: BottomAnchorRouteRequest["reason"];
};
export function deriveRouteBottomAnchorIntent(input: {
cachedIntent: RouteBottomAnchorIntent | null;
routeKey: string | null;
hasAppliedAuthoritativeHistoryAtEntry: boolean;
}): RouteBottomAnchorIntent | null {
if (!input.routeKey) {
return null;
}
if (input.cachedIntent?.routeKey === input.routeKey) {
return input.cachedIntent;
}
return {
routeKey: input.routeKey,
reason: input.hasAppliedAuthoritativeHistoryAtEntry ? "resume" : "initial-entry",
};
}
export function deriveRouteBottomAnchorRequest(input: {
intent: RouteBottomAnchorIntent | null;
effectiveAgentId: string | null;
}): BottomAnchorRouteRequest | null {
if (!input.intent || !input.effectiveAgentId) {
return null;
}
return {
reason: input.intent.reason,
agentId: input.effectiveAgentId,
requestKey: `${input.intent.routeKey}:${input.intent.reason}`,
};
}