ltcai 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -33
- package/desktop/electron/main.cjs +44 -0
- package/docs/CHANGELOG.md +106 -0
- package/docs/REALTIME_COLLABORATION.md +3 -3
- package/docs/V3_FRONTEND.md +9 -8
- package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
- package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
- package/docs/V4_1_VALIDATION_REPORT.md +47 -0
- package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +95 -45
- package/docs/kg-schema.md +6 -2
- package/docs/spec-vs-impl.md +10 -10
- package/frontend/index.html +24 -0
- package/frontend/openapi.json +14190 -0
- package/frontend/src/App.tsx +184 -0
- package/frontend/src/api/client.ts +317 -0
- package/frontend/src/api/openapi.ts +16637 -0
- package/frontend/src/components/primitives.tsx +204 -0
- package/frontend/src/components/ui/badge.tsx +27 -0
- package/frontend/src/components/ui/button.tsx +37 -0
- package/frontend/src/components/ui/card.tsx +22 -0
- package/frontend/src/components/ui/input.tsx +16 -0
- package/frontend/src/components/ui/textarea.tsx +16 -0
- package/frontend/src/lib/utils.ts +33 -0
- package/frontend/src/main.tsx +23 -0
- package/frontend/src/pages/Act.tsx +245 -0
- package/frontend/src/pages/Ask.tsx +200 -0
- package/frontend/src/pages/Brain.tsx +267 -0
- package/frontend/src/pages/Capture.tsx +158 -0
- package/frontend/src/pages/Library.tsx +187 -0
- package/frontend/src/pages/System.tsx +344 -0
- package/frontend/src/routes.ts +85 -0
- package/frontend/src/store/appStore.ts +54 -0
- package/frontend/src/styles.css +107 -0
- package/kg_schema.py +2 -603
- package/knowledge_graph.py +37 -4958
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/admin.py +15 -16
- package/latticeai/api/agents.py +13 -6
- package/latticeai/api/auth.py +19 -11
- package/latticeai/api/invitations.py +100 -0
- package/latticeai/api/knowledge_graph.py +4 -11
- package/latticeai/api/plugins.py +3 -6
- package/latticeai/api/realtime.py +4 -7
- package/latticeai/api/setup.py +5 -4
- package/latticeai/api/static_routes.py +13 -16
- package/latticeai/api/ui_redirects.py +26 -0
- package/latticeai/api/workflow_designer.py +39 -6
- package/latticeai/api/workspace.py +24 -10
- package/latticeai/app_factory.py +88 -17
- package/latticeai/brain/_kg_common.py +1123 -0
- package/latticeai/brain/discovery.py +1455 -0
- package/latticeai/brain/documents.py +218 -0
- package/latticeai/brain/ingest.py +644 -0
- package/latticeai/brain/projection.py +561 -0
- package/latticeai/brain/provenance.py +401 -0
- package/latticeai/brain/retrieval.py +1316 -0
- package/latticeai/brain/schema.py +640 -0
- package/latticeai/brain/store.py +216 -0
- package/latticeai/brain/write_master.py +225 -0
- package/latticeai/core/invitations.py +131 -0
- package/latticeai/core/marketplace.py +1 -1
- package/latticeai/core/multi_agent.py +1 -1
- package/latticeai/core/policy.py +54 -0
- package/latticeai/core/realtime.py +65 -44
- package/latticeai/core/sessions.py +31 -5
- package/latticeai/core/users.py +147 -0
- package/latticeai/core/workspace_os.py +420 -20
- package/latticeai/services/agent_runtime.py +242 -4
- package/latticeai/services/run_executor.py +328 -0
- package/latticeai/services/workspace_service.py +27 -19
- package/package.json +54 -27
- package/scripts/build_frontend_assets.mjs +38 -0
- package/scripts/bump_version.py +1 -1
- package/scripts/export_openapi.py +31 -0
- package/scripts/lint_frontend.mjs +86 -0
- package/scripts/run_python.mjs +47 -0
- package/src-tauri/Cargo.lock +4833 -0
- package/src-tauri/Cargo.toml +19 -0
- package/src-tauri/build.rs +3 -0
- package/src-tauri/capabilities/default.json +7 -0
- package/src-tauri/src/main.rs +78 -0
- package/src-tauri/tauri.conf.json +36 -0
- package/static/app/asset-manifest.json +32 -0
- package/static/app/assets/core-CwxXejkd.js +2 -0
- package/static/app/assets/core-CwxXejkd.js.map +1 -0
- package/static/app/assets/index-CJRAzNnf.js +333 -0
- package/static/app/assets/index-CJRAzNnf.js.map +1 -0
- package/static/app/assets/index-CSwBBgf4.css +2 -0
- package/static/app/index.html +25 -0
- package/static/manifest.json +2 -2
- package/static/sw.js +4 -4
- package/scripts/build_v3_assets.mjs +0 -170
- package/scripts/lint_v3.mjs +0 -97
- package/static/account.html +0 -113
- package/static/activity.html +0 -73
- package/static/admin.html +0 -486
- package/static/agents.html +0 -139
- package/static/chat.html +0 -841
- package/static/css/reference/account.css +0 -439
- package/static/css/reference/admin.css +0 -610
- package/static/css/reference/base.css +0 -1661
- package/static/css/reference/chat.css +0 -4623
- package/static/css/reference/graph.css +0 -1016
- package/static/css/responsive.css +0 -861
- package/static/graph.html +0 -122
- package/static/platform.css +0 -104
- package/static/plugins.html +0 -136
- package/static/scripts/account.js +0 -238
- package/static/scripts/admin.js +0 -1614
- package/static/scripts/chat.js +0 -5081
- package/static/scripts/graph.js +0 -1804
- package/static/scripts/platform.js +0 -64
- package/static/scripts/ux.js +0 -167
- package/static/scripts/workspace.js +0 -948
- package/static/v3/asset-manifest.json +0 -56
- package/static/v3/css/lattice.base.49deefb5.css +0 -128
- package/static/v3/css/lattice.base.css +0 -128
- package/static/v3/css/lattice.components.cde18231.css +0 -472
- package/static/v3/css/lattice.components.css +0 -472
- package/static/v3/css/lattice.shell.29d36d85.css +0 -452
- package/static/v3/css/lattice.shell.css +0 -452
- package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
- package/static/v3/css/lattice.tokens.css +0 -135
- package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
- package/static/v3/css/lattice.views.css +0 -360
- package/static/v3/index.html +0 -68
- package/static/v3/js/app.356e6452.js +0 -26
- package/static/v3/js/app.js +0 -26
- package/static/v3/js/core/api.7a308b89.js +0 -568
- package/static/v3/js/core/api.js +0 -568
- package/static/v3/js/core/components.f25b3b93.js +0 -230
- package/static/v3/js/core/components.js +0 -230
- package/static/v3/js/core/dom.a2773eb0.js +0 -148
- package/static/v3/js/core/dom.js +0 -148
- package/static/v3/js/core/router.584570f2.js +0 -37
- package/static/v3/js/core/router.js +0 -37
- package/static/v3/js/core/routes.7222343d.js +0 -93
- package/static/v3/js/core/routes.js +0 -93
- package/static/v3/js/core/shell.a1657f20.js +0 -391
- package/static/v3/js/core/shell.js +0 -391
- package/static/v3/js/core/store.204a08b2.js +0 -113
- package/static/v3/js/core/store.js +0 -113
- package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
- package/static/v3/js/views/admin-audit.js +0 -185
- package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
- package/static/v3/js/views/admin-permissions.js +0 -177
- package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
- package/static/v3/js/views/admin-policies.js +0 -102
- package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
- package/static/v3/js/views/admin-private-vpc.js +0 -135
- package/static/v3/js/views/admin-security.07c66b72.js +0 -180
- package/static/v3/js/views/admin-security.js +0 -180
- package/static/v3/js/views/admin-users.03bac88c.js +0 -168
- package/static/v3/js/views/admin-users.js +0 -168
- package/static/v3/js/views/agents.014d0b74.js +0 -541
- package/static/v3/js/views/agents.js +0 -541
- package/static/v3/js/views/chat.e6dd7dd0.js +0 -601
- package/static/v3/js/views/chat.js +0 -601
- package/static/v3/js/views/files.adad14c1.js +0 -365
- package/static/v3/js/views/files.js +0 -365
- package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
- package/static/v3/js/views/graph-canvas.js +0 -509
- package/static/v3/js/views/home.24f8b8ae.js +0 -200
- package/static/v3/js/views/home.js +0 -200
- package/static/v3/js/views/hooks.37895880.js +0 -220
- package/static/v3/js/views/hooks.js +0 -220
- package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
- package/static/v3/js/views/hybrid-search.js +0 -194
- package/static/v3/js/views/knowledge-graph.5e40cbeb.js +0 -509
- package/static/v3/js/views/knowledge-graph.js +0 -509
- package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
- package/static/v3/js/views/marketplace.js +0 -141
- package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
- package/static/v3/js/views/mcp.js +0 -114
- package/static/v3/js/views/memory.4ebdf474.js +0 -147
- package/static/v3/js/views/memory.js +0 -147
- package/static/v3/js/views/models.a1ffa147.js +0 -256
- package/static/v3/js/views/models.js +0 -256
- package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
- package/static/v3/js/views/my-computer.js +0 -463
- package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
- package/static/v3/js/views/pipeline.js +0 -157
- package/static/v3/js/views/planning.9ac3e313.js +0 -153
- package/static/v3/js/views/planning.js +0 -153
- package/static/v3/js/views/settings.8631fa5e.js +0 -318
- package/static/v3/js/views/settings.js +0 -318
- package/static/v3/js/views/skills.c6c2f965.js +0 -109
- package/static/v3/js/views/skills.js +0 -109
- package/static/v3/js/views/tools.e4f11276.js +0 -108
- package/static/v3/js/views/tools.js +0 -108
- package/static/v3/js/views/workflows.26c57290.js +0 -128
- package/static/v3/js/views/workflows.js +0 -128
- package/static/workflows.html +0 -146
- package/static/workspace.css +0 -1121
- package/static/workspace.html +0 -357
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Lattice AI v3 — Application shell
|
|
3
|
-
* Builds the persistent chrome (nav rail, topbar, view outlet), wires the
|
|
4
|
-
* router, workspace + mode + theme switchers, command palette, and mobile
|
|
5
|
-
* drawer. Renders views by lazy-loading their module and calling render(ctx).
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
import { h, icon, $, $$ } from "./dom.js";
|
|
9
|
-
import { store } from "./store.js";
|
|
10
|
-
import { api } from "./api.js";
|
|
11
|
-
import * as c from "./components.js";
|
|
12
|
-
import { createRouter } from "./router.js";
|
|
13
|
-
import { GROUPS, ROUTES, ROUTE_BY_KEY, MODE_RANK, visibleRoutes, loadView } from "./routes.js";
|
|
14
|
-
|
|
15
|
-
const MODES = [
|
|
16
|
-
{ key: "basic", label: "Basic", icon: "circle" },
|
|
17
|
-
{ key: "advanced", label: "Advanced", icon: "circles" },
|
|
18
|
-
{ key: "admin", label: "Admin", icon: "shield-half" },
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const ctxBase = { h, icon, api, store, c };
|
|
22
|
-
|
|
23
|
-
let els = {};
|
|
24
|
-
let router;
|
|
25
|
-
let currentRoute = null;
|
|
26
|
-
|
|
27
|
-
export function boot(rootEl) {
|
|
28
|
-
rootEl.classList.add("lt3-app");
|
|
29
|
-
rootEl.append(
|
|
30
|
-
h("a.lt3-skip", { href: "#lt3-view" }, "Skip to content"),
|
|
31
|
-
h("div.lt3-rail__scrim", { on: { click: closeDrawer } }),
|
|
32
|
-
buildRail(),
|
|
33
|
-
buildMain(),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
cacheEls(rootEl);
|
|
37
|
-
store.subscribe(onStateChange);
|
|
38
|
-
|
|
39
|
-
router = createRouter({ onRoute: renderRoute, fallback: "knowledge-graph" });
|
|
40
|
-
wireGlobalKeys();
|
|
41
|
-
router.start();
|
|
42
|
-
|
|
43
|
-
// Background: hydrate workspaces, identity, index status.
|
|
44
|
-
hydrate();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/* ── Rail ────────────────────────────────────────────────────────────────── */
|
|
48
|
-
function buildRail() {
|
|
49
|
-
return h("aside.lt3-rail", { id: "lt3-rail", "aria-label": "Primary" },
|
|
50
|
-
h("div.lt3-rail__brand",
|
|
51
|
-
h("div.lt3-rail__logo", { html: latticeMark() }),
|
|
52
|
-
h("div.lt3-rail__word", h("b", "Lattice AI"), h("small", "Private runtime")),
|
|
53
|
-
h("button.lt3-iconbtn.lt3-iconbtn--sm.lt3-rail__close", { "aria-label": "Close menu", on: { click: closeDrawer } }, icon("x")),
|
|
54
|
-
),
|
|
55
|
-
h("div.lt3-rail__scope", { id: "lt3-scope" }),
|
|
56
|
-
h("nav.lt3-rail__nav", { id: "lt3-nav", "aria-label": "Sections" }),
|
|
57
|
-
h("div.lt3-rail__foot",
|
|
58
|
-
h("div.lt3-rail__status", { id: "lt3-rail-status" }),
|
|
59
|
-
h("div.lt3-rail__foot-row",
|
|
60
|
-
h("button.lt3-rail__user", { id: "lt3-user", "aria-label": "Account", on: { click: () => router.navigate("settings") } }),
|
|
61
|
-
h("button.lt3-iconbtn", { id: "lt3-theme", "aria-label": "Toggle theme", title: "Toggle theme", on: { click: () => store.toggleTheme() } }, icon("moon")),
|
|
62
|
-
),
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function renderNav() {
|
|
68
|
-
const nav = els.nav;
|
|
69
|
-
const mode = store.get().mode;
|
|
70
|
-
const routes = visibleRoutes(mode);
|
|
71
|
-
nav.replaceChildren();
|
|
72
|
-
for (const group of GROUPS) {
|
|
73
|
-
const items = routes.filter((r) => r.group === group.id);
|
|
74
|
-
if (!items.length) continue;
|
|
75
|
-
const groupEl = h("div.lt3-navgroup",
|
|
76
|
-
h("div.lt3-navgroup__label", group.label),
|
|
77
|
-
items.map((r) => navItem(r)),
|
|
78
|
-
);
|
|
79
|
-
nav.append(groupEl);
|
|
80
|
-
}
|
|
81
|
-
markActive();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function navItem(route) {
|
|
85
|
-
return h("a.lt3-navitem", {
|
|
86
|
-
href: "#/" + route.key,
|
|
87
|
-
dataset: { key: route.key },
|
|
88
|
-
title: route.title || route.label,
|
|
89
|
-
on: { click: () => closeDrawer() },
|
|
90
|
-
},
|
|
91
|
-
icon(route.icon),
|
|
92
|
-
h("span.lt3-navitem__copy",
|
|
93
|
-
h("span.lt3-navitem__label", route.label),
|
|
94
|
-
route.desc ? h("span.lt3-navitem__meta", route.desc) : null,
|
|
95
|
-
),
|
|
96
|
-
route.key === "hybrid-search" ? h("span.lt3-navitem__dot", { style: { background: "var(--lt3-pillar-hybrid)" } }) : null,
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function markActive() {
|
|
101
|
-
$$(".lt3-navitem", els.nav).forEach((a) => {
|
|
102
|
-
const on = a.dataset.key === (currentRoute && currentRoute.key);
|
|
103
|
-
if (on) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current");
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function renderScope() {
|
|
108
|
-
const ws = store.activeWorkspace();
|
|
109
|
-
els.scope.replaceChildren(
|
|
110
|
-
h("button.lt3-scope", { "aria-haspopup": "listbox", on: { click: openScopeMenu } },
|
|
111
|
-
h("div.lt3-scope__icon", icon(ws.type === "organization" ? "building-community" : "user")),
|
|
112
|
-
h("div.lt3-scope__meta", h("b", ws.name), h("small", `${ws.type} · ${ws.your_role || "member"}`)),
|
|
113
|
-
icon("selector"),
|
|
114
|
-
),
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function renderUser() {
|
|
119
|
-
const u = store.get().user;
|
|
120
|
-
const initials = (u.nickname || u.email || "U").slice(0, 2);
|
|
121
|
-
els.user.replaceChildren(
|
|
122
|
-
h("span.lt3-avatar", initials),
|
|
123
|
-
h("div.lt3-rail__user-meta", h("b", u.nickname || u.email || "You"), h("small", u.role || "local")),
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function updateThemeIcon() {
|
|
128
|
-
const dark = document.documentElement.getAttribute("data-lt-theme") === "dark"
|
|
129
|
-
|| (!store.get().theme && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
130
|
-
els.theme.replaceChildren(icon(dark ? "sun" : "moon"));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/* ── Main / topbar ──────────────────────────────────────────────────────── */
|
|
134
|
-
function buildMain() {
|
|
135
|
-
return h("div.lt3-main",
|
|
136
|
-
h("header.lt3-topbar",
|
|
137
|
-
h("button.lt3-iconbtn.lt3-topbar__menu", { "aria-label": "Open menu", on: { click: openDrawer } }, icon("menu-2")),
|
|
138
|
-
h("div.lt3-topbar__crumbs", { id: "lt3-crumbs" }),
|
|
139
|
-
h("div.lt3-spacer"),
|
|
140
|
-
h("button.lt3-cmd-trigger", { "aria-label": "Search and commands", on: { click: openPalette } },
|
|
141
|
-
icon("search"), h("span", "Search & commands"), h("span.lt3-kbd", "⌘K")),
|
|
142
|
-
h("div", { id: "lt3-idxchip" }),
|
|
143
|
-
h("div.lt3-mode", { id: "lt3-mode", role: "tablist", "aria-label": "Workspace mode" },
|
|
144
|
-
MODES.map((m) => h("button", {
|
|
145
|
-
type: "button", role: "tab", dataset: { mode: m.key },
|
|
146
|
-
on: { click: () => store.setMode(m.key) },
|
|
147
|
-
}, icon(m.icon), h("span", m.label))),
|
|
148
|
-
),
|
|
149
|
-
),
|
|
150
|
-
h("main.lt3-view", { id: "lt3-view", tabindex: "-1" },
|
|
151
|
-
h("div.lt3-view__inner", { id: "lt3-outlet" }),
|
|
152
|
-
),
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function renderMode() {
|
|
157
|
-
$$("#lt3-mode button", els.root).forEach((b) => b.dataset.active = String(b.dataset.mode === store.get().mode));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function renderCrumbs() {
|
|
161
|
-
const r = currentRoute;
|
|
162
|
-
if (!r) return;
|
|
163
|
-
const parts = [h("span.lt3-crumb", store.activeWorkspace().name)];
|
|
164
|
-
if (r.group === "admin") parts.push(icon("chevron-right"), h("span.lt3-crumb", "Admin"));
|
|
165
|
-
parts.push(icon("chevron-right"), h("span.lt3-crumb.lt3-crumb--current", r.title || r.label));
|
|
166
|
-
els.crumbs.replaceChildren(...parts);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function renderIndexChip() {
|
|
170
|
-
els.idxchip.replaceChildren(c.indexChip(store.get().indexStatus));
|
|
171
|
-
renderRailStatus();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function renderRailStatus() {
|
|
175
|
-
if (!els.railStatus) return;
|
|
176
|
-
const status = store.get().indexStatus;
|
|
177
|
-
const pipes = status?.pipelines || {};
|
|
178
|
-
const keys = ["knowledge_graph", "vector_index", "hybrid"];
|
|
179
|
-
const ready = keys.filter((key) => String(pipes[key]?.state || "").toLowerCase() === "ready").length;
|
|
180
|
-
const unavailable = !Object.keys(pipes).length;
|
|
181
|
-
els.railStatus.replaceChildren(
|
|
182
|
-
h("div.lt3-rail__status-top",
|
|
183
|
-
h("span.lt3-rail__status-dot", { dataset: { state: unavailable ? "pending" : ready === keys.length ? "ready" : "partial" } }),
|
|
184
|
-
h("span", unavailable ? "Local index pending" : `${ready}/${keys.length} retrieval signals ready`),
|
|
185
|
-
),
|
|
186
|
-
h("div.lt3-rail__status-sub", unavailable ? "Start backend to sync live state" : "Graph · vector · hybrid"),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/* ── View rendering ─────────────────────────────────────────────────────── */
|
|
191
|
-
async function renderRoute({ key, params }) {
|
|
192
|
-
let route = ROUTE_BY_KEY[key] || ROUTE_BY_KEY.home;
|
|
193
|
-
// Deep-linking into an admin area surfaces Admin mode so the rail matches.
|
|
194
|
-
if (route.admin && store.get().mode !== "admin") store.setMode("admin");
|
|
195
|
-
currentRoute = route;
|
|
196
|
-
store.setRoute({ key: route.key, params });
|
|
197
|
-
|
|
198
|
-
document.title = `${route.title || route.label} · Lattice AI`;
|
|
199
|
-
markActive();
|
|
200
|
-
renderCrumbs();
|
|
201
|
-
|
|
202
|
-
const outlet = els.outlet;
|
|
203
|
-
outlet.replaceChildren(c.loading({ lines: 4, block: true }));
|
|
204
|
-
els.view.scrollTop = 0;
|
|
205
|
-
|
|
206
|
-
try {
|
|
207
|
-
const mod = await loadView(route.view);
|
|
208
|
-
if (currentRoute !== route) return; // navigated away during load
|
|
209
|
-
els.view.classList.toggle("lt3-view--flush", mod.layout === "flush");
|
|
210
|
-
const ctx = { ...ctxBase, route, params, navigate: router.navigate, toast: c.toast };
|
|
211
|
-
const node = await mod.render(ctx);
|
|
212
|
-
if (currentRoute !== route) return;
|
|
213
|
-
outlet.replaceChildren(node);
|
|
214
|
-
} catch (err) {
|
|
215
|
-
console.error("[shell] view render failed:", route.view, err);
|
|
216
|
-
outlet.replaceChildren(c.errorState(`View "${route.label}" failed to load.`, () => renderRoute({ key: route.key, params })));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function renderCurrent() {
|
|
221
|
-
if (currentRoute) renderRoute({ key: currentRoute.key, params: store.get().route.params || {} });
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/* ── State reactions ────────────────────────────────────────────────────── */
|
|
225
|
-
function onStateChange(_state, change) {
|
|
226
|
-
switch (change.type) {
|
|
227
|
-
case "mode": renderNav(); renderMode(); renderCurrent(); break;
|
|
228
|
-
case "workspace": renderScope(); renderCrumbs(); renderCurrent(); break;
|
|
229
|
-
case "workspaces": renderScope(); break;
|
|
230
|
-
case "user": renderUser(); break;
|
|
231
|
-
case "theme": updateThemeIcon(); break;
|
|
232
|
-
case "index": renderIndexChip(); break;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/* ── Workspace scope menu ───────────────────────────────────────────────── */
|
|
237
|
-
function openScopeMenu(ev) {
|
|
238
|
-
ev.stopPropagation();
|
|
239
|
-
closeMenus();
|
|
240
|
-
const rect = ev.currentTarget.getBoundingClientRect();
|
|
241
|
-
const list = store.get().workspaces;
|
|
242
|
-
const menu = h("div.lt3-menu", { id: "lt3-scope-menu", role: "listbox", style: { top: rect.bottom + 6 + "px", left: rect.left + "px" } },
|
|
243
|
-
list.map((w) => h("button.lt3-menu__item", {
|
|
244
|
-
role: "option", dataset: { active: String(w.workspace_id === store.get().workspaceId) },
|
|
245
|
-
on: { click: () => { store.setWorkspace(w.workspace_id); closeMenus(); } },
|
|
246
|
-
},
|
|
247
|
-
icon(w.type === "organization" ? "building-community" : "user"),
|
|
248
|
-
h("div", h("div", { style: { fontWeight: 600 } }, w.name), h("small.lt3-faint", { style: { textTransform: "capitalize" } }, w.type)),
|
|
249
|
-
w.workspace_id === store.get().workspaceId ? icon("check", "") : null,
|
|
250
|
-
)),
|
|
251
|
-
h("div.lt3-menu__sep"),
|
|
252
|
-
h("button.lt3-menu__item", { on: { click: () => { c.toast("Organization creation opens in Settings", "info"); closeMenus(); router.navigate("settings"); } } },
|
|
253
|
-
icon("plus"), "New organization"),
|
|
254
|
-
);
|
|
255
|
-
document.body.append(menu);
|
|
256
|
-
setTimeout(() => document.addEventListener("click", closeMenusOnce, { once: true }), 0);
|
|
257
|
-
}
|
|
258
|
-
function closeMenus() { $$(".lt3-menu").forEach((m) => m.remove()); }
|
|
259
|
-
function closeMenusOnce() { closeMenus(); }
|
|
260
|
-
|
|
261
|
-
/* ── Mobile drawer ──────────────────────────────────────────────────────── */
|
|
262
|
-
function openDrawer() { els.root.dataset.drawer = "open"; }
|
|
263
|
-
function closeDrawer() { delete els.root.dataset.drawer; }
|
|
264
|
-
|
|
265
|
-
/* ── Command palette ────────────────────────────────────────────────────── */
|
|
266
|
-
function paletteItems() {
|
|
267
|
-
const mode = store.get().mode;
|
|
268
|
-
const currentRoutes = visibleRoutes(mode);
|
|
269
|
-
const nav = currentRoutes.map((r) => ({
|
|
270
|
-
group: "Go to", label: r.title || r.label, icon: r.icon, hint: r.label === r.title ? r.group : r.label,
|
|
271
|
-
run: () => router.navigate(r.key),
|
|
272
|
-
}));
|
|
273
|
-
const actions = [
|
|
274
|
-
{ group: "Actions", label: "Toggle light / dark theme", icon: "contrast", run: () => store.toggleTheme() },
|
|
275
|
-
{ group: "Actions", label: "Mode: Basic", icon: "circle", run: () => store.setMode("basic") },
|
|
276
|
-
{ group: "Actions", label: "Mode: Advanced", icon: "circles", run: () => store.setMode("advanced") },
|
|
277
|
-
{ group: "Actions", label: "Mode: Admin", icon: "shield-half", run: () => store.setMode("admin") },
|
|
278
|
-
{ group: "Actions", label: "New chat", icon: "message-plus", run: () => router.navigate("chat", { new: "1" }) },
|
|
279
|
-
{ group: "Actions", label: "Run hybrid search", icon: "arrows-join", run: () => router.navigate("hybrid-search") },
|
|
280
|
-
];
|
|
281
|
-
return [...nav, ...actions];
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function openPalette() {
|
|
285
|
-
if ($("#lt3-palette")) return;
|
|
286
|
-
const all = paletteItems();
|
|
287
|
-
let active = 0, filtered = all;
|
|
288
|
-
|
|
289
|
-
const listEl = h("div.lt3-palette__list");
|
|
290
|
-
const input = h("input", { type: "text", placeholder: "Search views, run a command…", "aria-label": "Command palette", autocomplete: "off" });
|
|
291
|
-
const palette = h("div.lt3-palette", { id: "lt3-palette", role: "dialog", "aria-modal": "true", "aria-label": "Command palette" },
|
|
292
|
-
h("div.lt3-palette__input", icon("search"), input, h("span.lt3-kbd", "Esc")),
|
|
293
|
-
listEl,
|
|
294
|
-
);
|
|
295
|
-
const scrim = h("div.lt3-scrim", { id: "lt3-palette-scrim", on: { click: close } });
|
|
296
|
-
document.body.append(scrim, palette);
|
|
297
|
-
input.focus();
|
|
298
|
-
|
|
299
|
-
function renderList() {
|
|
300
|
-
listEl.replaceChildren();
|
|
301
|
-
if (!filtered.length) { listEl.append(h("div.lt3-palette__empty", "No matches")); return; }
|
|
302
|
-
let lastGroup = null;
|
|
303
|
-
filtered.forEach((item, i) => {
|
|
304
|
-
if (item.group !== lastGroup) { listEl.append(h("div.lt3-palette__group-label", item.group)); lastGroup = item.group; }
|
|
305
|
-
listEl.append(h("button.lt3-palette__item", {
|
|
306
|
-
dataset: { active: String(i === active) },
|
|
307
|
-
on: { click: () => { item.run(); close(); }, mousemove: () => { if (active !== i) { active = i; paint(); } } },
|
|
308
|
-
}, icon(item.icon), h("span", item.label), item.hint && h("small", item.hint)));
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
function paint() { $$(".lt3-palette__item", listEl).forEach((el, i) => el.dataset.active = String(i === active)); ensureVisible(); }
|
|
312
|
-
function ensureVisible() {
|
|
313
|
-
const el = $$(".lt3-palette__item", listEl)[active];
|
|
314
|
-
if (el) el.scrollIntoView({ block: "nearest" });
|
|
315
|
-
}
|
|
316
|
-
function filter() {
|
|
317
|
-
const q = input.value.trim().toLowerCase();
|
|
318
|
-
filtered = !q ? all : all.filter((it) => (it.label + " " + (it.hint || "")).toLowerCase().includes(q));
|
|
319
|
-
active = 0; renderList();
|
|
320
|
-
}
|
|
321
|
-
function close() { palette.remove(); scrim.remove(); document.removeEventListener("keydown", onKey, true); }
|
|
322
|
-
function onKey(e) {
|
|
323
|
-
if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); close(); }
|
|
324
|
-
else if (e.key === "ArrowDown") { e.preventDefault(); active = Math.min(filtered.length - 1, active + 1); paint(); }
|
|
325
|
-
else if (e.key === "ArrowUp") { e.preventDefault(); active = Math.max(0, active - 1); paint(); }
|
|
326
|
-
else if (e.key === "Enter") { e.preventDefault(); const it = filtered[active]; if (it) { it.run(); close(); } }
|
|
327
|
-
}
|
|
328
|
-
input.addEventListener("input", filter);
|
|
329
|
-
document.addEventListener("keydown", onKey, true);
|
|
330
|
-
renderList();
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function wireGlobalKeys() {
|
|
334
|
-
document.addEventListener("keydown", (e) => {
|
|
335
|
-
if ((e.metaKey || e.ctrlKey) && (e.key === "k" || e.key === "K")) { e.preventDefault(); openPalette(); }
|
|
336
|
-
if (e.key === "Escape") { closeMenus(); closeDrawer(); }
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/* ── Hydration ──────────────────────────────────────────────────────────── */
|
|
341
|
-
async function hydrate() {
|
|
342
|
-
// Identity (best-effort; never blocks the UI).
|
|
343
|
-
api.raw("/account/profile").then((r) => {
|
|
344
|
-
if (r.ok && r.data && (r.data.email || r.data.nickname)) {
|
|
345
|
-
store.setUser({ email: r.data.email, nickname: r.data.nickname || r.data.email, role: r.data.role || "user" });
|
|
346
|
-
} else { renderUser(); }
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// Workspaces from the OS payload (fallback-safe).
|
|
350
|
-
api.workspaceOs().then((r) => {
|
|
351
|
-
const reg = r.data && r.data.workspace_registry;
|
|
352
|
-
if (reg && Array.isArray(reg.workspaces) && reg.workspaces.length) store.setWorkspaces(reg.workspaces);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
// Index status powers the topbar chip + Home pillars.
|
|
356
|
-
api.indexStatus().then((r) => store.setIndexStatus(r.data));
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/* ── Init helpers ───────────────────────────────────────────────────────── */
|
|
360
|
-
function cacheEls(root) {
|
|
361
|
-
els = {
|
|
362
|
-
root,
|
|
363
|
-
nav: $("#lt3-nav", root),
|
|
364
|
-
scope: $("#lt3-scope", root),
|
|
365
|
-
user: $("#lt3-user", root),
|
|
366
|
-
theme: $("#lt3-theme", root),
|
|
367
|
-
crumbs: $("#lt3-crumbs", root),
|
|
368
|
-
idxchip: $("#lt3-idxchip", root),
|
|
369
|
-
railStatus: $("#lt3-rail-status", root),
|
|
370
|
-
outlet: $("#lt3-outlet", root),
|
|
371
|
-
view: $("#lt3-view", root),
|
|
372
|
-
};
|
|
373
|
-
renderNav();
|
|
374
|
-
renderScope();
|
|
375
|
-
renderUser();
|
|
376
|
-
renderMode();
|
|
377
|
-
updateThemeIcon();
|
|
378
|
-
renderIndexChip();
|
|
379
|
-
renderRailStatus();
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function latticeMark() {
|
|
383
|
-
// Crystalline lattice glyph — the product mark.
|
|
384
|
-
return `<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
385
|
-
<path d="M12 2.5 4 7v10l8 4.5L20 17V7L12 2.5Z" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round" opacity=".55"/>
|
|
386
|
-
<path d="M12 7.5 7.5 10v4L12 16.5 16.5 14v-4L12 7.5Z" fill="currentColor" opacity=".9"/>
|
|
387
|
-
<circle cx="12" cy="2.5" r="1.3" fill="currentColor"/><circle cx="4" cy="7" r="1.1" fill="currentColor"/>
|
|
388
|
-
<circle cx="20" cy="7" r="1.1" fill="currentColor"/><circle cx="4" cy="17" r="1.1" fill="currentColor"/>
|
|
389
|
-
<circle cx="20" cy="17" r="1.1" fill="currentColor"/><circle cx="12" cy="21.5" r="1.3" fill="currentColor"/>
|
|
390
|
-
</svg>`;
|
|
391
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Lattice AI v3 — App state store
|
|
3
|
-
* A minimal observable store with namespaced persistence. Holds the cross-view
|
|
4
|
-
* product state: theme, mode (Basic/Advanced/Admin), and the active workspace
|
|
5
|
-
* (Personal/Organization). Views/shell subscribe to react to changes.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
const LS = {
|
|
9
|
-
theme: "lt-theme", // shared with the rest of Lattice (data-lt-theme)
|
|
10
|
-
mode: "lt3-mode",
|
|
11
|
-
workspace: "lt3-workspace",
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function load(key, fallback) {
|
|
15
|
-
try { const v = localStorage.getItem(key); return v == null ? fallback : v; }
|
|
16
|
-
catch { return fallback; }
|
|
17
|
-
}
|
|
18
|
-
function save(key, value) {
|
|
19
|
-
try { localStorage.setItem(key, value); } catch { /* private mode */ }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const VALID_MODES = ["basic", "advanced", "admin"];
|
|
23
|
-
|
|
24
|
-
const state = {
|
|
25
|
-
theme: load(LS.theme, ""), // "" → follow OS
|
|
26
|
-
mode: VALID_MODES.includes(load(LS.mode)) ? load(LS.mode) : "basic",
|
|
27
|
-
workspaceId: load(LS.workspace, "personal"),
|
|
28
|
-
workspaces: [
|
|
29
|
-
{ workspace_id: "personal", name: "Personal Workspace", type: "personal", your_role: "owner" },
|
|
30
|
-
],
|
|
31
|
-
user: { email: "", nickname: "You", role: "user" },
|
|
32
|
-
indexStatus: null,
|
|
33
|
-
route: { key: "knowledge-graph", params: {} },
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const subscribers = new Set();
|
|
37
|
-
|
|
38
|
-
function emit(change) {
|
|
39
|
-
for (const fn of subscribers) {
|
|
40
|
-
try { fn(state, change); } catch (err) { console.error("[store] subscriber", err); }
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const store = {
|
|
45
|
-
get: () => state,
|
|
46
|
-
|
|
47
|
-
subscribe(fn) { subscribers.add(fn); return () => subscribers.delete(fn); },
|
|
48
|
-
|
|
49
|
-
/* ── Theme ─────────────────────────────────────────────── */
|
|
50
|
-
applyTheme() {
|
|
51
|
-
const root = document.documentElement;
|
|
52
|
-
if (state.theme === "dark" || state.theme === "light") {
|
|
53
|
-
root.setAttribute("data-lt-theme", state.theme);
|
|
54
|
-
} else {
|
|
55
|
-
root.removeAttribute("data-lt-theme"); // OS-follow via tokens.css media query
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
setTheme(theme) {
|
|
59
|
-
state.theme = theme === "dark" || theme === "light" ? theme : "";
|
|
60
|
-
if (state.theme) save(LS.theme, state.theme); else { try { localStorage.removeItem(LS.theme); } catch {} }
|
|
61
|
-
store.applyTheme();
|
|
62
|
-
emit({ type: "theme" });
|
|
63
|
-
},
|
|
64
|
-
toggleTheme() {
|
|
65
|
-
const effective = document.documentElement.getAttribute("data-lt-theme")
|
|
66
|
-
|| (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
67
|
-
store.setTheme(effective === "dark" ? "light" : "dark");
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/* ── Mode ──────────────────────────────────────────────── */
|
|
71
|
-
setMode(mode) {
|
|
72
|
-
if (!VALID_MODES.includes(mode) || mode === state.mode) return;
|
|
73
|
-
state.mode = mode;
|
|
74
|
-
save(LS.mode, mode);
|
|
75
|
-
emit({ type: "mode" });
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/* ── Workspace ─────────────────────────────────────────── */
|
|
79
|
-
setWorkspaces(list) {
|
|
80
|
-
if (Array.isArray(list) && list.length) {
|
|
81
|
-
state.workspaces = list;
|
|
82
|
-
if (!list.some((w) => w.workspace_id === state.workspaceId)) {
|
|
83
|
-
state.workspaceId = list[0].workspace_id;
|
|
84
|
-
save(LS.workspace, state.workspaceId);
|
|
85
|
-
}
|
|
86
|
-
emit({ type: "workspaces" });
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
setWorkspace(id) {
|
|
90
|
-
if (id === state.workspaceId) return;
|
|
91
|
-
state.workspaceId = id;
|
|
92
|
-
save(LS.workspace, id);
|
|
93
|
-
emit({ type: "workspace" });
|
|
94
|
-
},
|
|
95
|
-
activeWorkspace() {
|
|
96
|
-
return state.workspaces.find((w) => w.workspace_id === state.workspaceId) || state.workspaces[0];
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
setUser(user) { state.user = { ...state.user, ...user }; emit({ type: "user" }); },
|
|
100
|
-
setIndexStatus(s) { state.indexStatus = s; emit({ type: "index" }); },
|
|
101
|
-
setRoute(route) { state.route = route; emit({ type: "route" }); },
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
store.applyTheme();
|
|
105
|
-
|
|
106
|
-
// Follow OS theme changes while the user hasn't pinned a preference.
|
|
107
|
-
if (window.matchMedia) {
|
|
108
|
-
try {
|
|
109
|
-
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
110
|
-
if (!state.theme) emit({ type: "theme" });
|
|
111
|
-
});
|
|
112
|
-
} catch { /* legacy Safari */ }
|
|
113
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Lattice AI v3 — App state store
|
|
3
|
-
* A minimal observable store with namespaced persistence. Holds the cross-view
|
|
4
|
-
* product state: theme, mode (Basic/Advanced/Admin), and the active workspace
|
|
5
|
-
* (Personal/Organization). Views/shell subscribe to react to changes.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
const LS = {
|
|
9
|
-
theme: "lt-theme", // shared with the rest of Lattice (data-lt-theme)
|
|
10
|
-
mode: "lt3-mode",
|
|
11
|
-
workspace: "lt3-workspace",
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function load(key, fallback) {
|
|
15
|
-
try { const v = localStorage.getItem(key); return v == null ? fallback : v; }
|
|
16
|
-
catch { return fallback; }
|
|
17
|
-
}
|
|
18
|
-
function save(key, value) {
|
|
19
|
-
try { localStorage.setItem(key, value); } catch { /* private mode */ }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const VALID_MODES = ["basic", "advanced", "admin"];
|
|
23
|
-
|
|
24
|
-
const state = {
|
|
25
|
-
theme: load(LS.theme, ""), // "" → follow OS
|
|
26
|
-
mode: VALID_MODES.includes(load(LS.mode)) ? load(LS.mode) : "basic",
|
|
27
|
-
workspaceId: load(LS.workspace, "personal"),
|
|
28
|
-
workspaces: [
|
|
29
|
-
{ workspace_id: "personal", name: "Personal Workspace", type: "personal", your_role: "owner" },
|
|
30
|
-
],
|
|
31
|
-
user: { email: "", nickname: "You", role: "user" },
|
|
32
|
-
indexStatus: null,
|
|
33
|
-
route: { key: "knowledge-graph", params: {} },
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const subscribers = new Set();
|
|
37
|
-
|
|
38
|
-
function emit(change) {
|
|
39
|
-
for (const fn of subscribers) {
|
|
40
|
-
try { fn(state, change); } catch (err) { console.error("[store] subscriber", err); }
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const store = {
|
|
45
|
-
get: () => state,
|
|
46
|
-
|
|
47
|
-
subscribe(fn) { subscribers.add(fn); return () => subscribers.delete(fn); },
|
|
48
|
-
|
|
49
|
-
/* ── Theme ─────────────────────────────────────────────── */
|
|
50
|
-
applyTheme() {
|
|
51
|
-
const root = document.documentElement;
|
|
52
|
-
if (state.theme === "dark" || state.theme === "light") {
|
|
53
|
-
root.setAttribute("data-lt-theme", state.theme);
|
|
54
|
-
} else {
|
|
55
|
-
root.removeAttribute("data-lt-theme"); // OS-follow via tokens.css media query
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
setTheme(theme) {
|
|
59
|
-
state.theme = theme === "dark" || theme === "light" ? theme : "";
|
|
60
|
-
if (state.theme) save(LS.theme, state.theme); else { try { localStorage.removeItem(LS.theme); } catch {} }
|
|
61
|
-
store.applyTheme();
|
|
62
|
-
emit({ type: "theme" });
|
|
63
|
-
},
|
|
64
|
-
toggleTheme() {
|
|
65
|
-
const effective = document.documentElement.getAttribute("data-lt-theme")
|
|
66
|
-
|| (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
67
|
-
store.setTheme(effective === "dark" ? "light" : "dark");
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/* ── Mode ──────────────────────────────────────────────── */
|
|
71
|
-
setMode(mode) {
|
|
72
|
-
if (!VALID_MODES.includes(mode) || mode === state.mode) return;
|
|
73
|
-
state.mode = mode;
|
|
74
|
-
save(LS.mode, mode);
|
|
75
|
-
emit({ type: "mode" });
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/* ── Workspace ─────────────────────────────────────────── */
|
|
79
|
-
setWorkspaces(list) {
|
|
80
|
-
if (Array.isArray(list) && list.length) {
|
|
81
|
-
state.workspaces = list;
|
|
82
|
-
if (!list.some((w) => w.workspace_id === state.workspaceId)) {
|
|
83
|
-
state.workspaceId = list[0].workspace_id;
|
|
84
|
-
save(LS.workspace, state.workspaceId);
|
|
85
|
-
}
|
|
86
|
-
emit({ type: "workspaces" });
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
setWorkspace(id) {
|
|
90
|
-
if (id === state.workspaceId) return;
|
|
91
|
-
state.workspaceId = id;
|
|
92
|
-
save(LS.workspace, id);
|
|
93
|
-
emit({ type: "workspace" });
|
|
94
|
-
},
|
|
95
|
-
activeWorkspace() {
|
|
96
|
-
return state.workspaces.find((w) => w.workspace_id === state.workspaceId) || state.workspaces[0];
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
setUser(user) { state.user = { ...state.user, ...user }; emit({ type: "user" }); },
|
|
100
|
-
setIndexStatus(s) { state.indexStatus = s; emit({ type: "index" }); },
|
|
101
|
-
setRoute(route) { state.route = route; emit({ type: "route" }); },
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
store.applyTheme();
|
|
105
|
-
|
|
106
|
-
// Follow OS theme changes while the user hasn't pinned a preference.
|
|
107
|
-
if (window.matchMedia) {
|
|
108
|
-
try {
|
|
109
|
-
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
110
|
-
if (!state.theme) emit({ type: "theme" });
|
|
111
|
-
});
|
|
112
|
-
} catch { /* legacy Safari */ }
|
|
113
|
-
}
|