Switch to prefixed IDs and tell agents which Mac a message came from
This commit is contained in:
@@ -39,7 +39,7 @@ func (m *Manager) lockDelivery(sessionID string) func() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) Message(ctx context.Context, sessionID, actor, text, model, sendID string, images ...string) (api.AgentSession, bool, error) {
|
||||
func (m *Manager) Message(ctx context.Context, sessionID, actor, text, model, sendID, client string, images ...string) (api.AgentSession, bool, error) {
|
||||
unlock := m.lockDelivery(sessionID)
|
||||
defer unlock()
|
||||
|
||||
@@ -60,7 +60,7 @@ func (m *Manager) Message(ctx context.Context, sessionID, actor, text, model, se
|
||||
}
|
||||
held := sess.State == api.AgentSessionStateIdle && sess.Role == api.Implementer && (automatedActor(actor) && m.interrupted(sess.Id) || m.heldForLanding(sess.TaskId, sess.Id))
|
||||
if !held && (sess.State != api.AgentSessionStateRunning || sess.Role != api.Implementer) {
|
||||
sess, err = m.Send(ctx, sessionID, actor, text, model, sendID, images...)
|
||||
sess, err = m.Send(ctx, sessionID, actor, text, model, sendID, client, images...)
|
||||
return sess, false, err
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (m *Manager) Message(ctx context.Context, sessionID, actor, text, model, se
|
||||
if err != nil {
|
||||
return api.AgentSession{}, false, err
|
||||
}
|
||||
err = m.store.AddTaskInput(ctx, store.TaskInput{TaskID: sess.TaskId, Member: sess.Member, Actor: actor, Text: text, Images: images, SendID: sendID}, task.ProjectId, sess.Id)
|
||||
err = m.store.AddTaskInput(ctx, store.TaskInput{TaskID: sess.TaskId, Member: sess.Member, Actor: actor, Text: text, Images: images, SendID: sendID, Client: client}, task.ProjectId, sess.Id)
|
||||
if err != nil {
|
||||
return api.AgentSession{}, false, err
|
||||
}
|
||||
@@ -153,7 +153,7 @@ func (m *Manager) deliverQueued(ctx context.Context, sess api.AgentSession) (boo
|
||||
}
|
||||
|
||||
in := inputs[0]
|
||||
_, err = m.Send(ctx, sess.Id, in.Actor, in.Text, "", in.SendID, in.Images...)
|
||||
_, err = m.Send(ctx, sess.Id, in.Actor, in.Text, "", in.SendID, in.Client, in.Images...)
|
||||
if errors.Is(err, ErrConflict) {
|
||||
slog.Info("queued message held: session changed state", "session", sess.Id, "task", task.Id, "err", err)
|
||||
return true, nil
|
||||
@@ -188,6 +188,7 @@ type queued struct {
|
||||
actor string
|
||||
text string
|
||||
sendID string
|
||||
client string
|
||||
}
|
||||
|
||||
func (m *Manager) takeQueuedMidTurn(ctx context.Context, l *live) []store.TaskInput {
|
||||
@@ -278,6 +279,9 @@ func (m *Manager) recordQueued(ctx context.Context, l *live, msgs []queued) stri
|
||||
if q.sendID != "" {
|
||||
payload["send_id"] = q.sendID
|
||||
}
|
||||
if q.client != "" {
|
||||
payload["client"] = q.client
|
||||
}
|
||||
err := m.emit(ctx, l, q.actor, "user.message", payload)
|
||||
if err != nil {
|
||||
slog.Error("record mid-turn message", "session", l.id, "err", err)
|
||||
@@ -293,6 +297,10 @@ func (m *Manager) recordQueued(ctx context.Context, l *live, msgs []queued) stri
|
||||
fmt.Fprintf(b, "%s (not %s) sent you this message while you were working; take it into account now:\n\n%s", actorName(q.actor), leadOwner(q.actor), q.text)
|
||||
continue
|
||||
}
|
||||
if q.client != "" {
|
||||
fmt.Fprintf(b, "%s sent you this message from %s while you were working; take it into account now:\n\n%s", q.actor, m.clientName(q.client), q.text)
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(b, "%s sent you this message while you were working; take it into account now:\n\n%s", q.actor, q.text)
|
||||
}
|
||||
slog.Info("queued messages sent mid-turn", "session", l.id, "count", len(msgs))
|
||||
|
||||
Reference in New Issue
Block a user