mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Fix lint issues (#65)
This commit is contained in:
parent
6f31e689de
commit
f3542a576f
@ -474,11 +474,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|||||||
{!rejectFormOpen && messageInput}
|
{!rejectFormOpen && messageInput}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{!chatStarted && (
|
{!chatStarted && <div className="flex justify-center gap-2">{ImportButtons(importChat)}</div>}
|
||||||
<div className="flex justify-center gap-2">
|
|
||||||
{ImportButtons(importChat)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!chatStarted &&
|
{!chatStarted &&
|
||||||
ExamplePrompts((event, messageInput) => {
|
ExamplePrompts((event, messageInput) => {
|
||||||
if (isStreaming) {
|
if (isStreaming) {
|
||||||
|
@ -201,6 +201,7 @@ export const ChatImpl = memo(
|
|||||||
// Load any repository in the initial messages.
|
// Load any repository in the initial messages.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const repositoryId = getMessagesRepositoryId(initialMessages);
|
const repositoryId = getMessagesRepositoryId(initialMessages);
|
||||||
|
|
||||||
if (repositoryId) {
|
if (repositoryId) {
|
||||||
simulationRepositoryUpdated(repositoryId);
|
simulationRepositoryUpdated(repositoryId);
|
||||||
}
|
}
|
||||||
@ -497,6 +498,7 @@ export const ChatImpl = memo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const previousRepositoryId = getPreviousRepositoryId(messages, messageIndex);
|
const previousRepositoryId = getPreviousRepositoryId(messages, messageIndex);
|
||||||
|
|
||||||
if (!previousRepositoryId) {
|
if (!previousRepositoryId) {
|
||||||
toast.error('No repository ID found for rewind');
|
toast.error('No repository ID found for rewind');
|
||||||
return;
|
return;
|
||||||
@ -547,10 +549,7 @@ export const ChatImpl = memo(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onRejectChange = async (
|
const onRejectChange = async (messageId: string, data: RejectChangeData) => {
|
||||||
messageId: string,
|
|
||||||
data: RejectChangeData,
|
|
||||||
) => {
|
|
||||||
console.log('RejectChange', messageId, data);
|
console.log('RejectChange', messageId, data);
|
||||||
|
|
||||||
setApproveChangesMessageId(undefined);
|
setApproveChangesMessageId(undefined);
|
||||||
|
@ -80,7 +80,7 @@ export const ImportFolderButton: React.FC<ImportFolderButtonProps> = ({ classNam
|
|||||||
}
|
}
|
||||||
|
|
||||||
const repositoryContents = await getFileRepositoryContents(textFiles);
|
const repositoryContents = await getFileRepositoryContents(textFiles);
|
||||||
const repositoryId = await createRepositoryImported("ImportFolder", repositoryContents);
|
const repositoryId = await createRepositoryImported('ImportFolder', repositoryContents);
|
||||||
|
|
||||||
const messages = createChatFromFolder(folderName, repositoryId);
|
const messages = createChatFromFolder(folderName, repositoryId);
|
||||||
|
|
||||||
|
@ -54,21 +54,21 @@ export const Messages = React.forwardRef<HTMLDivElement, MessagesProps>((props:
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{previousRepositoryId && repositoryId && onRewind && (
|
{previousRepositoryId && repositoryId && onRewind && (
|
||||||
<div className="flex gap-2 flex-col lg:flex-row">
|
<div className="flex gap-2 flex-col lg:flex-row">
|
||||||
<WithTooltip tooltip="Undo changes in this message">
|
<WithTooltip tooltip="Undo changes in this message">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onRewind(messageId);
|
onRewind(messageId);
|
||||||
}}
|
}}
|
||||||
key="i-ph:arrow-u-up-left"
|
key="i-ph:arrow-u-up-left"
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'i-ph:arrow-u-up-left',
|
'i-ph:arrow-u-up-left',
|
||||||
'text-xl text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary transition-colors',
|
'text-xl text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary transition-colors',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</WithTooltip>
|
</WithTooltip>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -3,22 +3,15 @@ import { useState, useEffect } from 'react';
|
|||||||
import { atom } from 'nanostores';
|
import { atom } from 'nanostores';
|
||||||
import type { Message as BaseMessage } from 'ai';
|
import type { Message as BaseMessage } from 'ai';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { workbenchStore } from '~/lib/stores/workbench';
|
|
||||||
import { logStore } from '~/lib/stores/logs'; // Import logStore
|
import { logStore } from '~/lib/stores/logs'; // Import logStore
|
||||||
import {
|
import { getMessages, getNextId, openDatabase, setMessages, duplicateChat, createChatFromMessages } from './db';
|
||||||
getMessages,
|
|
||||||
getNextId,
|
|
||||||
getUrlId,
|
|
||||||
openDatabase,
|
|
||||||
setMessages,
|
|
||||||
duplicateChat,
|
|
||||||
createChatFromMessages,
|
|
||||||
} from './db';
|
|
||||||
import { loadProblem } from '~/components/chat/LoadProblemButton';
|
import { loadProblem } from '~/components/chat/LoadProblemButton';
|
||||||
import { createAsyncSuspenseValue } from '~/lib/asyncSuspenseValue';
|
import { createAsyncSuspenseValue } from '~/lib/asyncSuspenseValue';
|
||||||
|
|
||||||
// Messages in a chat's history. The repository may update in response to changes in the messages.
|
/*
|
||||||
// Each message which changes the repository state must have a repositoryId.
|
* Messages in a chat's history. The repository may update in response to changes in the messages.
|
||||||
|
* Each message which changes the repository state must have a repositoryId.
|
||||||
|
*/
|
||||||
export interface Message extends BaseMessage {
|
export interface Message extends BaseMessage {
|
||||||
// Describes the state of the project after changes in this message were applied.
|
// Describes the state of the project after changes in this message were applied.
|
||||||
repositoryId?: string;
|
repositoryId?: string;
|
||||||
@ -193,6 +186,7 @@ function navigateChat(nextId: string) {
|
|||||||
export function getPreviousRepositoryId(messages: Message[], index: number): string | undefined {
|
export function getPreviousRepositoryId(messages: Message[], index: number): string | undefined {
|
||||||
for (let i = index - 1; i >= 0; i--) {
|
for (let i = index - 1; i >= 0; i--) {
|
||||||
const message = messages[i];
|
const message = messages[i];
|
||||||
|
|
||||||
if (message.repositoryId) {
|
if (message.repositoryId) {
|
||||||
return message.repositoryId;
|
return message.repositoryId;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import { sendCommandDedicatedClient } from "./ReplayProtocolClient";
|
import { sendCommandDedicatedClient } from './ReplayProtocolClient';
|
||||||
|
|
||||||
// Get the contents of a repository as a base64 string of the zip file.
|
// Get the contents of a repository as a base64 string of the zip file.
|
||||||
export async function getRepositoryContents(repositoryId: string): Promise<string> {
|
export async function getRepositoryContents(repositoryId: string): Promise<string> {
|
||||||
const rv = await sendCommandDedicatedClient({
|
const rv = (await sendCommandDedicatedClient({
|
||||||
method: 'Nut.getRepository',
|
method: 'Nut.getRepository',
|
||||||
params: { repositoryId },
|
params: { repositoryId },
|
||||||
}) as { repositoryContents: string };
|
})) as { repositoryContents: string };
|
||||||
return rv.repositoryContents;
|
return rv.repositoryContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remotely create an imported repository from the given contents.
|
// Remotely create an imported repository from the given contents.
|
||||||
export async function createRepositoryImported(reason: string, repositoryContents: string): Promise<string> {
|
export async function createRepositoryImported(reason: string, repositoryContents: string): Promise<string> {
|
||||||
const rv = await sendCommandDedicatedClient({
|
const rv = (await sendCommandDedicatedClient({
|
||||||
method: 'Nut.createRepository',
|
method: 'Nut.createRepository',
|
||||||
params: {
|
params: {
|
||||||
repositoryContents,
|
repositoryContents,
|
||||||
@ -20,6 +20,6 @@ export async function createRepositoryImported(reason: string, repositoryContent
|
|||||||
reason,
|
reason,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}) as { repositoryId: string };
|
})) as { repositoryId: string };
|
||||||
return rv.repositoryId;
|
return rv.repositoryId;
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,12 @@ interface SimulationPacketServerURL {
|
|||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulation data specifying a repository ID to set up a dev server
|
/*
|
||||||
// for static resources and any initial database contents.
|
* Simulation data specifying a repository ID to set up a dev server
|
||||||
|
* for static resources and any initial database contents.
|
||||||
|
*/
|
||||||
interface SimulationPacketRepositoryId {
|
interface SimulationPacketRepositoryId {
|
||||||
kind: "repositoryId";
|
kind: 'repositoryId';
|
||||||
repositoryId: string;
|
repositoryId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,6 +486,10 @@ Focus specifically on fixing this bug. Do not guess about other problems.
|
|||||||
content: systemPrompt,
|
content: systemPrompt,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { repositoryId } = await gChatManager.sendChatMessage('developer', protocolMessages, { baseRepositoryId, onResponsePart });
|
const { repositoryId } = await gChatManager.sendChatMessage('developer', protocolMessages, {
|
||||||
|
baseRepositoryId,
|
||||||
|
onResponsePart,
|
||||||
|
});
|
||||||
|
|
||||||
return repositoryId;
|
return repositoryId;
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,16 @@ export async function getFileRepositoryContents(files: File[]): Promise<string>
|
|||||||
);
|
);
|
||||||
|
|
||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
|
|
||||||
for (const { path, content } of artifacts) {
|
for (const { path, content } of artifacts) {
|
||||||
zip.file(path, content);
|
zip.file(path, content);
|
||||||
}
|
}
|
||||||
return await zip.generateAsync({ type: "base64" });
|
|
||||||
|
return await zip.generateAsync({ type: 'base64' });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createChatFromFolder(
|
export function createChatFromFolder(folderName: string, repositoryId: string): Message[] {
|
||||||
folderName: string,
|
const filesContent = `I've imported the contents of the "${folderName}" folder.`;
|
||||||
repositoryId: string
|
|
||||||
): Message[] {
|
|
||||||
let filesContent = `I've imported the contents of the "${folderName}" folder.`;
|
|
||||||
|
|
||||||
const userMessage: Message = {
|
const userMessage: Message = {
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
Loading…
Reference in New Issue
Block a user