← back to Slack Dm Viewer

claude-steve.html

362 lines

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Claude + Steve | Message Viewer</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  <style>
    :root {
      --bg-primary: #0a0a0f;
      --bg-secondary: #111118;
      --bg-card: #16161f;
      --bg-hover: #1c1c28;
      --border: #252535;
      --border-accent: #3b3b55;
      --text-primary: #e8e8f0;
      --text-secondary: #8888a0;
      --text-muted: #555568;
      --accent: #6c5ce7;
      --accent-light: #a29bfe;
      --accent-glow: rgba(108,92,231,0.15);
      --green: #00b894;
      --red: #e17055;
      --link: #74b9ff;
      --radius: 12px;
      --radius-sm: 8px;
      --radius-xs: 4px;
      --shadow: 0 4px 24px rgba(0,0,0,0.3);
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      background: var(--bg-primary); color: var(--text-primary);
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      min-height: 100vh; overflow-x: hidden;
    }
    body::before {
      content: ''; position: fixed; top: -200px; left: 50%; transform: translateX(-50%);
      width: 800px; height: 600px;
      background: radial-gradient(ellipse, rgba(108,92,231,0.06) 0%, transparent 70%);
      pointer-events: none; z-index: 0;
    }
    .topnav {
      position: sticky; top: 0; z-index: 100;
      background: rgba(10,10,15,0.85); backdrop-filter: blur(20px);
      border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px;
      display: flex; align-items: center; justify-content: space-between;
    }
    .topnav-left { display: flex; align-items: center; gap: 12px; }
    .topnav-logo {
      width: 32px; height: 32px; border-radius: 8px;
      background: linear-gradient(135deg, var(--accent), #8b5cf6);
      display: flex; align-items: center; justify-content: center;
      font-size: 16px; font-weight: 700; color: #fff;
      box-shadow: 0 0 20px rgba(108,92,231,0.3);
    }
    .topnav-title { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; }
    .topnav-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
    .topnav-right { display: flex; align-items: center; gap: 10px; }
    .badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; letter-spacing: 0.3px; }
    .badge-live { background: rgba(0,184,148,0.15); color: var(--green); }
    .badge-count { background: var(--accent-glow); color: var(--accent-light); }
    .btn {
      padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
      background: var(--bg-card); color: var(--text-primary); font-size: 12px;
      font-weight: 500; cursor: pointer; transition: all 0.2s; font-family: inherit;
    }
    .btn:hover { background: var(--bg-hover); border-color: var(--border-accent); }
    .btn:disabled { opacity: 0.4; cursor: not-allowed; }
    .search-bar {
      background: var(--bg-secondary); border-bottom: 1px solid var(--border);
      padding: 10px 24px; display: flex; align-items: center; gap: 10px;
    }
    .search-wrap { flex: 1; position: relative; }
    .search-wrap .s-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }
    .search-wrap input {
      width: 100%; padding: 9px 12px 9px 36px; background: var(--bg-card);
      border: 1px solid var(--border); border-radius: var(--radius-sm);
      color: var(--text-primary); font-size: 13px; font-family: inherit; outline: none;
    }
    .search-wrap input:focus { border-color: var(--accent); }
    .search-wrap input::placeholder { color: var(--text-muted); }
    .filter-chip {
      padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border);
      background: transparent; color: var(--text-secondary); font-size: 12px;
      cursor: pointer; transition: all 0.2s; font-family: inherit; white-space: nowrap;
    }
    .filter-chip:hover, .filter-chip.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent-light); }
    .main { max-width: 820px; margin: 0 auto; padding: 16px 20px 80px; position: relative; z-index: 1; }
    .date-divider { display: flex; align-items: center; gap: 16px; margin: 24px 0 12px; }
    .date-divider::before, .date-divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); }
    .date-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
    .msg { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius); transition: background 0.15s; margin-bottom: 2px; }
    .msg:hover { background: var(--bg-hover); }
    .msg.search-hit { background: var(--accent-glow); border-left: 3px solid var(--accent); }
    .msg-avatar {
      width: 36px; height: 36px; border-radius: 10px;
      background: linear-gradient(135deg, #2563eb, #1e40af);
      display: flex; align-items: center; justify-content: center;
      font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; margin-top: 2px;
    }
    .msg-body { flex: 1; min-width: 0; }
    .msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
    .msg-name { font-size: 14px; font-weight: 600; }
    .msg-time { font-size: 11px; color: var(--text-muted); }
    .msg-text { font-size: 14px; line-height: 1.6; color: var(--text-secondary); word-break: break-word; }
    .msg-text a { color: var(--link); text-decoration: none; }
    .msg-text a:hover { text-decoration: underline; }
    .msg-text code { background: var(--bg-card); border: 1px solid var(--border); padding: 1px 5px; border-radius: var(--radius-xs); font-family: monospace; font-size: 12px; color: var(--accent-light); }
    .msg-text pre { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; margin: 8px 0; overflow-x: auto; font-family: monospace; font-size: 12px; line-height: 1.5; }
    .msg-text blockquote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 6px 0; color: var(--text-muted); font-style: italic; }
    .att { margin-top: 8px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); }
    .att-title { font-size: 13px; font-weight: 600; color: var(--link); margin-bottom: 4px; }
    .att-title a { color: var(--link); text-decoration: none; }
    .att-title a:hover { text-decoration: underline; }
    .att-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
    .att img { max-width: 400px; max-height: 280px; border-radius: var(--radius-sm); margin-top: 8px; border: 1px solid var(--border); }
    .loading-wrap { text-align: center; padding: 60px 20px; }
    .loading-spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 14px; }
    @keyframes spin { to { transform: rotate(360deg); } }
    .loading-text { font-size: 13px; color: var(--text-muted); }
    .empty { text-align: center; padding: 80px 20px; color: var(--text-muted); }
    .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
    .empty h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
    .stats-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
    .stat-card { flex: 1; min-width: 140px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
    .stat-card .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
    .stat-card .value { font-size: 22px; font-weight: 700; }
    .stat-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
    .toast { position: fixed; bottom: 24px; right: 24px; padding: 10px 18px; border-radius: var(--radius-sm); font-size: 13px; z-index: 1000; animation: slideIn 0.3s ease; max-width: 360px; box-shadow: var(--shadow); }
    .toast-ok { background: rgba(0,184,148,0.15); color: var(--green); border: 1px solid rgba(0,184,148,0.3); }
    .toast-err { background: rgba(225,112,85,0.15); color: var(--red); border: 1px solid rgba(225,112,85,0.3); }
    @keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
    .back-link { color: var(--text-muted); text-decoration: none; font-size: 12px; }
    .back-link:hover { color: var(--text-primary); }
    @media (max-width: 640px) {
      .topnav { padding: 0 14px; } .search-bar { padding: 8px 14px; }
      .main { padding: 10px 12px 60px; } .msg { padding: 10px 8px; }
      .msg-avatar { width: 28px; height: 28px; font-size: 11px; }
      .stat-card { min-width: 100px; } .att img { max-width: 100%; }
    }
  </style>
</head>
<body>
  <div id="app"></div>
  <script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
  <script src="https://unpkg.com/@babel/standalone/babel.min.js" crossorigin></script>
  <script src="https://unpkg.com/dompurify@3.0.6/dist/purify.min.js" crossorigin></script>
  <script type="text/babel">
    const { useState, useEffect, useMemo, useCallback } = React;
    const AUTH = '';

    function fmtTime(ts) {
      if (!ts) return '';
      const d = new Date(parseFloat(ts) * 1000);
      return isNaN(d.getTime()) ? '' : d.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true, timeZone: 'America/Los_Angeles' });
    }
    function fmtDate(ts) {
      if (!ts) return '';
      const d = new Date(parseFloat(ts) * 1000);
      if (isNaN(d.getTime())) return '';
      const now = new Date();
      const y = new Date(now); y.setDate(y.getDate() - 1);
      if (d.toDateString() === now.toDateString()) return 'Today';
      if (d.toDateString() === y.toDateString()) return 'Yesterday';
      return d.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric', timeZone: 'America/Los_Angeles' });
    }
    function dateKey(ts) { return ts ? new Date(parseFloat(ts) * 1000).toDateString() : '-'; }

    function renderText(raw) {
      if (!raw) return '';
      let html = raw
        .replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>')
        .replace(/<(https?:\/\/[^|>]+)\|([^>]+)>/g, '<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>')
        .replace(/<(https?:\/\/[^>]+)>/g, '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>')
        .replace(/```([\s\S]*?)```/g, '<pre>$1</pre>')
        .replace(/`([^`]+)`/g, '<code>$1</code>')
        .replace(/\*([^*]+)\*/g, '<strong>$1</strong>')
        .replace(/_([^_]+)_/g, '<em>$1</em>')
        .replace(/~([^~]+)~/g, '<del>$1</del>')
        .replace(/^&gt; (.+)$/gm, '<blockquote>$1</blockquote>')
        .replace(/\n/g, '<br>');
      return DOMPurify.sanitize(html, { ALLOWED_TAGS: ['a','strong','em','del','code','pre','blockquote','br'], ALLOWED_ATTR: ['href','target','rel'] });
    }

    function Toast({ msg, type, onClose }) {
      useEffect(() => { const t = setTimeout(onClose, 4000); return () => clearTimeout(t); }, [onClose]);
      return React.createElement('div', { className: 'toast toast-' + type }, msg);
    }

    function Msg({ m, search }) {
      const isHit = search && m.text && m.text.toLowerCase().includes(search.toLowerCase());
      const sanitized = renderText(m.text);
      const textEl = React.createElement('div', { className: 'msg-text', dangerouslySetInnerHTML: { __html: sanitized } });

      const atts = (m.attachments || []).map((a, ai) =>
        React.createElement('div', { key: ai, className: 'att' },
          a.title && React.createElement('div', { className: 'att-title' },
            a.title_link ? React.createElement('a', { href: DOMPurify.sanitize(a.title_link), target: '_blank', rel: 'noopener noreferrer' }, a.title) : a.title),
          a.text && React.createElement('div', { className: 'att-desc' }, a.text),
          !a.title && !a.text && a.fallback && React.createElement('div', { className: 'att-desc' }, a.fallback),
          a.image_url && React.createElement('img', { src: DOMPurify.sanitize(a.image_url), alt: '', loading: 'lazy' }),
          a.thumb_url && !a.image_url && React.createElement('img', { src: DOMPurify.sanitize(a.thumb_url), alt: '', loading: 'lazy' })
        )
      );

      const files = (m.files || []).map((f, fi) =>
        React.createElement('div', { key: fi, className: 'att' },
          React.createElement('div', { className: 'att-title' },
            f.url_private ? React.createElement('a', { href: DOMPurify.sanitize(f.url_private), target: '_blank', rel: 'noopener noreferrer' }, f.name || 'File') : (f.name || 'File')),
          f.mimetype && f.mimetype.startsWith('image/') && f.url_private && React.createElement('img', { src: DOMPurify.sanitize(f.url_private), alt: f.name || '', loading: 'lazy' })
        )
      );

      return React.createElement('div', { className: 'msg' + (isHit ? ' search-hit' : '') },
        React.createElement('div', { className: 'msg-avatar' }, 'SA'),
        React.createElement('div', { className: 'msg-body' },
          React.createElement('div', { className: 'msg-head' },
            React.createElement('span', { className: 'msg-name' }, 'Steve Abrams'),
            React.createElement('span', { className: 'msg-time' }, fmtTime(m.ts))
          ),
          textEl,
          ...atts,
          ...files
        )
      );
    }

    function App() {
      const [messages, setMessages] = useState([]);
      const [loading, setLoading] = useState(true);
      const [search, setSearch] = useState('');
      const [filter, setFilter] = useState('all');
      const [toast, setToast] = useState(null);

      const load = useCallback(async () => {
        setLoading(true);
        try {
          const r = await fetch('/api/claude-steve/messages', { headers: { Authorization: AUTH } });
          const data = await r.json();
          if (data.ok) {
            setMessages(data.messages || []);
            setToast({ msg: data.count + ' messages loaded', type: 'ok' });
          } else {
            setToast({ msg: data.error || 'Failed', type: 'err' });
          }
        } catch (e) { setToast({ msg: e.message, type: 'err' }); }
        finally { setLoading(false); }
      }, []);

      useEffect(() => { load(); }, [load]);

      const filtered = useMemo(() => {
        let msgs = messages;
        if (filter === 'links') msgs = msgs.filter(m => /https?:\/\//.test(m.text || ''));
        else if (filter === 'media') msgs = msgs.filter(m => (m.attachments && m.attachments.length) || (m.files && m.files.length));
        if (search.trim()) { const q = search.toLowerCase(); msgs = msgs.filter(m => (m.text || '').toLowerCase().includes(q)); }
        return msgs;
      }, [messages, search, filter]);

      const grouped = useMemo(() => {
        const g = {};
        filtered.forEach(m => { const k = dateKey(m.ts); if (!g[k]) g[k] = { ts: m.ts, msgs: [] }; g[k].msgs.push(m); });
        return Object.values(g);
      }, [filtered]);

      const stats = useMemo(() => {
        if (!messages.length) return { total: 0, days: 0, links: 0, oldest: '' };
        const links = messages.filter(m => /https?:\/\//.test(m.text || '')).length;
        const dates = new Set(messages.map(m => dateKey(m.ts)));
        const oldest = messages[messages.length - 1];
        const od = oldest ? new Date(parseFloat(oldest.ts) * 1000) : null;
        return { total: messages.length, days: dates.size, links,
          oldest: od ? od.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'America/Los_Angeles' }) : '?' };
      }, [messages]);

      return React.createElement('div', null,
        // TopNav
        React.createElement('div', { className: 'topnav' },
          React.createElement('div', { className: 'topnav-left' },
            React.createElement('a', { href: '/', className: 'back-link' }, '\u2190 DMs'),
            React.createElement('div', { className: 'topnav-logo' }, 'CS'),
            React.createElement('div', null,
              React.createElement('div', { className: 'topnav-title' }, 'Claude + Steve'),
              React.createElement('div', { className: 'topnav-subtitle' }, '#claude-to-steve')
            )
          ),
          React.createElement('div', { className: 'topnav-right' },
            React.createElement('span', { className: 'badge badge-live' }, 'LIVE'),
            React.createElement('span', { className: 'badge badge-count' }, filtered.length + ' msgs'),
            React.createElement('button', { className: 'btn', onClick: load, disabled: loading }, loading ? 'Loading...' : 'Refresh')
          )
        ),
        // Search
        React.createElement('div', { className: 'search-bar' },
          React.createElement('div', { className: 'search-wrap' },
            React.createElement('span', { className: 's-icon' }, '\uD83D\uDD0D'),
            React.createElement('input', { placeholder: 'Search messages...', value: search, onChange: e => setSearch(e.target.value) })
          ),
          React.createElement('button', { className: 'filter-chip' + (filter === 'all' ? ' active' : ''), onClick: () => setFilter('all') }, 'All'),
          React.createElement('button', { className: 'filter-chip' + (filter === 'links' ? ' active' : ''), onClick: () => setFilter('links') }, 'Links'),
          React.createElement('button', { className: 'filter-chip' + (filter === 'media' ? ' active' : ''), onClick: () => setFilter('media') }, 'Media')
        ),
        // Main
        React.createElement('div', { className: 'main' },
          // Stats
          !loading && messages.length > 0 && React.createElement('div', { className: 'stats-row' },
            React.createElement('div', { className: 'stat-card' },
              React.createElement('div', { className: 'label' }, 'Messages'),
              React.createElement('div', { className: 'value' }, stats.total),
              React.createElement('div', { className: 'sub' }, "Steve's notes")
            ),
            React.createElement('div', { className: 'stat-card' },
              React.createElement('div', { className: 'label' }, 'Active Days'),
              React.createElement('div', { className: 'value' }, stats.days),
              React.createElement('div', { className: 'sub' }, 'Since ' + stats.oldest)
            ),
            React.createElement('div', { className: 'stat-card' },
              React.createElement('div', { className: 'label' }, 'Links Shared'),
              React.createElement('div', { className: 'value' }, stats.links),
              React.createElement('div', { className: 'sub' }, Math.round(stats.links / Math.max(stats.total, 1) * 100) + '% of messages')
            )
          ),
          // Loading
          loading && React.createElement('div', { className: 'loading-wrap' },
            React.createElement('div', { className: 'loading-spinner' }),
            React.createElement('div', { className: 'loading-text' }, 'Fetching from #claude-to-steve...')
          ),
          // Empty states
          !loading && filtered.length === 0 && messages.length > 0 && React.createElement('div', { className: 'empty' },
            React.createElement('div', { className: 'empty-icon' }, '\uD83D\uDD0D'),
            React.createElement('h3', null, 'No matches')
          ),
          !loading && messages.length === 0 && React.createElement('div', { className: 'empty' },
            React.createElement('div', { className: 'empty-icon' }, '\uD83D\uDCAC'),
            React.createElement('h3', null, 'No Messages')
          ),
          // Messages
          !loading && filtered.length > 0 && grouped.map((group, gi) =>
            React.createElement('div', { key: gi },
              React.createElement('div', { className: 'date-divider' },
                React.createElement('span', { className: 'date-label' }, fmtDate(group.ts))
              ),
              group.msgs.map((m, mi) => React.createElement(Msg, { key: m.ts || mi, m: m, search: search }))
            )
          )
        ),
        // Toast
        toast && React.createElement(Toast, { msg: toast.msg, type: toast.type, onClose: () => setToast(null) })
      );
    }

    ReactDOM.createRoot(document.getElementById('app')).render(React.createElement(App));
  </script>
  <script>
    window.claudettePageContext = function() { return { dashboard: 'claude-steve-viewer' }; };
  </script>
  <script src="http://45.61.58.125:9872/widget.js" data-claudette-endpoint="http://45.61.58.125:9872" defer></script>
</body>
</html>