Skip to content

Frontend Architecture

The RTC Agent frontend is a component library built on Lit Web Components. It exposes only a single <rtc-agent> component to the outside world, containing 16 sub-components internally, managed by 9 Controllers, with data distributed to child components via @lit/context.

File Explorer

File Explorer: Left panel shows the virtual file system directory tree (functions/, scenarios/, scripts/), right panel is an editor with live preview. All file data is stored in the browser’s IndexedDB.

Settings UI

Settings UI: Supports theme switching, language selection, font size adjustment, and other personalization options.

Window management is not a standalone component: Window Management is a functional module of the root component (implemented by the collaboration of WindowState Controller and WindowInteraction Controller), not an independent UI component. It controls three window states: normal (floating), maximized (full-screen), minimized (bubble).

Host applications only need to import a single component to access all functionality:

AttributeDescriptionExample
themeTheme switchinglight / dark / system
app-labelTitle bar text + bubble tooltip"RTC Assistant"
bubble-iconSVG/HTML inside the minimized bubbleCustom icon
scenarios-urlScenarios document URL"https://..."
agentConfigDeclarative function registration (recommended)JSON config object

For detailed API documentation, see Component API.

PrincipleDescription
Controllers do not reference each otherEach Controller independently manages its own state slice
Root component orchestrates<rtc-agent> acts as the hub, coordinating cross-Controller communication
Context distributionState is distributed to child components via @lit/context, avoiding prop drilling
Data layer isolationThe Persistence Controller manages all IndexedDB reads and writes

💡 Why not global state? Web Components run inside the host application’s page and may have multiple instances. For example, a page might embed both a “Customer Support Assistant” and a “Data Analysis Assistant” as two <rtc-agent> elements — they need independent sessions, messages, and auth state. Controller + Context ensures each instance’s state is fully isolated with no interference.

InteractionImplementation
DragTitle bar serves as the drag handle
Resize8 resize handles — 4 corners + 4 edges
KeyboardArrow keys to move, Shift to accelerate
Viewport constraintAlways stays within the visible area
LayerContentCustomization Method
Design TokensSpacing, typography, border radius, shadows, transitions, z-indexOverride CSS variables
Color Themeslight / dark color schemesSwitch via theme attribute
CSS VariablesWindow size, bubble size--rtc-* prefixed variables
FeatureBehavior
Auto-scrollAutomatically scrolls to the bottom when new messages arrive
Smart pausePauses auto-scroll when the user manually scrolls up
New message indicatorShows a “New messages” button when the user is not at the bottom
RenderingMarkdown rendering + code highlighting

When the user types text starting with /, command input mode is triggered:

CommandTypeFunction
/compactRPCManually trigger context compression
/loopLocal + RPCLoop execution (scheduled / dynamic)
/goalPromptGoal-driven; AI sets completion criteria, Judge model checks

See Commands.

ScenarioStrategy
Large message listsPaginated loading (cursor pagination); first load shows the latest 50
Long conversation scrollingVirtual scroll optimization (future release)
Markdown renderingOn-demand rendering; code highlighting loaded lazily
IndexedDB reads/writesUnified by Persistence Controller; batch operations reduce IO
FeatureImplementation
Keyboard navigationTab to switch focus, Enter to activate, Esc to close dialogs
ARIA labelsAll interactive elements have aria-label
Screen readerMessage list uses role="log"; new messages announced automatically
High contrastSupports system high-contrast mode