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} {!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) {

View File

@ -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);

View File

@ -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);

View File

@ -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;
} }

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. // 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;
} }

View File

@ -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;
} }

View File

@ -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;
} }

View File

@ -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',