Skip to content

Commit 5773b1e

Browse files
authored
Merge pull request #676 from Stijnus/main
Added some small UI enhancements to the Settings and Sidebar
2 parents 78cd04a + d479daa commit 5773b1e

33 files changed

+1094
-84
lines changed

.husky/pre-commit

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,42 @@
22

33
echo "🔍 Running pre-commit hook to check the code looks good... 🔍"
44

5+
# Load NVM if available (useful for managing Node.js versions)
56
export NVM_DIR="$HOME/.nvm"
6-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm if you're using i
7+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
78

8-
echo "Running typecheck..."
9-
which pnpm
9+
# Ensure `pnpm` is available
10+
echo "Checking if pnpm is available..."
11+
if ! command -v pnpm >/dev/null 2>&1; then
12+
echo "❌ pnpm not found! Please ensure pnpm is installed and available in PATH."
13+
exit 1
14+
fi
1015

16+
# Run typecheck
17+
echo "Running typecheck..."
1118
if ! pnpm typecheck; then
12-
echo "❌ Type checking failed! Please review TypeScript types."
13-
echo "Once you're done, don't forget to add your changes to the commit! 🚀"
14-
echo "Typecheck exit code: $?"
15-
exit 1
19+
echo "❌ Type checking failed! Please review TypeScript types."
20+
echo "Once you're done, don't forget to add your changes to the commit! 🚀"
21+
exit 1
1622
fi
1723

24+
# Run lint
1825
echo "Running lint..."
1926
if ! pnpm lint; then
20-
echo "❌ Linting failed! 'pnpm lint:fix' will help you fix the easy ones."
27+
echo "❌ Linting failed! Run 'pnpm lint:fix' to fix the easy issues."
2128
echo "Once you're done, don't forget to add your beautification to the commit! 🤩"
22-
echo "lint exit code: $?"
2329
exit 1
2430
fi
2531

26-
echo "👍 All good! Committing changes..."
32+
# Update commit.json with the latest commit hash
33+
echo "Updating commit.json with the latest commit hash..."
34+
COMMIT_HASH=$(git rev-parse HEAD)
35+
if [ $? -ne 0 ]; then
36+
echo "❌ Failed to get commit hash. Ensure you are in a git repository."
37+
exit 1
38+
fi
39+
40+
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
41+
git add app/commit.json
42+
43+
echo "👍 All checks passed! Committing changes..."

app/commit.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
{ "commit": "eeafc12522b184dcbded28c5c6606e4a23e6849f" }
2+

app/components/chat/ImportFolderButton.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Message } from 'ai';
33
import { toast } from 'react-toastify';
44
import { MAX_FILES, isBinaryFile, shouldIncludeFile } from '~/utils/fileUtils';
55
import { createChatFromFolder } from '~/utils/folderImport';
6+
import { logStore } from '~/lib/stores/logs'; // Assuming logStore is imported from this location
67

