Skip to content

Commit dc7f167

Browse files
authored
refactor(ui): split app sidebar responsibilities (#108422)
* refactor(ui): split app sidebar responsibilities * fix(ui): keep sidebar menu action type private
1 parent 8cc8fee commit dc7f167

10 files changed

Lines changed: 2588 additions & 2435 deletions

‎config/max-lines-baseline.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,6 @@ ui/src/api/gateway.node.test.ts
11301130
ui/src/api/types.ts
11311131
ui/src/app/app-host.ts
11321132
ui/src/components/app-sidebar.test.ts
1133-
ui/src/components/app-sidebar.ts
11341133
ui/src/components/browser/browser-panel.ts
11351134
ui/src/components/config-form.node.ts
11361135
ui/src/components/lobster-pet.ts
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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

Comments
 (0)