Skip to content

Sessions, Profiles, And Settings

RoyalTerminal keeps runtime session control, durable session documents, settings UI, themes, and capture files in separate but cooperating layers. That split is one of the main reasons the project scales beyond a single demo app.

The runtime session boundary

The runtime boundary is the session service. It is responsible for attaching an endpoint or transport, routing input, exposing selection and mode sources, and applying resize changes.

TypePurpose
ITerminalSessionServicePublic session-service contract used by hosts and the control.
TerminalSessionInputEventArgsEvent payload raised when input bytes are sent.
TerminalSessionServiceDefault session-service implementation.

The important design point is that this service does not own the UI. It sits between the UI and the transport/endpoint/VT layers.

Session profiles are the durable configuration format

The profile model is the durable description of a session, not the running session itself. That makes it usable by the settings UI, the demo, file-based persistence, and custom applications.

Profile document types

TypePurpose
TerminalSessionProfilesDocumentVersioned top-level profile document.
TerminalSessionProfileOne named profile.
TerminalSessionLayoutSettingsGrid, viewport, and scrollback settings.
TerminalSessionAppearanceSettingsFont, size, auto-scroll, opacity, and text highlighting settings.
TerminalTextHighlightingModeRegex text highlighting evaluation mode.
TerminalSessionTextHighlightRulePersisted regex highlight rule with optional light/dark foreground and background colors.
TerminalSessionBehaviorSettingsCopy, bell, backspace, shaping, ligature, and paste behavior settings.
TerminalSessionTransportProfileAll transport-specific settings for a profile.
TerminalSessionPtySettingsLocal PTY profile settings.
TerminalSessionPipeSettingsPipe process profile settings.
TerminalSessionSshSettingsSSH profile settings.
TerminalSessionRawTcpSettingsRaw TCP profile settings.
TerminalSessionTelnetSettingsTelnet profile settings.
TerminalSessionSerialSettingsSerial profile settings.
TerminalSessionSshAuthenticationSettingsStored SSH auth settings.
TerminalSessionLoggingSettingsSession logging settings.
TerminalSessionProxySettingsProxy settings stored with the profile.
TerminalSessionLogFormatStored log format enum.
TerminalSessionProxyTypeStored proxy type enum.

The model is intentionally broad. It is meant to cover what a terminal application needs to remember between runs, not just what is required to start a shell on the current machine.

Editing profiles in the UI

The Avalonia settings package is built around those profile records. The controls and state slices are public because real applications often want to host or extend that editor.

TypePurpose
TerminalSettingsPanelRoot settings host control.
TerminalSettingsSessionPanelSession editor surface.
TerminalSettingsConnectionPanelConnection editor surface.
TerminalSettingsTerminalPanelTerminal behavior editor surface.
TerminalSettingsAppearancePanelAppearance editor surface, including regex text highlighting.
TerminalSettingsSshPanelSSH editor surface.
TerminalSettingsLoggingPanelLogging editor surface.
TerminalSettingsCategoryStateBaseBase state slice.
TerminalSettingsPanelStateCentral settings state owner.
TerminalSettingsProfileItemProfile picker item.
TerminalSettingsTransportModeOptionTransport picker option.
TerminalSettingsSshAuthModeOptionSSH auth mode picker option.
TerminalSettingsTextHighlightingModeOptionRegex highlighting mode picker option.
TerminalSettingsHighlightRuleStateEditable regex highlight rule state.
TerminalSettingsSessionStateSession slice.
TerminalSettingsConnectionStateConnection slice.
TerminalSettingsTerminalBehaviorStateTerminal behavior slice.
TerminalSettingsAppearanceStateAppearance slice.
TerminalSettingsSshStateSSH slice.
TerminalSettingsLoggingStateLogging slice.

The point of the package is not just "draw a settings dialog". It is to give hosts a reusable editor for the same document model the runtime understands.

Serializing and mapping profiles

The public serializer and store abstractions are how profile documents move between disk, UI, and runtime options.

