diff --git a/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte b/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte index 2f94378..a4fbfba 100644 --- a/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte +++ b/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte @@ -15,7 +15,7 @@ let { onclose, oncreated }: Props = $props(); let formName = $state(''); - let formProvider = $state<'anthropic' | 'openai'>('anthropic'); + let formProvider = $state<'openai' | 'anthropic'>('openai'); let formApiType = $state<'chat_completions' | 'responses'>('chat_completions'); let formBaseUrl = $state(''); let formApiKey = $state(''); @@ -94,8 +94,8 @@ bind:value={formProvider} class="block w-full bg-transparent text-[13px] text-gray-700 dark:text-gray-300 outline-none py-0.5 cursor-pointer" > - + diff --git a/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte b/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte index ae57bee..c54d31e 100644 --- a/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte +++ b/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte @@ -130,8 +130,8 @@ bind:value={formProvider} class="block w-full bg-transparent text-[13px] text-gray-700 dark:text-gray-300 outline-none py-0.5 cursor-pointer" > - + diff --git a/cptr/frontend/src/lib/components/SetupWizard.svelte b/cptr/frontend/src/lib/components/SetupWizard.svelte new file mode 100644 index 0000000..55f5bc1 --- /dev/null +++ b/cptr/frontend/src/lib/components/SetupWizard.svelte @@ -0,0 +1,319 @@ + + +
+
+ +
+ {#each Array(totalSteps) as _, i} +
+ {/each} +
+ + {#if step === 0} + +
+

+ {$t('onboarding.welcomeTitle')} +

+

+ {$t('onboarding.welcomeDesc')} +

+ + +
+ {:else if step === 1} + +
+

+ {$t('onboarding.openFolder')} +

+

+ {$t('onboarding.openFolderDesc')} +

+ + {#if selectedPath} +

+ {selectedPath} +

+ {/if} + + + +
+ +
+
+ {:else if step === 2} + + +
{ if (e.key === 'Enter' && apiKey.trim()) connectAi(); }}> +

+ {$t('onboarding.connectAi')} +

+

+ {$t('onboarding.connectAiDesc')} +

+ + {#if aiConnected} +

+ {config.name} connected +

+ + {:else} +
+

Provider

+ +
+ + {#if provider === 'openai'} +
+

API Type

+ +
+ {/if} + +
+

{$t('connections.baseUrl')}

+ + + +
+ +
+

{$t('connections.apiKey')}

+ +
+ +

+ {$t('onboarding.keyStaysLocal')} +

+ + + +
+ +
+ {/if} +
+ {:else if step === 3} + +
+

+ {$t('onboarding.ready')} +

+

+ {$t('onboarding.readyDesc')} +

+ +
+

+ {$t('onboarding.tipSearch', { shortcut: searchShortcut })} +

+

+ {$t('onboarding.tipTerminal')} +

+

+ {$t('onboarding.tipMobile')} +

+
+ + +
+ {/if} +
+
+ +{#if showPicker} + { + showPicker = false; + const params = new URLSearchParams(window.location.search); + const wsPath = params.get('workspace'); + if (wsPath) { + selectedPath = wsPath; + const url = new URL(window.location.href); + url.searchParams.delete('workspace'); + window.history.replaceState({}, '', url.toString()); + next(); + } + }} + /> +{/if} + + diff --git a/cptr/frontend/src/lib/i18n/locales/en.json b/cptr/frontend/src/lib/i18n/locales/en.json index 5f446bc..58378dc 100644 --- a/cptr/frontend/src/lib/i18n/locales/en.json +++ b/cptr/frontend/src/lib/i18n/locales/en.json @@ -70,7 +70,7 @@ "files.date": "Date", "files.folder": "folder", "files.file": "file", - "files.clickToPreview": "{{process}} — click to preview", + "files.clickToPreview": "{{process}} - click to preview", "files.showHidden": "Show dotfiles", "files.hideHidden": "Hide dotfiles", "files.failedToLoad": "Failed to load directory", @@ -723,6 +723,31 @@ "admin.contextCompaction": "Context compaction", "admin.compactTokenThreshold": "Token threshold", "admin.compactTokenThresholdUnit": "tokens", - "admin.compactTokenThresholdHint": "Older messages are summarized when estimated context exceeds this limit. Default: 80,000." + "admin.compactTokenThresholdHint": "Older messages are summarized when estimated context exceeds this limit. Default: 80,000.", + + "onboarding.welcomeTitle": "Your computer, from anywhere", + "onboarding.welcomeDesc": "Code, manage, and control your machine from any device.", + "onboarding.getStarted": "Get started →", + "onboarding.openFolder": "Open a folder", + "onboarding.openFolderDesc": "Pick a project or folder to work with.", + "onboarding.skip": "Skip", + "onboarding.connectAi": "Connect AI", + "onboarding.connectAiDesc": "Add an API key to unlock chat, code editing, and automations.", + "onboarding.connectAiSkip": "I'll do this later", + "onboarding.keyStaysLocal": "Your key stays on this machine.", + "onboarding.connect": "Connect →", + "onboarding.ready": "You're all set", + "onboarding.readyDesc": "A few things to try:", + "onboarding.tipSearch": "Search for anything with {{shortcut}}", + "onboarding.tipTerminal": "Open a terminal right in the browser", + "onboarding.tipMobile": "Works on your phone, same URL", + "onboarding.startUsing": "Start →", + "onboarding.takeTour": "Take the tour", + "onboarding.suggestion1": "Explain this project", + "onboarding.suggestion2": "Find all TODOs", + "onboarding.suggestion3": "What files are here?", + "onboarding.suggestion4": "Help me write tests", + "onboarding.connectAiNudge": "Connect an AI provider to start chatting.", + "onboarding.goToConnections": "Settings → Connections" } diff --git a/cptr/frontend/src/routes/+layout.svelte b/cptr/frontend/src/routes/+layout.svelte index 9573a42..c424f64 100644 --- a/cptr/frontend/src/routes/+layout.svelte +++ b/cptr/frontend/src/routes/+layout.svelte @@ -43,10 +43,12 @@ import { t } from '$lib/i18n'; import { refreshChatState, bindGlobalChatListener } from '$lib/stores/chat'; import { refreshAudioState } from '$lib/stores/audio'; + import SetupWizard from '$lib/components/SetupWizard.svelte'; let { children } = $props(); let showSettings = $state(false); let showUpdateToast = $state(false); + let showSetup = $state(false); // Auth state type AuthState = 'checking' | 'needs_setup' | 'needs_login' | 'authenticated'; @@ -117,6 +119,20 @@ } }); + // Check ?setup=true param for admin setup wizard + $effect(() => { + if (!$stateLoaded) return; + if (authState !== 'authenticated') return; + + const params = new URLSearchParams(window.location.search); + if (params.get('setup') === 'true' && $session?.role === 'admin') { + showSetup = true; + const url = new URL(window.location.href); + url.searchParams.delete('setup'); + window.history.replaceState({}, '', url.toString()); + } + }); + async function checkAuth() { try { const params = new URLSearchParams(window.location.search); @@ -167,6 +183,7 @@ } async function handleAuth() { + const wasSetup = authState === 'needs_setup'; try { const auth = await getSession(); if (auth.authenticated) { @@ -181,6 +198,7 @@ initState(); refreshChatState(); refreshAudioState(); + if (wasSetup) showSetup = true; return; } } catch {} @@ -299,6 +317,8 @@ token={startupToken} onauth={handleAuth} /> +{:else if $stateLoaded && showSetup} + { showSetup = false; }} /> {:else if $stateLoaded}