Screens get their results after you look away, and keys do what they say

- Only some background results were routed to their own screen when
  another one was showing; the rest were dropped by whatever screen was
  up. Leaving Mirrors, Review, the Server step's source test, Fine-tune's
  defaults or Updates mid-check left it spinning for good. Leaving
  Users after "new password" lost the password, shown only once, after
  the server had already changed it, and kept every user action blocked.
  An import finished in the background never switched to the server.
  mirrorsMsg, checksPartMsg, checksMsg, userOpMsg, defaultsMsg,
  changesMsg, importReadMsg, importSavedMsg and servicesMsg now name
  their screen like the others.
- pgup went back from every screen, so the deploy log, the logs view
  and Fine-tune's lists never got to scroll with it. Past the wizard it
  now goes to the screen, as pgdown does; ctrl+p still goes back.
- Components bound ctrl+k to "up", but ctrl+k opens Go-to everywhere
  first. The binding is gone, and the cursor can't go to -1 when a
  search matches nothing.
- Forgetting a server showed no error when it failed: enter() cleared
  it straight after.
- "The database shell ended: exit status 1" was shown in green.
- Unused gradientLines and cPanel removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NarratorandClaude Opus 5.5 committed 2026-10-29 19:31:39 +01:00
1 parent c8ab8fddd3
commit 895e5e63d4
14 files changed
+70 -16

No files matched your search

