From 6e7177f27b4615a1384916c7f2a4f85f7812322a Mon Sep 17 00:00:00 2001 From: Jeffrey Smith Date: Fri, 27 Mar 2026 13:53:30 +0000 Subject: [PATCH] Fix default surface resolution for type:full packages resolveDefaultSurface was using ListEnabledByType("surface") which missed extension packages with type "full". Switch to List() and filter by source != core/builtin + type surface/full. Also make welcome surface smarter: detect when extensions exist but no default is set vs truly empty install, show appropriate messaging and CTA (Set Default Surface vs Go to Packages). Co-Authored-By: Claude Opus 4.6 (1M context) --- server/pages/pages_surfaces.go | 13 ++++--- src/js/sw/surfaces/welcome/index.js | 56 ++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/server/pages/pages_surfaces.go b/server/pages/pages_surfaces.go index 68f8655..a3e7088 100644 --- a/server/pages/pages_surfaces.go +++ b/server/pages/pages_surfaces.go @@ -129,14 +129,17 @@ func (e *Engine) resolveDefaultSurface(ctx context.Context, userID string) strin } } - // 3. First enabled extension surface - surfaces, err := e.stores.Packages.ListEnabledByType(ctx, "surface") + // 3. First enabled extension surface (type "surface" or "full") + allPkgs, err := e.stores.Packages.List(ctx) if err == nil { - for _, s := range surfaces { - if s.Source == "core" { + for _, s := range allPkgs { + if s.Source == "core" || s.Source == "builtin" { continue } - if s.Enabled { + if !s.Enabled { + continue + } + if s.Type == "surface" || s.Type == "full" { return "/s/" + s.ID } } diff --git a/src/js/sw/surfaces/welcome/index.js b/src/js/sw/surfaces/welcome/index.js index 0767e2e..be9fa7d 100644 --- a/src/js/sw/surfaces/welcome/index.js +++ b/src/js/sw/surfaces/welcome/index.js @@ -1,8 +1,10 @@ /** - * WelcomeSurface — shown when no extension surfaces are installed. - * Renders Topbar + a getting-started card with link to admin. + * WelcomeSurface — fallback landing page. + * Shown when no default surface is configured or no extensions are installed. + * Checks for available extension surfaces and adjusts messaging. */ const { html } = window; +const { useState, useEffect } = hooks; const { render } = preact; import { Topbar } from '../../shell/topbar.js'; @@ -10,27 +12,49 @@ import { Topbar } from '../../shell/topbar.js'; function WelcomeSurface() { const BASE = window.__BASE__ || ''; const isAdmin = sw.can?.('surface.admin.access'); + const [surfaces, setSurfaces] = useState([]); + + useEffect(() => { + sw.api.get('/api/v1/surfaces').then(list => { + setSurfaces((list || []).filter(s => s.source !== 'core')); + }).catch(() => {}); + }, []); + + const hasSurfaces = surfaces.length > 0; return html` <${Topbar} title="Switchboard" />
-
📦
+
${hasSurfaces ? '🏠' : '📦'}

Welcome to Switchboard

-

- No surfaces are installed yet. Install an extension surface - to get started. -

- ${isAdmin && html` - - Go to Packages - - `} - ${!isAdmin && html` -

- Ask your administrator to install a surface package. + ${hasSurfaces ? html` +

+ No default surface is configured. Choose a surface from + the menu, or ${isAdmin ? 'set a default in admin settings.' : 'ask your administrator to set a default.'}

+ ${isAdmin && html` + + Set Default Surface + + `} + ` : html` +

+ No surfaces are installed yet. Install an extension surface + to get started. +

+ ${isAdmin && html` + + Go to Packages + + `} + ${!isAdmin && html` +

+ Ask your administrator to install a surface package. +

+ `} `}