Render Markdown, add ask_human context, simplify inbox responses, group inbox by task

This commit is contained in:
Ian Gulliver
2026-10-14 10:37:04 -07:00
parent e9fd7de556
commit ca2644374d
25 changed files with 950 additions and 283 deletions
+12 -24
View File
@@ -145,54 +145,42 @@ func checkResponse(item api.InboxItem, c api.InboxResponseCreate) (api.InboxStat
if c.Text != nil {
text = strings.TrimSpace(*c.Text)
}
question := item.Kind == api.InboxItemKindQuestion
question := item.Kind == api.Question
bad := func(format string, args ...any) (api.InboxState, *httpError) {
return "", &httpError{http.StatusBadRequest, fmt.Errorf("item %s: "+format, append([]any{item.Id}, args...)...)}
}
switch c.Type {
case api.InboxResponseTypeOption:
case api.Option:
if !question {
return bad("only questions have options")
}
if c.Option == nil || !hasOption(item, *c.Option) {
return bad("option must be one of the question's options")
}
return api.Answered, nil
case api.InboxResponseTypeFreeForm:
if !question {
return bad("only questions take answers")
}
if text == "" {
return bad("free_form needs text")
if text != "" {
return bad("option takes no text; use other")
}
return api.Answered, nil
case api.InboxResponseTypeQuestion:
if !question {
return bad("only questions take follow-up questions")
case api.Other:
if item.Kind == api.Report {
return bad("reports are only dismissed")
}
if text == "" {
return bad("question needs text")
return bad("other needs text")
}
return api.Open, nil
return api.Answered, nil
case api.InboxResponseTypeRedirect:
if text == "" {
return bad("redirect needs text")
}
return api.Redirected, nil
case api.InboxResponseTypeSnooze:
case api.Snooze:
if c.SnoozeUntil == nil || !c.SnoozeUntil.After(time.Now()) {
return bad("snooze needs a future snooze_until")
}
return api.Open, nil
case api.InboxResponseTypeDismiss:
case api.Dismiss:
if question {
return bad("questions need an answer or a redirect, not a dismissal")
return bad("questions need an option or other, not a dismissal")
}
return api.Dismissed, nil
}