docs: document control ui sources

This commit is contained in:
Peter Steinberger
2026-06-04 20:56:47 -04:00
parent 39cc11ad28
commit 12a56d4d46
317 changed files with 320 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
// Control UI config module wires control ui chunking behavior.
export function normalizeModuleId(id: string): string {
return id.replace(/\\/g, "/");
}

1
ui/src/css.d.ts vendored
View File

@@ -1 +1,2 @@
// Control UI type declarations define css contracts.
declare module "*.css";

View File

@@ -1,3 +1,4 @@
// Control UI i18n module implements index behavior.
export * from "./lib/types.ts";
export * from "./lib/translate.ts";
export * from "./lib/lit-controller.ts";

View File

@@ -1,3 +1,4 @@
// Control UI i18n module implements lit controller behavior.
import type { ReactiveController, ReactiveControllerHost } from "lit";
import { i18n } from "./translate.ts";

View File

@@ -1,3 +1,4 @@
// Control UI i18n module implements registry behavior.
import type { Locale, TranslationMap } from "./types.ts";
type LazyLocale = Exclude<Locale, "en">;

View File

@@ -1,3 +1,4 @@
// Control UI i18n module implements translate behavior.
import { getSafeLocalStorage } from "../../local-storage.ts";
import { en } from "../locales/en.ts";
import {

View File

@@ -1,3 +1,4 @@
// Control UI type declarations define types contracts.
export type TranslationMap = { [key: string]: string | TranslationMap };
export type Locale =

View File

@@ -1,3 +1,4 @@
// Control UI English locale strings are the i18n source bundle.
import type { TranslationMap } from "../lib/types.ts";
export const en: TranslationMap = {

View File

@@ -1,3 +1,4 @@
// Control UI tests cover translate behavior.
import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createStorageMock } from "../../test-helpers/storage.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements local storage behavior.
function isStorage(value: unknown): value is Storage {
return (
Boolean(value) &&

View File

@@ -1,3 +1,4 @@
// Control UI module implements main behavior.
import "./styles.css";
import "./ui/app.ts";
import { inferControlUiPublicAssetPath } from "./ui/public-assets.ts";

View File

@@ -1,3 +1,4 @@
// Control UI type declarations define markdown it task lists contracts.
declare module "markdown-it-task-lists" {
import type MarkdownIt from "markdown-it";
interface TaskListsOptions {

View File

@@ -1,3 +1,4 @@
// Control UI tests cover control ui e2e behavior.
import { describe, expect, it } from "vitest";
import {
resolvePlaywrightChromiumExecutablePath,

View File

@@ -1,3 +1,4 @@
// Control UI test helper supports control ui e2e setup.
import { spawnSync } from "node:child_process";
import { existsSync } from "node:fs";
import { createRequire } from "node:module";

View File

@@ -1,3 +1,4 @@
// Control UI test helper supports custom theme setup.
import { normalizeImportedCustomTheme } from "../ui/custom-theme.ts";
export function createTweakcnThemePayload() {

View File

@@ -1,3 +1,4 @@
// Control UI test helper supports load styles setup.
import "../styles/base.css";
import "../styles/layout.css";
import "../styles/layout.mobile.css";

View File

@@ -1,3 +1,4 @@
// Control UI test helper supports modal dialog setup.
import { expect } from "vitest";
import type { OpenClawModalDialog } from "../ui/components/modal-dialog.ts";

View File

@@ -1,3 +1,4 @@
// Control UI test helper supports storage setup.
export function createStorageMock(): Storage {
const store = new Map<string, string>();
return {

View File

@@ -1,3 +1,4 @@
// Control UI type declarations define create markdown preview contracts.
declare module "@create-markdown/preview" {
export type PreviewThemeOptions = {
sanitize?: ((html: string) => string) | undefined;

View File

@@ -1,3 +1,4 @@
// Control UI type declarations define highlight js subpaths contracts.
declare module "highlight.js/lib/core" {
import hljs from "highlight.js/lib/core";

View File

@@ -1,3 +1,4 @@
// Control UI module implements activity model behavior.
import { formatUnknownText, truncateText } from "./format.ts";
export const ACTIVITY_ENTRY_LIMIT = 100;

View File

@@ -1,3 +1,4 @@
// Control UI tests cover app channels behavior.
import { afterEach, describe, expect, it, vi } from "vitest";
import { handleChannelConfigReload, handleChannelConfigSave } from "./app-channels.ts";
import type { ChannelsState } from "./controllers/channels.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app channels behavior.
import { resolveControlUiAuthHeader } from "./control-ui-auth.ts";
import {
loadChannels,

View File

@@ -1,3 +1,4 @@
// Control UI module implements app chat behavior.
import type { CommandsListResult } from "../../../packages/gateway-protocol/src/index.js";
import { setLastActiveSessionKey } from "./app-last-active-session.ts";
import { scheduleChatScroll, resetChatScroll } from "./app-scroll.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover app defaults behavior.
import { describe, expect, it } from "vitest";
import { DEFAULT_SESSIONS_FILTERS } from "./app-defaults.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app defaults behavior.
import type { LogLevel } from "./types.ts";
import type { CronFormState } from "./ui-types.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app events behavior.
export type EventLogEntry = {
ts: number;
event: string;

View File

@@ -1,3 +1,4 @@
// Control UI module implements app gateway behavior.
import { ConnectErrorDetailCodes } from "../../../packages/gateway-protocol/src/connect-error-details.js";
import {
GATEWAY_EVENT_UPDATE_AVAILABLE,

View File

@@ -1,3 +1,4 @@
// Control UI module implements app last active session behavior.
import type { UiSettings } from "./storage.ts";
type LastActiveSessionHost = {

View File

@@ -1,3 +1,4 @@
// Control UI module implements app lifecycle behavior.
import { connectGateway } from "./app-gateway.ts";
import {
startLogsPolling,

View File

@@ -1,3 +1,4 @@
// Control UI tests cover app native bridge behavior.
import { afterEach, describe, expect, it, vi } from "vitest";
import { initNativeBridge, isWebView2, sendToNative } from "./app-native-bridge.ts";
import {

View File

@@ -1,3 +1,4 @@
// Control UI module implements app native bridge behavior.
type WebView2Bridge = {
postMessage(message: unknown): void;
addEventListener(type: "message", listener: (event: MessageEvent) => void): void;

View File

@@ -1,3 +1,4 @@
// Control UI module implements app polling behavior.
import type { DebugState } from "./controllers/debug.ts";
import { loadDebug } from "./controllers/debug.ts";
import type { LogsState } from "./controllers/logs.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app render usage tab behavior.
import { nothing } from "lit";
import type { AppViewState } from "./app-view-state.ts";
import type { UsageState } from "./controllers/usage.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover app renderreaming behavior.
import { describe, expect, it } from "vitest";
import { formatDreamNextCycle } from "./app-render.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover app render behavior.
import { render } from "lit";
import { describe, expect, it, vi } from "vitest";
import { t } from "../i18n/index.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app render behavior.
import { html, nothing } from "lit";
import { t } from "../i18n/index.ts";
import {

View File

@@ -1,3 +1,4 @@
// Control UI module implements app render behavior.
import { html, nothing } from "lit";
import { guard } from "lit/directives/guard.js";
import { styleMap } from "lit/directives/style-map.js";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover app scroll behavior.
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { handleChatScroll, scheduleChatScroll, resetChatScroll } from "./app-scroll.ts";
import type { ChatAutoScrollMode } from "./storage.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app scroll behavior.
import { normalizeChatAutoScrollMode, type ChatAutoScrollMode } from "./storage.ts";
/** Distance (px) from the bottom within which we consider the user "near bottom". */

View File

@@ -1,3 +1,4 @@
// Control UI tests cover app settings behavior.
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createImportedCustomThemeFixture } from "../test-helpers/custom-theme.ts";
import { createStorageMock } from "../test-helpers/storage.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app settings behavior.
import { roleScopesAllow } from "../../../src/shared/operator-scope-compat.js";
import { t } from "../i18n/index.ts";
import { refreshChat } from "./app-chat.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app tool stream behavior.
import { updateActivityFromToolEvent, type ActivityEntry } from "./activity-model.ts";
import { createChatModelOverride } from "./chat-model-ref.ts";
import type { ChatModelOverride } from "./chat-model-ref.types.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app view state behavior.
import type { ActivityEntry, ActivityStatus } from "./activity-model.ts";
import type { ChatAbortOptions, ChatSendOptions } from "./app-chat.ts";
import type { EventLogEntry } from "./app-events.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements app behavior.
import { LitElement } from "lit";
import { state } from "lit/decorators.js";
import { i18n, I18nController, isSupportedLocale, t } from "../i18n/index.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover assistant identity behavior.
import { describe, expect, it } from "vitest";
import { normalizeAssistantIdentity } from "./assistant-identity.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements assistant identity behavior.
import { coerceIdentityValue } from "../../../src/shared/assistant-identity-values.js";
const MAX_ASSISTANT_NAME = 50;

View File

@@ -1,3 +1,4 @@
// Control UI tests cover browser redact behavior.
import { describe, expect, it } from "vitest";
import { redactToolDetail, redactToolPayloadText } from "./browser-redact.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements browser redact behavior.
const PAYMENT_CREDENTIAL_KEYS =
"card[-_]?number|card[-_]?cvc|card[-_]?cvv|cvc|cvv|security[-_]?code|securityCode|payment[-_]?credential|paymentCredential|shared[-_]?payment[-_]?token|sharedPaymentToken";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover canvas url behavior.
import { describe, expect, it } from "vitest";
import { resolveCanvasIframeUrl } from "./canvas-url.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements canvas url behavior.
const A2UI_PATH = "/__openclaw__/a2ui";
const CANVAS_HOST_PATH = "/__openclaw__/canvas";
const CANVAS_CAPABILITY_PATH_PREFIX = "/__openclaw__/cap";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover chat event reload behavior.
import { describe, expect, it } from "vitest";
import { shouldReloadHistoryForFinalEvent } from "./chat-event-reload.ts";

View File

@@ -1,3 +1,4 @@
// Control UI module implements chat event reload behavior.
import { extractText } from "./chat/message-extract.ts";
import type { ChatEventPayload } from "./controllers/chat.ts";
import { normalizeLowercaseStringOrEmpty } from "./string-coerce.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover chat model ref behavior.
import { describe, expect, it } from "vitest";
import {
buildChatModelOption,

View File

@@ -1,3 +1,4 @@
// Control UI module implements chat model ref behavior.
import type { ChatModelOverride } from "./chat-model-ref.types.ts";
import type { ModelCatalogEntry } from "./types.ts";
export type { ChatModelOverride } from "./chat-model-ref.types.ts";

View File

@@ -1,3 +1,4 @@
// Control UI type declarations define chat model ref contracts.
export type ChatModelOverride =
| {
kind: "qualified";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover chat model select state behavior.
import { describe, expect, it } from "vitest";
import {
resolveChatModelOverrideValue,

View File

@@ -1,3 +1,4 @@
// Control UI module implements chat model select state behavior.
import type { AppViewState } from "./app-view-state.ts";
import {
buildCatalogDisplayLookup,

View File

@@ -1,3 +1,4 @@
// Control UI module implements chat model helpers behavior.
import type {
GatewaySessionRow,
ModelCatalogEntry,

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements attachment payload store behavior.
import type { ChatAttachment } from "../ui-types.ts";
type AttachmentPayload = {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements attachment support behavior.
export const CHAT_ATTACHMENT_ACCEPT =
"image/*,audio/*,application/pdf,text/*,.csv,.json,.md,.txt,.zip," +
".doc,.docx,.xls,.xlsx,.ppt,.pptx";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover build chat items behavior.
import { describe, expect, it } from "vitest";
import type { MessageGroup } from "../types/chat-types.ts";
import { buildChatItems, type BuildChatItemsProps } from "./build-chat-items.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements build chat items behavior.
import type { ChatItem, MessageGroup, NormalizedMessage, ToolCard } from "../types/chat-types.ts";
import type { ChatQueueItem } from "../ui-types.ts";
import {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements chat avatar behavior.
import { html } from "lit";
import type { AssistantIdentity } from "../assistant-identity.ts";
import {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements chat queue behavior.
import { html, nothing } from "lit";
import { t } from "../../i18n/index.ts";
import { icons } from "../icons.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover chat responsive behavior.
import { existsSync } from "node:fs";
import { chromium, type Browser, type Page } from "playwright";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements chat sidebar raw behavior.
import type { SidebarContent } from "../sidebar-content.ts";
function toPlainTextCodeFence(value: string, language = ""): string {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements chat welcome behavior.
import { html } from "lit";
import { t } from "../../i18n/index.ts";
import {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements composer persistence behavior.
import { getSafeSessionStorage } from "../../local-storage.ts";
import { DEFAULT_AGENT_ID, normalizeAgentId, parseAgentSessionKey } from "../session-key.ts";
import type { ChatAttachment, ChatQueueItem, ChatQueueSkillWorkshopRevision } from "../ui-types.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements context notice behavior.
import { html, nothing } from "lit";
import { icons } from "../icons.ts";
import type { GatewaySessionRow } from "../types.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements copy as markdown behavior.
import { html, type TemplateResult } from "lit";
import { icons } from "../icons.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements deleted messages behavior.
import { getSafeLocalStorage } from "../../local-storage.ts";
const PREFIX = "openclaw:deleted:";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements export behavior.
import { timestampMsToIsoString } from "@openclaw/normalization-core/number-coercion";
import { extractTextCached } from "./message-extract.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements grouped render behavior.
import { html, nothing } from "lit";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { until } from "lit/directives/until.js";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements heartbeat display behavior.
import { normalizeLowercaseStringOrEmpty } from "../string-coerce.ts";
const HEARTBEAT_TOKEN = "HEARTBEAT_OK";

View File

@@ -1,2 +1,3 @@
// Control UI chat module implements history limits behavior.
export const CHAT_HISTORY_RENDER_LIMIT = 100;
export const CHAT_HISTORY_RENDER_CHAR_BUDGET = 240_000;

View File

@@ -1,3 +1,4 @@
// Control UI tests cover history merge behavior.
import { describe, expect, it } from "vitest";
import { preserveOptimisticTailMessages } from "../controllers/chat.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements input history behavior.
import { CHAT_HISTORY_RENDER_LIMIT } from "./history-limits.ts";
import { extractText } from "./message-extract.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover message extract behavior.
import { describe, expect, it } from "vitest";
import {
extractText,

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements message extract behavior.
import { stripInternalRuntimeContext } from "../../../../src/agents/internal-runtime-context.js";
import { stripInboundMetadata } from "../../../../src/auto-reply/reply/strip-inbound-meta.js";
import { stripEnvelope } from "../../../../src/shared/chat-envelope.js";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover message normalizer behavior.
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { normalizeMessage } from "./message-normalizer.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements pinned messages behavior.
import { getSafeLocalStorage } from "../../local-storage.ts";
const PREFIX = "openclaw:pinned:";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements pinned summary behavior.
import { extractTextCached } from "./message-extract.ts";
export function getPinnedMessageSummary(message: unknown): string {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk audio behavior.
export function bytesToBase64(bytes: Uint8Array): string {
let binary = "";
const chunkSize = 0x8000;

View File

@@ -1,3 +1,4 @@
// Control UI tests cover realtime talk conversation behavior.
import { describe, expect, it } from "vitest";
import {
createRealtimeTalkConversationState,

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk conversation behavior.
export type RealtimeTalkConversationRole = "user" | "assistant";
export type RealtimeTalkConversationEntry = {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk gateway relay behavior.
import { bytesToBase64, floatToPcm16 } from "./realtime-talk-audio.ts";
import { RealtimeTalkPcmOutputQueue } from "./realtime-talk-pcm-output.ts";
import {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk google live behavior.
import { base64ToBytes, bytesToBase64, floatToPcm16 } from "./realtime-talk-audio.ts";
import { RealtimeTalkPcmOutputQueue } from "./realtime-talk-pcm-output.ts";
import type { RealtimeTalkJsonPcmWebSocketSessionResult } from "./realtime-talk-shared.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk pcm output behavior.
import { base64ToBytes, pcm16ToFloat } from "./realtime-talk-audio.ts";
export class RealtimeTalkPcmOutputQueue {

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk shared behavior.
import { REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME } from "../../../../src/talk/agent-consult-tool.js";
import {
buildRealtimeVoiceAgentCancelProviderResult,

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk webrtc behavior.
import type { RealtimeTalkWebRtcSdpSessionResult } from "./realtime-talk-shared.ts";
import {
REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME,

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements realtime talk behavior.
import { normalizeTalkTransport } from "../../../../src/talk/talk-session-controller.js";
import type { GatewayBrowserClient } from "../gateway.ts";
import { GatewayRelayRealtimeTalkTransport } from "./realtime-talk-gateway-relay.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover role normalizer behavior.
import { describe, expect, it } from "vitest";
import { isToolResultMessage, normalizeRoleForGrouping } from "./role-normalizer.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements run controls behavior.
import { html, nothing } from "lit";
import { t } from "../../i18n/index.ts";
import { icons } from "../icons.ts";

View File

@@ -1,3 +1,4 @@
// Control UI tests cover run lifecycle behavior.
import { describe, expect, it } from "vitest";
import { isSessionRunActive } from "../session-run-state.ts";
import type { SessionsListResult } from "../types.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements run lifecycle behavior.
import { resetToolStream, type CompactionStatus, type FallbackStatus } from "../app-tool-stream.ts";
import { uiSessionRowMatchesSelectedChat } from "../session-key.ts";
import { isSessionRunActive } from "../session-run-state.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements search match behavior.
import { normalizeLowercaseStringOrEmpty } from "../string-coerce.ts";
import { extractTextCached } from "./message-extract.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements session cache behavior.
const MAX_CACHED_CHAT_SESSIONS = 20;
export function getOrCreateSessionCacheValue<T>(

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements session controls behavior.
import { html } from "lit";
import { repeat } from "lit/directives/repeat.js";
import { t } from "../../i18n/index.ts";

View File

@@ -1,3 +1,4 @@
// Control UI chat module implements side result render behavior.
import { html, nothing, type TemplateResult } from "lit";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { icons } from "../icons.ts";

Some files were not shown because too many files have changed in this diff Show More