Skip to content

feat: add message retry and regenerate functionality#39

Open
Ashok161 wants to merge 2 commits intocodercops:devfrom
Ashok161:feat/issue-18-retry-regenerate
Open

feat: add message retry and regenerate functionality#39
Ashok161 wants to merge 2 commits intocodercops:devfrom
Ashok161:feat/issue-18-retry-regenerate

Conversation

@Ashok161
Copy link
Copy Markdown
Contributor

Summary

  • add retry buttons for error assistant messages and regenerate actions for the latest successful assistant reply
  • refactor widget sending so normal send, retry, and regenerate share the same streaming path and preserve history state
  • add server-side regenerate support by removing the previous assistant reply and avoiding duplicate user messages with stable message ids
  • add tests for message actions, widget retry/regenerate flows, conversation removal, and regenerate handling in the server

Verification

  • corepack pnpm --filter @chatcops/widget test
  • corepack pnpm --filter @chatcops/server test -- tests/handler.test.ts
  • corepack pnpm --filter @chatcops/core test -- tests/conversation/manager.test.ts
  • corepack pnpm -r typecheck
  • corepack pnpm --filter @chatcops/core build
  • corepack pnpm --filter @chatcops/widget build
  • corepack pnpm --filter @chatcops/server build

Closes #18

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

@Ashok161 is attempting to deploy a commit to the CODERCOPS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chatcops-website Ready Ready Preview, Comment Mar 27, 2026 1:54am

Request Review

@anurag629
Copy link
Copy Markdown
Member

Hey @Ashok161, this PR has merge conflicts with dev — likely from the tool timeout PR (#38) that was merged earlier. Can you rebase on latest dev and resolve the conflicts? Then I'll do a proper review.

git fetch upstream
git rebase upstream/dev
# resolve conflicts
git push --force-with-lease

@anurag629
Copy link
Copy Markdown
Member

Also one thing — as per our contributing guide, the workflow is to work directly on your fork's dev branch and PR from dev → upstream dev. Feature branches work too but keeping it on dev keeps things simpler. No need to change this PR, just for next time.

# Conflicts:
#	packages/server/tests/handler.test.ts
@Ashok161 Ashok161 force-pushed the feat/issue-18-retry-regenerate branch from 97ac7d8 to b650792 Compare March 25, 2026 05:59
@Ashok161
Copy link
Copy Markdown
Contributor Author

@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

Copy link
Copy Markdown
Member

@anurag629 anurag629 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@Ashok161 Ashok161 force-pushed the feat/issue-18-retry-regenerate branch from edcf6f7 to 3da6182 Compare April 4, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add message retry and regenerate functionality

2 participants