Conversation
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Fix AUTHOR_NAMES unused in content-collections.ts - Add fallbacks for optional article.title and meta_description in blog routes Co-authored-by: Cursor <cursoragent@cursor.com>
- useMCP: set isReady=true in catch block to allow chat fallback on transient errors - context-bar: always slice displayChips so expand/collapse button stays visible Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
| for (const e of prevEntities) { | ||
| if (!seen.has(e.key)) { | ||
| seen.add(e.key); | ||
| merged.push(e); | ||
| } | ||
| } | ||
| for (const e of entities) { | ||
| if (!seen.has(e.key)) { | ||
| seen.add(e.key); | ||
| merged.push(e); | ||
| } |
There was a problem hiding this comment.
🟡 persistContext never updates stale context entities, causing stale data after chat mode transitions
The persistContext function in chat-context.ts merges entities by always giving priority to previously persisted entities. When an entity with the same key (e.g., session:info) is persisted again with updated data (e.g., a changed session title or new transcript), the stale version from prevEntities is kept and the fresh version from entities is silently discarded.
Root Cause and Impact
In apps/desktop/src/store/zustand/chat-context.ts:36-46, prevEntities are iterated first and added to the seen set, so when the loop reaches the matching entity in entities, it's skipped:
for (const e of prevEntities) {
if (!seen.has(e.key)) { seen.add(e.key); merged.push(e); }
}
for (const e of entities) {
if (!seen.has(e.key)) { seen.add(e.key); merged.push(e); } // skipped for same key!
}This is called from sendMessage (apps/desktop/src/components/chat/session.tsx:247-256) on every message send with contextEntitiesRef.current. On the first send, the session entity (key session:info) is persisted. On subsequent sends, even if the session title or content has been updated (e.g., auto-enhance completed), the updated entity is ignored.
Further, in session.tsx:226-228, the final contextEntities is computed as composeContextEntities([persistedEntities, ephemeralEntities]), which also gives precedence to persistedEntities. So after a chat mode transition (floating → panel → full tab), the stale persisted entity wins over the fresh ephemeral entity.
Impact: After a session's metadata changes (title, enhanced content, transcript word count) during an active chat, the context bar will display stale information that won't update until a new chat group is created.
Prompt for agents
In apps/desktop/src/store/zustand/chat-context.ts, the persistContext function's merge logic should prefer the new entities over the previously persisted ones for matching keys. Change the merge order: iterate over `entities` first (to get fresh data), then iterate over `prevEntities` (to retain previously accumulated entities that are no longer in the current set). This ensures that entities with updated data (same key) get the latest version while still accumulating context entities that may no longer be in the ephemeral set.
Alternatively, you could iterate `entities` first and `prevEntities` second:
for (const e of entities) { if (!seen.has(e.key)) { seen.add(e.key); merged.push(e); } }
for (const e of prevEntities) { if (!seen.has(e.key)) { seen.add(e.key); merged.push(e); } }
Was this helpful? React with 👍 or 👎 to provide feedback.
Made with Cursor