Repository navigation
[5246] fix(frontend): keep the agent chat draft when committing a revision - #5250
Conversation
…ision The revision-change effect in AgentConversation called stripProvenance.clear(), which empties the composer text as well as the template chip. A commit swaps the panel's entityId (old revision -> new revision), so the effect fired and wiped whatever the user was typing. Use the existing clearProvenance() primitive (drops the chip only) for the revision swap, leaving the in-progress draft intact. clear() is still used on the legitimate post-send/commit paths where the text should go.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe template provenance hook now exposes a provenance-only clearing callback. Agent conversation entity changes use it to remove the template chip while preserving the composer draft. ChangesTemplate provenance reset
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
web/oss/src/components/TemplateStrip/hooks/useTemplateProvenance.tsx (1)
36-38: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for the two clearing behaviors.
Verify that
clearProvenance()removes the selected template without callingcomposerApi.setText, whileclear()still clears both provenance and composer text. This directly protects the draft-preservation fix.Also applies to: 128-128
web/oss/src/components/AgentChatSlice/AgentConversation.tsx (1)
622-626: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd an entity-change regression test.
Mount the conversation with a non-empty draft and selected provenance, change
entityId, then assert that the draft remains while the provenance selection is cleared. This validates the hook/caller contract behind issue#5246.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d4ac6edb-e065-4ee0-ad21-e4f244707b0c
📒 Files selected for processing (2)
web/oss/src/components/AgentChatSlice/AgentConversation.tsxweb/oss/src/components/TemplateStrip/hooks/useTemplateProvenance.tsx
What
Fixes #5246 — committing a new revision in the agent playground clears the message the user is currently typing.
Root cause
The composer draft is stored per session (
composerDraftBySession[sessionId]), a key that is stable across commits, andAgentConversationstays mounted through a commit — only itsentityIdprop swaps (old revision → new revision). So the draft loss was not a remount.The culprit is a reset effect that runs on every
entityIdchange:Its intent is only to reset the template provenance chip so a template name picked against the old revision doesn't leak into the new one. But
clear()does more than that — it also runssetText("")on the composer, emptying the Lexical editor:So: commit →
entityIdswaps → effect fires →clear()→ the user's draft is nuked. The agent's owncommit_revisiontool takes the sameswitchEntitypath, so it blanked the box mid-conversation too.Fix
The hook already had the right primitive —
clearProvenance()("Drop provenance without touching composer text") — it just wasn't exposed on the public API. Two small edits:clearProvenancefromuseTemplateProvenance(return + type).stripProvenance.clearProvenance()instead ofclear().This preserves the effect's real purpose (reset the template chip on revision swap) while leaving the in-progress draft intact. The legitimate
clear()calls on the post-send / post-commit paths (where the composer should empty) are unchanged.Testing