+8
View File
@@ -209,6 +209,9 @@ func (a *App) update(msg tea.Msg) (tea.Model, tea.Cmd) {
case noteMsg:
a.status = sGood.Render(string(m))
return a, nil
case failNoteMsg:
a.status = sBad.Render(string(m))
return a, nil
case autoBackMsg:
if _, ok := a.cur().(*deployScreen); ok {
a.status = sGood.Render("✓ " + m.text)
@@ -275,6 +278,11 @@ func (a *App) update(msg tea.Msg) (tea.Model, tea.Cmd) {
return a, a.go_(1)
}
case "ctrl+p", "pgup":
// Past the wizard, pgup scrolls the screen (the deploy log,
// Fine-tune's lists), as pgdown does; ctrl+p still goes back.
if m.String() == "pgup" && a.step > a.index("Review") {
break
}
if !(deploying && ds.running) {
return a, a.back()
}
+4
View File
@@ -27,6 +27,8 @@ type importReadMsg struct {
err error
}
func (importReadMsg) owner() string { return "Servers" }
type importSavedMsg struct {
name string
cfg *config.Config
@@ -34,6 +36,8 @@ type importSavedMsg struct {
err error
}
func (importSavedMsg) owner() string { return "Servers" }
type importState struct {
form *form
im *config.Import // read, waiting for enter
+1 -1
View File
@@ -246,7 +246,7 @@ func (s *maintenanceScreen) keepDays() (int, error) {
func databaseShell(c *config.Config) tea.Cmd {
return tea.ExecProcess(deploy.DatabaseShell(c), func(err error) tea.Msg {
if err != nil {
return noteMsg("The database shell ended: " + err.Error())
return failNoteMsg("The database shell ended: " + err.Error())
}
return nil
})
+2
View File
@@ -52,6 +52,8 @@ type mirrorsMsg struct {
res mirrorsResult
}
func (mirrorsMsg) owner() string { return "Mirrors" }
type mirrorsScreen struct {
cfg *config.Config
server string
+3
View File
@@ -32,6 +32,9 @@ type homeserverScreen struct {
// noteMsg puts a line on the status bar.
type noteMsg string
// failNoteMsg puts a line on the status bar that says something failed.
type failNoteMsg string
func (s *homeserverScreen) name() string { return "Homeserver" }
func (s *homeserverScreen) title() string {
if s.saver != nil {
+26
View File
@@ -21,6 +21,32 @@ func TestResultReachesItsScreen(t *testing.T) {
}
}
// The same for the other screens that wait on the server: a user's new
// password, shown only once, isn't lost by looking elsewhere meanwhile.
func TestMoreResultsReachTheirScreens(t *testing.T) {
a := demoApp(t, 120, 36)
openUsers(a)
us := a.cur().(*usersScreen)
us.busy = true
openDashboard(a)
if a.cur() == us {
t.Fatal("still on Users")
}
a.Update(userOpMsg{op: &userOp{user: "@bob:example.org"}, info: "new password", password: "s3cret"})
if us.busy || us.password != "s3cret" {
t.Errorf("users missed its answer: busy %v, password %q", us.busy, us.password)
}
ms := a.screens[a.index("Mirrors")].(*mirrorsScreen)
ms.loading = [3]bool{true, true, true}
for part := range ms.loading {
a.Update(mirrorsMsg{server: ms.server, part: part})
}
if ms.loading != [3]bool{} {
t.Errorf("mirrors still loading: %v", ms.loading)
}
}
func TestDashboardRefreshesItself(t *testing.T) {
a := demoApp(t, 120, 36)
openDashboard(a)
+4 -4
View File
@@ -123,14 +123,14 @@ func (s *componentsScreen) update(msg tea.Msg) tea.Cmd {
}
items := s.items()
switch k.String() {
case "up", "ctrl+k":
case "up": // not ctrl+k: that's Go-to, everywhere
s.cursor = max(0, s.cursor-1)
return nil
case "down", "ctrl+j":
s.cursor = min(len(items)-1, s.cursor+1)
s.cursor = max(0, min(len(items)-1, s.cursor+1))
return nil
case " ", "ctrl+@":
if s.cursor < len(items) {
if s.cursor >= 0 && s.cursor < len(items) {
it := items[s.cursor]
if s.toggles(it) {
s.selected[it.ID] = !s.selected[it.ID]
@@ -169,7 +169,7 @@ func (s *componentsScreen) update(msg tea.Msg) tea.Cmd {
case "k":
s.cursor = max(0, s.cursor-1)
case "j":
s.cursor = min(len(items)-1, s.cursor+1)
s.cursor = max(0, min(len(items)-1, s.cursor+1))
case "p":
s.leave(s.cfg)
p, ok := currentPreset(s.cfg)
+2
View File
@@ -32,6 +32,8 @@ type checksPartMsg struct {
ch chan checksPartMsg
}
func (checksPartMsg) owner() string { return "Review" }
func waitChecks(ch chan checksPartMsg) tea.Cmd {
return func() tea.Msg {
m, ok := <-ch
+2
View File
@@ -31,6 +31,8 @@ type servicesMsg struct {
err error
}
func (servicesMsg) owner() string { return "Manage" }
type manageMode int
const (
+2
View File
@@ -143,6 +143,8 @@ func (s *welcomeScreen) view(w, h int) string {
type checksMsg []deploy.Check
func (checksMsg) owner() string { return "Server" }
type serverScreen struct {
cfg *config.Config
form *form
+6 -2
View File
@@ -102,6 +102,8 @@ type changesMsg struct {
err error
}
func (changesMsg) owner() string { return "Updates" }
type updatesScreen struct {
cfg *config.Config
loading bool
@@ -604,10 +606,12 @@ func (s *serversScreen) update(msg tea.Msg) tea.Cmd {
}
if s.confirm {
if confirmKey(k.String(), &s.cursor, &s.confirm, len(s.list)) || k.String() == "x" {
if err := config.RemoveProfile(s.list[s.cursor].Name); err != nil {
err := config.RemoveProfile(s.list[s.cursor].Name)
cmd := s.enter(s.cfg) // clears s.err
if err != nil {
s.err = err.Error()
}
return s.enter(s.cfg)
return cmd
}
return nil
}
+2
View File
@@ -31,6 +31,8 @@ type defaultsMsg struct {
err error
}
func (defaultsMsg) owner() string { return "Tuning" }
// tuneRole is a role as the screen lists it.
type tuneRole struct {
config.Role
+6 -9
View File
@@ -98,9 +98,8 @@ var themes = []theme{
}
var (
themeName string
cPurple, cMint, cPink, cAmber, cRed, cText, cMuted, cFaint, cPanel ac
cOnAccent ac
themeName string
cPurple, cMint, cPink, cAmber, cRed, cText, cMuted, cFaint, cOnAccent ac
sTitle, sSub, sMuted, sFaint, sAccent, sGood, sWarn, sBad, sPink, sKey, sSection lipgloss.Style
sPanel, sPanelFocus, sBadge lipgloss.Style
@@ -111,7 +110,7 @@ func init() { applyTheme(themes[0]) }
func applyTheme(t theme) {
themeName = t.name
cPurple, cMint, cPink, cAmber, cRed = t.accent, t.good, t.pink, t.amber, t.red
cText, cMuted, cFaint, cPanel, cOnAccent = t.text, t.muted, t.faint, t.panel, t.onAccent
cText, cMuted, cFaint, cOnAccent = t.text, t.muted, t.faint, t.onAccent
sTitle = lipgloss.NewStyle().Foreground(cText).Bold(true)
sSub = lipgloss.NewStyle().Foreground(cMuted)
@@ -235,11 +234,9 @@ func gradient(s string) string {
return b.String()
}
// gradientLines colours a multi-line block column-wise so each line shares the ramp.
func gradientLines(block string) string { return gradientLinesAt(block, 0) }
// gradientLinesAt is gradientLines with the ramp moved along by shift: it
// runs there and back, so any shift is a smooth step from the last.
// gradientLinesAt colours a multi-line block column-wise so each line
// shares the ramp, moved along by shift: it runs there and back, so any
// shift is a smooth step from the last.
func gradientLinesAt(block string, shift float64) string {
stops := gradientStops()
lines := strings.Split(block, "\n")
+2
View File
@@ -43,6 +43,8 @@ type userOpMsg struct {
err error
}
func (userOpMsg) owner() string { return "Users" }
type userMode int
const (