@shellui/core 0.5.4-alpha.1 → 0.6.0-beta.1
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 +114 -133
- 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.ts +4 -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 +4 -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 +46 -2
- package/src/i18n/translations/en/settings.json +151 -2
- package/src/i18n/translations/fr/common.json +46 -2
- package/src/i18n/translations/fr/settings.json +151 -2
- package/src/index.css +57 -4
- package/src/index.ts +1 -0
- package/src/routes/components/NavigationItemRoute.tsx +2 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Button } from '../../../../components/ui/button';
|
|
4
|
+
import { useSettings } from '../../hooks/useSettings';
|
|
5
|
+
import {
|
|
6
|
+
collectDevelopAiDiagnostics,
|
|
7
|
+
DEVELOP_AI_TEST_PROMPT,
|
|
8
|
+
runDevelopAiPrompt,
|
|
9
|
+
runDevelopAiStream,
|
|
10
|
+
type DevelopAiDiagnostics,
|
|
11
|
+
} from '../../../ai/developHarness';
|
|
12
|
+
|
|
13
|
+
type BusyAction = 'refresh' | 'list' | 'prompt' | 'stream' | null;
|
|
14
|
+
|
|
15
|
+
function yesNo(value: boolean, yes: string, no: string): string {
|
|
16
|
+
return value ? yes : no;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const AiTestTools = () => {
|
|
20
|
+
const { t } = useTranslation('settings');
|
|
21
|
+
const { settings } = useSettings();
|
|
22
|
+
const [diagnostics, setDiagnostics] = useState<DevelopAiDiagnostics | null>(null);
|
|
23
|
+
const [busy, setBusy] = useState<BusyAction>(null);
|
|
24
|
+
const [log, setLog] = useState('');
|
|
25
|
+
const [error, setError] = useState<string | null>(null);
|
|
26
|
+
|
|
27
|
+
const appendLog = useCallback((line: string) => {
|
|
28
|
+
setLog((prev) => (prev ? `${prev}\n${line}` : line));
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
const refresh = useCallback(
|
|
32
|
+
async (options?: { log?: boolean }) => {
|
|
33
|
+
setBusy('refresh');
|
|
34
|
+
setError(null);
|
|
35
|
+
try {
|
|
36
|
+
const next = await collectDevelopAiDiagnostics(settings);
|
|
37
|
+
setDiagnostics(next);
|
|
38
|
+
if (options?.log) {
|
|
39
|
+
appendLog(t('develop.testing.ai.logRefreshed'));
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
setError(err instanceof Error ? err.message : t('develop.testing.ai.unknownError'));
|
|
43
|
+
} finally {
|
|
44
|
+
setBusy(null);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[appendLog, settings, t],
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
void refresh();
|
|
52
|
+
}, [refresh]);
|
|
53
|
+
|
|
54
|
+
const listModels = useCallback(async () => {
|
|
55
|
+
setBusy('list');
|
|
56
|
+
setError(null);
|
|
57
|
+
try {
|
|
58
|
+
const next = await collectDevelopAiDiagnostics(settings);
|
|
59
|
+
setDiagnostics(next);
|
|
60
|
+
if (next.models.length === 0) {
|
|
61
|
+
appendLog(t('develop.testing.ai.logNoModels'));
|
|
62
|
+
} else {
|
|
63
|
+
appendLog(
|
|
64
|
+
t('develop.testing.ai.logModels', {
|
|
65
|
+
list: next.models.map((m) => `${m.id} (${m.status})`).join(', '),
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
setError(err instanceof Error ? err.message : t('develop.testing.ai.unknownError'));
|
|
71
|
+
} finally {
|
|
72
|
+
setBusy(null);
|
|
73
|
+
}
|
|
74
|
+
}, [appendLog, settings, t]);
|
|
75
|
+
|
|
76
|
+
const runPrompt = useCallback(async () => {
|
|
77
|
+
setBusy('prompt');
|
|
78
|
+
setError(null);
|
|
79
|
+
try {
|
|
80
|
+
const result = await runDevelopAiPrompt(settings, DEVELOP_AI_TEST_PROMPT);
|
|
81
|
+
appendLog(
|
|
82
|
+
t('develop.testing.ai.logPromptResult', {
|
|
83
|
+
model: result.modelId,
|
|
84
|
+
text: result.text,
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
const message = err instanceof Error ? err.message : t('develop.testing.ai.unknownError');
|
|
89
|
+
setError(message);
|
|
90
|
+
appendLog(t('develop.testing.ai.logPromptError', { message }));
|
|
91
|
+
} finally {
|
|
92
|
+
setBusy(null);
|
|
93
|
+
}
|
|
94
|
+
}, [appendLog, settings, t]);
|
|
95
|
+
|
|
96
|
+
const runStream = useCallback(async () => {
|
|
97
|
+
setBusy('stream');
|
|
98
|
+
setError(null);
|
|
99
|
+
appendLog(t('develop.testing.ai.logStreamStart'));
|
|
100
|
+
try {
|
|
101
|
+
const result = await runDevelopAiStream(settings, DEVELOP_AI_TEST_PROMPT, (chunk) => {
|
|
102
|
+
appendLog(t('develop.testing.ai.logStreamChunk', { chunk }));
|
|
103
|
+
});
|
|
104
|
+
appendLog(
|
|
105
|
+
t('develop.testing.ai.logStreamDone', {
|
|
106
|
+
model: result.modelId,
|
|
107
|
+
text: result.text,
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
const message = err instanceof Error ? err.message : t('develop.testing.ai.unknownError');
|
|
112
|
+
setError(message);
|
|
113
|
+
appendLog(t('develop.testing.ai.logStreamError', { message }));
|
|
114
|
+
} finally {
|
|
115
|
+
setBusy(null);
|
|
116
|
+
}
|
|
117
|
+
}, [appendLog, settings, t]);
|
|
118
|
+
|
|
119
|
+
const clearLog = useCallback(() => {
|
|
120
|
+
setLog('');
|
|
121
|
+
setError(null);
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
const yes = t('develop.testing.ai.yes');
|
|
125
|
+
const no = t('develop.testing.ai.no');
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<div className="space-y-3">
|
|
129
|
+
<div>
|
|
130
|
+
<h4
|
|
131
|
+
className="mb-1 text-sm font-medium"
|
|
132
|
+
style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
|
|
133
|
+
>
|
|
134
|
+
{t('develop.testing.ai.title')}
|
|
135
|
+
</h4>
|
|
136
|
+
<p className="text-sm text-muted-foreground">{t('develop.testing.ai.description')}</p>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div className="space-y-1 rounded-md border border-border/70 bg-muted/30 p-3 text-sm">
|
|
140
|
+
<p>
|
|
141
|
+
<span className="font-medium">{t('develop.testing.ai.webGpu')}: </span>
|
|
142
|
+
{diagnostics
|
|
143
|
+
? yesNo(diagnostics.webGpuAvailable, yes, no)
|
|
144
|
+
: t('develop.testing.ai.loading')}
|
|
145
|
+
{diagnostics?.webGpuDetail ? (
|
|
146
|
+
<span className="text-muted-foreground"> — {diagnostics.webGpuDetail}</span>
|
|
147
|
+
) : null}
|
|
148
|
+
</p>
|
|
149
|
+
<p>
|
|
150
|
+
<span className="font-medium">{t('develop.testing.ai.ollama')}: </span>
|
|
151
|
+
{diagnostics
|
|
152
|
+
? yesNo(diagnostics.ollamaReachable, yes, no)
|
|
153
|
+
: t('develop.testing.ai.loading')}
|
|
154
|
+
{typeof diagnostics?.ollamaLatencyMs === 'number'
|
|
155
|
+
? ` (${diagnostics.ollamaLatencyMs} ms)`
|
|
156
|
+
: null}
|
|
157
|
+
{diagnostics?.ollamaDetail ? (
|
|
158
|
+
<span className="text-muted-foreground"> — {diagnostics.ollamaDetail}</span>
|
|
159
|
+
) : null}
|
|
160
|
+
</p>
|
|
161
|
+
<p>
|
|
162
|
+
<span className="font-medium">{t('develop.testing.ai.defaultModel')}: </span>
|
|
163
|
+
{diagnostics?.defaultModelId ?? t('develop.testing.ai.none')}
|
|
164
|
+
</p>
|
|
165
|
+
<p>
|
|
166
|
+
<span className="font-medium">{t('develop.testing.ai.adapters')}: </span>
|
|
167
|
+
{diagnostics?.adapters.length
|
|
168
|
+
? diagnostics.adapters.join(', ')
|
|
169
|
+
: t('develop.testing.ai.none')}
|
|
170
|
+
</p>
|
|
171
|
+
<p>
|
|
172
|
+
<span className="font-medium">{t('develop.testing.ai.aiEnabled')}: </span>
|
|
173
|
+
{diagnostics ? yesNo(diagnostics.aiEnabled, yes, no) : t('develop.testing.ai.loading')}
|
|
174
|
+
</p>
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<div className="flex flex-wrap gap-2">
|
|
178
|
+
<Button
|
|
179
|
+
variant="outline"
|
|
180
|
+
size="sm"
|
|
181
|
+
disabled={busy !== null}
|
|
182
|
+
onClick={() => void refresh({ log: true })}
|
|
183
|
+
>
|
|
184
|
+
{t('develop.testing.ai.buttons.refresh')}
|
|
185
|
+
</Button>
|
|
186
|
+
<Button
|
|
187
|
+
variant="outline"
|
|
188
|
+
size="sm"
|
|
189
|
+
disabled={busy !== null}
|
|
190
|
+
onClick={() => void listModels()}
|
|
191
|
+
>
|
|
192
|
+
{t('develop.testing.ai.buttons.listModels')}
|
|
193
|
+
</Button>
|
|
194
|
+
<Button
|
|
195
|
+
variant="outline"
|
|
196
|
+
size="sm"
|
|
197
|
+
disabled={busy !== null}
|
|
198
|
+
onClick={() => void runPrompt()}
|
|
199
|
+
>
|
|
200
|
+
{t('develop.testing.ai.buttons.prompt')}
|
|
201
|
+
</Button>
|
|
202
|
+
<Button
|
|
203
|
+
variant="outline"
|
|
204
|
+
size="sm"
|
|
205
|
+
disabled={busy !== null}
|
|
206
|
+
onClick={() => void runStream()}
|
|
207
|
+
>
|
|
208
|
+
{t('develop.testing.ai.buttons.stream')}
|
|
209
|
+
</Button>
|
|
210
|
+
<Button
|
|
211
|
+
variant="ghost"
|
|
212
|
+
size="sm"
|
|
213
|
+
disabled={busy !== null}
|
|
214
|
+
onClick={clearLog}
|
|
215
|
+
>
|
|
216
|
+
{t('develop.testing.ai.buttons.clear')}
|
|
217
|
+
</Button>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<p className="text-xs text-muted-foreground">{t('develop.testing.ai.promptHint')}</p>
|
|
221
|
+
|
|
222
|
+
{error ? <p className="text-sm text-destructive">{error}</p> : null}
|
|
223
|
+
|
|
224
|
+
{log ? (
|
|
225
|
+
<pre className="max-h-48 overflow-auto whitespace-pre-wrap rounded-md border border-border/70 bg-background p-3 text-xs">
|
|
226
|
+
{log}
|
|
227
|
+
</pre>
|
|
228
|
+
) : null}
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
@@ -79,6 +79,12 @@ const baseSettings: Settings = {
|
|
|
79
79
|
region: { timezone: 'UTC' },
|
|
80
80
|
cookieConsent: { acceptedHosts: [], consentedCookieHosts: [] },
|
|
81
81
|
serviceWorker: { enabled: false },
|
|
82
|
+
ai: {
|
|
83
|
+
enabled: true,
|
|
84
|
+
defaultModelId: null,
|
|
85
|
+
ollamaEnabled: true,
|
|
86
|
+
browserEnabled: true,
|
|
87
|
+
},
|
|
82
88
|
user: null,
|
|
83
89
|
};
|
|
84
90
|
|
|
@@ -235,10 +241,11 @@ describe('buildSettingsForPropagation', () => {
|
|
|
235
241
|
});
|
|
236
242
|
});
|
|
237
243
|
|
|
238
|
-
it('sets administration and
|
|
244
|
+
it('sets administration, storage, and email to null when not configured', () => {
|
|
239
245
|
const result = buildSettingsForPropagation(baseSettings, undefined, 'en');
|
|
240
246
|
expect(result.administration).toBeNull();
|
|
241
247
|
expect(result.storage).toBeNull();
|
|
248
|
+
expect(result.email).toBeNull();
|
|
242
249
|
});
|
|
243
250
|
|
|
244
251
|
it('propagates showInAdmin false when hosting admin is disabled', () => {
|
|
@@ -266,4 +273,50 @@ describe('buildSettingsForPropagation', () => {
|
|
|
266
273
|
const result = buildSettingsForPropagation(baseSettings, config, 'en');
|
|
267
274
|
expect(result.hosting).toEqual({ url: 'http://localhost:8002' });
|
|
268
275
|
});
|
|
276
|
+
|
|
277
|
+
it('propagates email url and strips a trailing slash', () => {
|
|
278
|
+
const config = {
|
|
279
|
+
email: {
|
|
280
|
+
url: 'http://localhost:8003/',
|
|
281
|
+
},
|
|
282
|
+
} as ShellUIConfig;
|
|
283
|
+
|
|
284
|
+
const result = buildSettingsForPropagation(baseSettings, config, 'en');
|
|
285
|
+
expect(result.email).toEqual({ url: 'http://localhost:8003' });
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('uses the production email url when email is set without url', () => {
|
|
289
|
+
const config = {
|
|
290
|
+
email: {},
|
|
291
|
+
} as ShellUIConfig;
|
|
292
|
+
|
|
293
|
+
const result = buildSettingsForPropagation(baseSettings, config, 'en');
|
|
294
|
+
expect(result.email).toEqual({ url: 'https://email.shellui.com' });
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it('propagates showInAdmin false for email and keeps the default url', () => {
|
|
298
|
+
const config = {
|
|
299
|
+
email: {
|
|
300
|
+
showInAdmin: false,
|
|
301
|
+
},
|
|
302
|
+
} as ShellUIConfig;
|
|
303
|
+
|
|
304
|
+
const result = buildSettingsForPropagation(baseSettings, config, 'en');
|
|
305
|
+
expect(result.email).toEqual({
|
|
306
|
+
url: 'https://email.shellui.com',
|
|
307
|
+
showInAdmin: false,
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('omits showInAdmin from propagated email by default', () => {
|
|
312
|
+
const config = {
|
|
313
|
+
email: {
|
|
314
|
+
url: 'https://email.shellui.com',
|
|
315
|
+
showInAdmin: true,
|
|
316
|
+
},
|
|
317
|
+
} as ShellUIConfig;
|
|
318
|
+
|
|
319
|
+
const result = buildSettingsForPropagation(baseSettings, config, 'en');
|
|
320
|
+
expect(result.email).toEqual({ url: 'https://email.shellui.com' });
|
|
321
|
+
});
|
|
269
322
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Settings, SettingsNavigationItem } from '@shellui/sdk';
|
|
1
|
+
import type { Settings, SettingsEmail, SettingsNavigationItem } from '@shellui/sdk';
|
|
2
2
|
import type { ShellUIConfig } from '../../config/types';
|
|
3
3
|
import { flattenNavigationItems } from './flattenNavigationItems';
|
|
4
4
|
import { getAvailableThemesForSettings } from './getAvailableThemesForSettings';
|
|
@@ -6,6 +6,18 @@ import { getResolvedAppearanceForSettings } from './getResolvedAppearanceForSett
|
|
|
6
6
|
import { resolveLabel } from './resolveLabel';
|
|
7
7
|
import { getPublishedLayoutChrome } from '../../layouts/floating/layoutChromeStore';
|
|
8
8
|
|
|
9
|
+
/** Production email-service origin. No trailing slash. */
|
|
10
|
+
const DEFAULT_EMAIL_SERVICE_URL = 'https://email.shellui.com';
|
|
11
|
+
|
|
12
|
+
const propagateEmail = (email: ShellUIConfig['email']): SettingsEmail | null => {
|
|
13
|
+
if (!email) return null;
|
|
14
|
+
const url = email.url?.trim().replace(/\/+$/, '') || DEFAULT_EMAIL_SERVICE_URL;
|
|
15
|
+
return {
|
|
16
|
+
url,
|
|
17
|
+
...(email.showInAdmin === false ? { showInAdmin: false } : {}),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
9
21
|
/**
|
|
10
22
|
* Build settings for propagation to iframes: inject navigation, full theme object,
|
|
11
23
|
* and list of available themes so apps can render theme pickers.
|
|
@@ -111,6 +123,8 @@ export const buildSettingsForPropagation = (
|
|
|
111
123
|
result = { ...result, hosting: null };
|
|
112
124
|
}
|
|
113
125
|
|
|
126
|
+
result = { ...result, email: propagateEmail(config?.email) };
|
|
127
|
+
|
|
114
128
|
const authBackendBaseUrl =
|
|
115
129
|
config?.backend?.type === 'shellui' && config.backend.url?.trim()
|
|
116
130
|
? config.backend.url.trim().replace(/\/+$/, '')
|
|
@@ -78,6 +78,12 @@ const baseSettings: Settings = {
|
|
|
78
78
|
region: { timezone: 'UTC' },
|
|
79
79
|
cookieConsent: { acceptedHosts: [], consentedCookieHosts: [] },
|
|
80
80
|
serviceWorker: { enabled: false },
|
|
81
|
+
ai: {
|
|
82
|
+
enabled: true,
|
|
83
|
+
defaultModelId: null,
|
|
84
|
+
ollamaEnabled: true,
|
|
85
|
+
browserEnabled: true,
|
|
86
|
+
},
|
|
81
87
|
user: null,
|
|
82
88
|
};
|
|
83
89
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import type { ShellUIConfig } from '../../config/types';
|
|
3
|
+
import { shouldShowStorageSettings } from './shouldShowStorageSettings';
|
|
4
|
+
|
|
5
|
+
const withStorage = {
|
|
6
|
+
storage: { url: 'http://localhost:8001' },
|
|
7
|
+
} as ShellUIConfig;
|
|
8
|
+
|
|
9
|
+
describe('shouldShowStorageSettings', () => {
|
|
10
|
+
it('shows when remote storage is configured and the user is signed in', () => {
|
|
11
|
+
expect(
|
|
12
|
+
shouldShowStorageSettings({
|
|
13
|
+
config: withStorage,
|
|
14
|
+
isAuthenticated: true,
|
|
15
|
+
aiEnabled: false,
|
|
16
|
+
}),
|
|
17
|
+
).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('hides remote storage when the user is signed out', () => {
|
|
21
|
+
expect(
|
|
22
|
+
shouldShowStorageSettings({
|
|
23
|
+
config: withStorage,
|
|
24
|
+
isAuthenticated: false,
|
|
25
|
+
aiEnabled: false,
|
|
26
|
+
}),
|
|
27
|
+
).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('shows when AI is enabled even without remote storage', () => {
|
|
31
|
+
expect(
|
|
32
|
+
shouldShowStorageSettings({
|
|
33
|
+
config: undefined,
|
|
34
|
+
isAuthenticated: false,
|
|
35
|
+
aiEnabled: true,
|
|
36
|
+
}),
|
|
37
|
+
).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('hides when AI is off and remote storage is not configured', () => {
|
|
41
|
+
expect(
|
|
42
|
+
shouldShowStorageSettings({
|
|
43
|
+
config: {} as ShellUIConfig,
|
|
44
|
+
isAuthenticated: true,
|
|
45
|
+
aiEnabled: false,
|
|
46
|
+
}),
|
|
47
|
+
).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ShellUIConfig } from '../../config/types';
|
|
2
|
+
import { isStorageSettingsEnabled } from '../../storage/quota';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Settings → Storage nav is shown when remote storage is available to the user,
|
|
6
|
+
* or when on-device AI is enabled at both config and Settings layers (local model disk).
|
|
7
|
+
*
|
|
8
|
+
* Pass `aiEnabled` only when `config.ai.enabled === true` AND `settings.ai.enabled !== false`.
|
|
9
|
+
* A shell without config AI must not keep Storage visible for AI alone.
|
|
10
|
+
*/
|
|
11
|
+
export function shouldShowStorageSettings(options: {
|
|
12
|
+
config: ShellUIConfig | undefined;
|
|
13
|
+
isAuthenticated: boolean;
|
|
14
|
+
/** Combined config + settings AI gate for local model disk usage. */
|
|
15
|
+
aiEnabled: boolean;
|
|
16
|
+
}): boolean {
|
|
17
|
+
const remoteVisible = isStorageSettingsEnabled(options.config) && options.isAuthenticated;
|
|
18
|
+
return remoteVisible || options.aiEnabled;
|
|
19
|
+
}
|