package main
import (
_ "embed"
"html/template"
"log"
"net/http"
"time"
"github.com/kami/maven/internal/ipc"
"github.com/kami/maven/internal/webauthn"
)
// shellHTML — the shell partial every page is wrapped in: "shellTop", the
// "sidebar" it calls, and "shellBottom". It used to be two Go string constants
// with the sidebar assembled by a strings.Builder, which is the one piece of
// markup that was still concatenated in Go.
//
// Two template pieces wrap every page:
//
// {{template "shellTop" ""}} ← opens , topbar, sidebar, content
// {{template "shellBottom"}} ← closes content, inspector,
//
// The page-key argument highlights the active sidebar link and sets breadcrumbs.
//
//go:embed shell.html
var shellHTML string
// sidebarSections maps sidebar section → page entries {label, url, icon}
var sidebarSections = []struct {
Label string
Pages []struct{ Label, URL, Key string }
}{
{
Label: "Workspace",
Pages: []struct{ Label, URL, Key string }{
{Label: "Dashboard", URL: "/dash", Key: "dash"},
},
},
{
Label: "Infrastructure",
Pages: []struct{ Label, URL, Key string }{
{Label: "History", URL: "/history", Key: "history"},
},
},
{
Label: "Automation",
Pages: []struct{ Label, URL, Key string }{
{Label: "Rule Trace", URL: "/trace", Key: "trace"},
{Label: "Notifications", URL: "/notifications", Key: "notifications"},
{Label: "Tasks", URL: "/tasks", Key: "tasks"},
{Label: "Reminders", URL: "/reminders", Key: "reminders"},
{Label: "Routines", URL: "/routines", Key: "routines"},
{Label: "Morning", URL: "/morning", Key: "morning"},
{Label: "Intake", URL: "/events", Key: "events"},
},
},
{
Label: "Ecosystem",
Pages: []struct{ Label, URL, Key string }{
{Label: "Siblings", URL: "/ecosystem", Key: "ecosystem"},
},
},
{
Label: "AI",
Pages: []struct{ Label, URL, Key string }{
{Label: "Chat", URL: "/chat", Key: "chat"},
{Label: "Voice", URL: "/", Key: "voice"},
},
},
{
Label: "Settings",
Pages: []struct{ Label, URL, Key string }{
{Label: "Tools", URL: "/tools", Key: "tools"},
{Label: "Model", URL: "/models", Key: "models"},
{Label: "Passkey", URL: "/auth/passkey", Key: "passkey"},
},
},
}
// pageChrome is the per-page title and ethos-icons.svg symbol id, keyed by the
// page key a page hands to shellTop. One table rather than two parallel
// switches, so a new page cannot end up with a title and no icon.
var pageChrome = map[string]struct{ Title, Icon string }{
"dash": {"Dashboard", "i-grid"},
"history": {"History", "i-clock"},
"trace": {"Rule Trace", "i-wave"},
"notifications": {"Notifications", "i-bell"},
"tasks": {"Tasks", "i-grid"},
"reminders": {"Reminders", "i-calendar"},
"routines": {"Routines", "i-repeat"},
"morning": {"Morning Routines", "i-calendar"},
"events": {"Intake", "i-download"},
"chat": {"Chat", "i-message"},
"voice": {"Voice", "i-mic"},
"ecosystem": {"Ecosystem", "i-grid"},
"tools": {"Tools", "i-settings"},
"models": {"Resident Model", "i-wave"},
"passkey": {"Passkey", "i-lock"},
}
// pageIcon returns the ethos-icons.svg symbol id for the given page. The
// sidebar template wraps it in the