Screens 2 and 3: new-task form, live log and diff; measured the merge gap they expose
This commit is contained in:
24
tui/model.go
24
tui/model.go
@@ -119,6 +119,7 @@ func loadRows(c *paperclip.Client, proj paperclip.Project) ([]Row, error) {
|
||||
type model struct {
|
||||
client *paperclip.Client
|
||||
project paperclip.Project
|
||||
agent string
|
||||
zones *zone.Manager
|
||||
|
||||
rows []Row
|
||||
@@ -130,10 +131,11 @@ type model struct {
|
||||
height int
|
||||
}
|
||||
|
||||
func newModel(c *paperclip.Client, proj paperclip.Project) model {
|
||||
func newModel(c *paperclip.Client, proj paperclip.Project, agent string) model {
|
||||
return model{
|
||||
client: c,
|
||||
project: proj,
|
||||
agent: agent,
|
||||
// The click-zone manager is created once, here, and the whole view is
|
||||
// wrapped and scanned through it. Wrapping parts separately drifts
|
||||
// when a pane is resized.
|
||||
@@ -171,6 +173,24 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case "r":
|
||||
m.loading = true
|
||||
return m, m.reload()
|
||||
case "a":
|
||||
// Assign the selected task to one agent. Paperclip wakes that
|
||||
// agent as soon as the assignment lands, so this is also the
|
||||
// "start work" key.
|
||||
if m.cursor < len(m.rows) && m.rows[m.cursor].Issue.AssigneeAgent == "" {
|
||||
c, id, agent := m.client, m.rows[m.cursor].Issue.ID, m.agent
|
||||
return m, func() tea.Msg {
|
||||
if _, err := c.Assign(id, agent); err != nil {
|
||||
return errMsg{err}
|
||||
}
|
||||
rows, err := loadRows(c, m.project)
|
||||
if err != nil {
|
||||
return errMsg{err}
|
||||
}
|
||||
return rowsMsg(rows)
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
case "up", "shift+tab":
|
||||
if m.cursor > 0 {
|
||||
m.cursor--
|
||||
@@ -283,7 +303,7 @@ func (m model) View() string {
|
||||
}
|
||||
|
||||
b.WriteString(mutedStyle.Render(truncate(
|
||||
"↑/↓ or Tab/Shift-Tab move · r refresh · q quit", m.width)))
|
||||
"↑/↓ or Tab/Shift-Tab move · a assign to Builder · r refresh · q quit", m.width)))
|
||||
|
||||
// One scan for the whole view.
|
||||
return m.zones.Scan(b.String())
|
||||
|
||||
Reference in New Issue
Block a user