feat: add message retry and regenerate functionality#39
feat: add message retry and regenerate functionality#39Ashok161 wants to merge 2 commits intocodercops:devfrom
Conversation
|
@Ashok161 is attempting to deploy a commit to the CODERCOPS Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Also one thing — as per our contributing guide, the workflow is to work directly on your fork's |
# Conflicts: # packages/server/tests/handler.test.ts
97ac7d8 to
b650792
Compare
|
@anurag629 I was following the guide, but then I was working on multiple PR's so I thought of using custom branch name's. I will follow the guide from next and try to work on one issue at a time |
anurag629
left a comment
There was a problem hiding this comment.
Good work on this @Ashok161, the retry and regenerate logic is well thought out. The retryRequests Map for preserving request context across retries is a nice touch. Found a couple of things that need fixing before we merge this.
| id: string; | ||
| role: 'user' | 'assistant'; | ||
| content: string; | ||
| status?: 'streaming' | 'complete' | 'error'; |
There was a problem hiding this comment.
So right now error messages with status: 'error' are getting saved to localStorage. If someone gets an error and refreshes the page, they'll see the error bubble with a retry button — but the retry won't work because retryRequests is an in-memory Map and it gets cleared on refresh.
The simplest fix would be to filter out error messages when saving:
messages: this.messages.filter(m => m.status !== 'error').map(...)Or if you want retry to survive refresh, you'd need to persist the retry context too, but I think filtering them out is the cleaner approach.
| @@ -1,36 +1,50 @@ | |||
| import { renderMarkdown } from '../markdown.js'; | |||
|
|
|||
| const RETRY_ICON = '<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M17.65 6.35A7.96 7.96 0 0012 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0112 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>'; | |||
There was a problem hiding this comment.
Both RETRY_ICON and REGENERATE_ICON are the same SVG. You can just use one shared constant instead of duplicating it. Or better, use different icons so the user can visually tell the difference between retry (error recovery) and regenerate (get a new response).
edcf6f7 to
3da6182
Compare
Summary
Verification
Closes #18