R rebuilds every pane detached; r refreshes data; Author gains guidance and preview; Repair gains the rebuild log
This commit is contained in:
@@ -55,7 +55,7 @@ type repairModel struct {
|
||||
width, height int
|
||||
}
|
||||
|
||||
var repairTabs = []string{"health", "layout"}
|
||||
var repairTabs = []string{"health", "layout", "rebuild log"}
|
||||
|
||||
func newRepairModel(c *paperclip.Client, folder string) repairModel {
|
||||
return repairModel{client: c, folder: folder}
|
||||
@@ -201,7 +201,17 @@ func (m repairModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, tea.Quit
|
||||
case "r":
|
||||
return m, m.load()
|
||||
case "[", "h", "]", "l", "tab":
|
||||
case "R":
|
||||
if err := startRebuild(m.folder); err != nil {
|
||||
m.err = err
|
||||
return m, nil
|
||||
}
|
||||
return m, tea.Quit
|
||||
case "[", "h":
|
||||
m.tab = (m.tab + len(repairTabs) - 1) % len(repairTabs)
|
||||
m.scroll = 0
|
||||
return m, nil
|
||||
case "]", "l", "tab":
|
||||
m.tab = (m.tab + 1) % len(repairTabs)
|
||||
m.scroll = 0
|
||||
return m, nil
|
||||
@@ -241,8 +251,11 @@ func (m repairModel) View() string {
|
||||
}
|
||||
|
||||
body := m.healthLines()
|
||||
if m.tab == 1 {
|
||||
switch m.tab {
|
||||
case 1:
|
||||
body = m.layoutLines()
|
||||
case 2:
|
||||
body = m.logLines()
|
||||
}
|
||||
|
||||
p := panel{title: "checks", width: m.width, height: m.height - 2, tabs: repairTabs, active: m.tab, focused: true}
|
||||
@@ -259,6 +272,7 @@ func (m repairModel) View() string {
|
||||
|
||||
footer := hintLine([]string{
|
||||
keyHint("[ ]", "switch tab"),
|
||||
keyHint("R", "rebuild every pane"),
|
||||
keyHint("↑↓ or j k", "scroll"),
|
||||
keyHint("r", "check again"),
|
||||
keyHint("q", "leave"),
|
||||
@@ -303,6 +317,18 @@ func (m repairModel) healthLines() []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// logLines shows what the last rebuild did. It is read from the log the rebuild
|
||||
// writes, so the record of a repair survives the panes it replaced.
|
||||
func (m repairModel) logLines() []string {
|
||||
out := []string{"", dimStyle().Render(" " + rebuildLogPath()), ""}
|
||||
for _, ln := range rebuildLogTail(m.height - 6) {
|
||||
out = append(out, " "+lipgloss.NewStyle().Foreground(lipgloss.Color(active.Text)).Render(ln))
|
||||
}
|
||||
out = append(out, "")
|
||||
out = append(out, dimStyle().Render(" press R on any screen to rebuild every pane"))
|
||||
return out
|
||||
}
|
||||
|
||||
func (m repairModel) layoutLines() []string {
|
||||
out := []string{""}
|
||||
out = append(out, dimStyle().Render(fmt.Sprintf(" %-9s %-14s %s", "workspace", "name", "panes")))
|
||||
|
||||
Reference in New Issue
Block a user