refactor: hide ui helper internals

This commit is contained in:
Peter Steinberger
2026-05-02 07:10:14 +01:00
parent ff56db1f5c
commit 49e2992be5
9 changed files with 13 additions and 18 deletions

View File

@@ -14,7 +14,7 @@ const MAX_ASSISTANT_AVATAR_REASON = 200;
// this module free of UI view imports (avoids an import cycle).
const RENDERABLE_AVATAR_URL_RE = /^(data:image\/|\/(?!\/))/i;
export const DEFAULT_ASSISTANT_NAME = "Assistant";
const DEFAULT_ASSISTANT_NAME = "Assistant";
export const DEFAULT_ASSISTANT_AVATAR = "A";
export type AssistantIdentity = {

View File

@@ -50,7 +50,7 @@ export function getChatAttachmentPreviewUrl(attachment: ChatAttachment): string
);
}
export function cloneChatAttachmentMetadata(attachment: ChatAttachment): ChatAttachment {
function cloneChatAttachmentMetadata(attachment: ChatAttachment): ChatAttachment {
const { dataUrl: _dataUrl, ...metadata } = attachment;
return metadata;
}
@@ -76,7 +76,7 @@ export function releaseChatAttachmentPayloads(attachments: readonly ChatAttachme
}
}
export function discardChatAttachmentDataUrl(id: string): void {
function discardChatAttachmentDataUrl(id: string): void {
const payload = payloads.get(id);
if (!payload) {
return;

View File

@@ -1,4 +1,4 @@
export const MAX_CACHED_CHAT_SESSIONS = 20;
const MAX_CACHED_CHAT_SESSIONS = 20;
export function getOrCreateSessionCacheValue<T>(
map: Map<string, T>,

View File

@@ -78,7 +78,7 @@ export async function loadConfigSchema(state: ConfigState) {
}
}
export function applyConfigSchema(state: ConfigState, res: ConfigSchemaResponse) {
function applyConfigSchema(state: ConfigState, res: ConfigSchemaResponse) {
state.configSchema = res.schema ?? null;
state.configUiHints = res.uiHints ?? {};
state.configSchemaVersion = res.version ?? null;

View File

@@ -89,9 +89,7 @@ export type CronModelSuggestionsState = {
cronModelSuggestions: string[];
};
export function supportsAnnounceDelivery(
form: Pick<CronFormState, "sessionTarget" | "payloadKind">,
) {
function supportsAnnounceDelivery(form: Pick<CronFormState, "sessionTarget" | "payloadKind">) {
return form.sessionTarget !== "main" && form.payloadKind === "agentTurn";
}
@@ -523,7 +521,7 @@ function jobToForm(job: CronJob, prev: CronFormState): CronFormState {
return normalizeCronFormState(next);
}
export function buildCronSchedule(form: CronFormState) {
function buildCronSchedule(form: CronFormState) {
if (form.scheduleKind === "at") {
const ms = Date.parse(form.scheduleAt);
if (!Number.isFinite(ms)) {
@@ -559,7 +557,7 @@ export function buildCronSchedule(form: CronFormState) {
return { kind: "cron" as const, expr, tz: form.cronTz.trim() || undefined, staggerMs };
}
export function buildCronPayload(form: CronFormState) {
function buildCronPayload(form: CronFormState) {
if (form.payloadKind === "systemEvent") {
const text = form.payloadText.trim();
if (!text) {

View File

@@ -106,10 +106,7 @@ export async function loadExecApprovals(
}
}
export function applyExecApprovalsSnapshot(
state: ExecApprovalsState,
snapshot: ExecApprovalsSnapshot,
) {
function applyExecApprovalsSnapshot(state: ExecApprovalsState, snapshot: ExecApprovalsSnapshot) {
state.execApprovalsSnapshot = snapshot;
if (!state.execApprovalsDirty) {
state.execApprovalsForm = cloneConfigObject(snapshot.file ?? {});

View File

@@ -147,7 +147,7 @@ type SelectedConnectAuth = {
canFallbackToShared: boolean;
};
export const CONTROL_UI_OPERATOR_ROLE = "operator";
const CONTROL_UI_OPERATOR_ROLE = "operator";
export const CONTROL_UI_OPERATOR_SCOPES = [
"operator.admin",

View File

@@ -36,7 +36,7 @@ export function parseAgentSessionKey(
return { agentId, rest };
}
export function normalizeMainKey(value: string | undefined | null): string {
function normalizeMainKey(value: string | undefined | null): string {
return normalizeOptionalLowercaseString(value) ?? DEFAULT_MAIN_KEY;
}

View File

@@ -11,7 +11,7 @@ export type ResolvedTheme =
| "custom-light";
export const VALID_THEME_NAMES = new Set<ThemeName>(["claw", "knot", "dash", "custom"]);
export const VALID_THEME_MODES = new Set<ThemeMode>(["system", "light", "dark"]);
const VALID_THEME_MODES = new Set<ThemeMode>(["system", "light", "dark"]);
type ThemeSelection = { theme: ThemeName; mode: ThemeMode };
@@ -29,7 +29,7 @@ const LEGACY_MAP: Record<string, ThemeSelection> = {
system: { theme: "claw", mode: "system" },
};
export function prefersLightScheme(): boolean {
function prefersLightScheme(): boolean {
if (typeof globalThis.matchMedia !== "function") {
return false;
}