Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions ui/desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const isLauncher = searchParams.get('window') === 'launcher';

useEffect(() => {
const handleFatalError = (_: any, errorMessage: string) => {

Check warning on line 12 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
setFatalError(errorMessage);
};

Expand All @@ -25,9 +25,5 @@
return <ErrorScreen error={fatalError} onReload={() => window.electron.reloadApp()} />;
}

if (isLauncher) {
return <LauncherWindow />;
} else {
return <ChatWindow />;
}
return isLauncher ? <LauncherWindow /> : <ChatWindow />;
}
4 changes: 2 additions & 2 deletions ui/desktop/src/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
chats,
setChats,
selectedChatId,
setSelectedChatId,

Check warning on line 42 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / build

'setSelectedChatId' is defined but never used. Allowed unused args must match /^_/u
initialQuery,
setProgressMessage,
setWorking,
Expand Down Expand Up @@ -81,7 +81,7 @@
setWorking(Working.Working);
}
},
onFinish: async (message, options) => {

Check warning on line 84 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / build

'options' is defined but never used. Allowed unused args must match /^_/u
setProgressMessage('Task finished. Click here to expand.');
setWorking(Working.Idle);

Expand All @@ -104,7 +104,7 @@
c.id === selectedChatId ? { ...c, messages } : c
);
setChats(updatedChats);
}, [messages, selectedChatId]);

Check warning on line 107 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has missing dependencies: 'chats' and 'setChats'. Either include them or remove the dependency array. If 'setChats' changes too often, find the parent component that defines it and wrap that definition in useCallback

const initialQueryAppended = useRef(false);
useEffect(() => {
Expand All @@ -112,7 +112,7 @@
append({ role: 'user', content: initialQuery });
initialQueryAppended.current = true;
}
}, [initialQuery]);

Check warning on line 115 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has a missing dependency: 'append'. Either include it or remove the dependency array

useEffect(() => {
if (messages.length > 0) {
Expand Down Expand Up @@ -190,8 +190,8 @@
};

return (
<div className="chat-content flex flex-col w-screen h-screen items-center justify-center p-[10px]">
<div className="relative block h-[20px] w-screen">
<div className="chat-content flex flex-col w-full h-screen items-center justify-center p-[10px]">
<div className="relative block h-[20px] w-full">
<MoreMenu />
</div>
<Card className="flex flex-col flex-1 h-[calc(100vh-95px)] w-full bg-card-gradient dark:bg-dark-card-gradient mt-0 border-none rounded-2xl relative">
Expand Down
4 changes: 2 additions & 2 deletions ui/desktop/src/components/UserMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function UserMessage({ message }) {
const urls = extractUrls(message.content, []);

return (
<div className="flex justify-end mb-[16px]">
<div className="flex-col max-w-[90%]">
<div className="flex justify-end mb-[16px] w-full">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change make every user message the full width of the chat space?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution would be max-w-full if so and we don't want that. This would let a single word message like "hi" have a small bubble, but constrain maximum width.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no doesn't make it full width

<div className="flex-col max-w-[85%]">
<div className="flex bg-user-bubble dark:bg-user-bubble-dark text-goose-text-light dark:text-goose-text-light-dark rounded-2xl p-4">
<MarkdownContent
content={message.content}
Expand Down
75 changes: 72 additions & 3 deletions ui/desktop/src/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,79 @@ import ReactDOM from 'react-dom/client'
import { BrowserRouter as Router } from 'react-router-dom'
import App from './App'

// Error Boundary Component
class ErrorBoundary extends React.Component<
{ children: React.ReactNode },
{ hasError: boolean }
> {
constructor(props: { children: React.ReactNode }) {
super(props)
this.state = { hasError: false }
}

static getDerivedStateFromError(_: Error) {
return { hasError: true }
}

componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
// Send error to main process
window.electron.logInfo(`[ERROR] ${error.toString()}\n${errorInfo.componentStack}`)
}

render() {
if (this.state.hasError) {
return <h1>Something went wrong.</h1>
}

return this.props.children
}
}

// Set up console interceptors
const originalConsole = {
log: console.log,
error: console.error,
warn: console.warn,
info: console.info,
}

// Intercept console methods
console.log = (...args) => {
window.electron.logInfo(`[LOG] ${args.join(' ')}`)
originalConsole.log(...args)
}

console.error = (...args) => {
window.electron.logInfo(`[ERROR] ${args.join(' ')}`)
originalConsole.error(...args)
}

console.warn = (...args) => {
window.electron.logInfo(`[WARN] ${args.join(' ')}`)
originalConsole.warn(...args)
}

console.info = (...args) => {
window.electron.logInfo(`[INFO] ${args.join(' ')}`)
originalConsole.info(...args)
}

// Capture unhandled promise rejections
window.addEventListener('unhandledrejection', (event) => {
window.electron.logInfo(`[UNHANDLED REJECTION] ${event.reason}`)
})

// Capture global errors
window.addEventListener('error', (event) => {
window.electron.logInfo(`[GLOBAL ERROR] ${event.message} at ${event.filename}:${event.lineno}:${event.colno}`)
})

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<Router>
<App />
</Router>
<ErrorBoundary>
<Router>
<App />
</Router>
</ErrorBoundary>
</React.StrictMode>,
)
Loading