UI overhaul: dark theme, tabs, sidebar cards, message style toggle

This commit is contained in:
Clay 2026-12-02 23:03:23 -05:00
parent 145e2b48e0
commit 23ccd6d03c
6 changed files with 288 additions and 77 deletions

View file

@ -48,6 +48,7 @@ Against local open-oscar-server 0.25.0 with `DISABLE_AUTH=true`, TOC listener 98
## Current blockers / environment notes
- **TOC 980 root cause (fixed 2026-12-02):** `src/toc.js` `roastPassword` incorrectly prepended `00 02` before XORing. open-oscar-server `wire.RoastTOCPassword` XORs the full payload with `Tic/Toc` and does not strip a prefix, so the extra bytes corrupted the cleartext and caused 980 on real-auth servers. Fixed by removing the prefix. Verified: local auth-enabled oscar-server and remote `oscar.claytonia.net:9898` both sign on with `steve/please` (`SIGN_ON:TOC2.0`).
- **UI overhaul (initial, 2026-12-02):** dark theme, sidebar sections as cards, conversations moved to tabs above chat window, message style toggle (Bubbles/Classic AIM-IRC) persisted in localStorage. Local static assets only, no build step.
- **Web API chat unavailable on 0.25.0:** do not rely on `/chat/*` Web API endpoints on this server. TOC is the working transport for chat/invites.
- **TOC is HTTP-mixed on 9898:** normal HTTP clients get 404; TOC clients must send `FLAPON\r\n\r\n` first. Any proxy in front of 9898 must pass raw TCP.
- **No reliable all-users list:** Management API not exposed; `memberDir/search` returned empty. UI has direct "Start IM by screen name" flow.
@ -84,13 +85,12 @@ Against local open-oscar-server 0.25.0 with `DISABLE_AUTH=true`, TOC listener 98
## Needs to be done next
1. **Unblock remote auth:** clear/unlock `8520258` sessions on OSCAR server; re-verify Web API and TOC login.
2. **Remote TOC e2e:** after auth fixed, test IM, chat join, invite, accept, chat send against `oscar.claytonia.net:9898` from web UI.
3. **Harden TOC client:** handle reconnect/backoff, keepalive timeout, parse CONFIG2 buddy list properly, handle TOC1/TOC2 variants, handle chat errors/room not found.
4. **Decide Web API vs TOC responsibility:** currently TOC preferred for IM/chat when connected; Web API still used for buddylist/presence/profile where it works. Make this explicit and test fallback.
1. **UI polish follow-up:** refine dark theme/tabs/cards as needed, add tab close buttons, unread indicators, chat room membership/leave/invite-send UI, better mobile layout.
2. **Harden TOC client:** handle reconnect/backoff, keepalive timeout, parse CONFIG2 buddy list properly, handle TOC1/TOC2 variants, handle chat errors/room not found.
3. **Chat UX:** show chat room membership, leave button, invite-send UI, better system messages, error states.
4. **Web API vs TOC responsibility:** currently TOC preferred for IM/chat when connected; Web API still used for buddylist/presence/profile where it works. Make this explicit and test fallback.
5. **User list UX:** no management API. Keep direct screen-name open; consider caching known buddies/recent contacts locally in browser.
6. **UI polish:** show chat room membership, leave button, invite-send UI, better system messages, error states.
7. **M5:** systemd service, env file permissions, nginx/certbot review, CSP/rate-limit review.
6. **M5:** systemd service, env file permissions, nginx/certbot review, CSP/rate-limit review.
## Files of interest

View file

@ -13,6 +13,7 @@ Plan for a small browser chat client for our Open OSCAR Server, built on Node 20
- **Implementation pivot:** added `src/toc.js` (FLAP/TOC2 client) and `src/toc-session.js` (SSE bridge). Auth can log in via Web API, TOC, or both; messages/chat prefer TOC when connected.
- **Remote blocker:** temp account `8520258`/`please` currently rejected by both Web API (3011) and TOC (980). Needs server-side session clear/unlock before remote e2e.
- **User list:** no Management API exposed; `memberDir/search` not a reliable all-users source. UI provides direct "Start IM by screen name".
- **UI overhaul requested:** dark theme; conversations as tabs on top of chat window; left sidebar sections as cards; message style toggle (bubbles vs old-school AIM/IRC). Local static assets only, no build step.
## 1. Goal and scope

