oclaw/interfaces/admin/static/chat.html
oliver 746570dfc9 Polish Admin/Chat UI and fix WhatsApp group session titles.
Surface group names in channel titles, theme composer chips for light mode, and trim unused Runtime alert/stack panels.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-11 04:59:39 +08:00

791 lines
23 KiB
HTML

<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Chat</title>
<!-- Avoid render-blocking external fonts (can stall first paint ~30s on blocked networks). -->
<link rel="stylesheet" href="/admin/assets/styles.css" />
<link rel="stylesheet" href="/admin/assets/theme-deepseek.css" />
<link rel="stylesheet" href="/admin/assets/theme-presets.css" />
<style>
html,
body {
width: 100%;
min-width: 100%;
}
body.theme-ds-body.chat-standalone-page {
margin: 0;
min-height: 100vh;
background: var(--ds-bg, #0d0d0d);
color: var(--ds-text, #e8e8e8);
display: flex;
flex-direction: column;
}
#app {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
padding: 0;
box-sizing: border-box;
width: 100%;
min-width: 100%;
}
.chat-app--login {
flex: 1;
min-height: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
box-sizing: border-box;
}
#app .chat-layout {
flex: 1;
min-height: 0;
width: 100%;
min-width: 100%;
}
.chat-sess-row {
display: flex;
align-items: stretch;
gap: 0;
margin-bottom: 2px;
min-height: 40px;
border: 1px solid transparent;
border-radius: 8px;
background: transparent;
}
.chat-sess-row:hover {
background: var(--chat-sess-hover-bg, rgba(255, 255, 255, 0.05));
border-color: transparent;
}
.chat-sess-row--active {
background: var(--chat-sess-active-bg, rgba(148, 163, 184, 0.12));
border-color: transparent;
}
.chat-sess-row .chat-sess-btn {
flex: 1;
min-width: 0;
}
.chat-sess-more {
flex: 0 0 2rem;
min-width: 2rem;
padding: 10px 0;
border-radius: 0;
border: 1px solid transparent;
background: transparent;
color: inherit;
cursor: pointer;
font-size: 1.1rem;
line-height: 1;
-webkit-appearance: none;
appearance: none;
box-shadow: none;
}
.chat-user-row {
display: flex;
align-items: stretch;
gap: 0;
border: 1px solid transparent;
border-radius: 0;
background: transparent;
}
.chat-user-row:hover {
background: var(--chat-sess-hover-bg, rgba(255, 255, 255, 0.06));
border-color: var(--chat-sess-border, rgba(255, 255, 255, 0.12));
}
.chat-user-row .chat-sess-btn {
flex: 1;
min-width: 0;
}
.chat-sess-more:hover {
background: transparent;
}
.chat-sess-more:focus {
outline: none;
}
.chat-sess-more:focus-visible {
outline: 1px solid var(--chat-sess-border, rgba(255, 255, 255, 0.2));
outline-offset: 1px;
}
.chat-sess-more--active {
background: transparent;
border-color: transparent;
}
.chat-sess-more--active:hover {
background: transparent;
}
.chat-sess-menu-pop {
/* Must stay above .u-overlay-scrim (250) or menu clicks hit the transparent scrim. */
z-index: 300;
background: var(--ds-panel, var(--ds-surface, #222));
border: 1px solid var(--ds-border, rgba(255, 255, 255, 0.12));
border-radius: 8px;
padding: 4px;
min-width: 11rem;
box-shadow: var(--ds-pop-shadow, 0 8px 24px rgba(0, 0, 0, 0.45));
color: var(--ds-text, inherit);
}
.chat-sess-menu-item {
display: block;
width: 100%;
text-align: left;
padding: 8px 10px;
border: none;
background: transparent;
color: inherit;
cursor: pointer;
border-radius: 6px;
font-size: 13px;
}
.chat-sess-menu-item:hover {
background: var(--ds-menu-hover-bg, rgba(255, 255, 255, 0.06));
}
.chat-sess-menu-sep {
height: 1px;
margin: 4px 6px;
background: var(--ds-menu-sep, rgba(255, 255, 255, 0.08));
}
.chat-msg__md {
line-height: 1.45;
word-break: break-word;
}
.chat-msg .chat-msg__md p {
margin: 0.28em 0;
}
.chat-msg .chat-msg__md > :first-child {
margin-top: 0;
}
.chat-msg .chat-msg__md > :last-child {
margin-bottom: 0;
}
.chat-msg__md pre {
overflow: auto;
padding: 8px;
border-radius: 8px;
background: rgba(0, 0, 0, 0.35);
font-size: 12px;
}
.chat-msg__md code {
font-family: ui-monospace, monospace;
font-size: 0.92em;
}
/* 父级 .chat-msg 的 pre-wrap 会继承到子节点,影响图片与 Markdown 排版 */
.chat-msg .chat-msg__md,
.chat-msg .chat-att-wrap {
white-space: normal;
}
.chat-msg__md img {
max-width: 100%;
height: auto;
border-radius: 8px;
display: block;
margin: 0.25rem 0;
vertical-align: middle;
cursor: zoom-in;
}
.chat-msg__plain {
white-space: pre-wrap;
}
.chat-msg__stream-status {
font-size: 12px;
line-height: 1.35;
color: var(--ds-text-muted, rgba(232, 232, 232, 0.62));
margin-bottom: 6px;
}
.chat-att-wrap {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 8px;
}
.chat-att-img {
max-width: 180px;
max-height: 180px;
border-radius: 8px;
object-fit: cover;
cursor: zoom-in;
}
.chat-img-lightbox {
position: fixed;
inset: 0;
z-index: 300;
background: var(--ds-lightbox-bg, rgba(0, 0, 0, 0.88));
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
box-sizing: border-box;
}
.chat-img-lightbox__inner {
position: relative;
max-width: 100%;
max-height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.chat-img-lightbox__img {
max-width: min(96vw, 100%);
max-height: min(92vh, 100%);
width: auto;
height: auto;
object-fit: contain;
border-radius: 4px;
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.chat-img-lightbox__close {
position: absolute;
top: -8px;
right: -8px;
width: 40px;
height: 40px;
border: 1px solid var(--ds-border, rgba(255, 255, 255, 0.2));
border-radius: 999px;
background: var(--ds-lightbox-control-bg, rgba(255, 255, 255, 0.12));
color: var(--ds-lightbox-control-fg, #eee);
font-size: 26px;
line-height: 1;
cursor: pointer;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
}
.chat-img-lightbox__close:hover {
background: var(--ds-lightbox-control-hover-bg, rgba(255, 255, 255, 0.22));
}
.chat-att-chip {
font-size: 12px;
opacity: 0.9;
}
.chat-att-ref {
min-width: 200px;
max-width: 280px;
border: 1px solid var(--ds-border, rgba(255, 255, 255, 0.14));
border-radius: 10px;
background: rgba(255, 255, 255, 0.04);
padding: 10px 12px;
box-sizing: border-box;
}
.chat-att-ref__name {
font-size: 13px;
font-weight: 600;
line-height: 1.35;
margin-bottom: 4px;
word-break: break-all;
}
.chat-att-ref__meta {
font-size: 11px;
line-height: 1.35;
opacity: 0.75;
word-break: break-all;
}
.chat-att-ref__actions {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.chat-att-ref__action,
.chat-att-ref__link,
.chat-att-ref__btn {
display: inline-flex;
align-items: center;
justify-content: center;
margin: 0;
border: 1px solid var(--ds-border, rgba(255, 255, 255, 0.14));
background: rgba(255, 255, 255, 0.05);
color: var(--ds-text, #e8e8e8);
border-radius: 6px;
font-size: 12px;
font-weight: 500;
line-height: 1.2;
padding: 4px 9px;
text-decoration: none;
cursor: pointer;
}
.chat-att-ref__action:hover,
.chat-att-ref__link:hover,
.chat-att-ref__btn:hover {
background: rgba(255, 255, 255, 0.09);
text-decoration: none;
}
.chat-att-ref__action:disabled {
opacity: 0.55;
cursor: not-allowed;
}
.chat-att-ref__preview {
margin: 8px 0 0;
padding: 8px;
border-radius: 6px;
border: 1px solid var(--ds-border, rgba(255, 255, 255, 0.14));
background: rgba(0, 0, 0, 0.26);
max-height: 180px;
overflow: auto;
white-space: pre-wrap;
word-break: break-word;
font-size: 11px;
line-height: 1.35;
}
.chat-att-ref__preview:empty {
display: none;
}
.chat-composer-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
padding: 2px 4px 8px;
}
.chat-composer-chip,
.chat-composer-chip--select {
appearance: none;
-webkit-appearance: none;
height: 30px;
min-height: 30px;
max-height: 30px;
padding: 0 12px;
border-radius: 999px;
border: 1px solid var(--ds-border, rgba(148, 163, 184, 0.28));
background-color: var(--ds-surface-2, #152033);
color: var(--ds-text, #e2e8f0);
font-size: 12px;
font-weight: 500;
line-height: 1;
box-sizing: border-box;
cursor: pointer;
}
.chat-composer-chip--select {
min-width: 148px;
max-width: 240px;
padding-right: 28px;
background-color: var(--ds-surface-2, #152033);
background-image:
linear-gradient(45deg, transparent 50%, var(--ds-text-muted, rgba(148, 163, 184, 0.85)) 50%),
linear-gradient(135deg, var(--ds-text-muted, rgba(148, 163, 184, 0.85)) 50%, transparent 50%);
background-position:
calc(100% - 14px) calc(50% - 2px),
calc(100% - 9px) calc(50% - 2px);
background-size: 5px 5px, 5px 5px;
background-repeat: no-repeat;
}
.chat-composer-chip--select option {
background-color: var(--ds-surface, #0f172a);
color: var(--ds-text, #e2e8f0);
}
.chat-composer-chip:hover,
.chat-composer-chip--select:hover {
background-color: var(--ds-menu-hover-bg, rgba(148, 163, 184, 0.16));
border-color: var(--ds-accent-border, rgba(94, 179, 255, 0.35));
}
.chat-composer-chip:focus-visible,
.chat-composer-chip--select:focus-visible {
outline: none;
border-color: var(--ds-accent-border-strong, rgba(94, 179, 255, 0.5));
box-shadow: 0 0 0 2px var(--ds-accent-soft, rgba(94, 179, 255, 0.2));
}
.chat-composer-shell {
border-radius: 12px;
border: 1px solid var(--ds-border, rgba(148, 163, 184, 0.18));
background: var(--ds-composer-shell-bg, rgba(0, 0, 0, 0.28));
padding: 6px 8px 6px 6px;
}
.chat-composer-shell--busy .chat-composer__field {
opacity: 0.72;
}
.chat-pending-files {
display: flex;
flex-wrap: wrap;
gap: 6px;
max-height: 4.5rem;
overflow-y: auto;
padding: 2px 4px 6px;
margin: 0 -2px;
}
.chat-pending-files:empty {
display: none;
}
.chat-pending-row {
display: inline-flex;
align-items: center;
gap: 4px;
max-width: 100%;
padding: 2px 8px 2px 10px;
border-radius: 999px;
background: var(--ds-menu-hover-bg, rgba(148, 163, 184, 0.12));
font-size: 11px;
}
.chat-pending-row .muted {
max-width: 12rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.chat-pending-row .chat-pending-remove {
padding: 0 4px;
min-height: 22px;
min-width: 22px;
font-size: 14px;
line-height: 1;
border: none;
background: transparent;
color: inherit;
opacity: 0.75;
border-radius: 6px;
cursor: pointer;
}
.chat-pending-row .chat-pending-remove:hover {
opacity: 1;
background: var(--ds-menu-hover-bg, rgba(148, 163, 184, 0.16));
}
.chat-composer-row {
display: flex;
align-items: flex-end;
gap: 4px;
}
.chat-composer-iconbtn {
flex: 0 0 40px;
width: 40px;
height: 40px;
position: relative;
padding: 0;
margin: 0 0 2px 2px;
border: none;
border-radius: 10px;
background: transparent;
color: var(--ds-text-muted, rgba(148, 163, 184, 0.85));
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.chat-composer-iconbtn:hover {
background: var(--ds-menu-hover-bg, rgba(148, 163, 184, 0.12));
color: var(--ds-text, #e2e8f0);
}
.chat-composer-iconbtn:focus-visible {
outline: 1px solid var(--chat-sess-border, rgba(255, 255, 255, 0.25));
outline-offset: 1px;
}
.chat-composer-iconbtn svg {
display: block;
}
.chat-composer__field {
flex: 1;
min-width: 0;
min-height: 44px;
max-height: 200px;
resize: none;
border: none;
border-radius: 0;
padding: 10px 8px 12px 4px;
margin-bottom: 2px;
background: transparent;
color: inherit;
line-height: 1.45;
}
.chat-composer__field:focus {
outline: none;
}
.chat-composer__field::placeholder {
color: var(--ds-text-muted, rgba(232, 232, 232, 0.45));
}
.chat-composer-actions {
position: relative;
flex: 0 0 40px;
width: 40px;
height: 40px;
margin: 0 2px 2px 0;
}
.chat-composer-send,
.chat-composer-stop {
position: absolute;
right: 0;
bottom: 0;
width: 40px;
height: 40px;
padding: 0;
border: none;
border-radius: 999px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: opacity 0.12s ease;
}
.chat-composer-send {
background: rgba(94, 179, 255, 0.92);
color: #0a0a0c;
}
.chat-composer-send:hover:not(:disabled) {
background: rgba(120, 195, 255, 1);
}
.chat-composer-send:disabled {
opacity: 0.35;
cursor: not-allowed;
}
.chat-composer-stop {
background: rgba(255, 255, 255, 0.12);
color: #f3f3f3;
opacity: 0;
pointer-events: none;
}
.chat-composer-stop:hover:not(:disabled) {
background: rgba(255, 80, 80, 0.35);
color: #fff;
}
.chat-composer-stop:disabled {
opacity: 0;
pointer-events: none;
}
.chat-composer-shell--busy .chat-composer-send {
opacity: 0;
pointer-events: none;
}
.chat-composer-shell--busy .chat-composer-stop:not(:disabled) {
opacity: 1;
pointer-events: auto;
}
.chat-msg-cap {
padding: 6px 0;
font-size: 12px;
}
#app .chat-status {
flex-shrink: 0;
min-height: 1.25rem;
line-height: 1.35;
}
.chat-confirm-backdrop {
position: fixed;
inset: 0;
z-index: 400;
background: var(--ds-overlay-bg, rgba(0, 0, 0, 0.58));
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
}
.chat-confirm-card {
width: min(420px, 92vw);
background: var(--ds-surface, #ffffff);
border: 1px solid var(--ds-accent-border, rgba(94, 179, 255, 0.35));
border-radius: 12px;
box-shadow: var(--ds-modal-shadow, 0 16px 48px rgba(0, 0, 0, 0.55));
color: var(--ds-text, #e8e8e8);
padding: 14px;
}
.chat-confirm-text {
font-size: 14px;
line-height: 1.45;
color: var(--ds-text, #e8e8e8);
}
.chat-nav__toolbar {
display: flex;
flex-direction: column;
gap: 8px;
}
.chat-nav__footer .chat-nav__jobs {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
box-sizing: border-box;
margin: 0;
padding: 7px 10px;
border-radius: 8px;
border: 1px solid transparent;
background: transparent;
color: inherit;
cursor: pointer;
font-size: 12px;
opacity: 0.92;
}
.chat-nav__footer .chat-nav__jobs:hover {
background: var(--chat-sess-hover-bg, rgba(255, 255, 255, 0.05));
border-color: var(--ds-border, rgba(255, 255, 255, 0.1));
opacity: 1;
}
.chat-nav__footer .chat-nav__jobs--active {
border-color: rgba(245, 158, 11, 0.45);
background: rgba(245, 158, 11, 0.1);
opacity: 1;
}
.chat-jobs-badge {
min-width: 1.15rem;
height: 1.15rem;
padding: 0 5px;
border-radius: 999px;
color: #fff;
font-size: 11px;
line-height: 1.15rem;
text-align: center;
font-weight: 600;
flex: 0 0 auto;
}
.chat-jobs-badge--idle {
background: rgba(148, 163, 184, 0.4);
}
.chat-jobs-badge--hot {
background: rgba(239, 68, 68, 0.9);
box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}
.chat-jobs-row {
border: 1px solid var(--ds-border, rgba(255, 255, 255, 0.12));
border-radius: 10px;
padding: 10px;
background: rgba(255, 255, 255, 0.03);
}
.chat-jobs-row--running {
border-color: rgba(245, 158, 11, 0.45);
}
.chat-jobs-row__top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 6px;
}
.chat-jobs-row__name {
font-weight: 600;
font-size: 14px;
}
.chat-jobs-row__meta {
font-size: 12px;
line-height: 1.4;
margin-bottom: 8px;
}
.chat-jobs-row__cmd {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
.chat-jobs-pill {
font-size: 11px;
padding: 2px 8px;
border-radius: 999px;
border: 1px solid rgba(255, 255, 255, 0.15);
}
.chat-jobs-pill--running {
background: rgba(245, 158, 11, 0.2);
border-color: rgba(245, 158, 11, 0.4);
}
.chat-jobs-pill--succeeded {
background: rgba(34, 197, 94, 0.18);
border-color: rgba(34, 197, 94, 0.35);
}
.chat-jobs-pill--failed,
.chat-jobs-pill--timeout,
.chat-jobs-pill--cancelled {
background: rgba(239, 68, 68, 0.15);
border-color: rgba(239, 68, 68, 0.35);
}
.chat-jobs-log {
margin: 8px 0 0;
padding: 8px;
max-height: 220px;
overflow: auto;
font-size: 11px;
line-height: 1.35;
white-space: pre-wrap;
word-break: break-word;
background: rgba(0, 0, 0, 0.25);
border-radius: 8px;
}
/* First paint before chat.js runs (desktop / slow network): avoid empty #app “black hole”. */
.chat-boot-splash {
flex: 1;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
box-sizing: border-box;
}
.chat-boot-splash__card {
width: min(520px, 92vw);
padding: 22px 20px;
border-radius: 14px;
border: 1px solid var(--ds-splash-border, rgba(255, 255, 255, 0.1));
background: var(--ds-splash-bg, rgba(255, 255, 255, 0.04));
color: var(--ds-text, #e8e8e8);
line-height: 1.5;
}
.chat-boot-splash__title {
font-weight: 600;
font-size: 15px;
margin-bottom: 8px;
display: flex;
align-items: center;
gap: 10px;
}
.chat-boot-splash__spinner {
width: 18px;
height: 18px;
border: 2px solid var(--ds-splash-spinner-track, rgba(255, 255, 255, 0.15));
border-top-color: var(--ds-splash-spinner-active, rgba(255, 255, 255, 0.75));
border-radius: 999px;
animation: chat-boot-spin 1s linear infinite;
flex: 0 0 auto;
}
@keyframes chat-boot-spin {
to {
transform: rotate(360deg);
}
}
.chat-boot-splash__muted {
opacity: 0.78;
font-size: 13px;
white-space: pre-wrap;
}
</style>
<!-- Local markdown helpers (vendored; no CDN). Load marked/purify before chat.js. -->
<script defer src="/admin/assets/vendor/marked.min.js"></script>
<script defer src="/admin/assets/vendor/purify.min.js"></script>
<script defer src="/admin/assets/admin-theme.js"></script>
<script
defer
src="/admin/assets/chat.js?v=20260811-vendor"
onerror="(function(){var s=document.getElementById('chat-boot-splash');if(s){s.querySelector('.chat-boot-splash__title span:last-child').textContent='无法加载 chat.js';s.querySelector('.chat-boot-splash__muted').textContent='请确认网关已启动且 /admin/assets/chat.js 可访问。';}})()"
></script>
<!-- Mermaid is larger; load after chat.js so login is not delayed by parse. -->
<script
defer
src="/admin/assets/vendor/mermaid.min.js"
onload="(function(){try{ if (window.__oclawHydrateMermaidAll) window.__oclawHydrateMermaidAll(); }catch(e){}})()"
></script>
<script>
(function () {
setTimeout(function () {
var s = document.getElementById("chat-boot-splash");
if (!s || !document.body.contains(s)) return;
var title = s.querySelector(".chat-boot-splash__title span:last-child");
var muted = s.querySelector(".chat-boot-splash__muted");
if (title) title.textContent = "加载仍在进行…";
if (muted) {
muted.textContent = "若超过数秒仍无登录框,请确认网关已启动后刷新。桌面端可查看 desktop.log / backend.log。";
}
}, 4000);
})();
</script>
</head>
<body class="theme-ds-body chat-standalone-page">
<div id="app">
<div id="chat-boot-splash" class="chat-boot-splash" role="status" aria-live="polite">
<div class="chat-boot-splash__card">
<div class="chat-boot-splash__title">
<span class="chat-boot-splash__spinner" aria-hidden="true"></span>
<span>正在加载…</span>
</div>
<div class="chat-boot-splash__muted">
正在启动本地界面;若长时间停留,请确认网关已启动。桌面端可查看 desktop.log / backend.log。
</div>
</div>
</div>
</div>
</body>
</html>