Files
openclaw/src/gateway/session-utils-contracts.ts
Peter Steinberger ff72f287c3 fix(gateway): declare viewer presence explicitly instead of deriving it from subscriptions (#116001)
* fix(gateway): declare viewer presence explicitly instead of deriving it from subscriptions

* refactor(ui): isolate viewer presence lifecycle ownership

* chore(protocol): register viewer presence schema owner

* fix(ui): keep viewer presence cleared after detach

* chore: drop changelog edits from this PR

CHANGELOG.md is release-owned; release generation derives entries from merged
PRs. Release-note context stays in the PR body.
2026-07-29 13:56:54 -04:00

52 lines
1.8 KiB
TypeScript

import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "@openclaw/normalization-core/string-coerce";
import type { resolveSessionModelRef } from "../agents/session-model-ref.js";
import type { buildSubagentRunReadIndex } from "../agents/subagent-registry-read.js";
import type { ThinkLevel, listThinkingLevelOptions } from "../auto-reply/thinking.js";
import type { SessionAcpMeta, SessionEntry } from "../config/sessions.js";
import type { ModelCostConfig } from "../utils/usage-format.js";
export type SessionActorProfileIdentity = {
label?: string;
avatarUrl?: string;
};
export type SessionListRowContext = {
subagentRuns: ReturnType<typeof buildSubagentRunReadIndex>;
storeChildSessionsByKey: Map<string, string[]>;
selectedModelByOverrideRef: Map<string, ReturnType<typeof resolveSessionModelRef>>;
thinkingMetadataByModelRef: Map<
string,
{
levels: ReturnType<typeof listThinkingLevelOptions>;
defaultLevel: ThinkLevel;
}
>;
displayModelIdentityByKey: Map<string, { provider?: string; model?: string }>;
modelCostConfigByModelRef: Map<string, ModelCostConfig | undefined>;
userProfileIdentityById: Map<string, SessionActorProfileIdentity | undefined>;
acpSessionMetaByEntry: Map<SessionEntry, SessionAcpMeta | undefined>;
};
export type SessionListRowContextProvider = () => SessionListRowContext;
export type GatewaySessionStoreTarget = {
agentId: string;
storePath: string;
canonicalKey: string;
storeKeys: string[];
};
export type GatewaySessionStoreTargetWithStore = GatewaySessionStoreTarget & {
store: Record<string, SessionEntry>;
};
export function createSessionRowModelCacheKey(
provider: string | undefined,
model: string | undefined,
) {
return `${normalizeLowercaseStringOrEmpty(provider)}\0${normalizeOptionalString(model) ?? ""}`;
}