fix(agent-threads): hide prompt reference directives in thread titles
Add a shared visiblePromptText helper and strip reference tokens, image-generator directives, and model-selection lines from agent thread summaries and the assistant panel header, so titles show the user's actual prompt instead of internal directives. Covered by a server test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,44 @@ func TestAgentThreadsOnlyListsAgentConversationThreads(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentThreadsSummaryHidesPromptReferenceDirectives(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
repo := memory.NewProjectRepository()
|
||||
service := NewDesignService(repo, nil, nil, nil, nil)
|
||||
now := time.Now()
|
||||
project := design.Project{
|
||||
ID: "project-agent-reference-history",
|
||||
Title: "Agent history",
|
||||
Status: design.StatusReady,
|
||||
LastThreadID: "thread-agent",
|
||||
UpdatedAt: now,
|
||||
Messages: []design.Message{
|
||||
{
|
||||
ID: "agent-user",
|
||||
Role: "user",
|
||||
Type: "user",
|
||||
Content: "Reference image 1 (image): http://localhost:19000/canvas-assets/reference.png 灰裤子拆成单件衣服,为了后面电商配图。\nSelected model: GPT Image 2",
|
||||
ThreadID: "thread-agent",
|
||||
CreatedAt: now,
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := repo.Save(ctx, project); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
threads, err := service.AgentThreads(ctx, project.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(threads) != 1 {
|
||||
t.Fatalf("expected one agent thread, got %#v", threads)
|
||||
}
|
||||
if threads[0].Text != "灰裤子拆成单件衣服,为了后面电商配图。" {
|
||||
t.Fatalf("expected visible prompt text only, got %q", threads[0].Text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectScopedToAgentThreadKeepsOnlyCurrentConversationContext(t *testing.T) {
|
||||
now := time.Now()
|
||||
project := design.Project{
|
||||
|
||||
Reference in New Issue
Block a user