Work>work: selectable runs, log pre-chosen, merge tab no longer shows another task's merge
This commit is contained in:
40
tui/work.go
40
tui/work.go
@@ -373,6 +373,13 @@ func (m workModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
|
||||
case workMsg:
|
||||
if msg.task.ID != "" && msg.task.ID != m.task.ID {
|
||||
m.runAt = 0
|
||||
m.logRunID, m.logText = "", ""
|
||||
if len(msg.runs) > 0 {
|
||||
m.logRunID = msg.runs[0].ID
|
||||
}
|
||||
}
|
||||
m.task = msg.task
|
||||
if msg.tasks != nil {
|
||||
m.taskList = msg.tasks
|
||||
@@ -540,7 +547,7 @@ func (m workModel) runsLines(width int) []string {
|
||||
} else {
|
||||
out = append(out, dimStyle().Render(fmt.Sprintf("%-18s %-12s %-10s %-10s %s",
|
||||
"state", "woken by", "started", "ended", "took")))
|
||||
for _, r := range m.runs {
|
||||
for i, r := range m.runs {
|
||||
started, took := "-", "-"
|
||||
if t, err := time.Parse(time.RFC3339, r.StartedAt); err == nil {
|
||||
started = t.Local().Format("15:04:05")
|
||||
@@ -567,6 +574,11 @@ func (m workModel) runsLines(width int) []string {
|
||||
}
|
||||
// Pad the plain text first, then colour it: styling first would
|
||||
// make the escape codes count as characters and break the columns.
|
||||
row := fmt.Sprintf("%-18s %-12s %-10s %-10s %s", r.Status, r.Source, started, ended, took)
|
||||
if i == m.runAt {
|
||||
out = append(out, selectedStyle2().Render(padTo("▸ "+row, width)))
|
||||
continue
|
||||
}
|
||||
out = append(out, fmt.Sprintf("%-18s %-12s %-10s %-10s %s",
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color(colour)).Render(fmt.Sprintf("%-18s", r.Status)),
|
||||
fmt.Sprintf("%-12s", r.Source), started, ended, took))
|
||||
@@ -696,8 +708,22 @@ func (m workModel) logLinesWork(width int) []string {
|
||||
}
|
||||
|
||||
func (m workModel) mergeLines(width int) []string {
|
||||
tail := mergeLogTail(max(6, m.height-6))
|
||||
joined := strings.Join(tail, "\n")
|
||||
if m.task.Identifier != "" && !strings.Contains(joined, m.task.Identifier) {
|
||||
// The log on disk belongs to another task. Say so instead of showing
|
||||
// someone else's merge as if it were this one.
|
||||
return []string{"",
|
||||
" " + mutedStyle2().Render("no merge has been run from this screen for "+m.task.Identifier),
|
||||
"",
|
||||
" " + dimStyle().Render("the last merge recorded was for another task:"),
|
||||
" " + dimStyle().Render(firstLineWith(tail, "merge of ")),
|
||||
"",
|
||||
" " + dimStyle().Render("press m to merge this task"),
|
||||
}
|
||||
}
|
||||
out := []string{"", dimStyle().Render(" " + mergeLogPath()), ""}
|
||||
for _, ln := range mergeLogTail(max(6, m.height-6)) {
|
||||
for _, ln := range tail {
|
||||
colour := active.Text
|
||||
switch {
|
||||
case strings.Contains(ln, "refused"), strings.Contains(ln, "stopped"):
|
||||
@@ -740,3 +766,13 @@ func baseRefOf(t paperclip.Issue) string {
|
||||
}
|
||||
return "main"
|
||||
}
|
||||
|
||||
// firstLineWith finds the first line mentioning a marker, for a one-line hint.
|
||||
func firstLineWith(lines []string, marker string) string {
|
||||
for _, l := range lines {
|
||||
if strings.Contains(l, marker) {
|
||||
return strings.TrimSpace(l)
|
||||
}
|
||||
}
|
||||
return "none"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user