Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ ui:
| Option | Default | |
| --- | --- | --- |
| `start_assigns` | `off` | start work also assigns the issue to you |
| `start_status` | | and moves it there (`In Progress`), unless the move has a screen |
| `start_status` | | and moves it there (`In Progress`); a move with a screen opens its form when fields are missing |
| `branch_template` | `{key}-{summary}` | the copied branch name: `{key} {summary} {type} {project}` |
| `work_branch_template` | `issue/{key}-{summary}` | start work's new branch; `branch_template` when that is set |
| `work_agent` | `claude` | the herdr agent start work offers first |
Expand Down
2 changes: 1 addition & 1 deletion internal/i18n/nl/go-rest.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"Lower-case letters, digits, - and _ only.": "Alleen kleine letters, cijfers, - en _.",
"Moved to %s": "Verplaatst naar %s",
"Moving to %s": "Verplaatsen naar %s",
"The move to %s has a screen: it opens next": "De overgang naar %s heeft een scherm: dat opent hierna",
"Not assigned: %s": "Niet toegewezen: %s",
"Not moved: %s": "Niet verplaatst: %s",
"Off the board (%d)": "Buiten het bord (%d)",
Expand Down Expand Up @@ -262,7 +263,6 @@
"the file must be .woff2, .woff, .ttf or .otf": "het bestand moet .woff2, .woff, .ttf of .otf zijn",
"the keyring refused it (%s); keeping it in the file": "de sleutelhanger weigerde het (%s); het blijft in het bestand",
"the message file, as git passes it": "het berichtbestand, zoals git het meegeeft",
"the move to %s asks for fields: move it with s": "de overgang naar %s vraagt om velden: verplaats met s",
"the rule watch's JQL that saw the change; empty for a board": "de JQL van de regel-watch die de wijziging zag; leeg voor een bord",
"the status before, for -on status": "de status ervoor, voor -on status",
"the terminal needs a same-origin Origin": "de terminal vereist een Origin van dezelfde herkomst",
Expand Down
1 change: 0 additions & 1 deletion internal/i18n/nl/ui-issue-edit.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@
"tab/↑↓ field · ↵ toggle · ctrl+s start · esc cancel": "tab/↑↓ veld · ↵ aan/uit · ctrl+s starten · esc annuleren",
"text, status:review points>2 prio>=high -label:ui": "tekst, status:review points>2 prio>=high -label:ui",
"the comment is for %s": "de reactie is voor %s",
"the move to %s asks for fields: %s moves it": "de overgang naar %s vraagt velden: %s verplaatst hem",
"this board has no sprints": "dit bord heeft geen sprints",
"type to filter · %s": "typ om te filteren · %s",
"ui -old: add ui, remove old": "ui -oud: voeg ui toe, verwijder oud",
Expand Down
6 changes: 4 additions & 2 deletions internal/ui/click_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,10 @@ func TestStartWrites(t *testing.T) {
}
writes, screen = nil, true
m.opts.startAssigns = false
if msg = m.startWrites("ABC-1")().(startWritesMsg); msg.err == nil || len(writes) != 0 {
t.Errorf("a screen: writes %q, err %v", writes, msg.err)
// A move with a screen is left to the move form's own path.
msg = m.startWrites("ABC-1")().(startWritesMsg)
if msg.err != nil || msg.move != "In Progress" || len(writes) != 0 {
t.Errorf("a screen: writes %q, move %q, err %v", writes, msg.move, msg.err)
}
m.opts.startStatus = ""
if m.startWrites("ABC-1") != nil {
Expand Down
23 changes: 15 additions & 8 deletions internal/ui/jira_work.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,14 @@ func slugify(s string) string {
type startWritesMsg struct {
key string
did []string
err error
// move is the status whose move has a screen: the move form takes it.
move string
err error
}

// startWrites assigns the started issue to you (ui.start_assigns) and
// moves it to its startStatus, when it isn't so already. A move with a
// screen of its own is left to the move form. nil with neither set.
// screen of its own goes through the move form. nil with neither set.
func (m *Model) startWrites(key string) tea.Cmd {
assign, status := m.opts.startAssigns, m.startStatus(key)
if !assign && status == "" {
Expand All @@ -441,7 +443,7 @@ func (m *Model) startWrites(key string) tea.Cmd {
if m.jiraIssue != nil && m.jiraIssue.Key == key {
cur = m.jiraIssue.Status
}
c, ctx, moveKey := m.jiraClient, m.ctx, helpKey(m.keys.JiraStatus)
c, ctx := m.jiraClient, m.ctx
return func() tea.Msg {
var did []string
if assign {
Expand All @@ -464,7 +466,7 @@ func (m *Model) startWrites(key string) tea.Cmd {
case i < 0:
return startWritesMsg{key: key, did: did, err: errors.New(i18n.Tf("no move to %s from here", status))}
case ts[i].HasScreen:
return startWritesMsg{key: key, did: did, err: errors.New(i18n.Tf("the move to %s asks for fields: %s moves it", status, moveKey))}
return startWritesMsg{key: key, did: did, move: ts[i].ToName}
}
if err := c.DoTransition(ctx, key, ts[i].ID); err != nil {
return startWritesMsg{key: key, did: did, err: err}
Expand All @@ -475,17 +477,22 @@ func (m *Model) startWrites(key string) tea.Cmd {
}
}

// handleStartWrites says what start work changed and reloads the issue.
// handleStartWrites says what start work changed and reloads the issue. A
// move with a screen goes on as any other move: made at once when its
// required fields are filled, through its form otherwise.
func (m Model) handleStartWrites(msg startWritesMsg) (tea.Model, tea.Cmd) {
if len(msg.did) > 0 {
m.status = msg.key + " " + strings.Join(msg.did, ", ")
}
if msg.err != nil {
m.fail(msg.key + ": " + msg.err.Error())
}
board := m.refreshJiraAfterEdit()
cmds := []tea.Cmd{m.refreshJiraAfterEdit()}
if r := m.currentRef(); r != nil && r.jiraKey == msg.key {
return m, tea.Batch(m.loadCurrentRef(), board)
cmds = append(cmds, m.loadCurrentRef())
}
return m, board
if to := msg.move; to != "" {
cmds = append(cmds, m.prepareJiraMove(msg.key, to, jiraFromPanel, func(t jira.TransitionMeta) bool { return strings.EqualFold(t.ToName, to) }))
}
return m, tea.Batch(cmds...)
}
26 changes: 26 additions & 0 deletions internal/web/api_agents_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"context"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"os/exec"
Expand Down Expand Up @@ -282,3 +283,28 @@ func TestStartConfiguredAgent(t *testing.T) {
}
}
}

// TestStartWritesScreen: a start status whose move has a screen is not made
// and not refused: it is handed to the page, which opens the move's form.
func TestStartWritesScreen(t *testing.T) {
posted := false
fake := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.HasSuffix(r.URL.Path, "/transitions") {
http.NotFound(w, r)
return
}
if r.Method == http.MethodPost {
posted = true
w.WriteHeader(http.StatusNoContent)
return
}
_, _ = io.WriteString(w, `{"transitions":[{"id":"21","name":"Start","hasScreen":true,"to":{"id":"3","name":"In Progress"}}]}`)
}))
t.Cleanup(fake.Close)
cl := jira.New(jira.Config{BaseURL: fake.URL, Email: "d@example.com", APIToken: "x", Projects: []string{"DEMO"}})
s := New(context.Background(), Options{Client: cl, Site: "demo", UI: config.UIConfig{StartStatus: "in progress"}})
did, move, err := startWrites(context.Background(), s, "DEMO-1", "To Do", false, func(string, string, string) {})
if err != nil || len(did) != 0 || posted || move == nil || *move != (startMove{ID: "21", Name: "In Progress"}) {
t.Errorf("did %v, move %+v, posted %v, err %v", did, move, posted, err)
}
}
22 changes: 15 additions & 7 deletions internal/web/api_agents_work.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,11 @@ func (p *startPlan) run(ctx context.Context, report func(startStep)) (map[string
if p.another || !p.actions {
return out, nil
}
did, werr := startWrites(ctx, p.s, key, p.iss.Status, p.cfg.Assigns, step)
did, move, werr := startWrites(ctx, p.s, key, p.iss.Status, p.cfg.Assigns, step)
out["Did"] = did
if move != nil {
out["Move"] = move
}
if werr != nil {
out["Warn"] = werr.Error()
}
Expand Down Expand Up @@ -641,9 +644,13 @@ func startError(key, repo string, err error) error {
return fmt.Errorf("%s: %s: %w", key, i18n.T("start work"), err)
}

// startMove is a move start work leaves to the page: it has a screen, so it
// goes as a move picked there does, through its form when fields are missing.
type startMove struct{ ID, Name string }

// startWrites assigns the issue to you and moves it to its start status, when
// it isn't there already.
func startWrites(ctx context.Context, s *Server, key, current string, assign bool, step func(name, state, text string)) ([]string, error) {
// it isn't there already. A move with a screen is returned, not made.
func startWrites(ctx context.Context, s *Server, key, current string, assign bool, step func(name, state, text string)) ([]string, *startMove, error) {
did := []string{}
c := s.Client()
if assign {
Expand All @@ -654,7 +661,7 @@ func startWrites(ctx context.Context, s *Server, key, current string, assign boo
}
if err != nil {
step("assign", "warn", i18n.Tf("Not assigned: %s", err.Error()))
return did, err
return did, nil, err
}
did = append(did, i18n.T("assigned to you"))
step("assign", "ok", i18n.T("Assigned to you"))
Expand All @@ -668,7 +675,8 @@ func startWrites(ctx context.Context, s *Server, key, current string, assign boo
case i < 0:
err = fmt.Errorf(i18n.T("no move to %s from here"), st)
case ts[i].HasScreen:
err = fmt.Errorf(i18n.T("the move to %s asks for fields: move it with s"), st)
step("move", "ok", i18n.Tf("The move to %s has a screen: it opens next", ts[i].ToName))
return did, &startMove{ID: ts[i].ID, Name: ts[i].ToName}, nil
default:
if err = c.DoTransition(ctx, key, ts[i].ID); err == nil {
did = append(did, i18n.Tf("moved to %s", ts[i].ToName))
Expand All @@ -678,10 +686,10 @@ func startWrites(ctx context.Context, s *Server, key, current string, assign boo
}
if err != nil {
step("move", "warn", i18n.Tf("Not moved: %s", err.Error()))
return did, err
return did, nil, err
}
}
return did, nil
return did, nil, nil
}

func issueBranchName(ctx context.Context, s *Server, r *http.Request) (any, error) {
Expand Down
2 changes: 2 additions & 0 deletions internal/web/static/js/views/agent_start.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,7 @@ function form(app, key, f, { another, path, notice }) {
ui.toast(T('%s: %s started in %s', key, r.Agent, home(r.Path)) + (did.length ? ' · ' + did.join(', ') : ''), { ms: 8000, action: show });
if (r.Warn) ui.toast(key + ': ' + r.Warn, { kind: 'err', ms: 10000 });
app.bus.emit('issue:changed', { key });
// The start status's move has a screen: taken as a move picked by hand, through its form when fields are missing.
if (r.Move) import('./fields.js').then(f => f.takeMove(app, key, r.Move)).catch(e => ui.errToast(e));
}
}
Loading