Let agents cancel open questions; fix snapshots missing same-size edits
This commit is contained in:
@@ -190,6 +190,26 @@ func (s *Store) Respond(ctx context.Context, actor string, resolutions []Resolut
|
||||
})
|
||||
}
|
||||
|
||||
var ErrNotOpen = errors.New("inbox item is not open")
|
||||
|
||||
func (s *Store) WithdrawItem(ctx context.Context, id string) error {
|
||||
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
|
||||
res, err := tx.ExecContext(ctx, `UPDATE inbox_items SET state = ?, resolved_at = ?, snoozed_until = NULL WHERE id = ? AND state = ?`,
|
||||
string(api.Dismissed), now(), id, string(api.Open))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := res.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n == 0 {
|
||||
return ErrNotOpen
|
||||
}
|
||||
return emitItem(ctx, tx, emit, "inbox.updated", id, agentActor)
|
||||
})
|
||||
}
|
||||
|
||||
func dismissTaskInbox(ctx context.Context, tx *sql.Tx, emit emitFunc, taskID, actor string) error {
|
||||
ids := []string{}
|
||||
rows, err := tx.QueryContext(ctx, `SELECT id FROM inbox_items WHERE task_id = ? AND state = ?`, taskID, string(api.Open))
|
||||
|
||||
Reference in New Issue
Block a user