Архитектура: централизовать inventory root-frame state и root-scoped carryover в continuity policy

This commit is contained in:
2026-04-19 09:25:22 +03:00
parent c9730c986a
commit 46dfef6fb6
9 changed files with 297 additions and 132 deletions
@@ -1,6 +1,8 @@
// @ts-nocheck
import {
buildRootScopedCarryoverFilters,
buildInventoryRootFrameFromAddressDebug,
hydrateInventoryRootFrameState,
readAddressDebugFilters,
readAddressDebugItem,
readAddressDebugTemporalScope,
@@ -732,46 +734,19 @@ export function createAssistantTransitionPolicy(deps) {
hasSelectedObjectInventorySignalPrimary || hasSelectedObjectInventorySignalAlternate
? inferSelectedObjectInventoryFollowupIntent(userMessage, alternateMessage)
: null;
let inventoryRootFrame =
const inventoryRootFrameCandidate =
deps.findRecentInventoryRootFrame(items) ??
continuitySnapshot.inventoryRootFrame ??
buildInventoryRootFrameFromAddressDebug(continuitySnapshot.lastGroundedAddressDebug, deps.toNonEmptyString);
if (inventoryRootFrame && navigationOrganization && !deps.toNonEmptyString(inventoryRootFrame.filters?.organization)) {
inventoryRootFrame = {
...inventoryRootFrame,
filters: {
...(inventoryRootFrame.filters ?? {}),
organization: navigationOrganization
}
};
}
if (inventoryRootFrame && navigationDateScope) {
inventoryRootFrame = {
...inventoryRootFrame,
filters: {
...(inventoryRootFrame.filters ?? {}),
as_of_date:
deps.toNonEmptyString(inventoryRootFrame.filters?.as_of_date) ??
deps.toNonEmptyString(navigationDateScope.as_of_date) ??
undefined,
period_from:
deps.toNonEmptyString(inventoryRootFrame.filters?.period_from) ??
deps.toNonEmptyString(navigationDateScope.period_from) ??
undefined,
period_to:
deps.toNonEmptyString(inventoryRootFrame.filters?.period_to) ??
deps.toNonEmptyString(navigationDateScope.period_to) ??
undefined
}
};
}
let currentFrameKind = inventoryRootFrame
? deps.isInventoryDrilldownFrameIntent(sourceIntent)
? "inventory_drilldown"
: deps.isInventoryRootFrameIntent(sourceIntent)
? "inventory_root"
: "generic"
: null;
let { inventoryRootFrame, currentFrameKind } = hydrateInventoryRootFrameState(
inventoryRootFrameCandidate,
sourceIntent,
navigationOrganization,
navigationDateScope,
deps.toNonEmptyString,
deps.isInventoryDrilldownFrameIntent,
deps.isInventoryRootFrameIntent
);
let resolvedCounterpartyFromDisplay = false;
let displayedEntityTargetIntent = null;
let previousFilters = resolveAddressDebugCarryoverFilters(previousAddressDebug, deps.toNonEmptyString);
@@ -919,7 +894,7 @@ export function createAssistantTransitionPolicy(deps) {
previousIntent = null;
previousAnchorType = null;
previousAnchor = null;
previousFilters = deps.buildRootScopedCarryoverFilters(previousFilters, inventoryRootFrame);
previousFilters = buildRootScopedCarryoverFilters(previousFilters, inventoryRootFrame, deps.toNonEmptyString);
currentFrameKind = inventoryRootFrame ? "inventory_root" : currentFrameKind;
followupSelectionMode = "carry_root_context";
}