HH-598: hide unavailable AI takeover (#155)

* fix(HH-598): hide unavailable AI takeover

* fix: isolate inbox assistant availability

---------

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-24 12:49:46 +08:00
committed by GitHub
co-authored by rogee
parent 907d8ea4e1
commit a7e96afef4
6 changed files with 151 additions and 16 deletions
@@ -533,6 +533,28 @@ func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenUnbound() {
assert.Nil(s.T(), resp["assistant"])
}
func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenBoundAssistantInactive() {
assistant := &model.CaptainAssistant{AccountID: s.testAccount.ID, Name: "Inactive Helper", Config: json.RawMessage(`{}`), Status: model.AssistantStatusDraft}
s.Require().NoError(s.db.Create(assistant).Error)
s.Require().NoError(s.db.Create(&model.CaptainInbox{AccountID: s.testAccount.ID, AssistantID: assistant.ID, InboxID: s.testInbox.ID}).Error)
assertUnavailable := func() {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", s.convURL(s.testConv.ID)+"/inbox_assistant", nil)
s.router.ServeHTTP(w, req)
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
s.Require().NoError(json.Unmarshal(w.Body.Bytes(), &resp))
assert.Nil(s.T(), resp["assistant"])
}
assertUnavailable()
assistant.Status = model.AssistantStatusArchived
s.Require().NoError(s.db.Save(assistant).Error)
assertUnavailable()
}
func (s *ConversationCrudTestSuite) TestInboxAssistant_UsesDisplayIDRoute() {
displayID := uint(77)
s.testConv.DisplayID = &displayID