feat(gateway): add web UI with dashboard and chat interface
Refactor GatewayServer to serve HTTP and WebSocket on a shared http.Server. Add static file serving with path traversal protection, a dark-themed dashboard (system health, sessions, tools) and a WebSocket chat interface with streaming tool events and markdown rendering.
This commit is contained in:
@@ -0,0 +1,532 @@
|
||||
/* ==========================================================================
|
||||
Flynn Gateway — Shared Dark Theme
|
||||
Terminal-aesthetic dark theme used by chat.html and index.html (dashboard).
|
||||
========================================================================== */
|
||||
|
||||
/* ---------- CSS Custom Properties (Design Tokens) ---------- */
|
||||
:root {
|
||||
--bg-primary: #0d1117;
|
||||
--bg-secondary: #161b22;
|
||||
--bg-tertiary: #1c2128;
|
||||
--bg-input: #0d1117;
|
||||
|
||||
--text-primary: #c9d1d9;
|
||||
--text-secondary: #8b949e;
|
||||
--text-muted: #6e7681;
|
||||
|
||||
--accent: #58a6ff;
|
||||
--accent-muted: rgba(88, 166, 255, 0.15);
|
||||
|
||||
--error: #f85149;
|
||||
--error-muted: rgba(248, 81, 73, 0.15);
|
||||
|
||||
--success: #3fb950;
|
||||
--success-muted: rgba(63, 185, 80, 0.15);
|
||||
|
||||
--warning: #d29922;
|
||||
|
||||
--border: #30363d;
|
||||
--border-light: #21262d;
|
||||
|
||||
--font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
|
||||
--font-size-base: 14px;
|
||||
--font-size-sm: 12px;
|
||||
--font-size-lg: 18px;
|
||||
--font-size-xl: 24px;
|
||||
|
||||
--line-height: 1.55;
|
||||
--radius: 6px;
|
||||
--radius-lg: 10px;
|
||||
--container-max: 900px;
|
||||
|
||||
--transition: 150ms ease;
|
||||
}
|
||||
|
||||
/* ---------- Reset ---------- */
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* ---------- Base ---------- */
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden; /* Pages handle their own scrolling */
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-base);
|
||||
line-height: var(--line-height);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
/* ---------- Links ---------- */
|
||||
a {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
transition: opacity var(--transition);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
opacity: 0.8;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* ---------- Container ---------- */
|
||||
.container {
|
||||
max-width: var(--container-max);
|
||||
margin: 0 auto;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
/* ---------- Header ---------- */
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
header h1 {
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
header #status {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
header #status.connected {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
header #status.disconnected,
|
||||
header #status.status-error {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
header #status.status-ok {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
/* ---------- Scrollbar (Webkit) ---------- */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Chat-Specific Styles
|
||||
========================================================================== */
|
||||
|
||||
/* Chat layout — full viewport flex column */
|
||||
.chat-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
max-width: var(--container-max);
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* Scrollable message area */
|
||||
.messages {
|
||||
flex: 1 1 0;
|
||||
overflow-y: auto;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* Individual message bubble */
|
||||
.message {
|
||||
padding: 10px 14px;
|
||||
border-radius: var(--radius);
|
||||
max-width: 85%;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
font-size: var(--font-size-base);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
/* User messages — right-aligned with accent tint */
|
||||
.message.user {
|
||||
align-self: flex-end;
|
||||
background-color: var(--accent-muted);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid rgba(88, 166, 255, 0.25);
|
||||
}
|
||||
|
||||
/* Assistant messages — left-aligned with subtle bg */
|
||||
.message.assistant {
|
||||
align-self: flex-start;
|
||||
background-color: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-light);
|
||||
}
|
||||
|
||||
/* Error messages */
|
||||
.message.error {
|
||||
align-self: flex-start;
|
||||
background-color: var(--error-muted);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid rgba(248, 81, 73, 0.35);
|
||||
}
|
||||
|
||||
/* Input area — fixed at the bottom of chat */
|
||||
.input-area {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
background-color: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.input-area input {
|
||||
flex: 1 1 0;
|
||||
padding: 10px 12px;
|
||||
background-color: var(--bg-input);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-base);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
outline: none;
|
||||
transition: border-color var(--transition);
|
||||
}
|
||||
|
||||
.input-area input::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.input-area input:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.input-area button {
|
||||
padding: 10px 18px;
|
||||
background-color: var(--accent);
|
||||
color: var(--bg-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-base);
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
transition: opacity var(--transition);
|
||||
}
|
||||
|
||||
.input-area button:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.input-area button:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Dashboard-Specific Styles
|
||||
========================================================================== */
|
||||
|
||||
/* Dashboard layout — grid of cards */
|
||||
.dashboard {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: 16px;
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
/* Section headings in dashboard page */
|
||||
.container > section {
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.container > section > h2 {
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* Dashboard header — spans full width */
|
||||
.dashboard-header {
|
||||
grid-column: 1 / -1;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.dashboard-header h1 {
|
||||
font-size: var(--font-size-xl);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Card component */
|
||||
.card {
|
||||
background-color: var(--bg-secondary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 16px;
|
||||
transition: border-color var(--transition);
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
border-color: var(--text-muted);
|
||||
}
|
||||
|
||||
.card h2 {
|
||||
font-size: var(--font-size-base);
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.card .value {
|
||||
font-size: var(--font-size-xl);
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.card .label {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-muted);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Status indicators */
|
||||
.status-ok {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.status-error {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.status-warning {
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.status-dot.ok {
|
||||
background-color: var(--success);
|
||||
}
|
||||
|
||||
.status-dot.error {
|
||||
background-color: var(--error);
|
||||
}
|
||||
|
||||
.status-dot.warning {
|
||||
background-color: var(--warning);
|
||||
}
|
||||
|
||||
/* Session list */
|
||||
.session-list {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.session-list li {
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid var(--border-light);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.session-list li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.session-list li a {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
/* Tool list */
|
||||
.tool-list {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.tool-list li {
|
||||
padding: 6px 0;
|
||||
border-bottom: 1px solid var(--border-light);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.tool-list li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Utility Classes
|
||||
========================================================================== */
|
||||
|
||||
/* Tool event display — monospace block for tool_start / tool_end */
|
||||
.tool-event {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
background-color: var(--bg-tertiary);
|
||||
color: var(--text-muted);
|
||||
border: 1px solid var(--border-light);
|
||||
border-radius: var(--radius);
|
||||
padding: 8px 10px;
|
||||
margin: 4px 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* CSS spinner animation */
|
||||
.spinner {
|
||||
display: inline-block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: 2px solid var(--border);
|
||||
border-top-color: var(--accent);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Hidden utility */
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Text utilities */
|
||||
.text-muted {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.text-secondary {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.text-accent {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.text-error {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.text-success {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.text-sm {
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.text-lg {
|
||||
font-size: var(--font-size-lg);
|
||||
}
|
||||
|
||||
/* Badges */
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
font-size: var(--font-size-sm);
|
||||
border-radius: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge.ok {
|
||||
background-color: var(--success-muted);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.badge.error {
|
||||
background-color: var(--error-muted);
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Responsive — Small Screens (<600px)
|
||||
========================================================================== */
|
||||
@media (max-width: 600px) {
|
||||
.container {
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.messages {
|
||||
padding: 10px 8px;
|
||||
}
|
||||
|
||||
.message {
|
||||
max-width: 95%;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
.input-area {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.input-area input {
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
.input-area button {
|
||||
padding: 8px 14px;
|
||||
}
|
||||
|
||||
.dashboard {
|
||||
grid-template-columns: 1fr;
|
||||
padding: 16px 8px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.card .value {
|
||||
font-size: var(--font-size-lg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user