78
interface ImportFolderButtonProps {
89
className?: string;
@@ -16,9 +17,15 @@ export const ImportFolderButton: React.FC<ImportFolderButtonProps> = ({ classNam
1617
const allFiles = Array.from(e.target.files || []);
1718

1819
if (allFiles.length > MAX_FILES) {
20+
const error = new Error(`Too many files: ${allFiles.length}`);
21+
logStore.logError('File import failed - too many files', error, {
22+
fileCount: allFiles.length,
23+
maxFiles: MAX_FILES,
24+
});
1925
toast.error(
2026
`This folder contains ${allFiles.length.toLocaleString()} files. This product is not yet optimized for very large projects. Please select a folder with fewer than ${MAX_FILES.toLocaleString()} files.`,
2127
);
28+
2229
return;
2330
}
2431

@@ -31,7 +38,10 @@ export const ImportFolderButton: React.FC<ImportFolderButtonProps> = ({ classNam
3138
const filteredFiles = allFiles.filter((file) => shouldIncludeFile(file.webkitRelativePath));
3239

3340
if (filteredFiles.length === 0) {
41+
const error = new Error('No valid files found');
42+
logStore.logError('File import failed - no valid files', error, { folderName });
3443
toast.error('No files found in the selected folder');
44+
3545
return;
3646
}
3747

@@ -48,11 +58,18 @@ export const ImportFolderButton: React.FC<ImportFolderButtonProps> = ({ classNam
4858
.map((f) => f.file.webkitRelativePath.split('/').slice(1).join('/'));
4959

5060
if (textFiles.length === 0) {
61+
const error = new Error('No text files found');
62+
logStore.logError('File import failed - no text files', error, { folderName });
5163
toast.error('No text files found in the selected folder');
64+
5265
return;
5366
}
5467

5568
if (binaryFilePaths.length > 0) {
69+
logStore.logWarning(`Skipping binary files during import`, {
70+
folderName,
71+
binaryCount: binaryFilePaths.length,
72+
});
5673
toast.info(`Skipping ${binaryFilePaths.length} binary files`);
5774
}
5875

@@ -62,8 +79,14 @@ export const ImportFolderButton: React.FC<ImportFolderButtonProps> = ({ classNam
6279
await importChat(folderName, [...messages]);
6380
}
6481

82+
logStore.logSystem('Folder imported successfully', {
83+
folderName,
84+
textFileCount: textFiles.length,
85+
binaryFileCount: binaryFilePaths.length,
86+
});
6587
toast.success('Folder imported successfully');
6688
} catch (error) {
89+
logStore.logError('Failed to import folder', error, { folderName });
6790
console.error('Failed to import folder:', error);
6891
toast.error('Failed to import folder');
6992
} finally {

app/components/settings/SettingsWindow.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ import ProvidersTab from './providers/ProvidersTab';
1010
import { useSettings } from '~/lib/hooks/useSettings';
1111
import FeaturesTab from './features/FeaturesTab';
1212
import DebugTab from './debug/DebugTab';
13+
import EventLogsTab from './event-logs/EventLogsTab';
1314
import ConnectionsTab from './connections/ConnectionsTab';
1415

1516
interface SettingsProps {
1617
open: boolean;
1718
onClose: () => void;
1819
}
1920

20-
type TabType = 'chat-history' | 'providers' | 'features' | 'debug' | 'connection';
21+
type TabType = 'chat-history' | 'providers' | 'features' | 'debug' | 'event-logs' | 'connection';
2122

22-
// Providers that support base URL configuration
2323
export const SettingsWindow = ({ open, onClose }: SettingsProps) => {
24-
const { debug } = useSettings();
24+
const { debug, eventLogs } = useSettings();
2525
const [activeTab, setActiveTab] = useState<TabType>('chat-history');
2626

2727
const tabs: { id: TabType; label: string; icon: string; component?: ReactElement }[] = [
@@ -39,6 +39,16 @@ export const SettingsWindow = ({ open, onClose }: SettingsProps) => {
3939
},
4040
]
4141
: []),
42+
...(eventLogs
43+
? [
44+
{
45+
id: 'event-logs' as TabType,
46+
label: 'Event Logs',
47+
icon: 'i-ph:list-bullets',
48+
component: <EventLogsTab />,
49+
},
50+
]
51+
: []),
4252
];
4353

4454
return (

app/components/settings/chat-history/ChatHistoryTab.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { toast } from 'react-toastify';
44
import { db, deleteById, getAll } from '~/lib/persistence';
55
import { classNames } from '~/utils/classNames';
66
import styles from '~/components/settings/Settings.module.scss';
7+
import { logStore } from '~/lib/stores/logs'; // Import logStore for event logging
78

89
export default function ChatHistoryTab() {
910
const navigate = useNavigate();
@@ -22,21 +23,23 @@ export default function ChatHistoryTab() {
2223

2324
const handleDeleteAllChats = async () => {
2425
if (!db) {
26+
const error = new Error('Database is not available');
27+
logStore.logError('Failed to delete chats - DB unavailable', error);
2528
toast.error('Database is not available');
29+
2630
return;
2731
}
2832

2933
try {
3034
setIsDeleting(true);
3135

3236
const allChats = await getAll(db);
33-
34-
// Delete all chats one by one
3537
await Promise.all(allChats.map((chat) => deleteById(db!, chat.id)));
36-
38+
logStore.logSystem('All chats deleted successfully', { count: allChats.length });
3739
toast.success('All chats deleted successfully');
3840
navigate('/', { replace: true });
3941
} catch (error) {
42+
logStore.logError('Failed to delete chats', error);
4043
toast.error('Failed to delete chats');
4144
console.error(error);
4245
} finally {
@@ -46,7 +49,10 @@ export default function ChatHistoryTab() {
4649

4750
const handleExportAllChats = async () => {
4851
if (!db) {
52+
const error = new Error('Database is not available');
53+
logStore.logError('Failed to export chats - DB unavailable', error);
4954
toast.error('Database is not available');
55+
5056
return;
5157
}
5258

@@ -58,8 +64,10 @@ export default function ChatHistoryTab() {
5864
};
5965

6066
downloadAsJson(exportData, `all-chats-${new Date().toISOString()}.json`);
67+
logStore.logSystem('Chats exported successfully', { count: allChats.length });
6168
toast.success('Chats exported successfully');
6269
} catch (error) {
70+
logStore.logError('Failed to export chats', error);
6371
toast.error('Failed to export chats');
6472
console.error(error);
6573
}

app/components/settings/connections/ConnectionsTab.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react';
22
import { toast } from 'react-toastify';
33
import Cookies from 'js-cookie';
4+
import { logStore } from '~/lib/stores/logs';
45

56
export default function ConnectionsTab() {
67
const [githubUsername, setGithubUsername] = useState(Cookies.get('githubUsername') || '');
@@ -9,6 +10,10 @@ export default function ConnectionsTab() {
910
const handleSaveConnection = () => {
1011
Cookies.set('githubUsername', githubUsername);
1112
Cookies.set('githubToken', githubToken);
13+
logStore.logSystem('GitHub connection settings updated', {
14+
username: githubUsername,
15+
hasToken: !!githubToken,
16+
});
1217
toast.success('GitHub credentials saved successfully!');
1318
};
1419

0 commit comments

Comments
 (0)