Hide details of Nut's behavior by default (#113)

This commit is contained in:
Brian Hackett
2025-05-06 11:16:27 -10:00
committed by GitHub
parent 721ed2c5aa
commit e90b0bbff9
7 changed files with 229 additions and 75 deletions

View File

@@ -1,10 +1,10 @@
import { useState, useMemo, useCallback } from 'react';
import { debounce } from '~/utils/debounce';
import type { ChatContents } from '~/lib/persistence/chats';
import type { ChatSummary } from '~/lib/persistence/chats';
interface UseSearchFilterOptions {
items: ChatContents[];
searchFields?: (keyof ChatContents)[];
items: ChatSummary[];
searchFields?: (keyof ChatSummary)[];
debounceMs?: number;
}

View File

@@ -8,11 +8,25 @@ import { getMessagesRepositoryId, type Message } from './message';
import { assert } from '~/lib/replay/ReplayProtocolClient';
import type { DeploySettingsDatabase } from '~/lib/replay/Deploy';
export interface ChatContents {
export interface ChatSummary {
id: string;
createdAt: string;
updatedAt: string;
title: string;
}
const CHAT_SUMMARY_COLUMNS = ['id', 'created_at', 'updated_at', 'title', 'deleted'].join(',');
function databaseRowToChatSummary(d: any): ChatSummary {
return {
id: d.id,
createdAt: d.created_at,
updatedAt: d.updated_at,
title: d.title,
};
}
export interface ChatContents extends ChatSummary {
repositoryId: string | undefined;
messages: Message[];
lastProtocolChatId: string | undefined;
@@ -21,10 +35,7 @@ export interface ChatContents {
function databaseRowToChatContents(d: any): ChatContents {
return {
id: d.id,
createdAt: d.created_at,
updatedAt: d.updated_at,
title: d.title,
...databaseRowToChatSummary(d),
messages: d.messages,
repositoryId: d.repository_id,
lastProtocolChatId: d.last_protocol_chat_id,
@@ -55,20 +66,20 @@ function setLocalChats(chats: ChatContents[] | undefined): void {
// delete finishes.
const deletedChats = new Set<string>();
async function getAllChats(): Promise<ChatContents[]> {
async function getAllChats(): Promise<ChatSummary[]> {
const userId = await getCurrentUserId();
if (!userId) {
return getLocalChats();
}
const { data, error } = await getSupabase().from('chats').select('*').eq('deleted', false);
const { data, error } = await getSupabase().from('chats').select(CHAT_SUMMARY_COLUMNS).eq('deleted', false);
if (error) {
throw error;
}
const chats = data.map(databaseRowToChatContents);
const chats = data.map(databaseRowToChatSummary);
return chats.filter((chat) => !deletedChats.has(chat.id));
}

View File

@@ -9,6 +9,7 @@ interface MessageBase {
role: MessageRole;
repositoryId?: string;
peanuts?: number;
category?: string;
// Not part of the protocol, indicates whether the user has explicitly approved
// the message. Once approved, the approve/reject UI is not shown again for the message.
@@ -67,3 +68,33 @@ export function createMessagesForRepository(title: string, repositoryId: string)
return messages;
}
export enum PlaywrightTestStatus {
Pass = 'Pass',
Fail = 'Fail',
NotRun = 'NotRun',
}
export interface PlaywrightTestResult {
title: string;
status: PlaywrightTestStatus;
recordingId?: string;
}
export function parseTestResultsMessage(contents: string): PlaywrightTestResult[] {
const results: PlaywrightTestResult[] = [];
const lines = contents.split('\n');
for (const line of lines) {
const match = line.match(/TestResult (.*?) (.*?) (.*)/);
if (!match) {
continue;
}
const [status, recordingId, title] = match.slice(1);
results.push({
status: status as PlaywrightTestStatus,
title,
recordingId: recordingId == 'NoRecording' ? undefined : recordingId,
});
}
return results;
}