feat: make user made changes persistent after reload (#1387)

* feat: save user made changes persistent

* fix: remove artifact from user message on the UI

* fix: message Id generation fix
This commit is contained in:
Anirban Kar
2025-02-27 13:34:57 +05:30
committed by GitHub
parent a33a1268c3
commit b98485d99f
6 changed files with 58 additions and 10 deletions

View File

@@ -25,6 +25,7 @@ import { createSampler } from '~/utils/sampler';
import { getTemplates, selectStarterTemplate } from '~/utils/selectStarterTemplate';
import { logStore } from '~/lib/stores/logs';
import { streamingState } from '~/lib/stores/streaming';
import { filesToArtifacts } from '~/utils/fileUtils';
const toastAnimation = cssTransition({
enter: 'animated fadeInRight',
@@ -320,17 +321,17 @@ export const ChatImpl = memo(
const { assistantMessage, userMessage } = temResp;
setMessages([
{
id: `${new Date().getTime()}`,
id: `1-${new Date().getTime()}`,
role: 'user',
content: messageContent,
},
{
id: `${new Date().getTime()}`,
id: `2-${new Date().getTime()}`,
role: 'assistant',
content: assistantMessage,
},
{
id: `${new Date().getTime()}`,
id: `3-${new Date().getTime()}`,
role: 'user',
content: `[Model: ${model}]\n\n[Provider: ${provider.name}]\n\n${userMessage}`,
annotations: ['hidden'],
@@ -371,17 +372,18 @@ export const ChatImpl = memo(
setMessages(messages.slice(0, -1));
}
const fileModifications = workbenchStore.getFileModifcations();
const modifiedFiles = workbenchStore.getModifiedFiles();
chatStore.setKey('aborted', false);
if (fileModifications !== undefined) {
if (modifiedFiles !== undefined) {
const userUpdateArtifact = filesToArtifacts(modifiedFiles, `${Date.now()}`);
append({
role: 'user',
content: [
{
type: 'text',
text: `[Model: ${model}]\n\n[Provider: ${provider.name}]\n\n${messageContent}`,
text: `[Model: ${model}]\n\n[Provider: ${provider.name}]\n\n${userUpdateArtifact}${messageContent}`,
},
...imageDataList.map((imageData) => ({
type: 'image',