feat: App shell with login, session sidebar, chat panel, right panel

- Create RightPanel component with browser/artifacts tab switching
- Replace App.tsx with 3-column layout (auth loading/login/app states)
- Replace main.tsx with globals.css import (remove index.css)
- Remove Vite template files (App.css, index.css, assets/react.svg)
- Fix LoginPage.tsx FormEvent type-only import for verbatimModuleSyntax
- Fix vite.config.ts to use vitest/config for proper test property typing
- Add tests: RightPanel (10 tests), App rendering states (7 tests)
This commit is contained in:
Ken
2026-05-26 19:34:07 +00:00
parent 3b01753336
commit 3723c5bf93
10 changed files with 272 additions and 415 deletions
+41 -114
View File
@@ -1,121 +1,48 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from './assets/vite.svg'
import heroImg from './assets/hero.png'
import './App.css'
import { useAuth } from './hooks/useAuth'
import { useSessions } from './hooks/useSessions'
import { useChat } from './hooks/useChat'
import { LoginPage } from './components/LoginPage'
import { SessionSidebar } from './components/SessionSidebar'
import { ChatPanel } from './components/ChatPanel'
import { RightPanel } from './components/RightPanel'
function App() {
const [count, setCount] = useState(0)
const { user, loading: authLoading, login, logout } = useAuth()
const { sessions, activeSessionId, createNew, switchTo, refresh } = useSessions()
const { messages, isStreaming, sendMessage } = useChat(activeSessionId)
if (authLoading) {
return (
<div className='login-page'>
<div style={{ color: '#8888aa' }}>Loading...</div>
</div>
)
}
if (!user) {
return <LoginPage onLogin={login} />
}
return (
<>
<section id="center">
<div className="hero">
<img src={heroImg} className="base" width="170" height="179" alt="" />
<img src={reactLogo} className="framework" alt="React logo" />
<img src={viteLogo} className="vite" alt="Vite logo" />
</div>
<div>
<h1>Get started</h1>
<p>
Edit <code>src/App.tsx</code> and save to test <code>HMR</code>
</p>
</div>
<button
type="button"
className="counter"
onClick={() => setCount((count) => count + 1)}
>
Count is {count}
</button>
</section>
<div className="ticks"></div>
<section id="next-steps">
<div id="docs">
<svg className="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#documentation-icon"></use>
</svg>
<h2>Documentation</h2>
<p>Your questions, answered</p>
<ul>
<li>
<a href="https://vite.dev/" target="_blank">
<img className="logo" src={viteLogo} alt="" />
Explore Vite
</a>
</li>
<li>
<a href="https://react.dev/" target="_blank">
<img className="button-icon" src={reactLogo} alt="" />
Learn more
</a>
</li>
</ul>
</div>
<div id="social">
<svg className="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#social-icon"></use>
</svg>
<h2>Connect with us</h2>
<p>Join the Vite community</p>
<ul>
<li>
<a href="https://github.com/vitejs/vite" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#github-icon"></use>
</svg>
GitHub
</a>
</li>
<li>
<a href="https://chat.vite.dev/" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#discord-icon"></use>
</svg>
Discord
</a>
</li>
<li>
<a href="https://x.com/vite_js" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#x-icon"></use>
</svg>
X.com
</a>
</li>
<li>
<a href="https://bsky.app/profile/vite.dev" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#bluesky-icon"></use>
</svg>
Bluesky
</a>
</li>
</ul>
</div>
</section>
<div className="ticks"></div>
<section id="spacer"></section>
</>
<div className='app-layout'>
<SessionSidebar
sessions={sessions}
activeSessionId={activeSessionId}
onSelect={(id) => switchTo(id)}
onCreate={async () => {
await createNew()
await refresh()
}}
onLogout={logout}
/>
<ChatPanel
messages={messages}
isStreaming={isStreaming}
onSend={sendMessage}
sessionId={activeSessionId}
/>
<RightPanel sessionId={activeSessionId} />
</div>
)
}