fix(chat): emit retrieval references when citation output is disabled
Decouple the references SSE event from the per-agent citation output toggle so the retrieval-results drawer still works, and align follow-up suggestion card layout with the chat column.
This commit is contained in:
@@ -66,8 +66,10 @@ const dismiss = () => {
|
|||||||
@import (reference) '../css/suggested-questions.less';
|
@import (reference) '../css/suggested-questions.less';
|
||||||
|
|
||||||
.follow-ups {
|
.follow-ups {
|
||||||
max-width: 760px;
|
width: 100%;
|
||||||
margin: -4px 0 28px 46px;
|
max-width: 600px;
|
||||||
|
margin: -4px 0 28px;
|
||||||
|
margin-right: auto;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
border: 1px solid var(--td-component-stroke);
|
border: 1px solid var(--td-component-stroke);
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
@@ -139,7 +141,7 @@ const dismiss = () => {
|
|||||||
@keyframes spin { to { transform: rotate(360deg); } }
|
@keyframes spin { to { transform: rotate(360deg); } }
|
||||||
|
|
||||||
.follow-up-card-enter-active {
|
.follow-up-card-enter-active {
|
||||||
transform-origin: 24px 0;
|
transform-origin: left top;
|
||||||
transition:
|
transition:
|
||||||
opacity .22s ease .04s,
|
opacity .22s ease .04s,
|
||||||
transform .28s cubic-bezier(.22, .61, .36, 1) .04s,
|
transform .28s cubic-bezier(.22, .61, .36, 1) .04s,
|
||||||
|
|||||||
@@ -1189,10 +1189,12 @@ func (s *sessionService) consumeFallbackStream(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// emitKnowledgeReferencesEvent streams retrieved chunks to the client as a
|
// emitKnowledgeReferencesEvent streams retrieved chunks to the client as a
|
||||||
// `references` SSE event. Must run before CHAT_COMPLETION_STREAM so citations
|
// `references` SSE event. These references drive the retrieval-results UI and
|
||||||
// arrive while the connection is still open (complete closes the stream).
|
// remain available even when inline citations in the model answer are disabled.
|
||||||
|
// Must run before CHAT_COMPLETION_STREAM so the event arrives while the
|
||||||
|
// connection is still open (complete closes the stream).
|
||||||
func emitKnowledgeReferencesEvent(ctx context.Context, chatManage *types.ChatManage) {
|
func emitKnowledgeReferencesEvent(ctx context.Context, chatManage *types.ChatManage) {
|
||||||
if chatManage == nil || !chatManage.CitationsEnabled() || chatManage.EventBus == nil || len(chatManage.MergeResult) == 0 {
|
if chatManage == nil || chatManage.EventBus == nil || len(chatManage.MergeResult) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.Infof(ctx, "Emitting references event with %d results (pre-answer)", len(chatManage.MergeResult))
|
logger.Infof(ctx, "Emitting references event with %d results (pre-answer)", len(chatManage.MergeResult))
|
||||||
|
|||||||
@@ -52,29 +52,32 @@ type stubModelService struct {
|
|||||||
modelsByID map[string]*types.Model
|
modelsByID map[string]*types.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEmitKnowledgeReferencesEventHonorsCitationSetting(t *testing.T) {
|
func TestEmitKnowledgeReferencesEventIgnoresCitationOutputSetting(t *testing.T) {
|
||||||
bus := event.NewEventBus()
|
bus := event.NewEventBus()
|
||||||
emitted := 0
|
var emitted []event.Event
|
||||||
bus.On(event.EventAgentReferences, func(context.Context, event.Event) error {
|
bus.On(event.EventAgentReferences, func(_ context.Context, evt event.Event) error {
|
||||||
emitted++
|
emitted = append(emitted, evt)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
disabled := false
|
disabled := false
|
||||||
|
result := &types.SearchResult{ID: "chunk-1", KnowledgeTitle: "Doc"}
|
||||||
cm := &types.ChatManage{
|
cm := &types.ChatManage{
|
||||||
PipelineRequest: types.PipelineRequest{CitationEnabled: &disabled},
|
PipelineRequest: types.PipelineRequest{CitationEnabled: &disabled},
|
||||||
PipelineState: types.PipelineState{
|
PipelineState: types.PipelineState{
|
||||||
MergeResult: []*types.SearchResult{{ID: "chunk-1"}},
|
MergeResult: []*types.SearchResult{result},
|
||||||
},
|
},
|
||||||
PipelineContext: types.PipelineContext{EventBus: bus.AsEventBusInterface()},
|
PipelineContext: types.PipelineContext{EventBus: bus.AsEventBusInterface()},
|
||||||
}
|
}
|
||||||
|
|
||||||
emitKnowledgeReferencesEvent(context.Background(), cm)
|
emitKnowledgeReferencesEvent(context.Background(), cm)
|
||||||
require.Zero(t, emitted)
|
require.Len(t, emitted, 1)
|
||||||
|
require.Equal(t, event.EventAgentReferences, emitted[0].Type)
|
||||||
|
require.Equal(t, []*types.SearchResult{result}, emitted[0].Data.(event.AgentReferencesData).References)
|
||||||
|
|
||||||
enabled := true
|
enabled := true
|
||||||
cm.CitationEnabled = &enabled
|
cm.CitationEnabled = &enabled
|
||||||
emitKnowledgeReferencesEvent(context.Background(), cm)
|
emitKnowledgeReferencesEvent(context.Background(), cm)
|
||||||
require.Equal(t, 1, emitted)
|
require.Len(t, emitted, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stubModelService) CreateModel(context.Context, *types.Model) error {
|
func (s *stubModelService) CreateModel(context.Context, *types.Model) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user