main.go: remove ~300 lines of stale routes referencing deleted handlers (channels, messages, folders, personas, notes, projects, memories, models, providers, tasks, roles, usage, routing, capabilities, etc.) Fix branding: "Chat Switchboard" → "Switchboard Core" pages: remove chat/notes/projects surface manifests and templates Keep: admin, settings, team-admin, workflow, workflow-landing frontend: delete chat/, notes/, projects/ surface directories (19 files) Delete 5 CSS files (4,144 lines): sw-chat-*, sw-notes-*, sw-projects-* SDK: strip gutted API domains (594→287 lines), remove chatPane/notesPane tests: remove integration_test.go (5,194 lines, broken imports to deleted packages) and perm_enforcement_test.go (551 lines, depended on deleted test helpers). Fix testmain_test.go (remove providers import). openapi.yaml: replace 12,491-line stale spec with kernel auth stub. Full ICD rebuild is Step 8 proper. Auth (builtin, mTLS, OIDC) untouched throughout. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
99 lines
3.0 KiB
Go
99 lines
3.0 KiB
Go
package pages
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// SeedSurfaces writes core surface manifests to the registry table.
|
|
// Called once at startup. Does NOT overwrite the enabled flag — admin
|
|
// toggles survive restarts.
|
|
func (e *Engine) SeedSurfaces() {
|
|
if e.stores.Packages == nil {
|
|
log.Printf("[pages] Surface registry not available — skipping seed")
|
|
return
|
|
}
|
|
ctx := context.Background()
|
|
for _, s := range e.surfaces {
|
|
manifest := map[string]any{
|
|
"route": s.Route,
|
|
"alt_routes": s.AltRoutes,
|
|
"template": s.Template,
|
|
"components": s.Components,
|
|
"data_requires": s.DataRequires,
|
|
"auth": s.Auth,
|
|
"layout": s.Layout,
|
|
}
|
|
if err := e.stores.Packages.Seed(ctx, s.ID, s.Title, s.Source, manifest); err != nil {
|
|
log.Printf("[pages] Failed to seed surface %q: %v", s.ID, err)
|
|
}
|
|
}
|
|
log.Printf("[pages] Seeded %d core surfaces into registry", len(e.surfaces))
|
|
|
|
// v0.31.0: Clean up old "editor" core surface row.
|
|
// Editor is now an installable package — the old seed row would show a
|
|
// broken nav link until the package .pkg is uploaded via admin UI.
|
|
if sr, err := e.stores.Packages.Get(ctx, "editor"); err == nil && sr != nil && sr.Source == "extension" {
|
|
if sr.Type == "" || sr.Type == "surface" {
|
|
if delErr := e.stores.Packages.Delete(ctx, "editor"); delErr != nil {
|
|
log.Printf("[pages] Failed to clean up old editor surface: %v", delErr)
|
|
} else {
|
|
log.Printf("[pages] Cleaned up old editor core surface — install editor .pkg via admin UI")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// IsSurfaceEnabled checks if a surface is enabled in the registry.
|
|
// Chat and Admin are always enabled (system-critical).
|
|
// Returns true if the surface is not found (fail-open for backward compat).
|
|
func (e *Engine) IsSurfaceEnabled(surfaceID string) bool {
|
|
// Chat and Admin cannot be disabled — they're system-critical
|
|
if surfaceID == "chat" || surfaceID == "admin" {
|
|
return true
|
|
}
|
|
if e.stores.Packages == nil {
|
|
return true // No registry = all surfaces enabled (backward compat)
|
|
}
|
|
ctx := context.Background()
|
|
sr, err := e.stores.Packages.Get(ctx, surfaceID)
|
|
if err != nil || sr == nil {
|
|
return true // Not in registry = assume enabled (backward compat)
|
|
}
|
|
return sr.Enabled
|
|
}
|
|
|
|
// EnabledSurfaceIDs returns a list of enabled surface IDs for nav rendering.
|
|
func (e *Engine) EnabledSurfaceIDs() []string {
|
|
if e.stores.Packages == nil {
|
|
// No registry — return all core surface IDs
|
|
var all []string
|
|
for _, s := range e.surfaces {
|
|
all = append(all, s.ID)
|
|
}
|
|
return all
|
|
}
|
|
ctx := context.Background()
|
|
ids, err := e.stores.Packages.ListEnabled(ctx)
|
|
if err != nil {
|
|
log.Printf("[pages] Failed to load enabled surfaces: %v", err)
|
|
// Fallback: return all core surface IDs
|
|
var all []string
|
|
for _, s := range e.surfaces {
|
|
all = append(all, s.ID)
|
|
}
|
|
return all
|
|
}
|
|
return ids
|
|
}
|
|
|
|
// disabledRedirect returns a handler that redirects to the root.
|
|
func (e *Engine) disabledRedirect() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
c.Redirect(http.StatusTemporaryRedirect, e.cfg.BasePath+"/")
|
|
}
|
|
}
|