修复: 重命名时缓存缺条目补建防标题丢失
- 缓存缺 entry(缓存损坏或新会话未入缓存)时补建,标题才能落盘 - 补缓存补建测试,顺带补齐测试文件缺失的换行
This commit is contained in:
+8
-3
@@ -191,10 +191,15 @@ func (m *Model) setUserTitle(sessionID, title string) tea.Cmd {
|
||||
}
|
||||
}
|
||||
if m.history.Cache != nil {
|
||||
if entry, ok := m.history.Cache[sessionID]; ok {
|
||||
entry.UserTitle = title
|
||||
m.cacheDirty = true
|
||||
entry, ok := m.history.Cache[sessionID]
|
||||
if !ok {
|
||||
// 缓存缺 entry(如缓存文件损坏/新会话未入缓存)时补建,
|
||||
// 否则标题只改内存不落盘,重启后丢失
|
||||
entry = &cacheEntry{}
|
||||
m.history.Cache[sessionID] = entry
|
||||
}
|
||||
entry.UserTitle = title
|
||||
m.cacheDirty = true
|
||||
}
|
||||
// 调度落盘,避免改名只存在内存、被磁盘旧缓存覆盖
|
||||
return cacheFlushTick()
|
||||
|
||||
Reference in New Issue
Block a user