Fix lint issues (#65)

This commit is contained in:
Brian Hackett 2025-03-14 17:12:54 -07:00 committed by GitHub
parent 6f31e689de
commit f3542a576f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 46 additions and 52 deletions

View File

@ -474,11 +474,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
{!rejectFormOpen && messageInput}
</div>
</div>
{!chatStarted && (
<div className="flex justify-center gap-2">
{ImportButtons(importChat)}
</div>
)}
{!chatStarted && <div className="flex justify-center gap-2">{ImportButtons(importChat)}</div>}
{!chatStarted &&
ExamplePrompts((event, messageInput) => {
if (isStreaming) {

View File

@ -201,6 +201,7 @@ export const ChatImpl = memo(
// Load any repository in the initial messages.
useEffect(() => {
const repositoryId = getMessagesRepositoryId(initialMessages);
if (repositoryId) {
simulationRepositoryUpdated(repositoryId);
}
@ -497,6 +498,7 @@ export const ChatImpl = memo(
}
const previousRepositoryId = getPreviousRepositoryId(messages, messageIndex);
if (!previousRepositoryId) {
toast.error('No repository ID found for rewind');
return;
@ -547,10 +549,7 @@ export const ChatImpl = memo(
});
};
const onRejectChange = async (
messageId: string,
data: RejectChangeData,
) => {
const onRejectChange = async (messageId: string, data: RejectChangeData) => {
console.log('RejectChange', messageId, data);
setApproveChangesMessageId(undefined);

View File

@ -80,7 +80,7 @@ export const ImportFolderButton: React.FC<ImportFolderButtonProps> = ({ classNam
}
const repositoryContents = await getFileRepositoryContents(textFiles);
const repositoryId = await createRepositoryImported("ImportFolder", repositoryContents);
const repositoryId = await createRepositoryImported('ImportFolder', repositoryContents);
const messages = createChatFromFolder(folderName, repositoryId);

View File

@ -3,22 +3,15 @@ import { useState, useEffect } from 'react';
import { atom } from 'nanostores';
import type { Message as BaseMessage } from 'ai';
import { toast } from 'react-toastify';
import { workbenchStore } from '~/lib/stores/workbench';
import { logStore } from '~/lib/stores/logs'; // Import logStore
import {
getMessages,
getNextId,
getUrlId,
openDatabase,
setMessages,
duplicateChat,
createChatFromMessages,
} from './db';
import { getMessages, getNextId, openDatabase, setMessages, duplicateChat, createChatFromMessages } from './db';
import { loadProblem } from '~/components/chat/LoadProblemButton';
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 {
// Describes the state of the project after changes in this message were applied.
repositoryId?: string;
@ -193,6 +186,7 @@ function navigateChat(nextId: string) {
export function getPreviousRepositoryId(messages: Message[], index: number): string | undefined {
for (let i = index - 1; i >= 0; i--) {
const message = messages[i];
if (message.repositoryId) {
return message.repositoryId;
}

View File

@ -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.
export async function getRepositoryContents(repositoryId: string): Promise<string> {
const rv = await sendCommandDedicatedClient({
const rv = (await sendCommandDedicatedClient({
method: 'Nut.getRepository',
params: { repositoryId },
}) as { repositoryContents: string };
})) as { repositoryContents: string };
return rv.repositoryContents;
}
// Remotely create an imported repository from the given contents.
export async function createRepositoryImported(reason: string, repositoryContents: string): Promise<string> {
const rv = await sendCommandDedicatedClient({
const rv = (await sendCommandDedicatedClient({
method: 'Nut.createRepository',
params: {
repositoryContents,
@ -20,6 +20,6 @@ export async function createRepositoryImported(reason: string, repositoryContent
reason,
},
},
}) as { repositoryId: string };
})) as { repositoryId: string };
return rv.repositoryId;
}

View File

@ -8,10 +8,12 @@ interface SimulationPacketServerURL {
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 {
kind: "repositoryId";
kind: 'repositoryId';
repositoryId: string;
}

View File

@ -486,6 +486,10 @@ Focus specifically on fixing this bug. Do not guess about other problems.
content: systemPrompt,
});
const { repositoryId } = await gChatManager.sendChatMessage('developer', protocolMessages, { baseRepositoryId, onResponsePart });
const { repositoryId } = await gChatManager.sendChatMessage('developer', protocolMessages, {
baseRepositoryId,
onResponsePart,
});
return repositoryId;
}

View File

@ -28,17 +28,16 @@ export async function getFileRepositoryContents(files: File[]): Promise<string>
);
const zip = new JSZip();
for (const { path, content } of artifacts) {
zip.file(path, content);
}
return await zip.generateAsync({ type: "base64" });
return await zip.generateAsync({ type: 'base64' });
}
export function createChatFromFolder(
folderName: string,
repositoryId: string
): Message[] {
let filesContent = `I've imported the contents of the "${folderName}" folder.`;
export function createChatFromFolder(folderName: string, repositoryId: string): Message[] {
const filesContent = `I've imported the contents of the "${folderName}" folder.`;
const userMessage: Message = {
role: 'user',