feat: standalone web UI (React + Vite)
React + TypeScript UI on port 5274. Connects to local daemon via WebSocket IPC (DaemonAdapter). Full chat layout with sidebar, message pane, and peer list. Mirrors the TUI feature set. - src/types.ts — IPC types mirroring proto.go - src/adapter/daemon — WebSocket IPC adapter with auto-reconnect - src/store/index.ts — Zustand store; handles all daemon events - src/pages/ — Onboarding (connect + join) and Chat - src/components/ — Sidebar, MessagePane, PeerList Dev: cd web && npm run dev (port 5274) Build: cd web && npm run build Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
46
web/src/components/Sidebar.tsx
Normal file
46
web/src/components/Sidebar.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { useWaste } from '../store'
|
||||
|
||||
export function Sidebar() {
|
||||
const { localPeer, networks, activeNetworkId, activeRoom, setActiveRoom, setActiveNetwork, messages } = useWaste()
|
||||
|
||||
// Rooms = general + any DM threads that have messages
|
||||
const rooms = ['general']
|
||||
Object.keys(messages).forEach(r => {
|
||||
if (r.startsWith('dm:') && !rooms.includes(r)) rooms.push(r)
|
||||
})
|
||||
|
||||
return (
|
||||
<nav className="sidebar">
|
||||
<div className="sidebar-identity">
|
||||
<span className="alias">{localPeer?.alias}</span>
|
||||
<span className="peer-id">{localPeer?.id.slice(0, 8)}…</span>
|
||||
</div>
|
||||
|
||||
<div className="sidebar-section">
|
||||
<span className="sidebar-label">Networks</span>
|
||||
{networks.map(n => (
|
||||
<button
|
||||
key={n.network_id}
|
||||
className={`sidebar-item ${n.network_id === activeNetworkId ? 'active' : ''}`}
|
||||
onClick={() => setActiveNetwork(n.network_id)}
|
||||
>
|
||||
{n.network_name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="sidebar-section">
|
||||
<span className="sidebar-label">Rooms</span>
|
||||
{rooms.map(r => (
|
||||
<button
|
||||
key={r}
|
||||
className={`sidebar-item ${r === activeRoom ? 'active' : ''}`}
|
||||
onClick={() => setActiveRoom(r)}
|
||||
>
|
||||
{r.startsWith('dm:') ? `@ ${r.slice(3, 11)}…` : `# ${r}`}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user