|
| 1 | +import { consume } from "@lit/context"; |
| 2 | +import { property } from "lit/decorators.js"; |
| 3 | +import type { UpdateAvailable } from "../api/types.ts"; |
| 4 | +import { |
| 5 | + DEFAULT_SIDEBAR_PINNED_ROUTES, |
| 6 | + type NavigationRouteId, |
| 7 | + type SidebarNavRoute, |
| 8 | +} from "../app-navigation.ts"; |
| 9 | +import type { RouteId } from "../app-route-paths.ts"; |
| 10 | +import { |
| 11 | + applicationContext, |
| 12 | + type ApplicationContext, |
| 13 | + type ApplicationNavigationOptions, |
| 14 | +} from "../app/context.ts"; |
| 15 | +import type { CatalogOpenTarget } from "../app/settings.ts"; |
| 16 | +import type { ThemeMode } from "../app/theme.ts"; |
| 17 | +import { OpenClawLightDomContentsElement } from "../lit/openclaw-element.ts"; |
| 18 | +import type { NewSessionTarget } from "../pages/new-session/location.ts"; |
| 19 | + |
| 20 | +/** Stable custom-element inputs. Behavior is layered in focused sidebar modules. */ |
| 21 | +export abstract class AppSidebarBase extends OpenClawLightDomContentsElement { |
| 22 | + @property({ attribute: false }) basePath = ""; |
| 23 | + @property({ attribute: false }) activeRouteId?: NavigationRouteId; |
| 24 | + @property({ attribute: false }) activePluginTabId = ""; |
| 25 | + @property({ attribute: false }) enabledRouteIds?: readonly NavigationRouteId[]; |
| 26 | + @property({ attribute: false }) connected = false; |
| 27 | + @property({ attribute: false }) terminalAvailable = false; |
| 28 | + @property({ attribute: false }) catalogOpenTarget: CatalogOpenTarget = "viewer"; |
| 29 | + @property({ attribute: false }) canPairDevice = false; |
| 30 | + @property({ attribute: false }) sessionKey = ""; |
| 31 | + @property({ attribute: false }) sidebarPinnedRoutes: readonly SidebarNavRoute[] = |
| 32 | + DEFAULT_SIDEBAR_PINNED_ROUTES; |
| 33 | + /** Agents surfaced first in the chip quick switcher when many exist. */ |
| 34 | + @property({ attribute: false }) pinnedAgentIds: readonly string[] = []; |
| 35 | + @property({ attribute: false }) themeMode: ThemeMode = "system"; |
| 36 | + @property({ attribute: false }) lobsterPetVisits = true; |
| 37 | + @property({ attribute: false }) lobsterPetSounds = false; |
| 38 | + @property({ attribute: false }) gatewayVersion: string | null = null; |
| 39 | + @property({ attribute: false }) devGitBranch: string | null = null; |
| 40 | + @property({ attribute: false }) updateAvailable: UpdateAvailable | null = null; |
| 41 | + @property({ attribute: false }) updateRunning = false; |
| 42 | + @property({ attribute: false }) onUpdate: () => void = () => undefined; |
| 43 | + @property({ attribute: false }) onOpenPalette?: () => void; |
| 44 | + @property({ attribute: false }) onToggleSidebar?: () => void; |
| 45 | + @property({ attribute: false }) onOpenNewSession?: ( |
| 46 | + agentId: string, |
| 47 | + target?: NewSessionTarget, |
| 48 | + ) => void; |
| 49 | + /** Agent id of the in-flight new-session draft; renders the draft row. */ |
| 50 | + @property({ attribute: false }) draftSessionAgentId = ""; |
| 51 | + @property({ attribute: false }) onUpdatePinnedRoutes?: (routes: SidebarNavRoute[]) => void; |
| 52 | + @property({ attribute: false }) onPairMobile?: () => void; |
| 53 | + @property({ attribute: false }) |
| 54 | + onNavigate?: (routeId: NavigationRouteId, options?: ApplicationNavigationOptions) => void; |
| 55 | + @property({ attribute: false }) onPreloadRoute?: (routeId: NavigationRouteId) => Promise<void>; |
| 56 | + |
| 57 | + @consume({ context: applicationContext, subscribe: true }) |
| 58 | + protected context?: ApplicationContext<RouteId>; |
| 59 | +} |
0 commit comments