View file

@ -264,6 +264,12 @@ document.getElementById('logoutBtn').addEventListener('click', async () => {
ui.showLogin();
});
document.getElementById('styleToggleBtn').addEventListener('click', () => {
const next = ui.getMessageStyle() === 'classic' ? 'bubbles' : 'classic';
ui.setMessageStyle(next);
ui.renderMessages(state);
});
document.getElementById('messageForm').addEventListener('submit', async (e) => {
e.preventDefault();
ui.setChatError('');
@ -363,6 +369,7 @@ async function loadBuddies() {
async function afterLogin(screenName) {
state.screenName = screenName;
ui.showChat(screenName);
ui.setMessageStyle(ui.getMessageStyle());
ui.setTocStatus(false);
ui.renderConversations(state);
ui.renderMessages(state);

View file

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Web OSCAR Chat</title>
<link rel="stylesheet" href="/style.css?v=11">
<link rel="stylesheet" href="/style.css?v=12">
</head>
<body>
<div id="app">
@ -12,7 +12,10 @@
<div class="brand">Web OSCAR Chat</div>
<div id="tocStatus" class="toc-status hidden" title="TOC disconnected"><span class="dot dot-off"></span><span class="toc-label">TOC</span></div>
<div id="me" class="me"></div>
<button id="logoutBtn" class="hidden" type="button">Log out</button>
<div class="topbar-actions">
<button id="styleToggleBtn" class="ghost-btn hidden" type="button" title="Toggle message style">Bubbles</button>
<button id="logoutBtn" class="hidden" type="button">Log out</button>
</div>
</header>
<div id="broadcastBanner" class="banner hidden" role="status"></div>
@ -30,13 +33,8 @@
</section>
<section id="chatView" class="chat-layout hidden">
<aside class="sidebar panel">
<div class="sidebar-section">
<h2>Conversations</h2>
<ul id="conversations" class="list"></ul>
</div>
<div class="sidebar-section">
<aside class="sidebar">
<div class="card sidebar-section">
<h2>Start IM</h2>
<form id="userSearchForm" class="inline-form">
<input id="userSearch" placeholder="Screen name" aria-label="Screen name">
@ -45,7 +43,7 @@
<ul id="userResults" class="list"></ul>
</div>
<div class="sidebar-section">
<div class="card sidebar-section">
<h2>Buddies</h2>
<form id="addBuddyForm" class="inline-form">
<input id="buddyName" placeholder="Screen name" aria-label="Buddy screen name">
@ -54,7 +52,7 @@
<ul id="buddies" class="list"></ul>
</div>
<div class="sidebar-section">
<div class="card sidebar-section">
<h2>Rooms</h2>
<form id="joinRoomForm" class="inline-form">
<input id="roomName" placeholder="Room name" aria-label="Room name">
@ -62,16 +60,21 @@
</form>
</div>
<div class="sidebar-section">
<div class="card sidebar-section">
<h2>Invites</h2>
<ul id="invites" class="list"></ul>
</div>
</aside>
<section class="panel chat-panel">
<div class="tabs-bar">
<ul id="conversations" class="tabs"></ul>
</div>
<div class="chat-header">
<h2 id="chatTitle">No conversation selected</h2>
<div id="chatMeta" class="muted"></div>
<div>
<h2 id="chatTitle">No conversation selected</h2>
<div id="chatMeta" class="muted"></div>
</div>
</div>
<div id="messages" class="messages" aria-live="polite"></div>
<form id="messageForm" class="message-form">
@ -84,6 +87,6 @@
</main>
</div>
<script type="module" src="/app.js?v=11"></script>
<script type="module" src="/app.js?v=12"></script>
</body>
</html>

View file

@ -15,11 +15,33 @@ function button(label, onClick, { active = false } = {}) {
return b;
}
const MSG_STYLE_KEY = 'oscar.msgStyle';
export function getMessageStyle() {
const v = localStorage.getItem(MSG_STYLE_KEY);
return v === 'classic' ? 'classic' : 'bubbles';
}
export function setMessageStyle(style) {
const v = style === 'classic' ? 'classic' : 'bubbles';
localStorage.setItem(MSG_STYLE_KEY, v);
applyMessageStyle();
const btn = document.getElementById('styleToggleBtn');
if (btn) btn.textContent = v === 'classic' ? 'Classic' : 'Bubbles';
}
export function applyMessageStyle() {
const box = document.getElementById('messages');
if (!box) return;
const style = getMessageStyle();
box.classList.toggle('style-bubbles', style === 'bubbles');
box.classList.toggle('style-classic', style === 'classic');
}
export function showLogin() {
el('loginView').classList.remove('hidden');
el('chatView').classList.add('hidden');
el('logoutBtn').classList.add('hidden');
el('tocStatus').classList.add('hidden');
const styleBtn = document.getElementById('styleToggleBtn');
if (styleBtn) styleBtn.classList.add('hidden');
el('me').textContent = '';
}
@ -28,6 +50,8 @@ export function showChat(screenName) {
el('chatView').classList.remove('hidden');
el('logoutBtn').classList.remove('hidden');
el('tocStatus').classList.remove('hidden');
const styleBtn = document.getElementById('styleToggleBtn');
if (styleBtn) styleBtn.classList.remove('hidden');
el('me').textContent = `Signed in as ${screenName}`;
}
@ -64,6 +88,7 @@ export function renderMessages(state) {
el('chatMeta').textContent = conv ? (conv.type === 'chat' ? 'Chat room' : 'Direct message') : '';
const box = el('messages');
applyMessageStyle();
clear(box);
if (!conv) return;
for (const msg of conv.messages) {
@ -73,7 +98,10 @@ export function renderMessages(state) {
const meta = document.createElement('div');
meta.className = 'meta';
const when = msg.time ? new Date(msg.time).toLocaleTimeString() : '';
meta.textContent = `${msg.from || 'unknown'}${when ? ' · ' + when : ''}`;
const from = msg.from || 'unknown';
meta.textContent = getMessageStyle() === 'classic'
? `[${when || ''}] <${from}>`
: `${from}${when ? ' · ' + when : ''}`;
const body = document.createElement('div');
body.className = 'body';

View file

@ -1,82 +1,254 @@
:root {
--bg: #f4f1ea;
--panel: #fffdf8;
--border: #d8d0c0;
--text: #1f1b16;
--muted: #6b6257;
--accent: #0a5f59;
--accent-soft: #dcefeb;
--danger: #9b2c2c;
--shadow: 0 1px 2px rgba(0,0,0,0.04);
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
color: var(--text);
background: linear-gradient(180deg, #efe8da 0%, var(--bg) 100%);
--bg: #121418;
--bg-soft: #181b21;
--panel: #1d2129;
--panel-2: #232834;
--border: #31394a;
--text: #e8edf3;
--muted: #9aa7b8;
--accent: #4da3ff;
--accent-soft: rgba(77, 163, 255, 0.15);
--danger: #ff6b6b;
--ok: #2ecc71;
--shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
--radius: 12px;
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
--sans: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
html, body { height: 100%; }
body {
margin: 0;
font-family: var(--sans);
background: linear-gradient(180deg, #101318 0%, var(--bg) 100%);
color: var(--text);
}
input, button {
font: inherit;
border-radius: 8px;
border: 1px solid var(--border);
padding: 0.55rem 0.75rem;
}
input {
background: #151922;
color: var(--text);
width: 100%;
}
input:focus, button:focus {
outline: 2px solid rgba(77,163,255,0.35);
outline-offset: 1px;
border-color: var(--accent);
}
button {
cursor: pointer; border: 1px solid var(--accent); background: var(--accent);
color: white; padding: 0.45rem 0.75rem; border-radius: 6px;
cursor: pointer;
background: var(--accent);
color: #08111d;
border-color: var(--accent);
font-weight: 600;
}
button:hover { filter: brightness(1.05); }
input {
width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border);
border-radius: 6px; background: white;
.ghost-btn {
background: transparent;
color: var(--text);
border-color: var(--border);
}
.ghost-btn:hover { background: var(--panel-2); }
.topbar {
display: flex; gap: 1rem; align-items: center; padding: 0.75rem 1rem;
border-bottom: 1px solid var(--border); background: rgba(255,253,248,0.9);
position: sticky; top: 0; backdrop-filter: blur(4px);
display: flex;
align-items: center;
gap: 1rem;
padding: 0.9rem 1rem;
border-bottom: 1px solid var(--border);
background: rgba(20, 24, 31, 0.95);
backdrop-filter: blur(6px);
position: sticky;
top: 0;
z-index: 10;
}
.brand { font-weight: 700; }
.me { margin-left: auto; color: var(--muted); font-size: 0.95rem; }
main { padding: 1rem; max-width: 1400px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.2px; }
.me { margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }
main { padding: 1rem; max-width: 1600px; margin: 0 auto; }
.panel {
background: var(--panel); border: 1px solid var(--border);
border-radius: 10px; box-shadow: var(--shadow);
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
}
.login-panel { max-width: 420px; margin: 4rem auto; padding: 1.25rem; }
.card {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.login-panel { max-width: 440px; margin: 4rem auto; padding: 1.25rem; }
.login-panel form { display: grid; gap: 0.75rem; }
.login-panel label { display: grid; gap: 0.3rem; font-size: 0.95rem; }
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; min-height: calc(100vh - 8rem); }
.sidebar { padding: 0.75rem; overflow: auto; }
.sidebar-section + .sidebar-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.sidebar h2, .chat-header h2 { margin: 0 0 0.5rem 0; font-size: 1rem; }
.list { list-style: none; padding: 0; margin: 0.5rem 0 0 0; display: grid; gap: 0.25rem; }
.list button {
width: 100%; text-align: left; background: transparent; color: var(--text);
border: 1px solid transparent; padding: 0.4rem 0.5rem;
.login-panel label { display: grid; gap: 0.3rem; font-size: 0.95rem; color: var(--muted); }
.login-panel h1 { margin-top: 0; margin-bottom: 0.25rem; }
.chat-layout {
display: grid;
grid-template-columns: 320px 1fr;
gap: 1rem;
min-height: calc(100vh - 8rem);
}
.list button:hover, .list button.active { background: var(--accent-soft); border-color: #bfd9d5; }
.sidebar { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.sidebar-section { padding: 0.9rem; }
.sidebar-section h2, .chat-header h2 { margin: 0 0 0.65rem 0; font-size: 0.95rem; color: #dce6f2; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }
.chat-panel { display: grid; grid-template-rows: auto 1fr auto auto; min-height: 60vh; }
.chat-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.messages { padding: 1rem; overflow: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.msg { max-width: 70ch; padding: 0.5rem 0.65rem; border-radius: 8px; background: #f2ede2; }
.msg.me { align-self: flex-end; background: #dcefeb; }
.msg .meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.15rem; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.message-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; padding: 0.75rem 1rem 0; border-top: 1px solid var(--border); }
.list { list-style: none; padding: 0; margin: 0.6rem 0 0 0; display: grid; gap: 0.35rem; }
.list button {
width: 100%;
text-align: left;
background: transparent;
color: var(--text);
border: 1px solid transparent;
padding: 0.45rem 0.55rem;
font-weight: 500;
}
.list button:hover, .list button.active {
background: var(--accent-soft);
border-color: rgba(77,163,255,0.3);
color: #fff;
}
.chat-panel {
display: grid;
grid-template-rows: auto auto 1fr auto auto;
min-height: 60vh;
min-width: 0;
}
.tabs-bar {
border-bottom: 1px solid var(--border);
background: rgba(0,0,0,0.08);
border-radius: var(--radius) var(--radius) 0 0;
overflow-x: auto;
}
.tabs {
list-style: none;
margin: 0;
padding: 0.5rem 0.5rem 0;
display: flex;
gap: 0.35rem;
min-width: max-content;
}
.tabs li { margin: 0; }
.tabs button {
background: transparent;
color: var(--muted);
border: 1px solid transparent;
border-bottom: none;
border-radius: 8px 8px 0 0;
padding: 0.5rem 0.75rem;
font-weight: 500;
max-width: 220px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tabs button:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tabs button.active {
color: var(--text);
background: var(--panel);
border-color: var(--border);
border-bottom: 1px solid var(--panel);
margin-bottom: -1px;
}
.chat-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.chat-header h2 { margin: 0; font-size: 1rem; }
.messages {
padding: 1rem;
overflow: auto;
display: flex;
flex-direction: column;
gap: 0.5rem;
background: #171b22;
}
/* Classic AIM/IRC style */
.messages.style-classic .msg {
max-width: 100%;
padding: 0.1rem 0;
background: transparent;
border: none;
}
.messages.style-classic .msg .meta {
display: inline;
margin-right: 0.4rem;
color: var(--muted);
font-size: 0.85rem;
font-family: var(--mono);
}
.messages.style-classic .msg .body {
display: inline;
white-space: pre-wrap;
word-break: break-word;
font-family: var(--mono);
font-size: 0.93rem;
}
.messages.style-classic .msg.me .meta,
.messages.style-classic .msg.me .body { color: #8ec5ff; }
/* Bubble style */
.messages.style-bubbles .msg {
max-width: min(70ch, 85%);
padding: 0.55rem 0.75rem;
border-radius: 14px;
background: #2a3140;
border: 1px solid #364055;
}
.messages.style-bubbles .msg.me {
align-self: flex-end;
background: #1f4b7a;
border-color: #2d639e;
}
.messages.style-bubbles .msg .meta {
font-size: 0.72rem;
color: var(--muted);
margin-bottom: 0.2rem;
}
.messages.style-bubbles .msg.me .meta { color: #bfdcff; }
.messages.style-bubbles .msg .body { white-space: pre-wrap; word-break: break-word; }
.message-form {
display: grid;
grid-template-columns: 1fr auto;
gap: 0.5rem;
padding: 0.75rem 1rem 0;
border-top: 1px solid var(--border);
}
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); min-height: 1.2em; margin: 0.5rem 1rem 0.75rem; font-size: 0.9rem; }
.banner {
margin: 0.75rem 1rem 0; padding: 0.6rem 0.75rem; background: #fff4cc;
border: 1px solid #ecd88f; border-radius: 8px; color: #5f4b00;
margin: 0.75rem 1rem 0;
padding: 0.6rem 0.75rem;
background: #3a3118;
border: 1px solid #6f5a1d;
border-radius: 8px;
color: #ffe8a3;
}
.hidden { display: none !important; }
@media (max-width: 900px) {
.chat-layout { grid-template-columns: 1fr; }
.chat-panel { min-height: 50vh; }
}
.invite { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem; background: #fff; display: grid; gap: 0.3rem; }
.invite { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; background: var(--panel-2); display: grid; gap: 0.35rem; }
.invite .meta { font-size: 0.8rem; color: var(--muted); }
.invite-actions { display: flex; gap: 0.5rem; }
.invite-actions button { padding: 0.25rem 0.5rem; font-size: 0.85rem; }
.invite-actions button { padding: 0.25rem 0.55rem; font-size: 0.85rem; }
.toc-status { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 1rem; font-size: 0.85rem; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-on { background: #2ecc71; box-shadow: 0 0 0 2px rgba(46,204,113,0.2); }
.dot-on { background: var(--ok); box-shadow: 0 0 0 2px rgba(46,204,113,0.2); }
.dot-off { background: #e74c3c; box-shadow: 0 0 0 2px rgba(231,76,60,0.2); }
.toc-label { font-size: 0.8rem; }
@media (max-width: 980px) {
.chat-layout { grid-template-columns: 1fr; }
.sidebar { order: 2; }
.chat-panel { min-height: 55vh; }
}