@shellui/core 0.5.4-alpha.1 → 0.6.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 +2 -0
- package/package.json +6 -4
- package/schemas/shellui.config.schema.json +104 -64
- package/src/app.tsx +5 -3
- package/src/components/ContentView.tsx +26 -5
- package/src/components/LoadingOverlay.tsx +1 -1
- package/src/components/ui/sonner.spec.tsx +138 -0
- package/src/components/ui/sonner.tsx +5 -5
- package/src/components/ui/switch.tsx +1 -1
- package/src/features/admin/AdminView.tsx +14 -3
- package/src/features/ai/AiBridge.tsx +106 -0
- package/src/features/ai/AiUnavailableResponder.tsx +39 -0
- package/src/features/ai/README.md +52 -0
- package/src/features/ai/ShellAiHost.tsx +24 -0
- package/src/features/ai/adapters/ollama.ts +170 -0
- package/src/features/ai/adapters/promptApi.spec.ts +135 -0
- package/src/features/ai/adapters/promptApi.ts +222 -0
- package/src/features/ai/adapters/webllm.experimental.spec.ts +69 -0
- package/src/features/ai/adapters/webllm.spec.ts +527 -0
- package/src/features/ai/adapters/webllm.ts +142 -0
- package/src/features/ai/aiDisabledResponses.spec.ts +29 -0
- package/src/features/ai/aiDisabledResponses.ts +32 -0
- package/src/features/ai/browserInstallStore.spec.ts +58 -0
- package/src/features/ai/browserInstallStore.ts +76 -0
- package/src/features/ai/catalog.ts +31 -0
- package/src/features/ai/createRegistry.ts +83 -0
- package/src/features/ai/developHarness.spec.ts +108 -0
- package/src/features/ai/developHarness.ts +161 -0
- package/src/features/ai/engine/formatAiError.spec.ts +85 -0
- package/src/features/ai/engine/formatAiError.ts +132 -0
- package/src/features/ai/engine/mapInitProgress.ts +9 -0
- package/src/features/ai/engine/normalizeWebLlmModule.spec.ts +47 -0
- package/src/features/ai/engine/vite-worker.d.ts +6 -0
- package/src/features/ai/engine/webllm.worker.ts +51 -0
- package/src/features/ai/engine/webllmEngine.ts +1011 -0
- package/src/features/ai/handleRequest.spec.ts +288 -0
- package/src/features/ai/handleRequest.ts +325 -0
- package/src/features/ai/isAiFeatureEnabled.spec.ts +15 -0
- package/src/features/ai/isAiFeatureEnabled.ts +9 -0
- package/src/features/ai/promptApiSupport.spec.ts +64 -0
- package/src/features/ai/promptApiSupport.ts +117 -0
- package/src/features/ai/registry.spec.ts +100 -0
- package/src/features/ai/registry.ts +131 -0
- package/src/features/ai/status.spec.ts +92 -0
- package/src/features/ai/status.ts +85 -0
- package/src/features/ai/types.ts +100 -0
- package/src/features/ai/webLlmBrowserSupport.spec.ts +86 -0
- package/src/features/ai/webLlmBrowserSupport.ts +92 -0
- package/src/features/alertDialog/DialogContext.tsx +3 -1
- package/src/features/auth/AuthProvider.tsx +254 -39
- package/src/features/auth/backends/index.ts +8 -0
- package/src/features/auth/backends/shellui.spec.ts +201 -0
- package/src/features/auth/backends/shellui.ts +93 -16
- package/src/features/auth/backends/supabase.ts +8 -0
- package/src/features/auth/backends/types.ts +16 -1
- package/src/features/auth/components/LoginButton.tsx +26 -2
- package/src/features/auth/components/LoginView.tsx +119 -134
- package/src/features/auth/components/OAuthCallbackView.tsx +12 -3
- package/src/features/auth/components/SessionLoadingView.tsx +21 -0
- package/src/features/auth/hooks/useAuth.tsx +12 -0
- package/src/features/auth/shellAccountRequests.ts +76 -0
- package/src/features/auth/utils/authRequestError.spec.ts +11 -0
- package/src/features/auth/utils/authRequestError.ts +10 -1
- package/src/features/auth/utils/authSessionPersistence.spec.ts +11 -0
- package/src/features/auth/utils/authSessionPersistence.ts +12 -0
- package/src/features/auth/utils/index.ts +5 -0
- package/src/features/auth/utils/resolveLoginSettings.spec.ts +33 -0
- package/src/features/auth/utils/resolveLoginSettings.ts +33 -0
- package/src/features/auth/utils/shareInFlight.spec.ts +41 -0
- package/src/features/auth/utils/shareInFlight.ts +14 -0
- package/src/features/config/ConfigProvider.ts +9 -1
- package/src/features/config/types.ts +43 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +8 -3
- package/src/features/layouts/filterNavigationForAuthState.spec.ts +41 -0
- package/src/features/layouts/floating/FloatingLayout.tsx +9 -4
- package/src/features/layouts/sidebar/SidebarLayout.tsx +9 -4
- package/src/features/layouts/utils.ts +6 -2
- package/src/features/layouts/windows/WindowsLayout.tsx +8 -3
- package/src/features/messaging/MessagingSecurityBootstrap.tsx +6 -6
- package/src/features/security/trustedFrames.spec.ts +65 -0
- package/src/features/security/trustedFrames.ts +52 -0
- package/src/features/settings/SettingsIcons.tsx +17 -0
- package/src/features/settings/SettingsProvider.tsx +28 -3
- package/src/features/settings/SettingsRoutes.tsx +8 -0
- package/src/features/settings/SettingsView.tsx +21 -4
- package/src/features/settings/components/Ai.tsx +830 -0
- package/src/features/settings/components/Develop.tsx +4 -0
- package/src/features/settings/components/Storage.tsx +197 -32
- package/src/features/settings/components/UserSettingsPanel.tsx +160 -12
- package/src/features/settings/components/createUserSettingsRoute.tsx +4 -0
- package/src/features/settings/components/develop/AiTestTools.tsx +231 -0
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +54 -1
- package/src/features/settings/utils/buildSettingsForPropagation.ts +15 -1
- package/src/features/settings/utils/mergePreferencesIntoSettings.spec.ts +6 -0
- package/src/features/settings/utils/shouldShowStorageSettings.spec.ts +49 -0
- package/src/features/settings/utils/shouldShowStorageSettings.ts +19 -0
- package/src/features/storage/uploads/UploadToastCard.tsx +2 -442
- package/src/features/storage/uploads/UploadToaster.tsx +2 -44
- package/src/features/storage/uploads/uploadQueue.ts +128 -308
- package/src/features/storage/uploads/useUploadQueue.ts +7 -3
- package/src/features/transfers/TransferToastCard.tsx +467 -0
- package/src/features/transfers/TransferToaster.tsx +50 -0
- package/src/features/transfers/index.ts +33 -0
- package/src/features/transfers/transferQueue.spec.ts +97 -0
- package/src/features/transfers/transferQueue.ts +442 -0
- package/src/features/transfers/types.ts +38 -0
- package/src/features/transfers/useTransferQueue.ts +30 -0
- package/src/i18n/translations/en/common.json +49 -2
- package/src/i18n/translations/en/settings.json +152 -2
- package/src/i18n/translations/fr/common.json +49 -2
- package/src/i18n/translations/fr/settings.json +152 -2
- package/src/index.css +57 -4
- package/src/index.ts +1 -0
- package/src/routes/components/NavigationItemRoute.tsx +2 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useRef,
|
|
3
|
+
useState,
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useCallback,
|
|
7
|
+
useMemo,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
} from 'react';
|
|
2
10
|
import {
|
|
3
11
|
getLogger,
|
|
4
12
|
shellui,
|
|
@@ -71,6 +79,12 @@ const defaultSettings: Settings = {
|
|
|
71
79
|
serviceWorker: {
|
|
72
80
|
enabled: false,
|
|
73
81
|
},
|
|
82
|
+
ai: {
|
|
83
|
+
enabled: true,
|
|
84
|
+
defaultModelId: null,
|
|
85
|
+
ollamaEnabled: true,
|
|
86
|
+
browserEnabled: true,
|
|
87
|
+
},
|
|
74
88
|
user: null,
|
|
75
89
|
accessToken: null,
|
|
76
90
|
};
|
|
@@ -151,6 +165,16 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
151
165
|
// Migrate from legacy "caching" key if present; default off for new installs
|
|
152
166
|
enabled: parsed.serviceWorker?.enabled ?? parsed.caching?.enabled ?? false,
|
|
153
167
|
},
|
|
168
|
+
ai: {
|
|
169
|
+
enabled: parsed.ai?.enabled ?? defaultSettings.ai.enabled,
|
|
170
|
+
defaultModelId:
|
|
171
|
+
parsed.ai?.defaultModelId !== undefined
|
|
172
|
+
? parsed.ai.defaultModelId
|
|
173
|
+
: defaultSettings.ai.defaultModelId,
|
|
174
|
+
ollamaEnabled: parsed.ai?.ollamaEnabled ?? defaultSettings.ai.ollamaEnabled,
|
|
175
|
+
browserEnabled: parsed.ai?.browserEnabled ?? defaultSettings.ai.browserEnabled,
|
|
176
|
+
ollamaBaseUrl: parsed.ai?.ollamaBaseUrl ?? defaultSettings.ai.ollamaBaseUrl,
|
|
177
|
+
},
|
|
154
178
|
user: parsed.user ?? null,
|
|
155
179
|
accessToken: null,
|
|
156
180
|
};
|
|
@@ -388,8 +412,9 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
388
412
|
}
|
|
389
413
|
}, [authUser, config]);
|
|
390
414
|
|
|
391
|
-
// Listen for settings updates from parent/other nodes
|
|
392
|
-
|
|
415
|
+
// Listen for settings updates from parent/other nodes.
|
|
416
|
+
// useLayoutEffect so SETTINGS_REQUESTED handlers exist before companion paint races.
|
|
417
|
+
useLayoutEffect(() => {
|
|
393
418
|
if (typeof window === 'undefined') {
|
|
394
419
|
return;
|
|
395
420
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
PackageIcon,
|
|
9
9
|
RefreshDoubleIcon,
|
|
10
10
|
HardDriveIcon,
|
|
11
|
+
SparklesIcon,
|
|
11
12
|
} from './SettingsIcons';
|
|
12
13
|
import { Appearance } from './components/Appearance';
|
|
13
14
|
import { LanguageAndRegion } from './components/LanguageAndRegion';
|
|
@@ -18,6 +19,7 @@ import { DataPrivacy } from './components/DataPrivacy';
|
|
|
18
19
|
import { ServiceWorker } from './components/ServiceWorker';
|
|
19
20
|
import { LegalDocumentsPanel } from './components/LegalDocumentsPanel';
|
|
20
21
|
import { Storage } from './components/Storage';
|
|
22
|
+
import { Ai } from './components/Ai';
|
|
21
23
|
import { isTauri } from '../../service-worker/register';
|
|
22
24
|
|
|
23
25
|
export const createSettingsRoutes = (t: (key: string) => string) => [
|
|
@@ -39,6 +41,12 @@ export const createSettingsRoutes = (t: (key: string) => string) => [
|
|
|
39
41
|
path: 'data-privacy',
|
|
40
42
|
element: <DataPrivacy />,
|
|
41
43
|
},
|
|
44
|
+
{
|
|
45
|
+
name: t('routes.ai'),
|
|
46
|
+
icon: SparklesIcon,
|
|
47
|
+
path: 'ai',
|
|
48
|
+
element: <Ai />,
|
|
49
|
+
},
|
|
42
50
|
{
|
|
43
51
|
name: t('routes.storage'),
|
|
44
52
|
icon: HardDriveIcon,
|
|
@@ -34,14 +34,16 @@ import type { NavigationItem } from '../config/types';
|
|
|
34
34
|
import { cn } from '../../lib/utils';
|
|
35
35
|
import { useAuth } from '../auth/hooks/useAuth';
|
|
36
36
|
import { getLegalDocuments } from '../legal/legalDocuments';
|
|
37
|
-
import {
|
|
37
|
+
import { shouldShowStorageSettings } from './utils/shouldShowStorageSettings';
|
|
38
|
+
import { isAiFeatureEnabled } from '../ai/isAiFeatureEnabled';
|
|
38
39
|
|
|
39
40
|
export const SettingsView = () => {
|
|
40
41
|
const location = useLocation();
|
|
41
42
|
const navigate = useNavigate();
|
|
42
43
|
const { settings } = useSettings();
|
|
43
44
|
const { config } = useConfig();
|
|
44
|
-
const { user, session, logout, isAuthenticated } =
|
|
45
|
+
const { user, session, logout, isAuthenticated, supportsAccountDeletion, supportsProfileUpdate } =
|
|
46
|
+
useAuth();
|
|
45
47
|
const { t, i18n } = useTranslation('settings');
|
|
46
48
|
// Re-check isTauri after mount and after a short delay so we catch late-injected __TAURI__ in dev
|
|
47
49
|
const [isTauriEnv, setIsTauriEnv] = useState(() => isTauri());
|
|
@@ -85,11 +87,21 @@ export const SettingsView = () => {
|
|
|
85
87
|
if (getLegalDocuments(config).length === 0) {
|
|
86
88
|
routes = routes.filter((route) => route.path !== 'legal-documents');
|
|
87
89
|
}
|
|
88
|
-
if (!
|
|
90
|
+
if (!isAiFeatureEnabled(config)) {
|
|
91
|
+
routes = routes.filter((route) => route.path !== 'ai');
|
|
92
|
+
}
|
|
93
|
+
const aiEnabledForStorage = isAiFeatureEnabled(config) && settings.ai?.enabled !== false;
|
|
94
|
+
if (
|
|
95
|
+
!shouldShowStorageSettings({
|
|
96
|
+
config,
|
|
97
|
+
isAuthenticated,
|
|
98
|
+
aiEnabled: aiEnabledForStorage,
|
|
99
|
+
})
|
|
100
|
+
) {
|
|
89
101
|
routes = routes.filter((route) => route.path !== 'storage');
|
|
90
102
|
}
|
|
91
103
|
return routes;
|
|
92
|
-
}, [filteredRoutes, config, isAuthenticated]);
|
|
104
|
+
}, [filteredRoutes, config, isAuthenticated, settings.ai?.enabled]);
|
|
93
105
|
|
|
94
106
|
// Application settings from navigation items with settings URL
|
|
95
107
|
const applicationRoutes = useMemo(() => {
|
|
@@ -125,11 +137,15 @@ export const SettingsView = () => {
|
|
|
125
137
|
accessToken: session?.accessToken ?? null,
|
|
126
138
|
settingsAccessToken: settings.accessToken ?? null,
|
|
127
139
|
rawUserSettings: settings.user ?? null,
|
|
140
|
+
canDeleteAccount: supportsAccountDeletion,
|
|
141
|
+
canEditName: supportsProfileUpdate,
|
|
128
142
|
}),
|
|
129
143
|
[
|
|
130
144
|
user,
|
|
131
145
|
logout,
|
|
132
146
|
t,
|
|
147
|
+
supportsAccountDeletion,
|
|
148
|
+
supportsProfileUpdate,
|
|
133
149
|
settings.developerFeatures.enabled,
|
|
134
150
|
settings.accessToken,
|
|
135
151
|
settings.user,
|
|
@@ -158,6 +174,7 @@ export const SettingsView = () => {
|
|
|
158
174
|
),
|
|
159
175
|
...userRoute,
|
|
160
176
|
...settingsNavRoutes.filter((route) => route.path === 'storage'),
|
|
177
|
+
...settingsNavRoutes.filter((route) => route.path === 'ai'),
|
|
161
178
|
],
|
|
162
179
|
},
|
|
163
180
|
{
|