TypePurpose
TerminalSessionProfileSerializerStatic serializer, normalizer, and validator for profile documents.
ITerminalSessionProfileStoreAsync persistence contract for profile documents.
JsonFileTerminalSessionProfileStoreJSON file-backed profile store.
TerminalSessionProfileStoreFactoryFactory for default profile stores and file paths.
TerminalSessionProfileMapperConverts between durable profiles and runnable transport options.

That mapping layer is critical. It prevents runtime startup code from having to understand every persisted profile detail directly.

Text highlighting profile data

Regex text highlighting is stored as appearance data because it changes how the terminal is drawn, not how the transport or VT engine behaves. The persisted profile fields are:

FieldPurpose
TextHighlightingModeStatic, Realtime, or Disabled.
TextHighlightRulesOrdered list of TerminalSessionTextHighlightRule entries.
ForegroundColor / BackgroundColorOptional default/light colors.
DarkForegroundColor / DarkBackgroundColorOptional dark-theme overrides.

The profile serializer normalizes color strings to #AARRGGBB, skips empty-pattern rules, and resets unknown mode values to Static. The runtime renderer uses the equivalent TerminalTextHighlightRule model with packed ARGB colors.

See Regex Text Highlighting for the full JSON shape, settings UI behavior, runtime API, and performance notes.

Themes are documents too

RoyalTerminal treats theme data as a real cross-layer document, not as UI-only colors.

TypePurpose
TerminalPaletteImmutable 256-color palette.
TerminalPaletteGenerationModePalette generation strategy enum.
TerminalPaletteGeneratorStatic generator for 256-color palettes.
TerminalOscColorReportFormatOSC report format enum.
TerminalThemeImmutable terminal theme snapshot.
TerminalThemeParserText theme parser.
TerminalThemeSerializerTheme serializer and deserializer.

This is why the same theme model works in managed VT, native VT, snapshot export, and rendering.

Capture files and replay data

RoyalTerminal also treats captures as durable documents. That makes them useful for debugging, support, and regression reproduction rather than only for live UI playback.

TypePurpose
TerminalCaptureEventKindOutput, input, resize, marker, and exit capture event kind.
TerminalCaptureEventOne captured event with a relative timestamp.
TerminalCaptureSessionSerializable capture session document.
TerminalCaptureRecorderRuntime recorder for capture events.
TerminalCaptureSessionSerializerNative JSON capture serializer plus explicit-format overloads.
ITerminalCaptureSessionFormatPluggable capture file format contract.
TerminalCaptureFileFormatDescriptorFormat id, display name, extensions, and MIME types for hosts and file pickers.
TerminalCaptureSessionFormatRegistryFormat lookup, save by id, and load probing by file name/content.
TerminalCaptureSessionFormatsBuilt-in RoyalTerminal JSON and asciicast v3 formats.
TerminalCaptureRuntimeAvalonia-facing capture and replay runtime bound to a control.

Use RoyalTerminal JSON (.rtcap.json) when capture fidelity matters most. Use asciicast v3 (.cast) when interoperability with asciinema-compatible tooling matters. See Capture Formats for the event mapping, extension model, and demo app behavior.

Shell profiles and defaults

RoyalTerminal also ships shell profile discovery as a reusable surface. That matters for hosts that want a sane default shell without scattering platform checks everywhere.

TypePurpose
ShellProfileNamed shell profile.
IShellProfileCatalogShell profile discovery contract.
DefaultShellProfileCatalogPlatform-aware default shell catalog.

Snapshot export lives next to session documents

Snapshot export is where a live terminal becomes a durable copy. The export contracts are shared across VT processors and stay outside the UI layer for that reason.

TypePurpose
TerminalSnapshotExportFormatSnapshot format enum.
TerminalSnapshotExportExtrasExtra export detail options.
TerminalSnapshotExportOptionsSnapshot export request.
ITerminalSnapshotExportSourceSnapshot export capability contract.

If the transport article is about running sessions, this article is about remembering them, editing them, exporting them, and replaying them later.

MIT Licensed