The console manages people, keys, organizations and the mirror, and scrolls a tall sidebar

Accounts, API keys and Organizations views read the store and change it by
running the users, keys and org commands in-process, so their checks and
messages are the ones shown. A Mirror view lists what the mirror holds and
which models use it, downloads into it and removes from it. Models gain
adding from a definition file.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-03 23:30:24 +02:00
1 parent c7d5ee16b5
commit eb7dac8a67
6 files changed
+949 -8

No files matched your search

+66 -4
View File
@@ -36,7 +36,11 @@ const (
cReplicas
cUsage
cQuotas
cMirror
cLogs
cAccounts
cKeys
cOrgs
cSettings
cAddNode
cReplicate
@@ -48,7 +52,7 @@ const (
cCount
)
var consoleLabels = [cCount]string{"Overview", "Nodes", "GPUs", "Models", "Replicas", "Usage", "Quotas", "Logs",
var consoleLabels = [cCount]string{"Overview", "Nodes", "GPUs", "Models", "Replicas", "Usage", "Quotas", "Mirror", "Logs", "Accounts", "API keys", "Organizations",
"server.yaml", "Add a node", "Replicate the store", "Serve a model", "Upgrade the cluster",
"Restart all replicas", "Back up now", "Leave"}
@@ -143,12 +147,17 @@ type consoleModel struct {
quotas []adminapi.QuotaView
quotasErr error
st *storeHolder
people peopleData
mirror consoleMirrorMsg
}
var usageGroupings = []string{"team", "project", "org"}
func newConsoleModel(addr, file string) consoleModel {
m := consoleModel{client: newCtlClient(addr), spin: newSpinner(), width: 100, height: 30, file: file}
m := consoleModel{client: newCtlClient(addr), spin: newSpinner(), width: 100, height: 30, file: file,
st: &storeHolder{file: file}}
m.node = strings.HasSuffix(file, "agent.yaml")
if m.node {
m.menu = cSettings
@@ -254,6 +263,12 @@ func (m consoleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.menu == cQuotas {
cmds = append(cmds, m.fetchQuotas())
}
if m.menu == cMirror {
cmds = append(cmds, m.fetchMirror())
}
if m.peopleView() {
cmds = append(cmds, m.fetchPeople())
}
if m.menu == cLogs && m.detail && m.logs.node != "" {
cmds = append(cmds, m.fetchLogs(m.logs.node))
}
@@ -269,6 +284,10 @@ func (m consoleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.usage, m.usageErr = msg.rows, msg.err
case consoleLogsMsg:
m.logs = msg
case consoleMirrorMsg:
m.mirror = msg
case consolePeopleMsg:
m.people = peopleData(msg)
case consoleQuotasMsg:
m.quotas, m.quotasErr = msg.rows, msg.err
case actionDoneMsg:
@@ -387,10 +406,29 @@ func (m consoleModel) key(k tea.KeyMsg) (tea.Model, tea.Cmd) {
m.menuD = m.replicaMenu(m.data.replicas[m.row])
case cQuotas:
m.menuD = m.quotaMenu(m.quotas[m.row])
case cMirror:
m.menuD = m.mirrorMenu(m.mirror.res.Models[m.row])
case cAccounts:
m.menuD = m.userMenu(m.people.users[m.row])
case cKeys:
m.menuD = m.keyMenu(m.people.keys[m.row])
case cOrgs:
m.menuD = m.orgMenu(m.people.orgs[m.row])
}
case "a":
if m.menu == cQuotas {
switch m.menu {
case cQuotas:
m.quotaForm(adminapi.QuotaView{})
case cModels:
m.addModelForm()
case cMirror:
m.mirrorFetchForm()
case cAccounts:
m.createUserForm()
case cKeys:
m.createKeyForm()
case cOrgs:
m.createOrgForm()
}
case "right", "l":
if m.menu == cUsage {
@@ -416,10 +454,19 @@ func (m consoleModel) onEnter() tea.Cmd {
return m.fetchUsage()
case cQuotas:
return m.fetchQuotas()
case cMirror:
return m.fetchMirror()
case cAccounts, cKeys, cOrgs:
// The quotas too, for an organization's quota form.
return tea.Batch(m.fetchPeople(), m.fetchQuotas())
}
return nil
}
func (m consoleModel) peopleView() bool {
return m.menu == cAccounts || m.menu == cKeys || m.menu == cOrgs
}
func (m consoleModel) leave() (tea.Model, tea.Cmd) {
if m.doc != nil && m.doc.Changed > 0 {
m.dialog, m.dialogTitle = "confirm-leave", "Unsaved changes"
@@ -717,6 +764,14 @@ func (m consoleModel) rowCount() int {
return len(m.usage)
case cQuotas:
return len(m.quotas)
case cMirror:
return len(m.mirror.res.Models)
case cAccounts:
return len(m.people.users)
case cKeys:
return len(m.people.keys)
case cOrgs:
return len(m.people.orgs)
}
return 0
}
@@ -732,6 +787,8 @@ func (m consoleModel) View() string {
continue
}
switch i {
case cAccounts:
nav = append(nav, navItem{Label: "", Heading: true}, navItem{Label: "People", Heading: true})
case cSettings:
nav = append(nav, navItem{Label: "", Heading: true}, navItem{Label: "Settings", Heading: true})
case cAddNode, cLeave:
@@ -871,7 +928,7 @@ func (m consoleModel) panel() (title, body, keys string) {
strings.Join(md.Profiles, ","), warn})
}
if m.inPanel {
keys = rowKeys
keys = "↑↓ row · Enter actions · A add from a file · ← back · Q leave"
}
return "Models", "\n" + table([]string{"MODEL", "READY", "STATUS", "CLASS", "PROFILES", ""}, rows, m.row, pw, m.inPanel), keys
case cReplicas:
@@ -905,6 +962,10 @@ func (m consoleModel) panel() (title, body, keys string) {
return "Usage", head + table([]string{"WHO", "REQUESTS", "TOKENS", "ERRORS", "SPENT"}, rows, m.row, pw, m.inPanel), keys
case cQuotas:
return m.quotasPanel(pw)
case cAccounts, cKeys, cOrgs:
return m.peoplePanel(pw)
case cMirror:
return m.mirrorPanel(pw)
case cSettings:
return m.settingsPanel(pw)
}
@@ -1174,6 +1235,7 @@ func runConsole(ctx context.Context, out io.Writer, file string) error {
return err
}
fm := final.(consoleModel)
fm.st.close()
menu = fm.menu
act := fm.action
switch act.kind {