탭 전환 빈 대화 누적 방지: 저장 게이트 + 목록 노이즈 필터
Some checks failed
Release Gate / gate (push) Has been cancelled

- ChatSessionStateService.SaveCurrentConversation에 persistable-content 검사 추가

- 무의미한 빈 새 대화는 저장/탭 기억 대상에서 제외

- ChatWindow 대화 목록에서 빈 노이즈 항목 필터링

- ChatSessionStateServiceTests 회귀 추가 및 문서 이력(2026-04-04 15:48 KST) 동기화
This commit is contained in:
2026-04-04 15:49:12 +09:00
parent 73a4111100
commit f8669c735d
5 changed files with 162 additions and 7 deletions

View File

@@ -225,6 +225,32 @@ public class ChatSessionStateServiceTests
session.GetConversationId("Code").Should().Be(conv.Id);
}
[Fact]
public void SaveCurrentConversation_DoesNotPersistEmptyFreshConversation()
{
var session = new ChatSessionStateService();
var storage = new ChatStorageService();
var conv = session.EnsureCurrentConversation("Cowork");
conv.Messages.Clear();
conv.ExecutionEvents.Clear();
conv.AgentRunHistory.Clear();
conv.DraftQueueItems.Clear();
conv.Preview = "";
conv.WorkFolder = "";
conv.SystemCommand = "";
conv.Permission = null;
conv.DataUsage = null;
conv.OutputFormat = null;
conv.Mood = null;
conv.Category = ChatCategory.General;
conv.Title = "새 대화";
session.SaveCurrentConversation(storage, "Cowork");
session.GetConversationId("Cowork").Should().BeNull();
storage.Load(conv.Id).Should().BeNull();
}
[Fact]
public void SaveCurrentConversation_RemembersConversationId_WhenOnlyAgentRunHistoryExists()
{
@@ -701,4 +727,54 @@ public class ChatSessionStateServiceTests
session.GetConversationId("Code").Should().BeNull();
session.GetConversationId("Chat").Should().BeNull();
}
[Fact]
public void LoadOrCreateConversation_RestoresRunHistoryAndExecutionEventsAfterRestart()
{
var storage = new ChatStorageService();
var settings = new SettingsService();
var sessionA = new ChatSessionStateService();
var conv = new ChatConversation
{
Id = $"conv-replay-{Guid.NewGuid():N}",
Tab = "Code",
Title = "restore test",
Messages = [new ChatMessage { Role = "user", Content = "build it" }],
ExecutionEvents =
[
new ChatExecutionEvent
{
RunId = "run-restore-1",
Type = "ToolResult",
ToolName = "build_run",
Summary = "build ok",
Timestamp = DateTime.Now
}
],
AgentRunHistory =
[
new ChatAgentRunRecord
{
RunId = "run-restore-1",
Status = "completed",
Summary = "done",
UpdatedAt = DateTime.Now
}
]
};
sessionA.SetCurrentConversation("Code", conv, storage);
sessionA.SaveCurrentConversation(storage, "Code");
sessionA.Save(settings);
var sessionB = new ChatSessionStateService();
sessionB.Load(settings);
var restored = sessionB.LoadOrCreateConversation("Code", storage, settings);
restored.Id.Should().Be(conv.Id);
restored.Tab.Should().Be("Code");
restored.ExecutionEvents.Should().ContainSingle();
restored.AgentRunHistory.Should().ContainSingle();
restored.AgentRunHistory[0].RunId.Should().Be("run-restore-1");
}
}