Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

app: add desktop onboarding flow (#17853)

Eva Hb7871fc0d1d8
diff --git a/app/cmd/app/app.go b/app/cmd/app/app.go
index 9c8b736b8..2ebfe253b 100644
--- a/app/cmd/app/app.go
+++ b/app/cmd/app/app.go
@@ -146,15 +146,10 @@ func main() {
// Do this after logging is set up so we can debug issues
if runtime.GOOS == "windows" && urlSchemeRequest != "" {
slog.Debug("checking for existing instance", "url", urlSchemeRequest)
- if checkAndHandleExistingInstance(urlSchemeRequest) {
- // The function will exit if it successfully sends to another instance
- // If we reach here, we're the first/only instance
- } else {
- // No existing instance found, handle the URL scheme in this instance
- go func() {
- handleURLSchemeInCurrentInstance(urlSchemeRequest)
- }()
- }
+ // This exits after forwarding the request when another instance is
+ // running. First-instance requests are handled later by osRun, after the
+ // Windows UI dependencies are initialized and from the primary thread.
+ checkAndHandleExistingInstance(urlSchemeRequest)
}
// Detect if this is a first start after an upgrade, in
@@ -205,6 +200,12 @@ func main() {
uiServerPort = port
st := &store.Store{}
+ if devMode {
+ if dbPath := strings.TrimSpace(os.Getenv("OLLAMA_APP_DB_PATH")); dbPath != "" {
+ st.DBPath = dbPath
+ slog.Debug("using development app database", "path", dbPath)
+ }
+ }
appStore = st
// Enable CORS in development mode
@@ -324,11 +325,11 @@ func main() {
quit()
}()
- if urlSchemeRequest != "" {
+ if urlSchemeRequest != "" && runtime.GOOS != "windows" {
go func() {
handleURLSchemeInCurrentInstance(urlSchemeRequest)
}()
- } else {
+ } else if urlSchemeRequest == "" {
slog.Debug("no URL scheme request to handle")
}
@@ -343,7 +344,13 @@ func main() {
}
}()
- osRun(cancel, hasCompletedFirstRun, startHidden)
+ settings, settingsErr := st.Settings()
+ showOnboarding := shouldShowOnboarding(settings, settingsErr)
+ if settingsErr != nil {
+ slog.Error("failed to load onboarding state", "error", settingsErr)
+ }
+
+ osRun(cancel, hasCompletedFirstRun, startHidden, showOnboarding, urlSchemeRequest)
slog.Info("shutting down desktop server")
if err := srv.Close(); err != nil {
@@ -355,6 +362,31 @@ func main() {
<-done
}
+func shouldShowOnboarding(settings store.Settings, err error) bool {
+ return err != nil || settings.OnboardingVersion < store.CurrentOnboardingVersion
+}
+
+func runInitialWindowsUI(
+ startHidden bool,
+ showOnboarding bool,
+ urlSchemeRequest string,
+ startHiddenFn func(),
+ handleURLFn func(string),
+ showOnboardingFn func(),
+) {
+ if urlSchemeRequest != "" {
+ handleURLFn(urlSchemeRequest)
+ return
+ }
+ if startHidden {
+ startHiddenFn()
+ return
+ }
+ if showOnboarding {
+ showOnboardingFn()
+ }
+}
+
func startHiddenTasks() {
// If an upgrade is ready and we're in hidden mode, perform it at startup.
// If we're not in hidden mode, we want to start as fast as possible and not
@@ -432,7 +464,7 @@ func checkUserLoggedIn(uiServerPort int) bool {
func handleConnectURLScheme() {
if checkUserLoggedIn(uiServerPort) {
slog.Info("user is already logged in, opening app instead")
- showWindow(wv.webview.Window())
+ openUI("/")
return
}
@@ -491,17 +523,23 @@ func parseURLScheme(urlSchemeRequest string) (isConnect bool, err error) {
// handleURLSchemeInCurrentInstance processes URL scheme requests in the current instance
func handleURLSchemeInCurrentInstance(urlSchemeRequest string) {
- isConnect, err := parseURLScheme(urlSchemeRequest)
+ err := dispatchURLSchemeRequest(urlSchemeRequest, handleConnectURLScheme, func() {
+ openUI("/")
+ })
if err != nil {
slog.Error("failed to parse URL scheme request", "url", urlSchemeRequest, "error", err)
- return
}
+}
+func dispatchURLSchemeRequest(urlSchemeRequest string, connect, open func()) error {
+ isConnect, err := parseURLScheme(urlSchemeRequest)
+ if err != nil {
+ return err
+ }
if isConnect {
- handleConnectURLScheme()
+ connect()
} else {
- if wv.webview != nil {
- showWindow(wv.webview.Window())
- }
+ open()
}
+ return nil
}
diff --git a/app/cmd/app/app_darwin.go b/app/cmd/app/app_darwin.go
index 8e886a124..190d4265e 100644
--- a/app/cmd/app/app_darwin.go
+++ b/app/cmd/app/app_darwin.go
@@ -54,14 +54,17 @@ func StartUI(path *C.cchar_t) {
//export ShowUI
func ShowUI() {
- // If webview is already running, just show the window
+ openUI("/")
+}
+
+func openUI(path string) {
if wv.IsRunning() && wv.webview != nil {
showWindow(wv.webview.Window())
- } else {
- root := C.CString("/")
- defer C.free(unsafe.Pointer(root))
- StartUI(root)
+ return
}
+ p := C.CString(path)
+ defer C.free(unsafe.Pointer(p))
+ StartUI(p)
}
//export StopUI
@@ -172,13 +175,13 @@ func UpdateAvailable(ver string) error {
return nil
}
-func osRun(_ func(), hasCompletedFirstRun, startHidden bool) {
+func osRun(_ func(), hasCompletedFirstRun, startHidden, showOnboarding bool, _ string) {
registerLaunchAgent(hasCompletedFirstRun)
// Run the native macOS app
// Note: this will block until the app is closed
slog.Debug("starting native darwin event loop")
- C.run(C._Bool(hasCompletedFirstRun), C._Bool(startHidden))
+ C.run(C._Bool(showOnboarding), C._Bool(startHidden))
}
func quit() {
@@ -229,6 +232,11 @@ func styleWindow(ptr unsafe.Pointer) {
C.styleWindow(C.uintptr_t(uintptr(ptr)))
}
+func setOnboardingWindowStyle(ptr unsafe.Pointer, enabled bool) {
+ styleWindow(ptr)
+ C.setWindowResizable(C.uintptr_t(uintptr(ptr)), C.bool(!enabled))
+}
+
func runInBackground() {
cmd := exec.Command(filepath.Join(updater.BundlePath, "Contents", "MacOS", "Ollama"), "hidden")
if cmd != nil {
@@ -257,6 +265,4 @@ func handleConnectURL() {
}
// checkAndHandleExistingInstance is not needed on non-Windows platforms
-func checkAndHandleExistingInstance(_ string) bool {
- return false
-}
+func checkAndHandleExistingInstance(_ string) {}
diff --git a/app/cmd/app/app_darwin.h b/app/cmd/app/app_darwin.h
index 4a5ba055f..12a644480 100644
--- a/app/cmd/app/app_darwin.h
+++ b/app/cmd/app/app_darwin.h
@@ -16,7 +16,7 @@ enum AppMove
MoveError,
};
-void run(bool firstTimeRun, bool startHidden);
+void run(bool showOnboarding, bool startHidden);
void killOtherInstances();
enum AppMove askToMoveToApplications();
int createSymlinkWithAuthorization();
@@ -38,6 +38,7 @@ void setWindowDelegate(void *window);
void showWindow(uintptr_t wndPtr);
void hideWindow(uintptr_t wndPtr);
void styleWindow(uintptr_t wndPtr);
+void setWindowResizable(uintptr_t wndPtr, bool resizable);
void drag(uintptr_t wndPtr);
void doubleClick(uintptr_t wndPtr);
void handleConnectURL();
diff --git a/app/cmd/app/app_darwin.m b/app/cmd/app/app_darwin.m
index 65f91b389..87bc9a397 100644
--- a/app/cmd/app/app_darwin.m
+++ b/app/cmd/app/app_darwin.m
@@ -19,7 +19,27 @@ extern NSString *SystemWidePath;
@implementation AppDelegate
-bool firstTimeRun,startHidden; // Set in run before initialization
+bool showOnboarding,startHidden; // Set in run before initialization
+
+static NSBundle *OllamaResourceBundle(void) {
+ NSBundle *bundle = [NSBundle mainBundle];
+ if ([bundle.bundlePath hasSuffix:@".app"]) {
+ return bundle;
+ }
+
+ NSString *cwdPath = [[NSFileManager defaultManager] currentDirectoryPath];
+ NSArray<NSString *> *bundlePaths = @[
+ [cwdPath stringByAppendingPathComponent:@"darwin/Ollama.app"],
+ [cwdPath stringByAppendingPathComponent:@"app/darwin/Ollama.app"],
+ ];
+ for (NSString *bundlePath in bundlePaths) {
+ if ([[NSFileManager defaultManager] fileExistsAtPath:bundlePath]) {
+ return [NSBundle bundleWithPath:bundlePath];
+ }
+ }
+
+ return bundle;
+}
- (void)application:(NSApplication *)application openURLs:(NSArray<NSURL *> *)urls {
for (NSURL *url in urls) {
@@ -30,11 +50,9 @@ bool firstTimeRun,startHidden; // Set in run before initialization
// Special case: handle connect by opening browser instead of app
handleConnectURL();
} else {
- // Set app to be active and visible
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
- [NSApp activateIgnoringOtherApps:YES];
+ [self openUI];
}
-
+
break;
}
}
@@ -51,29 +69,24 @@ bool firstTimeRun,startHidden; // Set in run before initialization
// if we're in development mode, set the app icon
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
if (![bundlePath hasSuffix:@".app"]) {
- NSString *cwdPath =
- [[NSFileManager defaultManager] currentDirectoryPath];
- NSString *iconPath = [cwdPath
- stringByAppendingPathComponent:
- [NSString
- stringWithFormat:
- @"darwin/Ollama.app/Contents/Resources/icon.icns"]];
+ NSString *iconPath =
+ [OllamaResourceBundle() pathForResource:@"icon" ofType:@"icns"];
NSImage *customIcon = [[NSImage alloc] initWithContentsOfFile:iconPath];
[NSApp setApplicationIconImage:customIcon];
}
// Create status item and menu
NSMenu *menu = [[NSMenu alloc] init];
+ [menu addItemWithTitle:@"Settings..."
+ action:@selector(settingsUI)
+ keyEquivalent:@","];
+
NSMenuItem *openMenuItem =
- [[NSMenuItem alloc] initWithTitle:@"Open Ollama"
+ [[NSMenuItem alloc] initWithTitle:@"Open Ollama Chat"
action:@selector(openUI)
keyEquivalent:@""];
[openMenuItem setTarget:self];
[menu addItem:openMenuItem];
-
- [menu addItemWithTitle:@"Settings..."
- action:@selector(settingsUI)
- keyEquivalent:@","];
[menu addItem:[NSMenuItem separatorItem]];
NSMenuItem *updateAvailable =
@@ -214,10 +227,8 @@ bool firstTimeRun,startHidden; // Set in run before initialization
dispatch_async(dispatch_get_main_queue(), ^{
if (hidden || startHidden) {
darwinStartHiddenTasks();
- } else {
- if (!startHidden) {
- StartUI("/");
- }
+ } else if (showOnboarding) {
+ StartUI("/");
}
});
}
@@ -264,7 +275,7 @@ bool firstTimeRun,startHidden; // Set in run before initialization
}
- (void)openUI {
- ShowUI();
+ [self uiRequest:@"/"];
}
- (void)newChat {
@@ -325,17 +336,7 @@ bool firstTimeRun,startHidden; // Set in run before initialization
}
NSImage *statusImage;
- NSBundle *bundle = [NSBundle mainBundle];
- if (![bundle.bundlePath hasSuffix:@".app"]) {
- NSString *cwdPath =
- [[NSFileManager defaultManager] currentDirectoryPath];
- NSString *bundlePath =
- [cwdPath stringByAppendingPathComponent:
- [NSString stringWithFormat:@"darwin/Ollama.app"]];
- bundle = [NSBundle bundleWithPath:bundlePath];
- }
-
- statusImage = [bundle imageForResource:iconName];
+ statusImage = [OllamaResourceBundle() imageForResource:iconName];
[statusImage setTemplate:YES];
self.statusItem.button.image = statusImage;
}
@@ -621,12 +622,12 @@ decidePolicyForNavigationAction:(WKNavigationAction *)action
@end
AppDelegate *appDelegate;
-void run(bool ftr, bool sh) {
+void run(bool so, bool sh) {
[NSApplication sharedApplication];
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
appDelegate = [[AppDelegate alloc] init];
[NSApp setDelegate:appDelegate];
- firstTimeRun = ftr;
+ showOnboarding = so;
startHidden = sh;
[NSApp run];
StopUI();
@@ -1097,6 +1098,17 @@ void styleWindow(uintptr_t wndPtr) {
L.borderWidth = 0.0;
}
+void setWindowResizable(uintptr_t wndPtr, bool resizable) {
+ NSWindow *w = (__bridge NSWindow *)wndPtr;
+ if (!w) return;
+
+ if (resizable) {
+ w.styleMask |= NSWindowStyleMaskResizable;
+ } else {
+ w.styleMask &= ~NSWindowStyleMaskResizable;
+ }
+}
+
void drag(uintptr_t wndPtr) {
NSWindow *w = (__bridge NSWindow *)wndPtr;
if (!w) return;
diff --git a/app/cmd/app/app_test.go b/app/cmd/app/app_test.go
new file mode 100644
index 000000000..6023d731d
--- /dev/null
+++ b/app/cmd/app/app_test.go
@@ -0,0 +1,112 @@
+//go:build windows || darwin
+
+package main
+
+import (
+ "errors"
+ "testing"
+
+ "github.com/ollama/ollama/app/store"
+)
+
+func TestShouldShowOnboarding(t *testing.T) {
+ tests := []struct {
+ name string
+ settings store.Settings
+ err error
+ want bool
+ }{
+ {
+ name: "fresh install",
+ settings: store.Settings{OnboardingVersion: 0},
+ want: true,
+ },
+ {
+ name: "completed onboarding",
+ settings: store.Settings{OnboardingVersion: store.CurrentOnboardingVersion},
+ want: false,
+ },
+ {
+ name: "settings failure",
+ err: errors.New("settings unavailable"),
+ want: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := shouldShowOnboarding(tt.settings, tt.err); got != tt.want {
+ t.Fatalf("shouldShowOnboarding() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestDispatchURLSchemeRequest(t *testing.T) {
+ tests := []struct {
+ name string
+ request string
+ wantConnect bool
+ wantOpen bool
+ wantErr bool
+ }{
+ {name: "bare URL opens app", request: "ollama://", wantOpen: true},
+ {name: "connect URL starts connection", request: "ollama://connect", wantConnect: true},
+ {name: "unsupported URL", request: "ollama://unsupported", wantErr: true},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ connected := false
+ opened := false
+ err := dispatchURLSchemeRequest(
+ tt.request,
+ func() { connected = true },
+ func() { opened = true },
+ )
+ if (err != nil) != tt.wantErr {
+ t.Fatalf("dispatchURLSchemeRequest() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ if connected != tt.wantConnect {
+ t.Errorf("connect called = %v, want %v", connected, tt.wantConnect)
+ }
+ if opened != tt.wantOpen {
+ t.Errorf("open called = %v, want %v", opened, tt.wantOpen)
+ }
+ })
+ }
+}
+
+func TestRunInitialWindowsUIWithBareURL(t *testing.T) {
+ hiddenCalls := 0
+ urlCalls := 0
+ onboardingCalls := 0
+ openCalls := 0
+
+ runInitialWindowsUI(
+ false,
+ true,
+ "ollama://",
+ func() { hiddenCalls++ },
+ func(request string) {
+ urlCalls++
+ if err := dispatchURLSchemeRequest(request, func() {}, func() { openCalls++ }); err != nil {
+ t.Fatalf("dispatchURLSchemeRequest() error = %v", err)
+ }
+ },
+ func() { onboardingCalls++ },
+ )
+
+ if urlCalls != 1 {
+ t.Fatalf("URL handled %d times, want 1", urlCalls)
+ }
+ if openCalls != 1 {
+ t.Errorf("app opened %d times, want 1", openCalls)
+ }
+ if hiddenCalls != 0 {
+ t.Errorf("hidden startup called %d times, want 0", hiddenCalls)
+ }
+ if onboardingCalls != 0 {
+ t.Errorf("onboarding opened %d times, want 0", onboardingCalls)
+ }
+}
diff --git a/app/cmd/app/app_windows.go b/app/cmd/app/app_windows.go
index 3e2196dd7..c26b50e79 100644
--- a/app/cmd/app/app_windows.go
+++ b/app/cmd/app/app_windows.go
@@ -95,11 +95,15 @@ func (ac *appCallbacks) UIRun(path string) {
}
func (*appCallbacks) UIShow() {
- if wv.webview != nil {
+ openUI("/")
+}
+
+func openUI(path string) {
+ if wv.IsRunning() && wv.webview != nil {
showWindow(wv.webview.Window())
- } else {
- wv.Run("/")
+ return
}
+ wv.Run(path)
}
func (*appCallbacks) UITerminate() {
@@ -138,19 +142,7 @@ func (app *appCallbacks) HandleURLScheme(urlScheme string) {
// handleURLSchemeRequest processes URL scheme requests from other instances
func handleURLSchemeRequest(urlScheme string) {
- isConnect, err := parseURLScheme(urlScheme)
- if err != nil {
- slog.Error("failed to parse URL scheme request", "url", urlScheme, "error", err)
- return
- }
-
- if isConnect {
- handleConnectURLScheme()
- } else {
- if wv.webview != nil {
- showWindow(wv.webview.Window())
- }
- }
+ handleURLSchemeInCurrentInstance(urlScheme)
}
func UpdateAvailable(ver string) error {
@@ -161,7 +153,7 @@ func UpdateAvailable(ver string) error {
return app.t.UpdateAvailable(ver)
}
-func osRun(shutdown func(), hasCompletedFirstRun, startHidden bool) {
+func osRun(shutdown func(), hasCompletedFirstRun, startHidden, showOnboarding bool, urlSchemeRequest string) {
var err error
app.shutdown = shutdown
app.t, err = wintray.NewTray(app)
@@ -205,9 +197,7 @@ func osRun(shutdown func(), hasCompletedFirstRun, startHidden bool) {
}
}
}
- if startHidden {
- startHiddenTasks()
- } else {
+ runInitialWindowsUI(startHidden, showOnboarding, urlSchemeRequest, startHiddenTasks, handleURLSchemeInCurrentInstance, func() {
ptr := wv.Run("/")
// Set the window icon using the tray icon
@@ -225,7 +215,7 @@ func osRun(shutdown func(), hasCompletedFirstRun, startHidden bool) {
}
centerWindow(ptr)
- }
+ })
if !hasCompletedFirstRun {
// Only create the login shortcut on first start
@@ -408,6 +398,8 @@ func hideWindow(ptr unsafe.Pointer) {
}
}
+func setOnboardingWindowStyle(_ unsafe.Pointer, _ bool) {}
+
func runInBackground() {
exe, err := os.Executable()
if err != nil {
@@ -432,17 +424,13 @@ func drag(ptr unsafe.Pointer) {}
func doubleClick(ptr unsafe.Pointer) {}
// checkAndHandleExistingInstance checks if another instance is running and sends the URL to it
-func checkAndHandleExistingInstance(urlSchemeRequest string) bool {
+func checkAndHandleExistingInstance(urlSchemeRequest string) {
if urlSchemeRequest == "" {
- return false
+ return
}
// Try to send URL to existing instance using wintray messaging
if wintray.CheckAndSendToExistingInstance(urlSchemeRequest) {
os.Exit(0)
- return true
}
-
- // No existing instance, we'll handle it ourselves
- return false
}
diff --git a/app/cmd/app/webview.go b/app/cmd/app/webview.go
index 9332f10b4..f920ee64e 100644
--- a/app/cmd/app/webview.go
+++ b/app/cmd/app/webview.go
@@ -24,6 +24,13 @@ import (
"github.com/ollama/ollama/app/webview"
)
+const (
+ defaultWindowWidth = 1360
+ defaultWindowHeight = 960
+ onboardingWindowWidth = 900
+ onboardingWindowHeight = 660
+)
+
type Webview struct {
port int
token string
@@ -237,10 +244,38 @@ func (w *Webview) Run(path string) unsafe.Pointer {
showWindow(wv.Window())
})
+ wv.Bind("activateOllama", func() {
+ showWindow(wv.Window())
+ })
+
wv.Bind("close", func() {
hideWindow(wv.Window())
})
+ wv.Bind("setOnboardingWindow", func(enabled bool) {
+ wv.Dispatch(func() {
+ if enabled {
+ wv.SetSize(onboardingWindowWidth, onboardingWindowHeight, webview.HintFixed)
+ setOnboardingWindowStyle(wv.Window(), true)
+ return
+ }
+
+ width, height := defaultWindowWidth, defaultWindowHeight
+ if w.Store != nil {
+ storedWidth, storedHeight, err := w.Store.WindowSize()
+ if err != nil {
+ slog.Error("failed to restore window size", "error", err)
+ } else if storedWidth > 0 && storedHeight > 0 {
+ width, height = storedWidth, storedHeight
+ }
+ }
+
+ wv.SetSize(width, height, webview.HintNone)
+ wv.SetSize(800, 600, webview.HintMin)
+ setOnboardingWindowStyle(wv.Window(), false)
+ })
+ })
+
// Webviews do not allow access to the file system by default, so we need to
// bind file system operations here
wv.Bind("selectModelsDirectory", func() {
@@ -450,17 +485,17 @@ func (w *Webview) Run(path string) unsafe.Pointer {
}()
}
+ width, height := defaultWindowWidth, defaultWindowHeight
if w.Store != nil {
- width, height, err := w.Store.WindowSize()
+ storedWidth, storedHeight, err := w.Store.WindowSize()
if err != nil {
slog.Error("failed to get window size", "error", err)
}
- if width > 0 && height > 0 {
- wv.SetSize(width, height, webview.HintNone)
- } else {
- wv.SetSize(800, 600, webview.HintNone)
+ if storedWidth > 0 && storedHeight > 0 {
+ width, height = storedWidth, storedHeight
}
}
+ wv.SetSize(width, height, webview.HintNone)
wv.SetSize(800, 600, webview.HintMin)
w.webview = wv
diff --git a/app/store/database.go b/app/store/database.go
index 6c6767c52..b8b166588 100644
--- a/app/store/database.go
+++ b/app/store/database.go
@@ -14,7 +14,7 @@ import (
// currentSchemaVersion defines the current database schema version.
// Increment this when making schema changes that require migrations.
-const currentSchemaVersion = 16
+const currentSchemaVersion = 17
// database wraps the SQLite connection.
// SQLite handles its own locking for concurrent access:
@@ -82,7 +82,8 @@ func (db *database) init() error {
websearch_enabled BOOLEAN NOT NULL DEFAULT 0,
selected_model TEXT NOT NULL DEFAULT '',
sidebar_open BOOLEAN NOT NULL DEFAULT 0,
- last_home_view TEXT NOT NULL DEFAULT 'launch',
+ last_home_view TEXT NOT NULL DEFAULT 'chat',
+ onboarding_version INTEGER NOT NULL DEFAULT 0,
think_enabled BOOLEAN NOT NULL DEFAULT 0,
think_level TEXT NOT NULL DEFAULT '',
cloud_setting_migrated BOOLEAN NOT NULL DEFAULT 0,
@@ -271,6 +272,12 @@ func (db *database) migrate() error {
return fmt.Errorf("migrate v15 to v16: %w", err)
}
version = 16
+ case 16:
+ // Existing users should not be shown onboarding after an upgrade.
+ if err := db.migrateV16ToV17(); err != nil {
+ return fmt.Errorf("migrate v16 to v17: %w", err)
+ }
+ version = 17
default:
// If we have a version we don't recognize, just set it to current
// This might happen during development
@@ -527,7 +534,7 @@ func (db *database) migrateV14ToV15() error {
// migrateV15ToV16 adds the last_home_view column to the settings table
func (db *database) migrateV15ToV16() error {
- _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN last_home_view TEXT NOT NULL DEFAULT 'launch'`)
+ _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN last_home_view TEXT NOT NULL DEFAULT 'chat'`)
if err != nil && !duplicateColumnError(err) {
return fmt.Errorf("add last_home_view column: %w", err)
}
@@ -540,6 +547,23 @@ func (db *database) migrateV15ToV16() error {
return nil
}
+// migrateV16ToV17 adds versioned onboarding state. The schema default stays at
+// zero for genuinely new installs, while all existing rows are marked complete
+// and moved off the retired launch home view.
+func (db *database) migrateV16ToV17() error {
+ _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN onboarding_version INTEGER NOT NULL DEFAULT 0`)
+ if err != nil && !duplicateColumnError(err) {
+ return fmt.Errorf("add onboarding_version column: %w", err)
+ }
+
+ _, err = db.conn.Exec(`UPDATE settings SET onboarding_version = 1, last_home_view = 'chat', schema_version = 17`)
+ if err != nil {
+ return fmt.Errorf("complete onboarding for existing users: %w", err)
+ }
+
+ return nil
+}
+
// cleanupOrphanedData removes orphaned records that may exist due to the foreign key bug
func (db *database) cleanupOrphanedData() error {
_, err := db.conn.Exec(`
@@ -1188,9 +1212,9 @@ func (db *database) getSettings() (Settings, error) {
var s Settings
err := db.conn.QueryRow(`
- SELECT expose, survey, browser, models, agent, tools, working_dir, context_length, turbo_enabled, websearch_enabled, selected_model, sidebar_open, last_home_view, think_enabled, think_level, auto_update_enabled
+ SELECT expose, survey, browser, models, agent, tools, working_dir, context_length, turbo_enabled, websearch_enabled, selected_model, sidebar_open, last_home_view, onboarding_version, think_enabled, think_level, auto_update_enabled
FROM settings
- `).Scan(&s.Expose, &s.Survey, &s.Browser, &s.Models, &s.Agent, &s.Tools, &s.WorkingDir, &s.ContextLength, &s.TurboEnabled, &s.WebSearchEnabled, &s.SelectedModel, &s.SidebarOpen, &s.LastHomeView, &s.ThinkEnabled, &s.ThinkLevel, &s.AutoUpdateEnabled)
+ `).Scan(&s.Expose, &s.Survey, &s.Browser, &s.Models, &s.Agent, &s.Tools, &s.WorkingDir, &s.ContextLength, &s.TurboEnabled, &s.WebSearchEnabled, &s.SelectedModel, &s.SidebarOpen, &s.LastHomeView, &s.OnboardingVersion, &s.ThinkEnabled, &s.ThinkLevel, &s.AutoUpdateEnabled)
if err != nil {
return Settings{}, fmt.Errorf("get settings: %w", err)
}
@@ -1200,28 +1224,14 @@ func (db *database) getSettings() (Settings, error) {
func (db *database) setSettings(s Settings) error {
lastHomeView := strings.ToLower(strings.TrimSpace(s.LastHomeView))
- validLaunchView := map[string]struct{}{
- "launch": {},
- "openclaw": {},
- "claude": {},
- "hermes": {},
- "codex": {},
- "codex-app": {},
- "copilot": {},
- "opencode": {},
- "droid": {},
- "pi": {},
- }
if lastHomeView != "chat" {
- if _, ok := validLaunchView[lastHomeView]; !ok {
- lastHomeView = "launch"
- }
+ lastHomeView = "chat"
}
_, err := db.conn.Exec(`
UPDATE settings
- SET expose = ?, survey = ?, browser = ?, models = ?, agent = ?, tools = ?, working_dir = ?, context_length = ?, turbo_enabled = ?, websearch_enabled = ?, selected_model = ?, sidebar_open = ?, last_home_view = ?, think_enabled = ?, think_level = ?, auto_update_enabled = ?
- `, s.Expose, s.Survey, s.Browser, s.Models, s.Agent, s.Tools, s.WorkingDir, s.ContextLength, s.TurboEnabled, s.WebSearchEnabled, s.SelectedModel, s.SidebarOpen, lastHomeView, s.ThinkEnabled, s.ThinkLevel, s.AutoUpdateEnabled)
+ SET expose = ?, survey = ?, browser = ?, models = ?, agent = ?, tools = ?, working_dir = ?, context_length = ?, turbo_enabled = ?, websearch_enabled = ?, selected_model = ?, sidebar_open = ?, last_home_view = ?, onboarding_version = ?, think_enabled = ?, think_level = ?, auto_update_enabled = ?
+ `, s.Expose, s.Survey, s.Browser, s.Models, s.Agent, s.Tools, s.WorkingDir, s.ContextLength, s.TurboEnabled, s.WebSearchEnabled, s.SelectedModel, s.SidebarOpen, lastHomeView, s.OnboardingVersion, s.ThinkEnabled, s.ThinkLevel, s.AutoUpdateEnabled)
if err != nil {
return fmt.Errorf("set settings: %w", err)
}
diff --git a/app/store/database_test.go b/app/store/database_test.go
index 3411e11bf..d4c75a231 100644
--- a/app/store/database_test.go
+++ b/app/store/database_test.go
@@ -135,7 +135,7 @@ func TestMigrationV13ToV14ContextLength(t *testing.T) {
}
}
-func TestMigrationV15ToV16LastHomeViewDefaultsToLaunch(t *testing.T) {
+func TestMigrationV15ToV16LastHomeViewMigratesToChat(t *testing.T) {
tmpDir := t.TempDir()
dbPath := filepath.Join(tmpDir, "test.db")
@@ -161,8 +161,8 @@ func TestMigrationV15ToV16LastHomeViewDefaultsToLaunch(t *testing.T) {
t.Fatalf("failed to read last_home_view: %v", err)
}
- if lastHomeView != "launch" {
- t.Fatalf("expected last_home_view to default to launch after migration, got %q", lastHomeView)
+ if lastHomeView != "chat" {
+ t.Fatalf("expected last_home_view to migrate to chat, got %q", lastHomeView)
}
version, err := db.getSchemaVersion()
@@ -174,6 +174,53 @@ func TestMigrationV15ToV16LastHomeViewDefaultsToLaunch(t *testing.T) {
}
}
+func TestOnboardingVersionDefaultsAndMigration(t *testing.T) {
+ t.Run("fresh installs need onboarding", func(t *testing.T) {
+ dbPath := filepath.Join(t.TempDir(), "fresh.db")
+ db, err := newDatabase(dbPath)
+ if err != nil {
+ t.Fatalf("failed to create database: %v", err)
+ }
+ defer db.Close()
+
+ settings, err := db.getSettings()
+ if err != nil {
+ t.Fatalf("failed to read settings: %v", err)
+ }
+ if settings.OnboardingVersion != 0 {
+ t.Fatalf("expected fresh install onboarding version 0, got %d", settings.OnboardingVersion)
+ }
+ })
+
+ t.Run("existing installs skip onboarding", func(t *testing.T) {
+ dbPath := filepath.Join(t.TempDir(), "existing.db")
+ db, err := newDatabase(dbPath)
+ if err != nil {
+ t.Fatalf("failed to create database: %v", err)
+ }
+ defer db.Close()
+
+ if _, err := db.conn.Exec(`
+ ALTER TABLE settings DROP COLUMN onboarding_version;
+ UPDATE settings SET schema_version = 16;
+ `); err != nil {
+ t.Fatalf("failed to seed v16 settings row: %v", err)
+ }
+
+ if err := db.migrate(); err != nil {
+ t.Fatalf("migration from v16 to v17 failed: %v", err)
+ }
+
+ settings, err := db.getSettings()
+ if err != nil {
+ t.Fatalf("failed to read settings: %v", err)
+ }
+ if settings.OnboardingVersion != 1 {
+ t.Fatalf("expected existing install onboarding version 1, got %d", settings.OnboardingVersion)
+ }
+ })
+}
+
func TestChatDeletionWithCascade(t *testing.T) {
t.Run("chat deletion cascades to related messages", func(t *testing.T) {
tmpDir := t.TempDir()
diff --git a/app/store/migration_test.go b/app/store/migration_test.go
index 0b3c06112..9367bdce3 100644
--- a/app/store/migration_test.go
+++ b/app/store/migration_test.go
@@ -57,6 +57,14 @@ func TestConfigMigration(t *testing.T) {
t.Error("expected has completed first run to be true after migration")
}
+ settings, err := s.Settings()
+ if err != nil {
+ t.Fatalf("failed to get settings: %v", err)
+ }
+ if settings.OnboardingVersion != CurrentOnboardingVersion {
+ t.Fatalf("expected migrated user to skip onboarding, got version %d", settings.OnboardingVersion)
+ }
+
// Verify migration is marked as complete
migrated, err := s.db.isConfigMigrated()
if err != nil {
diff --git a/app/store/store.go b/app/store/store.go
index 369c1db20..490eb8a6c 100644
--- a/app/store/store.go
+++ b/app/store/store.go
@@ -167,13 +167,19 @@ type Settings struct {
// SidebarOpen indicates if the chat sidebar is open
SidebarOpen bool
- // LastHomeView stores the preferred home route target ("chat" or integration name)
+ // LastHomeView is retained for settings compatibility and resolves to chat.
LastHomeView string
+ // OnboardingVersion stores the latest onboarding flow the user has completed.
+ OnboardingVersion int
+
// AutoUpdateEnabled indicates if automatic updates should be downloaded
AutoUpdateEnabled bool
}
+// Keep in sync with CURRENT_ONBOARDING_VERSION in app/ui/app/src/lib/onboarding.ts.
+const CurrentOnboardingVersion = 1
+
type Store struct {
// DBPath allows overriding the default database path (mainly for testing)
DBPath string
@@ -334,6 +340,16 @@ func (s *Store) migrateFromConfig(database *database) error {
if err := database.setHasCompletedFirstRun(hasCompleted); err != nil {
return fmt.Errorf("migrate first time run: %w", err)
}
+ if hasCompleted {
+ settings, err := database.getSettings()
+ if err != nil {
+ return fmt.Errorf("read settings for onboarding migration: %w", err)
+ }
+ settings.OnboardingVersion = CurrentOnboardingVersion
+ if err := database.setSettings(settings); err != nil {
+ return fmt.Errorf("migrate onboarding completion: %w", err)
+ }
+ }
slog.Info("migrated first run status from config.json", "hasCompleted", hasCompleted)
// Mark as migrated
@@ -393,7 +409,7 @@ func (s *Store) Settings() (Settings, error) {
}
if settings.LastHomeView == "" {
- settings.LastHomeView = "launch"
+ settings.LastHomeView = "chat"
}
return settings, nil
diff --git a/app/store/store_test.go b/app/store/store_test.go
index d4a08a8ad..3d27cfa88 100644
--- a/app/store/store_test.go
+++ b/app/store/store_test.go
@@ -81,18 +81,18 @@ func TestStore(t *testing.T) {
}
})
- t.Run("settings default home view is launch", func(t *testing.T) {
+ t.Run("settings default home view is chat", func(t *testing.T) {
loaded, err := s.Settings()
if err != nil {
t.Fatal(err)
}
- if loaded.LastHomeView != "launch" {
- t.Fatalf("expected default LastHomeView to be launch, got %q", loaded.LastHomeView)
+ if loaded.LastHomeView != "chat" {
+ t.Fatalf("expected default LastHomeView to be chat, got %q", loaded.LastHomeView)
}
})
- t.Run("settings empty home view falls back to launch", func(t *testing.T) {
+ t.Run("settings empty home view falls back to chat", func(t *testing.T) {
if err := s.SetSettings(Settings{LastHomeView: ""}); err != nil {
t.Fatal(err)
}
@@ -102,12 +102,12 @@ func TestStore(t *testing.T) {
t.Fatal(err)
}
- if loaded.LastHomeView != "launch" {
- t.Fatalf("expected empty LastHomeView to fall back to launch, got %q", loaded.LastHomeView)
+ if loaded.LastHomeView != "chat" {
+ t.Fatalf("expected empty LastHomeView to fall back to chat, got %q", loaded.LastHomeView)
}
})
- t.Run("settings disabled home view falls back to launch", func(t *testing.T) {
+ t.Run("settings retired home view falls back to chat", func(t *testing.T) {
if err := s.SetSettings(Settings{LastHomeView: "claude-desktop"}); err != nil {
t.Fatal(err)
}
@@ -117,12 +117,12 @@ func TestStore(t *testing.T) {
t.Fatal(err)
}
- if loaded.LastHomeView != "launch" {
- t.Fatalf("expected disabled LastHomeView to fall back to launch, got %q", loaded.LastHomeView)
+ if loaded.LastHomeView != "chat" {
+ t.Fatalf("expected retired LastHomeView to fall back to chat, got %q", loaded.LastHomeView)
}
})
- t.Run("settings codex app home view is accepted", func(t *testing.T) {
+ t.Run("settings integration home view falls back to chat", func(t *testing.T) {
if err := s.SetSettings(Settings{LastHomeView: "codex-app"}); err != nil {
t.Fatal(err)
}
@@ -132,8 +132,8 @@ func TestStore(t *testing.T) {
t.Fatal(err)
}
- if loaded.LastHomeView != "codex-app" {
- t.Fatalf("expected codex-app LastHomeView to be preserved, got %q", loaded.LastHomeView)
+ if loaded.LastHomeView != "chat" {
+ t.Fatalf("expected integration LastHomeView to fall back to chat, got %q", loaded.LastHomeView)
}
})
@@ -227,6 +227,32 @@ func TestStore(t *testing.T) {
})
}
+func TestOnboardingVersionRoundTrip(t *testing.T) {
+ s, cleanup := setupTestStore(t)
+ defer cleanup()
+
+ settings, err := s.Settings()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if settings.OnboardingVersion != 0 {
+ t.Fatalf("expected onboarding version 0 by default, got %d", settings.OnboardingVersion)
+ }
+
+ settings.OnboardingVersion = 1
+ if err := s.SetSettings(settings); err != nil {
+ t.Fatal(err)
+ }
+
+ loaded, err := s.Settings()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if loaded.OnboardingVersion != 1 {
+ t.Fatalf("expected onboarding version 1, got %d", loaded.OnboardingVersion)
+ }
+}
+
// setupTestStore creates a temporary store for testing
func setupTestStore(t *testing.T) (*Store, func()) {
t.Helper()
diff --git a/app/ui/app/codegen/gotypes.gen.ts b/app/ui/app/codegen/gotypes.gen.ts
index 73569847d..6db6fd91a 100644
--- a/app/ui/app/codegen/gotypes.gen.ts
+++ b/app/ui/app/codegen/gotypes.gen.ts
@@ -415,6 +415,7 @@ export class Settings {
SelectedModel: string;
SidebarOpen: boolean;
LastHomeView: string;
+ OnboardingVersion: number;
AutoUpdateEnabled: boolean;
constructor(source: any = {}) {
@@ -434,6 +435,7 @@ export class Settings {
this.SelectedModel = source["SelectedModel"];
this.SidebarOpen = source["SidebarOpen"];
this.LastHomeView = source["LastHomeView"];
+ this.OnboardingVersion = source["OnboardingVersion"];
this.AutoUpdateEnabled = source["AutoUpdateEnabled"];
}
}
diff --git a/app/ui/app/public/hello.png b/app/ui/app/public/hello.png
index fd04d9d0a..c562f08dc 100644
Binary files a/app/ui/app/public/hello.png and b/app/ui/app/public/hello.png differ
diff --git a/app/ui/app/src/api.test.ts b/app/ui/app/src/api.test.ts
new file mode 100644
index 000000000..456286bca
--- /dev/null
+++ b/app/ui/app/src/api.test.ts
@@ -0,0 +1,27 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { fetchConnectUrl } from "./api";
+
+describe("fetchConnectUrl", () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ it("requests a desktop handoff after account creation", async () => {
+ vi.stubGlobal(
+ "fetch",
+ vi.fn().mockResolvedValue(
+ new Response(
+ JSON.stringify({
+ signin_url:
+ "https://ollama.com/connect?name=MacBook&key=public-key",
+ }),
+ { status: 401 },
+ ),
+ ),
+ );
+
+ await expect(fetchConnectUrl()).resolves.toBe(
+ "https://ollama.com/connect?name=MacBook&key=public-key&launch=true",
+ );
+ });
+});
diff --git a/app/ui/app/src/api.ts b/app/ui/app/src/api.ts
index c22fee0dc..8490e7c07 100644
--- a/app/ui/app/src/api.ts
+++ b/app/ui/app/src/api.ts
@@ -81,7 +81,9 @@ export async function fetchConnectUrl(): Promise<string> {
if (response.status === 401) {
const data = await response.json();
if (data.signin_url) {
- return data.signin_url;
+ const connectUrl = new URL(data.signin_url);
+ connectUrl.searchParams.set("launch", "true");
+ return connectUrl.toString();
}
}
@@ -418,7 +420,9 @@ export interface ModelRecommendationsResponse {
recommendations: ModelRecommendation[];
}
-export async function getModelRecommendations(): Promise<ModelRecommendation[]> {
+export async function getModelRecommendations(): Promise<
+ ModelRecommendation[]
+> {
const response = await fetch(
`${API_BASE}/api/experimental/model-recommendations`,
);
diff --git a/app/ui/app/src/components/ChatSidebar.tsx b/app/ui/app/src/components/ChatSidebar.tsx
index 2d1b07a61..cd9533e3e 100644
--- a/app/ui/app/src/components/ChatSidebar.tsx
+++ b/app/ui/app/src/components/ChatSidebar.tsx
@@ -6,14 +6,12 @@ import { getChat } from "@/api";
import { Link } from "@/components/ui/link";
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
import { ChatsResponse } from "@/gotypes";
-import { CogIcon, RocketLaunchIcon } from "@heroicons/react/24/outline";
+import { CogIcon } from "@heroicons/react/24/outline";
// there's a hidden debug feature to copy a chat's data to the clipboard by
// holding shift and clicking this many times within this many seconds
const DEBUG_SHIFT_CLICKS_REQUIRED = 5;
const DEBUG_SHIFT_CLICK_WINDOW_MS = 7000; // 7 seconds
-const launchSidebarRequestedKey = "ollama.launchSidebarRequested";
-
interface ChatSidebarProps {
currentChatId?: string;
}
@@ -268,8 +266,9 @@ export function ChatSidebar({ currentChatId }: ChatSidebarProps) {
<Link
href="/c/new"
mask={{ to: "/" }}
- className={`flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left text-sm text-neutral-700 hover:bg-neutral-100 dark:hover:bg-neutral-800 dark:text-neutral-100 ${currentChatId === "new" ? "bg-neutral-100 dark:bg-neutral-800" : ""
- }`}
+ className={`flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left text-sm text-neutral-700 hover:bg-neutral-100 dark:hover:bg-neutral-800 dark:text-neutral-100 ${
+ currentChatId === "new" ? "bg-neutral-100 dark:bg-neutral-800" : ""
+ }`}
draggable={false}
>
<svg
@@ -283,23 +282,6 @@ export function ChatSidebar({ currentChatId }: ChatSidebarProps) {
</svg>
<span className="truncate">New Chat</span>
</Link>
- <Link
- to="/c/$chatId"
- params={{ chatId: "launch" }}
- onClick={() => {
- if (currentChatId !== "launch") {
- sessionStorage.setItem(launchSidebarRequestedKey, "1");
- }
- }}
- className={`flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left text-sm text-neutral-700 hover:bg-neutral-100 dark:hover:bg-neutral-800 dark:text-neutral-100 cursor-pointer ${currentChatId === "launch"
- ? "bg-neutral-100 dark:bg-neutral-800"
- : ""
- }`}
- draggable={false}
- >
- <RocketLaunchIcon className="h-5 w-5 stroke-current" />
- <span className="truncate">Launch</span>
- </Link>
{isWindows && (
<Link
href="/settings"
@@ -321,18 +303,19 @@ export function ChatSidebar({ currentChatId }: ChatSidebarProps) {
{group.chats.map((chat) => (
<div
key={chat.id}
- className={`allow-context-menu flex items-center relative text-sm text-neutral-800 dark:text-neutral-400 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 ${chat.id === currentChatId
- ? "bg-neutral-100 text-black dark:bg-neutral-800"
- : ""
- }`}
+ className={`allow-context-menu flex items-center relative text-sm text-neutral-800 dark:text-neutral-400 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 ${
+ chat.id === currentChatId
+ ? "bg-neutral-100 text-black dark:bg-neutral-800"
+ : ""
+ }`}
onMouseEnter={() => handleMouseEnter(chat.id)}
onContextMenu={(e) =>
handleContextMenu(
e,
chat.id,
chat.title ||
- chat.userExcerpt ||
- chat.createdAt.toLocaleString(),
+ chat.userExcerpt ||
+ chat.createdAt.toLocaleString(),
)
}
>
diff --git a/app/ui/app/src/components/CopyButton.tsx b/app/ui/app/src/components/CopyButton.tsx
index e43a5007a..f7e6c018c 100644
--- a/app/ui/app/src/components/CopyButton.tsx
+++ b/app/ui/app/src/components/CopyButton.tsx
@@ -68,7 +68,7 @@ const CopyButton: React.FC<CopyButtonProps> = ({
const iconSize = size === "sm" ? "h-3 w-3" : "h-7 w-7";
const baseClasses =
size === "sm"
- ? `text-xs px-4 py-2 z-10 rounded-lg hover:cursor-pointer ${className}`
+ ? `text-xs px-4 py-2 z-10 cursor-pointer rounded-lg ${className}`
: `${iconSize} px-1 py-0.5 text-xs cursor-pointer rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 flex items-center justify-center ${className}`;
const icon = isCopied ? (
diff --git a/app/ui/app/src/components/LaunchCommands.tsx b/app/ui/app/src/components/LaunchCommands.tsx
deleted file mode 100644
index e050681dc..000000000
--- a/app/ui/app/src/components/LaunchCommands.tsx
+++ /dev/null
@@ -1,166 +0,0 @@
-import { useSettings } from "@/hooks/useSettings";
-import CopyButton from "@/components/CopyButton";
-
-interface LaunchCommand {
- id: string;
- name: string;
- command: string;
- description: string;
- icon: string;
- darkIcon?: string;
- iconClassName?: string;
- borderless?: boolean;
-}
-
-const LAUNCH_COMMANDS: LaunchCommand[] = [
- {
- id: "claude",
- name: "Claude Code",
- command: "ollama launch claude",
- description: "Anthropic's coding tool with subagents",
- icon: "/launch-icons/claude-code.svg",
- iconClassName: "h-7 w-7",
- },
- {
- id: "chatgpt",
- name: "ChatGPT",
- command: "ollama launch chatgpt",
- description: "Complete work with ChatGPT",
- icon: "/launch-icons/codex-app.png",
- iconClassName: "h-full w-full",
- },
- {
- id: "hermes",
- name: "Hermes Agent",
- command: "ollama launch hermes",
- description: "Self-improving AI agent built by Nous Research",
- icon: "/launch-icons/hermes-agent.svg",
- iconClassName: "h-7 w-7",
- },
- {
- id: "openclaw",
- name: "OpenClaw",
- command: "ollama launch openclaw",
- description: "Personal AI with 100+ skills",
- icon: "/launch-icons/openclaw.svg",
- },
- {
- id: "opencode",
- name: "OpenCode",
- command: "ollama launch opencode",
- description: "Anomaly's open-source coding agent",
- icon: "/launch-icons/opencode.svg",
- iconClassName: "h-7 w-7 rounded",
- },
- {
- id: "codex",
- name: "Codex",
- command: "ollama launch codex",
- description: "OpenAI's open-source coding agent",
- icon: "/launch-icons/codex.svg",
- darkIcon: "/launch-icons/codex-dark.svg",
- iconClassName: "h-7 w-7",
- },
- {
- id: "copilot",
- name: "Copilot CLI",
- command: "ollama launch copilot",
- description: "GitHub's AI coding agent for the terminal",
- icon: "/launch-icons/copilot.svg",
- darkIcon: "/launch-icons/copilot-dark.svg",
- iconClassName: "h-7 w-7",
- },
- {
- id: "droid",
- name: "Droid",
- command: "ollama launch droid",
- description: "Factory's coding agent across terminal and IDEs",
- icon: "/launch-icons/droid.svg",
- },
- {
- id: "dsh",
- name: "DeepSeek Harness",
- command: "ollama launch dsh",
- description: "DeepSeek's open-source agent harness",
- icon: "/launch-icons/deepseek-harness.svg",
- iconClassName: "h-7 w-7",
- },
- {
- id: "pi",
- name: "Pi",
- command: "ollama launch pi",
- description: "Minimal AI agent toolkit with plugin support",
- icon: "/launch-icons/pi.svg",
- darkIcon: "/launch-icons/pi-dark.svg",
- iconClassName: "h-7 w-7",
- },
-];
-
-export default function LaunchCommands() {
- const isWindows = navigator.platform.toLowerCase().includes("win");
- const { setSettings } = useSettings();
-
- const renderCommandCard = (item: LaunchCommand) => (
- <div key={item.command} className="w-full text-left">
- <div className="flex items-start gap-4 sm:gap-5">
- <div
- aria-hidden="true"
- className={`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg overflow-hidden ${item.borderless ? "" : "border border-neutral-200 bg-white dark:border-neutral-700 dark:bg-neutral-900"}`}
- >
- {item.darkIcon ? (
- <picture>
- <source srcSet={item.darkIcon} media="(prefers-color-scheme: dark)" />
- <img src={item.icon} alt="" className={`${item.iconClassName ?? "h-8 w-8"} rounded-sm`} />
- </picture>
- ) : (
- <img src={item.icon} alt="" className={item.borderless ? "h-full w-full rounded-xl" : `${item.iconClassName ?? "h-8 w-8"} rounded-sm`} />
- )}
- </div>
-
- <div className="min-w-0 flex-1">
- <span className="text-sm font-medium text-neutral-900 dark:text-neutral-100">
- {item.name}
- </span>
- <p className="mt-0.5 text-xs text-neutral-500 dark:text-neutral-400">
- {item.description}
- </p>
- <div className="mt-2 flex items-center gap-2 rounded-xl border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800 px-3 py-2">
- <code className="min-w-0 flex-1 truncate text-xs text-neutral-600 dark:text-neutral-300">
- {item.command}
- </code>
- <CopyButton
- content={item.command}
- size="md"
- title="Copy command to clipboard"
- className="text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-neutral-200/60 dark:hover:bg-neutral-700/70"
- onCopy={() => {
- setSettings({ LastHomeView: item.id }).catch(() => { });
- }}
- />
- </div>
- </div>
- </div>
- </div>
- );
-
- return (
- <main className="flex h-screen w-full flex-col relative">
- <section
- className={`flex-1 overflow-y-auto overscroll-contain relative min-h-0 ${isWindows ? "xl:pt-4" : "xl:pt-8"}`}
- >
- <div className="max-w-[730px] mx-auto w-full px-4 pt-4 pb-20 sm:px-6 sm:pt-6 sm:pb-24 lg:px-8 lg:pt-8 lg:pb-28">
- <h1 className="text-xl font-semibold text-neutral-900 dark:text-neutral-100">
- Launch
- </h1>
- <p className="mt-1 text-sm text-neutral-500 dark:text-neutral-400">
- Copy a command and run it in your terminal.
- </p>
-
- <div className="mt-6 grid gap-7">
- {LAUNCH_COMMANDS.map(renderCommandCard)}
- </div>
- </div>
- </section>
- </main>
- );
-}
diff --git a/app/ui/app/src/components/Logo.tsx b/app/ui/app/src/components/Logo.tsx
index 15624353b..bb8336746 100644
--- a/app/ui/app/src/components/Logo.tsx
+++ b/app/ui/app/src/components/Logo.tsx
@@ -1,16 +1,28 @@
-export default function Logo() {
+interface LogoProps {
+ size?: number;
+ containerClassName?: string;
+ showBackground?: boolean;
+}
+
+export default function Logo({
+ size = 60,
+ containerClassName = "mb-8",
+ showBackground = true,
+}: LogoProps = {}) {
return (
- <div className="flex mb-8 justify-center select-none">
+ <div className={`flex justify-center select-none ${containerClassName}`}>
<div className="relative select-none">
<svg
- width="60"
- height="60"
+ width={size}
+ height={size}
viewBox="0 0 3400 3400"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="select-none"
>
- <circle cx="1700" cy="1700" r="1700" fill="white" />
+ {showBackground && (
+ <circle cx="1700" cy="1700" r="1700" fill="white" />
+ )}
<path
d="M1070.57 220.832C1042.94 225.295 1009.78 239.748 986.406 257.6C915.632 311.371 860.798 425.502 837.632 567.687C828.918 621.458 822.967 696.057 822.967 753.016C822.967 820.177 830.831 906.04 842.095 965.337C844.646 978.514 845.921 990.203 844.858 991.053C844.008 991.904 833.594 1000.4 821.905 1009.76C781.948 1041.64 736.254 1090.73 704.799 1135.58C644.439 1221.23 605.333 1318.57 588.968 1423.98C582.592 1465.64 580.892 1549.8 585.992 1591.46C597.257 1687.53 626.161 1768.71 675.682 1843.1L691.834 1867.12L687.158 1874.98C654.003 1930.66 625.736 2011.21 612.559 2088.58C602.145 2149.79 600.87 2166.15 600.87 2248.19C600.87 2330.86 601.932 2347.23 611.709 2404.4C623.398 2472.84 647.202 2545.31 673.769 2593.56C682.483 2609.28 703.736 2642.01 706.286 2643.71C707.137 2644.14 704.586 2652 700.548 2661.14C669.943 2728.09 643.802 2817.14 632.962 2892.17C625.311 2943.6 624.249 2960.18 624.249 3014.37C624.249 3083.45 628.074 3117.03 642.526 3172.07L644.652 3180.15H735.616H826.793L820.842 3168.88C784.074 3100.87 780.673 2974.63 812.341 2848.6C826.793 2790.36 843.158 2747.64 873.763 2688.77L892.041 2653.07V2631.17C892.041 2610.77 891.616 2608.43 885.027 2595.04C879.926 2584.84 873.125 2576.13 861.011 2564.23C840.395 2544.25 825.518 2523.21 813.616 2497.28C761.333 2383.79 751.131 2215.25 787.899 2071.57C803.202 2011.64 828.493 1958.29 855.06 1929.18C873.125 1909.2 882.477 1886.88 882.477 1863.72C882.477 1839.7 873.975 1819.93 854.847 1799.32C800.014 1740.66 766.221 1669.25 754.107 1586.15C736.891 1467.77 768.134 1338.76 839.12 1236.53C908.618 1136.21 1006.17 1071.82 1115.2 1054.6C1139.64 1050.56 1185.34 1051.2 1210.84 1055.88C1238.68 1060.76 1256.11 1059.28 1273.96 1050.78C1296.07 1040.36 1307.12 1027.4 1320.08 997.642C1331.56 971.075 1340.49 956.623 1364.5 926.656C1393.41 890.738 1421.25 866.296 1465.88 836.754C1516.89 803.386 1574.91 779.158 1632.72 767.468C1653.76 763.218 1663.54 762.58 1702.86 762.58C1742.17 762.58 1751.95 763.218 1772.99 767.468C1857.79 784.683 1941.96 828.465 2009.12 890.525C2023.57 903.915 2058.21 946.847 2069.26 964.699C2073.51 971.713 2080.95 986.59 2085.63 997.642C2098.59 1027.4 2109.65 1040.36 2131.75 1050.78C2148.96 1059.06 2167.03 1060.76 2193.81 1056.3C2236.1 1049.08 2268.62 1049.71 2310.06 1058.21C2451.19 1086.69 2574.03 1202.95 2628.44 1358.74C2675.83 1495.4 2662.45 1638.43 2591.88 1747.67C2579.98 1766.16 2568.08 1781.04 2550.86 1799.32C2513.67 1839.06 2513.67 1888.37 2550.65 1929.18C2611.44 1995.7 2649.48 2159.35 2638 2303.66C2630.35 2398.88 2605.91 2484.1 2572.33 2532.35C2566.38 2540.85 2554.05 2555.3 2544.7 2564.23C2532.59 2576.13 2525.79 2584.84 2520.69 2595.04C2514.1 2608.43 2513.67 2610.77 2513.67 2631.17V2653.07L2531.95 2688.77C2562.55 2747.64 2578.92 2790.36 2593.37 2848.6C2624.61 2972.93 2621.85 3096.62 2586.15 3166.97C2583.17 3172.92 2580.62 3178.45 2580.62 3179.09C2580.62 3179.72 2621.21 3180.15 2670.95 3180.15H2761.06L2763.4 3171.01C2764.67 3166.12 2766.8 3158.68 2767.86 3154.43C2770.2 3145.08 2774.88 3117.45 2778.7 3090.88C2782.31 3064.11 2782.31 2965.49 2778.7 2935.73C2765.1 2827.77 2742.36 2742.12 2705.16 2661.14C2701.13 2652 2698.58 2644.14 2699.43 2643.71C2700.49 2643.08 2706.44 2634.57 2712.82 2625.01C2759.15 2554.87 2787.63 2466.67 2802.08 2350.21C2805.91 2318.11 2805.91 2180.18 2802.08 2149.36C2791.88 2069.87 2779.55 2015.89 2759.15 1961.27C2750.65 1938.53 2728.12 1890.5 2718.55 1874.98L2713.88 1867.12L2730.03 1843.1C2779.55 1768.71 2808.46 1687.53 2819.72 1591.46C2824.82 1549.8 2823.12 1465.64 2816.74 1423.98C2800.17 1318.36 2761.27 1221.44 2700.91 1135.58C2669.46 1090.73 2623.76 1041.64 2583.81 1009.76C2572.12 1000.4 2561.7 991.904 2560.85 991.053C2559.79 990.203 2561.07 978.514 2563.62 965.337C2589.33 831.228 2588.48 663.964 2561.49 533.256C2538.11 419.338 2495.61 328.799 2440.77 276.516C2396.99 234.859 2352.36 217.006 2298.8 220.407C2175.96 227.633 2076.92 368.968 2037.81 591.703C2031.43 627.621 2025.91 669.703 2025.91 681.18C2025.91 685.643 2025.06 689.256 2023.99 689.256C2022.93 689.256 2014.64 685.005 2005.72 679.692C1910.93 623.583 1805.51 593.616 1702.86 593.616C1600.2 593.616 1494.79 623.583 1400 679.692C1391.07 685.005 1382.78 689.256 1381.72 689.256C1380.66 689.256 1379.81 685.643 1379.81 681.18C1379.81 669.278 1374.07 625.921 1367.9 591.703C1332.41 391.709 1251.01 259.301 1142.83 225.933C1127.95 221.47 1085.66 218.494 1070.57 220.832ZM1106.7 393.834C1137.3 418.063 1171.31 487.349 1190.86 564.924C1194.48 578.951 1198.3 595.104 1199.36 601.054C1200.21 606.793 1202.55 619.758 1204.47 629.747C1212.75 674.804 1216.58 723.474 1217 782.771L1217.22 841.217L1202.55 862.896L1187.89 884.787H1153.67C1113.71 884.787 1073.97 889.888 1035.93 900.089C1022.32 903.49 1009.15 906.89 1006.6 907.528C1002.56 908.378 1001.92 907.103 999.583 889.675C987.043 795.098 987.681 690.319 1001.5 603.18C1016.8 506.052 1052.5 418.063 1087.36 392.134C1095.65 385.971 1097.14 386.183 1106.7 393.834ZM2318.57 392.347C2339.61 407.862 2362.77 449.093 2379.99 501.802C2414.63 607.218 2424.41 751.953 2406.13 889.675C2403.79 907.103 2403.15 908.378 2399.12 907.528C2396.57 906.89 2383.39 903.49 2369.79 900.089C2331.74 889.888 2292 884.787 2252.04 884.787H2217.82L2203.16 862.896L2188.5 841.217L2188.71 782.771C2189.13 700.308 2196.78 635.91 2215.06 564.286C2234.4 487.349 2268.62 418.063 2299.01 393.834C2308.58 386.183 2310.06 385.971 2318.57 392.347Z"
fill="black"
diff --git a/app/ui/app/src/components/Onboarding.test.tsx b/app/ui/app/src/components/Onboarding.test.tsx
new file mode 100644
index 000000000..90b3ded63
--- /dev/null
+++ b/app/ui/app/src/components/Onboarding.test.tsx
@@ -0,0 +1,170 @@
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it, vi } from "vitest";
+import {
+ FIRST_MODEL_COMMAND,
+ IntroScreen,
+ default as Onboarding,
+ RunOllamaScreen,
+ WelcomeScreen,
+} from "./Onboarding";
+import {
+ authenticationTimeoutAction,
+ nextOnboardingStep,
+ onboardingConnectUrl,
+} from "@/lib/onboarding";
+
+describe("Onboarding", () => {
+ it("explains what Ollama is before asking the user to choose a path", () => {
+ const html = renderToStaticMarkup(<IntroScreen onContinue={vi.fn()} />);
+
+ expect(html).toContain("Welcome to Ollama!");
+ expect(html.indexOf('alt="Ollama waving"')).toBeLessThan(
+ html.indexOf("Welcome to Ollama!"),
+ );
+ expect(html).not.toContain("Run open models locally or in the cloud.");
+ expect(html.indexOf("Connect your apps")).toBeLessThan(
+ html.indexOf("Easily switch models"),
+ );
+ expect(html.indexOf("Easily switch models")).toBeLessThan(
+ html.indexOf("Your data stays yours"),
+ );
+ expect(html).toContain("Power your existing coding apps with open models");
+ expect(html).toContain("Swap between frontier models in one click.");
+ expect(html).toContain("Your prompt data is never logged or trained on.");
+ expect(html).toContain("Continue");
+ expect(html).not.toContain("Skip");
+ });
+
+ it("shows the account choice only to signed-out users", () => {
+ expect(nextOnboardingStep("intro", "continue", false)).toBe("welcome");
+ expect(nextOnboardingStep("intro", "continue", true)).toBe("run");
+ expect(nextOnboardingStep("welcome", "local", false)).toBe("run");
+ });
+
+ it("lets an in-flight authentication check finish before timing out", () => {
+ expect(authenticationTimeoutAction(false, true)).toBe("defer");
+ expect(authenticationTimeoutAction(false, false)).toBe("fail");
+ expect(authenticationTimeoutAction(true, true)).toBe("ignore");
+ });
+
+ it("opens the device connection flow without relaunching the app", () => {
+ expect(
+ onboardingConnectUrl(
+ "https://ollama.com/connect?name=MacBook&key=public-key&launch=true",
+ "signin",
+ ),
+ ).toBe("https://ollama.com/connect?name=MacBook&key=public-key");
+ expect(
+ onboardingConnectUrl(
+ "https://ollama.com/connect?name=MacBook&key=public-key",
+ "signup",
+ ),
+ ).toBe(
+ "https://ollama.com/connect?name=MacBook&key=public-key&signup=true",
+ );
+ });
+
+ it("shows Run Ollama after a successful connection and hides sign in", () => {
+ const html = renderToStaticMarkup(
+ <Onboarding
+ isAuthenticated
+ isSigningIn={false}
+ signInError={null}
+ completionError={null}
+ onSignIn={vi.fn()}
+ onRetryCompletion={vi.fn()}
+ onUseLocal={vi.fn()}
+ showRun
+ />,
+ );
+
+ expect(html).toContain("Run Ollama");
+ expect(html).not.toContain("Welcome to Ollama");
+ expect(html).not.toContain("Sign up");
+ });
+
+ it("offers cloud sign-up, local setup, and sign in on the welcome screen", () => {
+ const html = renderToStaticMarkup(
+ <WelcomeScreen
+ isAuthenticated={false}
+ isSigningIn={false}
+ signInError={null}
+ onSignIn={vi.fn()}
+ onSignUp={vi.fn()}
+ onLocal={vi.fn()}
+ />,
+ );
+
+ expect(html).toContain("Create an account");
+ expect(html).toContain(
+ "Create your account for access to faster, larger open models.",
+ );
+ expect(html).toContain("Your data is never logged or trained on.");
+ expect(html).toContain("Sign up");
+ expect(html).toContain("No thanks, I&#x27;ll use Ollama locally");
+ expect(html).toContain("Sign in");
+ expect(html).not.toContain("Skip");
+ });
+
+ it("shows the cloud choice without a sign-in link for authenticated users", () => {
+ const html = renderToStaticMarkup(
+ <WelcomeScreen
+ isAuthenticated
+ isSigningIn={false}
+ signInError={null}
+ onSignIn={vi.fn()}
+ onSignUp={vi.fn()}
+ onLocal={vi.fn()}
+ />,
+ );
+
+ expect(html).toContain("Create an account");
+ expect(html).toContain(
+ "Create your account for access to faster, larger open models.",
+ );
+ expect(html).toContain("Your data is never logged or trained on.");
+ expect(html).not.toContain(">Sign in<");
+ });
+
+ it("shows only the local command on the final page", () => {
+ const html = renderToStaticMarkup(
+ <RunOllamaScreen completionError={null} onRetryCompletion={vi.fn()} />,
+ );
+
+ expect(html).toContain("Run Ollama");
+ expect(html).toContain(FIRST_MODEL_COMMAND);
+ expect(html).not.toContain("Finish");
+ expect(html).not.toContain("Sign in");
+ expect(html).not.toContain("create an account");
+ });
+
+ it("shows the connecting state on the welcome action", () => {
+ const html = renderToStaticMarkup(
+ <WelcomeScreen
+ isAuthenticated={false}
+ isSigningIn
+ signInError={null}
+ onSignIn={vi.fn()}
+ onSignUp={vi.fn()}
+ onLocal={vi.fn()}
+ />,
+ );
+
+ expect(html).toContain("Finish in your browser…");
+ expect(html).not.toContain("Waiting for sign in…");
+ });
+
+ it("shows a retryable error when onboarding completion cannot be saved", () => {
+ const onRetryCompletion = vi.fn();
+ const html = renderToStaticMarkup(
+ <RunOllamaScreen
+ completionError="Unable to save setup. Please try again."
+ onRetryCompletion={onRetryCompletion}
+ />,
+ );
+
+ expect(html).toContain("Unable to save setup. Please try again.");
+ expect(html).toContain('role="alert"');
+ expect(html).toContain("Try again");
+ });
+});
diff --git a/app/ui/app/src/components/Onboarding.tsx b/app/ui/app/src/components/Onboarding.tsx
new file mode 100644
index 000000000..e05682929
--- /dev/null
+++ b/app/ui/app/src/components/Onboarding.tsx
@@ -0,0 +1,302 @@
+import CopyButton from "@/components/CopyButton";
+import Logo from "@/components/Logo";
+import { nextOnboardingStep, type OnboardingStep } from "@/lib/onboarding";
+import {
+ ArrowsRightLeftIcon,
+ CommandLineIcon,
+ ShieldCheckIcon,
+} from "@heroicons/react/24/outline";
+import { useEffect, useState, type ReactNode } from "react";
+
+export const FIRST_MODEL_COMMAND = "ollama";
+
+interface ScreenProps {
+ isSigningIn: boolean;
+ signInError: string | null;
+ onSignIn: () => void;
+}
+
+interface WelcomeScreenProps extends ScreenProps {
+ isAuthenticated: boolean;
+ onLocal: () => void;
+ onSignUp: () => void;
+}
+
+interface RunOllamaScreenProps {
+ completionError: string | null;
+ onRetryCompletion: () => void;
+}
+
+function TitleBar({ onSignIn }: { onSignIn?: () => void }) {
+ return (
+ <header
+ className="relative flex h-10 shrink-0 items-center justify-center bg-white"
+ onDoubleClick={() => window.doubleClick?.()}
+ onMouseDown={() => window.drag?.()}
+ >
+ {onSignIn && (
+ <button
+ type="button"
+ className="absolute right-5 top-3 cursor-pointer rounded-md px-2 py-0 text-sm font-normal text-neutral-500 hover:text-neutral-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500"
+ onClick={onSignIn}
+ onMouseDown={(event) => event.stopPropagation()}
+ >
+ Sign in
+ </button>
+ )}
+ </header>
+ );
+}
+
+function OnboardingIcon({ compact = false }: { compact?: boolean }) {
+ return (
+ <div className="flex items-center justify-center">
+ <Logo
+ size={compact ? 42 : 54}
+ containerClassName="mb-0"
+ showBackground={false}
+ />
+ </div>
+ );
+}
+
+function OnboardingCard({ children }: { children: ReactNode }) {
+ return (
+ <section className="flex min-h-0 flex-1 items-center justify-center overflow-y-auto bg-white px-6 pb-10 pt-0">
+ <div className="flex w-full max-w-[760px] flex-col items-center justify-center bg-white px-10 py-6 text-center">
+ {children}
+ </div>
+ </section>
+ );
+}
+
+const OLLAMA_FEATURES = [
+ {
+ title: "Connect your apps",
+ description: "Power your existing coding apps with open models",
+ icon: CommandLineIcon,
+ },
+ {
+ title: "Easily switch models",
+ description: "Swap between frontier models in one click.",
+ icon: ArrowsRightLeftIcon,
+ },
+ {
+ title: "Your data stays yours",
+ description: "Your prompt data is never logged or trained on.",
+ icon: ShieldCheckIcon,
+ },
+];
+
+export function IntroScreen({ onContinue }: { onContinue: () => void }) {
+ return (
+ <main className="flex h-screen w-full flex-col overflow-hidden bg-white text-neutral-950">
+ <TitleBar />
+
+ <section className="flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 pb-10">
+ <div className="mx-auto flex min-h-full w-full max-w-[620px] flex-col items-center justify-center py-4 text-center">
+ <div className="flex flex-col items-center justify-center gap-2">
+ <img
+ src="/hello.png"
+ alt="Ollama waving"
+ className="h-[72px] w-[72px] select-none object-contain"
+ draggable={false}
+ />
+ <h1 className="font-rounded text-2xl font-medium leading-8">
+ Welcome to Ollama!
+ </h1>
+ </div>
+ <div className="mx-auto mt-8 flex w-fit max-w-full flex-col gap-6 text-left">
+ {OLLAMA_FEATURES.map((feature) => {
+ const Icon = feature.icon;
+
+ return (
+ <div key={feature.title} className="flex items-start gap-4">
+ <Icon className="mt-0.5 h-7 w-7 shrink-0 stroke-[1.5] text-neutral-700" />
+ <div>
+ <h2 className="text-sm font-medium text-neutral-950">
+ {feature.title}
+ </h2>
+ <p className="mt-0.5 text-[13px] leading-5 text-neutral-500">
+ {feature.description}
+ </p>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+
+ <button
+ type="button"
+ className="mt-8 flex h-11 w-full max-w-[240px] cursor-pointer items-center justify-center rounded-full bg-neutral-900 px-5 font-sans text-sm font-normal text-white transition-colors hover:bg-neutral-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500"
+ onClick={onContinue}
+ >
+ Continue
+ </button>
+ </div>
+ </section>
+ </main>
+ );
+}
+
+function InlineError({
+ message,
+ className = "mt-3 text-sm",
+}: {
+ message: string | null;
+ className?: string;
+}) {
+ if (!message) return null;
+
+ return (
+ <p role="alert" className={`${className} text-red-600`}>
+ {message}
+ </p>
+ );
+}
+
+export function WelcomeScreen({
+ isAuthenticated,
+ isSigningIn,
+ signInError,
+ onSignIn,
+ onSignUp,
+ onLocal,
+}: WelcomeScreenProps) {
+ return (
+ <main className="flex min-h-screen w-full flex-col bg-white text-neutral-950">
+ <TitleBar onSignIn={isAuthenticated ? undefined : onSignIn} />
+ <OnboardingCard>
+ <OnboardingIcon />
+ <h1 className="mt-7 font-rounded text-2xl font-medium leading-8">
+ Create an account
+ </h1>
+ <p className="mt-3 max-w-[400px] text-sm leading-6 text-neutral-400">
+ Create your account for access to faster, larger open models.
+ </p>
+ <p className="mt-1 max-w-[400px] text-sm leading-6 text-neutral-400">
+ Your data is never logged or trained on.
+ </p>
+
+ <div className="mt-7 flex w-full max-w-[240px] flex-col items-center">
+ <button
+ type="button"
+ className="flex h-11 w-full cursor-pointer items-center justify-center rounded-full bg-neutral-900 px-5 font-sans text-sm font-normal text-white transition-colors hover:bg-neutral-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500 disabled:cursor-wait disabled:opacity-70"
+ onClick={onSignUp}
+ disabled={isSigningIn}
+ aria-busy={isSigningIn}
+ >
+ {isSigningIn ? "Finish in your browser…" : "Sign up"}
+ </button>
+ <button
+ type="button"
+ className="mt-2 cursor-pointer rounded-md px-3 py-2 text-sm font-normal text-neutral-600 underline decoration-neutral-300 underline-offset-4 hover:text-neutral-950 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500"
+ onClick={onLocal}
+ >
+ No thanks, I&apos;ll use Ollama locally
+ </button>
+ <InlineError message={signInError} />
+ </div>
+ </OnboardingCard>
+ </main>
+ );
+}
+
+export function RunOllamaScreen({
+ completionError,
+ onRetryCompletion,
+}: RunOllamaScreenProps) {
+ return (
+ <main className="flex min-h-screen w-full flex-col bg-white text-neutral-950">
+ <TitleBar />
+ <OnboardingCard>
+ <OnboardingIcon compact />
+ <h1 className="mt-6 font-rounded text-[22px] font-medium leading-7">
+ Run Ollama
+ </h1>
+
+ <div className="mt-6 grid h-12 w-full max-w-[330px] grid-cols-[minmax(0,1fr)_32px] items-center rounded-full bg-neutral-100 px-4 pr-3">
+ <code className="min-w-0 truncate text-left font-mono text-sm">
+ {FIRST_MODEL_COMMAND}
+ </code>
+ <CopyButton
+ content={FIRST_MODEL_COMMAND}
+ size="md"
+ title="Copy command to clipboard"
+ className="shrink-0 text-neutral-400 hover:!bg-transparent hover:!text-neutral-400 dark:hover:!bg-transparent"
+ />
+ </div>
+
+ <p className="mt-3 max-w-xs text-[13px] leading-5 text-neutral-400">
+ Run this command in your terminal to get started.
+ </p>
+
+ <InlineError message={completionError} />
+ {completionError && (
+ <button
+ type="button"
+ className="mt-2 cursor-pointer rounded-md px-3 py-1 text-sm font-normal text-neutral-600 underline decoration-neutral-300 underline-offset-4 hover:text-neutral-950 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500"
+ onClick={onRetryCompletion}
+ >
+ Try again
+ </button>
+ )}
+ </OnboardingCard>
+ </main>
+ );
+}
+
+interface OnboardingProps extends ScreenProps {
+ completionError: string | null;
+ isAuthenticated: boolean;
+ onRetryCompletion: () => void;
+ onSignUp: () => void;
+ onUseLocal: () => void;
+ showRun: boolean;
+}
+
+export default function Onboarding(props: OnboardingProps) {
+ const [step, setStep] = useState<OnboardingStep>("intro");
+
+ useEffect(() => {
+ window.setOnboardingWindow?.(true);
+ return () => window.setOnboardingWindow?.(false);
+ }, []);
+
+ if (props.showRun || step === "run") {
+ return (
+ <RunOllamaScreen
+ completionError={props.completionError}
+ onRetryCompletion={props.onRetryCompletion}
+ />
+ );
+ }
+
+ if (step === "intro") {
+ return (
+ <IntroScreen
+ onContinue={() => {
+ const nextStep = nextOnboardingStep(
+ step,
+ "continue",
+ props.isAuthenticated,
+ );
+ if (nextStep === "run") props.onUseLocal();
+ setStep(nextStep);
+ }}
+ />
+ );
+ }
+
+ return (
+ <WelcomeScreen
+ {...props}
+ onLocal={() => {
+ props.onUseLocal();
+ setStep((current) =>
+ nextOnboardingStep(current, "local", props.isAuthenticated),
+ );
+ }}
+ />
+ );
+}
diff --git a/app/ui/app/src/components/Settings.tsx b/app/ui/app/src/components/Settings.tsx
index 3f0f5c466..80ccf8a77 100644
--- a/app/ui/app/src/components/Settings.tsx
+++ b/app/ui/app/src/components/Settings.tsx
@@ -12,13 +12,10 @@ import {
BoltIcon,
WrenchIcon,
CloudIcon,
- XMarkIcon,
CogIcon,
- ArrowLeftIcon,
ArrowDownTrayIcon,
} from "@heroicons/react/20/solid";
import { Settings as SettingsType } from "@/gotypes";
-import { useNavigate } from "@tanstack/react-router";
import { useUser } from "@/hooks/useUser";
import { useCloudStatus } from "@/hooks/useCloudStatus";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
@@ -61,7 +58,6 @@ export default function Settings() {
const [isAwaitingConnection, setIsAwaitingConnection] = useState(false);
const [connectionError, setConnectionError] = useState<string | null>(null);
const [pollingInterval, setPollingInterval] = useState<number | null>(null);
- const navigate = useNavigate();
const {
cloudDisabled,
cloudStatus,
@@ -273,10 +269,6 @@ export default function Settings() {
}
const isWindows = navigator.platform.toLowerCase().includes("win");
- const handleCloseSettings = () => {
- const chatId = settings.LastHomeView === "chat" ? "new" : "launch";
- navigate({ to: "/c/$chatId", params: { chatId } });
- };
return (
<main className="flex h-screen w-full flex-col select-none dark:bg-neutral-900">
@@ -288,24 +280,8 @@ export default function Settings() {
<h1
className={`${isWindows ? "pl-4" : "pl-24"} flex items-center font-rounded text-md font-medium dark:text-white`}
>
- {isWindows && (
- <button
- onClick={handleCloseSettings}
- className="hover:bg-neutral-100 mr-3 dark:hover:bg-neutral-800 rounded-full p-1.5"
- >
- <ArrowLeftIcon className="w-5 h-5 dark:text-white" />
- </button>
- )}
Settings
</h1>
- {!isWindows && (
- <button
- onClick={handleCloseSettings}
- className="p-1 hover:bg-neutral-100 mr-3 dark:hover:bg-neutral-800 rounded-full"
- >
- <XMarkIcon className="w-6 h-6 dark:text-white" />
- </button>
- )}
</header>
<div className="w-full p-6 overflow-y-auto flex-1 overscroll-contain">
<div className="space-y-4 max-w-2xl mx-auto">
@@ -463,7 +439,9 @@ export default function Settings() {
<div className="flex-shrink-0">
<Switch
checked={settings.AutoUpdateEnabled}
- onChange={(checked) => handleChange("AutoUpdateEnabled", checked)}
+ onChange={(checked) =>
+ handleChange("AutoUpdateEnabled", checked)
+ }
/>
</div>
</div>
@@ -544,7 +522,9 @@ export default function Settings() {
</Description>
<div className="mt-3">
<Slider
- value={settings.ContextLength || defaultContextLength || 0}
+ value={
+ settings.ContextLength || defaultContextLength || 0
+ }
onChange={(value) => {
handleChange("ContextLength", value);
}}
diff --git a/app/ui/app/src/hooks/useSettings.ts b/app/ui/app/src/hooks/useSettings.ts
index 1eebcf533..f544b1581 100644
--- a/app/ui/app/src/hooks/useSettings.ts
+++ b/app/ui/app/src/hooks/useSettings.ts
@@ -10,6 +10,7 @@ interface SettingsState {
selectedModel: string;
sidebarOpen: boolean;
lastHomeView: string;
+ onboardingVersion: number;
thinkEnabled: boolean;
thinkLevel: string;
}
@@ -23,6 +24,7 @@ type SettingsUpdate = Partial<{
SelectedModel: string;
SidebarOpen: boolean;
LastHomeView: string;
+ OnboardingVersion: number;
}>;
export function useSettings() {
@@ -52,7 +54,8 @@ export function useSettings() {
thinkLevel: settingsData?.settings?.ThinkLevel ?? "none",
selectedModel: settingsData?.settings?.SelectedModel ?? "",
sidebarOpen: settingsData?.settings?.SidebarOpen ?? false,
- lastHomeView: settingsData?.settings?.LastHomeView ?? "launch",
+ lastHomeView: settingsData?.settings?.LastHomeView ?? "chat",
+ onboardingVersion: settingsData?.settings?.OnboardingVersion ?? 0,
}),
[settingsData?.settings],
);
diff --git a/app/ui/app/src/index.css b/app/ui/app/src/index.css
index af1f265dc..eaaa8bd89 100644
--- a/app/ui/app/src/index.css
+++ b/app/ui/app/src/index.css
@@ -8,6 +8,19 @@
"SF Pro Rounded", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}
+@layer base {
+ a[href],
+ button:not(:disabled),
+ [role="button"]:not([aria-disabled="true"]) {
+ cursor: pointer;
+ }
+
+ button:disabled,
+ [role="button"][aria-disabled="true"] {
+ cursor: not-allowed;
+ }
+}
+
@media (prefers-color-scheme: dark) {
/* Dark mode styles go here */
:root {
diff --git a/app/ui/app/src/lib/onboarding.ts b/app/ui/app/src/lib/onboarding.ts
new file mode 100644
index 000000000..edfd8f032
--- /dev/null
+++ b/app/ui/app/src/lib/onboarding.ts
@@ -0,0 +1,47 @@
+// Keep in sync with store.CurrentOnboardingVersion in app/store/store.go.
+export const CURRENT_ONBOARDING_VERSION = 1;
+
+export type OnboardingAuthMode = "signin" | "signup";
+
+export function onboardingConnectUrl(
+ connectUrl: string,
+ mode: OnboardingAuthMode,
+): string {
+ const url = new URL(connectUrl);
+ url.searchParams.delete("launch");
+ if (mode === "signup") {
+ url.searchParams.set("signup", "true");
+ } else {
+ url.searchParams.delete("signup");
+ }
+ return url.toString();
+}
+
+export const AUTHENTICATION_TIMEOUT_MS = 5 * 60 * 1000;
+
+export type OnboardingStep = "intro" | "welcome" | "run";
+export type OnboardingAction = "continue" | "local";
+export type AuthenticationTimeoutAction = "ignore" | "defer" | "fail";
+
+export function nextOnboardingStep(
+ step: OnboardingStep,
+ action: OnboardingAction,
+ isAuthenticated: boolean,
+): OnboardingStep {
+ if (action === "local") return "run";
+ if (step === "intro") return isAuthenticated ? "run" : "welcome";
+ return step;
+}
+
+export function authenticationTimeoutAction(
+ settled: boolean,
+ checking: boolean,
+): AuthenticationTimeoutAction {
+ if (settled) return "ignore";
+ if (checking) return "defer";
+ return "fail";
+}
+
+export function homeChatId(): "new" {
+ return "new";
+}
diff --git a/app/ui/app/src/routeTree.gen.ts b/app/ui/app/src/routeTree.gen.ts
index e5caa3f63..4c877293f 100644
--- a/app/ui/app/src/routeTree.gen.ts
+++ b/app/ui/app/src/routeTree.gen.ts
@@ -12,6 +12,7 @@
import { Route as rootRoute } from './routes/__root'
import { Route as SettingsImport } from './routes/settings'
+import { Route as OnboardingImport } from './routes/onboarding'
import { Route as IndexImport } from './routes/index'
import { Route as CChatIdImport } from './routes/c.$chatId'
@@ -23,6 +24,12 @@ const SettingsRoute = SettingsImport.update({
getParentRoute: () => rootRoute,
} as any)
+const OnboardingRoute = OnboardingImport.update({
+ id: '/onboarding',
+ path: '/onboarding',
+ getParentRoute: () => rootRoute,
+} as any)
+
const IndexRoute = IndexImport.update({
id: '/',
path: '/',
@@ -46,6 +53,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof IndexImport
parentRoute: typeof rootRoute
}
+ '/onboarding': {
+ id: '/onboarding'
+ path: '/onboarding'
+ fullPath: '/onboarding'
+ preLoaderRoute: typeof OnboardingImport
+ parentRoute: typeof rootRoute
+ }
'/settings': {
id: '/settings'
path: '/settings'
@@ -67,12 +81,14 @@ declare module '@tanstack/react-router' {
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
+ '/onboarding': typeof OnboardingRoute
'/settings': typeof SettingsRoute
'/c/$chatId': typeof CChatIdRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
+ '/onboarding': typeof OnboardingRoute
'/settings': typeof SettingsRoute
'/c/$chatId': typeof CChatIdRoute
}
@@ -80,27 +96,30 @@ export interface FileRoutesByTo {
export interface FileRoutesById {
__root__: typeof rootRoute
'/': typeof IndexRoute
+ '/onboarding': typeof OnboardingRoute
'/settings': typeof SettingsRoute
'/c/$chatId': typeof CChatIdRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '/settings' | '/c/$chatId'
+ fullPaths: '/' | '/onboarding' | '/settings' | '/c/$chatId'
fileRoutesByTo: FileRoutesByTo
- to: '/' | '/settings' | '/c/$chatId'
- id: '__root__' | '/' | '/settings' | '/c/$chatId'
+ to: '/' | '/onboarding' | '/settings' | '/c/$chatId'
+ id: '__root__' | '/' | '/onboarding' | '/settings' | '/c/$chatId'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
+ OnboardingRoute: typeof OnboardingRoute
SettingsRoute: typeof SettingsRoute
CChatIdRoute: typeof CChatIdRoute
}
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
+ OnboardingRoute: OnboardingRoute,
SettingsRoute: SettingsRoute,
CChatIdRoute: CChatIdRoute,
}
@@ -116,6 +135,7 @@ export const routeTree = rootRoute
"filePath": "__root.tsx",
"children": [
"/",
+ "/onboarding",
"/settings",
"/c/$chatId"
]
@@ -123,6 +143,9 @@ export const routeTree = rootRoute
"/": {
"filePath": "index.tsx"
},
+ "/onboarding": {
+ "filePath": "onboarding.tsx"
+ },
"/settings": {
"filePath": "settings.tsx"
},
diff --git a/app/ui/app/src/routes/c.$chatId.tsx b/app/ui/app/src/routes/c.$chatId.tsx
index fa72ac496..fdef4721f 100644
--- a/app/ui/app/src/routes/c.$chatId.tsx
+++ b/app/ui/app/src/routes/c.$chatId.tsx
@@ -1,40 +1,25 @@
-import { createFileRoute } from "@tanstack/react-router";
+import { createFileRoute, redirect } from "@tanstack/react-router";
import { useChat } from "@/hooks/useChats";
import Chat from "@/components/Chat";
import { getChat } from "@/api";
import { SidebarLayout } from "@/components/layout/layout";
import { ChatSidebar } from "@/components/ChatSidebar";
-import LaunchCommands from "@/components/LaunchCommands";
-import { useEffect, useRef } from "react";
+import { useEffect } from "react";
import { useSettings } from "@/hooks/useSettings";
-const launchSidebarRequestedKey = "ollama.launchSidebarRequested";
-const launchSidebarSeenKey = "ollama.launchSidebarSeen";
-const fallbackSessionState = new Map<string, string>();
-
-function getSessionState() {
- if (typeof sessionStorage !== "undefined") {
- return sessionStorage;
- }
-
- return {
- getItem(key: string) {
- return fallbackSessionState.get(key) ?? null;
- },
- setItem(key: string, value: string) {
- fallbackSessionState.set(key, value);
- },
- removeItem(key: string) {
- fallbackSessionState.delete(key);
- },
- };
-}
-
export const Route = createFileRoute("/c/$chatId")({
component: RouteComponent,
+ beforeLoad: ({ params }) => {
+ if (params.chatId === "launch") {
+ throw redirect({
+ to: "/c/$chatId",
+ params: { chatId: "new" },
+ mask: { to: "/" },
+ });
+ }
+ },
loader: async ({ context, params }) => {
- // Skip loading for special non-chat views
- if (params.chatId !== "new" && params.chatId !== "launch") {
+ if (params.chatId !== "new") {
context.queryClient.ensureQueryData({
queryKey: ["chat", params.chatId],
queryFn: () => getChat(params.chatId),
@@ -47,61 +32,19 @@ export const Route = createFileRoute("/c/$chatId")({
function RouteComponent() {
const { chatId } = Route.useParams();
const { settingsData, setSettings } = useSettings();
- const previousChatIdRef = useRef<string | null>(null);
// Always call hooks at the top level - use a flag to skip data when chatId is a special view
const {
data: chatData,
isLoading: chatLoading,
error: chatError,
- } = useChat(chatId === "new" || chatId === "launch" ? "" : chatId);
+ } = useChat(chatId === "new" ? "" : chatId);
useEffect(() => {
if (!settingsData) {
return;
}
- const previousChatId = previousChatIdRef.current;
- previousChatIdRef.current = chatId;
-
- if (chatId === "launch") {
- const sessionState = getSessionState();
- const shouldOpenSidebar =
- previousChatId !== "launch" &&
- (() => {
- if (sessionState.getItem(launchSidebarRequestedKey) === "1") {
- sessionState.removeItem(launchSidebarRequestedKey);
- sessionState.setItem(launchSidebarSeenKey, "1");
- return true;
- }
-
- if (sessionState.getItem(launchSidebarSeenKey) !== "1") {
- sessionState.setItem(launchSidebarSeenKey, "1");
- return true;
- }
-
- return false;
- })();
- const updates: { LastHomeView?: string; SidebarOpen?: boolean } = {};
-
- if (settingsData.LastHomeView !== "launch") {
- updates.LastHomeView = "launch";
- }
-
- if (shouldOpenSidebar && !settingsData.SidebarOpen) {
- updates.SidebarOpen = true;
- }
-
- if (Object.keys(updates).length === 0) {
- return;
- }
-
- setSettings(updates).catch(() => {
- // Best effort persistence for home view preference.
- });
- return;
- }
-
if (settingsData.LastHomeView === "chat") {
return;
}
@@ -120,14 +63,6 @@ function RouteComponent() {
);
}
- if (chatId === "launch") {
- return (
- <SidebarLayout sidebar={<ChatSidebar currentChatId={chatId} />}>
- <LaunchCommands />
- </SidebarLayout>
- );
- }
-
// Handle existing chat case
if (chatLoading) {
return (
diff --git a/app/ui/app/src/routes/index.tsx b/app/ui/app/src/routes/index.tsx
index 9aadf0027..e22f3c25a 100644
--- a/app/ui/app/src/routes/index.tsx
+++ b/app/ui/app/src/routes/index.tsx
@@ -1,5 +1,6 @@
import { createFileRoute, redirect } from "@tanstack/react-router";
import { getSettings } from "@/api";
+import { CURRENT_ONBOARDING_VERSION, homeChatId } from "@/lib/onboarding";
export const Route = createFileRoute("/")({
beforeLoad: async ({ context }) => {
@@ -7,8 +8,11 @@ export const Route = createFileRoute("/")({
queryKey: ["settings"],
queryFn: getSettings,
});
- const chatId =
- settingsData?.settings?.LastHomeView === "chat" ? "new" : "launch";
+ if (settingsData.settings.OnboardingVersion < CURRENT_ONBOARDING_VERSION) {
+ throw redirect({ to: "/onboarding" });
+ }
+
+ const chatId = homeChatId();
throw redirect({
to: "/c/$chatId",
diff --git a/app/ui/app/src/routes/onboarding.tsx b/app/ui/app/src/routes/onboarding.tsx
new file mode 100644
index 000000000..51532e38a
--- /dev/null
+++ b/app/ui/app/src/routes/onboarding.tsx
@@ -0,0 +1,195 @@
+import Onboarding from "@/components/Onboarding";
+import { getSettings } from "@/api";
+import { useSettings } from "@/hooks/useSettings";
+import { useUser } from "@/hooks/useUser";
+import {
+ AUTHENTICATION_TIMEOUT_MS,
+ authenticationTimeoutAction,
+ CURRENT_ONBOARDING_VERSION,
+ homeChatId,
+ onboardingConnectUrl,
+ type OnboardingAuthMode,
+} from "@/lib/onboarding";
+import { createFileRoute, redirect } from "@tanstack/react-router";
+import { useCallback, useEffect, useRef, useState } from "react";
+
+export const Route = createFileRoute("/onboarding")({
+ beforeLoad: async ({ context }) => {
+ // Let developers review onboarding without resetting their local app data.
+ if (
+ import.meta.env.DEV &&
+ new URLSearchParams(window.location.search).get("preview") === "1"
+ ) {
+ return;
+ }
+
+ const settingsData = await context.queryClient.ensureQueryData({
+ queryKey: ["settings"],
+ queryFn: getSettings,
+ });
+
+ if (settingsData.settings.OnboardingVersion >= CURRENT_ONBOARDING_VERSION) {
+ const chatId = homeChatId();
+ throw redirect({
+ to: "/c/$chatId",
+ params: { chatId },
+ mask: { to: "/" },
+ });
+ }
+ },
+ component: OnboardingRoute,
+});
+
+function OnboardingRoute() {
+ const { settingsData, setSettings } = useSettings();
+ const { fetchConnectUrl, refetchUser, isAuthenticated } = useUser();
+ const [isAwaitingAuth, setIsAwaitingAuth] = useState(false);
+ const [showRun, setShowRun] = useState(false);
+ const [signInError, setSignInError] = useState<string | null>(null);
+ const [completionError, setCompletionError] = useState<string | null>(null);
+ const authAttemptRef = useRef(0);
+
+ const completeOnboarding = useCallback(async (): Promise<boolean> => {
+ setCompletionError(null);
+
+ try {
+ if (!settingsData) {
+ throw new Error("Settings are not loaded");
+ }
+
+ await setSettings({
+ OnboardingVersion: CURRENT_ONBOARDING_VERSION,
+ });
+ return true;
+ } catch (error) {
+ console.error("Failed to save onboarding state:", error);
+ setCompletionError("Unable to save setup. Please try again.");
+ return false;
+ }
+ }, [setSettings, settingsData]);
+
+ const showRunScreen = useCallback(() => {
+ setShowRun(true);
+ void completeOnboarding();
+ }, [completeOnboarding]);
+
+ const retryCompletion = useCallback(() => {
+ void completeOnboarding();
+ }, [completeOnboarding]);
+
+ const authenticate = useCallback(
+ async (mode: OnboardingAuthMode) => {
+ setSignInError(null);
+
+ if (isAuthenticated) {
+ showRunScreen();
+ return;
+ }
+
+ const authAttempt = ++authAttemptRef.current;
+ setIsAwaitingAuth(true);
+
+ try {
+ const result = await fetchConnectUrl();
+ if (authAttempt !== authAttemptRef.current) return;
+ if (!result.data) {
+ throw new Error("No sign-in URL was returned");
+ }
+
+ window.open(onboardingConnectUrl(result.data, mode), "_blank");
+ } catch (error) {
+ if (authAttempt !== authAttemptRef.current) return;
+ console.error("Failed to start sign in:", error);
+ setIsAwaitingAuth(false);
+ setSignInError("Unable to start sign in. Please try again.");
+ }
+ },
+ [fetchConnectUrl, isAuthenticated, showRunScreen],
+ );
+
+ const signIn = useCallback(() => authenticate("signin"), [authenticate]);
+ const signUp = useCallback(() => authenticate("signup"), [authenticate]);
+
+ const useLocal = useCallback(() => {
+ authAttemptRef.current += 1;
+ setIsAwaitingAuth(false);
+ setSignInError(null);
+ showRunScreen();
+ }, [showRunScreen]);
+
+ useEffect(() => {
+ if (!isAwaitingAuth) return;
+
+ let checking = false;
+ let settled = false;
+ let timeoutPending = false;
+ const authAttempt = authAttemptRef.current;
+
+ const failConnection = () => {
+ if (settled || authAttempt !== authAttemptRef.current) return;
+ settled = true;
+ setIsAwaitingAuth(false);
+ setSignInError(
+ "Connection is taking longer than expected. Please try again.",
+ );
+ };
+
+ const checkConnection = async () => {
+ if (checking || settled || authAttempt !== authAttemptRef.current) return;
+ checking = true;
+
+ try {
+ const result = await refetchUser();
+ if (
+ !settled &&
+ authAttempt === authAttemptRef.current &&
+ result.data?.name
+ ) {
+ settled = true;
+ setIsAwaitingAuth(false);
+ showRunScreen();
+ window.activateOllama?.();
+ }
+ } catch (error) {
+ console.error("Failed to check sign-in status:", error);
+ } finally {
+ checking = false;
+ if (timeoutPending) failConnection();
+ }
+ };
+
+ void checkConnection();
+ const pollingInterval = window.setInterval(checkConnection, 1000);
+ const timeout = window.setTimeout(() => {
+ const action = authenticationTimeoutAction(settled, checking);
+ if (action === "ignore") return;
+ if (action === "defer") {
+ timeoutPending = true;
+ return;
+ }
+ failConnection();
+ }, AUTHENTICATION_TIMEOUT_MS);
+
+ window.addEventListener("focus", checkConnection);
+ return () => {
+ settled = true;
+ window.clearInterval(pollingInterval);
+ window.clearTimeout(timeout);
+ window.removeEventListener("focus", checkConnection);
+ };
+ }, [isAwaitingAuth, refetchUser, showRunScreen]);
+
+ return (
+ <Onboarding
+ completionError={completionError}
+ isAuthenticated={isAuthenticated}
+ isSigningIn={isAwaitingAuth}
+ signInError={signInError}
+ onSignIn={signIn}
+ onSignUp={signUp}
+ onRetryCompletion={retryCompletion}
+ onUseLocal={useLocal}
+ showRun={showRun}
+ />
+ );
+}
diff --git a/app/ui/app/src/types/webview.d.ts b/app/ui/app/src/types/webview.d.ts
index ca962f77a..03283504a 100644
--- a/app/ui/app/src/types/webview.d.ts
+++ b/app/ui/app/src/types/webview.d.ts
@@ -24,6 +24,8 @@ declare global {
webview?: WebviewAPI;
drag?: () => void;
doubleClick?: () => void;
+ activateOllama?: () => void;
+ setOnboardingWindow?: (enabled: boolean) => void;
menu: (items: MenuItem[]) => Promise<string | null>;
OLLAMA_TOOLS?: boolean;
OLLAMA_WEBSEARCH?: boolean;
diff --git a/app/ui/ui.go b/app/ui/ui.go
index 658d79507..1c07b1d56 100644
--- a/app/ui/ui.go
+++ b/app/ui/ui.go
@@ -1464,11 +1464,21 @@ func (s *Server) settings(w http.ResponseWriter, r *http.Request) error {
return fmt.Errorf("failed to load settings: %w", err)
}
- var settings store.Settings
- if err := json.NewDecoder(r.Body).Decode(&settings); err != nil {
+ var request struct {
+ store.Settings
+ OnboardingVersion *int
+ }
+ if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
return fmt.Errorf("invalid request body: %w", err)
}
+ settings := request.Settings
+ if request.OnboardingVersion == nil {
+ settings.OnboardingVersion = old.OnboardingVersion
+ } else {
+ settings.OnboardingVersion = *request.OnboardingVersion
+ }
+
if err := s.Store.SetSettings(settings); err != nil {
return fmt.Errorf("failed to save settings: %w", err)
}
diff --git a/app/ui/ui_test.go b/app/ui/ui_test.go
index 5658b61eb..674e17cc6 100644
--- a/app/ui/ui_test.go
+++ b/app/ui/ui_test.go
@@ -718,6 +718,55 @@ func TestSettingsToggleAutoUpdateOff_CancelsDownload(t *testing.T) {
}
}
+func TestSettingsPreservesOnboardingVersionWhenOmitted(t *testing.T) {
+ testStore := &store.Store{
+ DBPath: filepath.Join(t.TempDir(), "db.sqlite"),
+ }
+ defer testStore.Close()
+
+ settings, err := testStore.Settings()
+ if err != nil {
+ t.Fatal(err)
+ }
+ settings.OnboardingVersion = 1
+ if err := testStore.SetSettings(settings); err != nil {
+ t.Fatal(err)
+ }
+
+ payload, err := json.Marshal(settings)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var fields map[string]any
+ if err := json.Unmarshal(payload, &fields); err != nil {
+ t.Fatal(err)
+ }
+ delete(fields, "OnboardingVersion")
+ payload, err = json.Marshal(fields)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ server := &Server{
+ Store: testStore,
+ Restart: func() {},
+ }
+ req := httptest.NewRequest("POST", "/api/v1/settings", bytes.NewReader(payload))
+ rr := httptest.NewRecorder()
+
+ if err := server.settings(rr, req); err != nil {
+ t.Fatalf("settings() error = %v", err)
+ }
+
+ saved, err := testStore.Settings()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if saved.OnboardingVersion != 1 {
+ t.Fatalf("OnboardingVersion = %d, want 1", saved.OnboardingVersion)
+ }
+}
+
func TestSettingsToggleAutoUpdateOn_WithPendingUpdate_ShowsNotification(t *testing.T) {
testStore := &store.Store{
DBPath: filepath.Join(t.TempDir(), "db.sqlite"),
diff --git a/app/wintray/eventloop.go b/app/wintray/eventloop.go
index dda433e28..b641723a2 100644
--- a/app/wintray/eventloop.go
+++ b/app/wintray/eventloop.go
@@ -80,7 +80,7 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui
t.app.DoUpdate()
case openUIMenuID:
// UI must be initialized on this thread so don't use the callbacks
- t.app.UIShow()
+ t.app.UIRun("/")
case settingsUIMenuID:
// UI must be initialized on this thread so don't use the callbacks
t.app.UIRun("/settings")
@@ -174,14 +174,7 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui
}
}
case uint32(FOCUS_WINDOW_MSG_ID):
- // Handle focus window request from another instance
- if t.app.UIRunning() {
- // If UI is already running, just show it
- t.app.UIShow()
- } else {
- // If UI is not running, start it
- t.app.UIRun("/")
- }
+ focusUI(t.app)
lResult = 1 // Return non-zero to indicate success
default:
// Calls the default window procedure to provide default processing for any window messages that an application does not process.
@@ -197,6 +190,14 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui
return
}
+func focusUI(app AppCallbacks) {
+ if app.UIRunning() {
+ app.UIShow()
+ return
+ }
+ app.UIRun("/")
+}
+
func (t *winTray) Quit() {
// slog.Debug("XXX in winTray.Quit")
t.quitting = true
diff --git a/app/wintray/eventloop_test.go b/app/wintray/eventloop_test.go
new file mode 100644
index 000000000..365f1b995
--- /dev/null
+++ b/app/wintray/eventloop_test.go
@@ -0,0 +1,43 @@
+//go:build windows
+
+package wintray
+
+import "testing"
+
+type lifecycleApp struct {
+ running bool
+ runPath string
+ showCall bool
+}
+
+func (a *lifecycleApp) UIRun(path string) { a.runPath = path }
+func (a *lifecycleApp) UIShow() { a.showCall = true }
+func (a *lifecycleApp) UITerminate() {}
+func (a *lifecycleApp) UIRunning() bool { return a.running }
+func (a *lifecycleApp) Quit() {}
+func (a *lifecycleApp) DoUpdate() {}
+
+func TestFocusUICreatesOrShowsWindow(t *testing.T) {
+ tests := []struct {
+ name string
+ running bool
+ wantRun string
+ wantShow bool
+ }{
+ {name: "creates window when tray only", wantRun: "/"},
+ {name: "shows existing window", running: true, wantShow: true},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ app := &lifecycleApp{running: tt.running}
+ focusUI(app)
+ if app.runPath != tt.wantRun {
+ t.Errorf("run path = %q, want %q", app.runPath, tt.wantRun)
+ }
+ if app.showCall != tt.wantShow {
+ t.Errorf("show called = %v, want %v", app.showCall, tt.wantShow)
+ }
+ })
+ }
+}
diff --git a/app/wintray/menus.go b/app/wintray/menus.go
index 106953b7a..0e6ab53cc 100644
--- a/app/wintray/menus.go
+++ b/app/wintray/menus.go
@@ -28,10 +28,10 @@ const (
)
func (t *winTray) initMenus() error {
- if err := t.addOrUpdateMenuItem(openUIMenuID, 0, openUIMenuTitle, false); err != nil {
+ if err := t.addOrUpdateMenuItem(settingsUIMenuID, 0, settingsUIMenuTitle, false); err != nil {
return fmt.Errorf("unable to create menu entries %w", err)
}
- if err := t.addOrUpdateMenuItem(settingsUIMenuID, 0, settingsUIMenuTitle, false); err != nil {
+ if err := t.addOrUpdateMenuItem(openUIMenuID, 0, openUIMenuTitle, false); err != nil {
return fmt.Errorf("unable to create menu entries %w", err)
}
if err := t.addOrUpdateMenuItem(diagLogsMenuID, 0, diagLogsMenuTitle, false); err != nil {
diff --git a/app/wintray/messages.go b/app/wintray/messages.go
index 12f6af06a..59afa1c39 100644
--- a/app/wintray/messages.go
+++ b/app/wintray/messages.go
@@ -12,6 +12,6 @@ const (
updateAvailableMenuTitle = "An update is available"
updateMenuTitle = "Restart to update"
diagLogsMenuTitle = "View logs"
- openUIMenuTitle = "Open Ollama"
+ openUIMenuTitle = "Open Ollama Chat"
settingsUIMenuTitle = "Settings..."
)