Skip to content

Commit

Permalink
fix: fully remove react-router now that it is unused (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhancock authored Feb 20, 2025
1 parent 353bf4c commit f509baf
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 431 deletions.
2 changes: 1 addition & 1 deletion ui/desktop/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const noWindowLocationHref = {
) {
context.report({
node,
message: 'Do not use window.location.href directly in Electron apps. Use React Router\'s navigate() instead.'
message: 'Do not use window.location.href directly in Electron apps. Use setView from the project instead'
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/desktop/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": {
"name": "Apache-2.0"
},
"version": "1.0.5"
"version": "1.0.7"
},
"paths": {
"/config": {
Expand Down
42 changes: 0 additions & 42 deletions ui/desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ui/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"react-dom": "^18.3.1",
"react-icons": "^5.3.0",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.28.0",
"react-select": "^5.9.0",
"react-syntax-highlighter": "^15.6.1",
"react-toastify": "^8.0.0",
Expand Down
5 changes: 2 additions & 3 deletions ui/desktop/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from 'react';
import { addExtensionFromDeepLink } from './extensions';
import { useNavigate } from 'react-router-dom';
import LauncherWindow from './LauncherWindow';
import ChatWindow from './ChatWindow';
import ErrorScreen from './components/ErrorScreen';
Expand All @@ -19,7 +18,7 @@ export default function App() {
const [isInstalling, setIsInstalling] = useState(false); // Track installation progress
const searchParams = new URLSearchParams(window.location.search);
const isLauncher = searchParams.get('window') === 'launcher';
const navigate = useNavigate();
const navigate = () => console.log('todo - bring back nav');

// Utility function to extract the command from the link
function extractCommand(link: string): string {
Expand Down Expand Up @@ -55,7 +54,7 @@ export default function App() {
console.log('Confirming installation for link:', pendingLink);

try {
await addExtensionFromDeepLink(pendingLink, navigate); // Proceed with adding the extension
await addExtensionFromDeepLink(pendingLink, navigate);
} catch (error) {
console.error('Failed to add extension:', error);
} finally {
Expand Down
14 changes: 0 additions & 14 deletions ui/desktop/src/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,6 @@ export default function ChatWindow() {
setupStoredProvider();
}, []);

// Render everything inside ChatLayout now
// We'll switch views inside the ChatLayout children.

// If we want to skip showing ChatLayout for the welcome screen, we can do so.
// But let's do exactly what's requested: put all view options under ChatLayout.

return (
<ChatLayout mode={mode}>
{/* Conditionally render based on `view` */}
Expand All @@ -395,14 +389,6 @@ export default function ChatWindow() {
setView={setView}
/>
)}
{view === 'configPage' && (
<ConfigPage
onClose={() => {
setView('chat');
}}
setView={setView}
/>
)}
{view === 'configureProviders' && (
<ConfigureProviders
onClose={() => {
Expand Down
150 changes: 0 additions & 150 deletions ui/desktop/src/ConfigTestingWindow.tsx

This file was deleted.

7 changes: 2 additions & 5 deletions ui/desktop/src/components/BottomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { useModel } from './settings/models/ModelContext';
import { useRecentModels } from './settings/models/RecentModels'; // Hook for recent models
import { Sliders } from 'lucide-react';
import { ModelRadioList } from './settings/models/ModelRadioList';
// Remove react-router-dom usage
// import { useNavigate } from 'react-router-dom';
import { Document, ChevronUp, ChevronDown } from './icons';
import type { View } from '../ChatWindow';

Expand All @@ -13,7 +11,7 @@ export default function BottomMenu({
setView,
}: {
hasMessages: boolean;
setView?: (view: View) => void;
setView: (view: View) => void;
}) {
const [isModelMenuOpen, setIsModelMenuOpen] = useState(false);
const { currentModel } = useModel();
Expand Down Expand Up @@ -133,8 +131,7 @@ export default function BottomMenu({
border-t border-borderSubtle mt-2"
onClick={() => {
setIsModelMenuOpen(false);
// Instead of navigate('/settings'), call setView('settings').
setView?.('settings');
setView('settings');
}}
>
<span className="text-sm">Tools and Settings</span>
Expand Down
11 changes: 2 additions & 9 deletions ui/desktop/src/components/MoreMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Popover, PopoverContent, PopoverTrigger, PopoverPortal } from '@radix-ui/react-popover';
import React, { useEffect, useState } from 'react';
import { FaMoon, FaSun } from 'react-icons/fa';
import VertDots from './ui/VertDots';
// Removed react-router-dom import
// import { useNavigate } from 'react-router-dom';
import { More } from './icons';
import { Settings, Grid, MessageSquare } from 'lucide-react';
import { Button } from './ui/button';
import type { View } from '../../ChatWindow';

interface VersionInfo {
Expand All @@ -15,7 +9,7 @@ interface VersionInfo {
}

// Accept setView as a prop from the parent (e.g. ChatContent)
export default function MoreMenu({ setView }: { setView?: (view: View) => void }) {
export default function MoreMenu({ setView }: { setView: (view: View) => void }) {
const [open, setOpen] = useState(false);
const [versions, setVersions] = useState<VersionInfo | null>(null);
const [showVersions, setShowVersions] = useState(false);
Expand Down Expand Up @@ -231,8 +225,7 @@ export default function MoreMenu({ setView }: { setView?: (view: View) => void }
<button
onClick={() => {
setOpen(false);
// Instead of navigate('/settings'), call setView to switch.
setView?.('settings');
setView('settings');
}}
className="w-full text-left p-2 text-sm hover:bg-bgSubtle transition-colors"
>
Expand Down
Loading

0 comments on commit f509baf

Please sign in to comment.